:root {
    --bg: #1a1a2e;
    --card-bg: #22223a;
    --border: #3a3a5c;
    --text: #eee;
    --muted: #999;
    --accent: #5a5ad6;
    --error: #d64545;
    --success: #3aa35a;
    --field: #2d4a2d;
    --road: #6b6b6b;
    --seat0: #4ea3e0;
    --seat1: #e05a4e;
    --bridge: #e0a94e;
    --magic: #a64dff;
    --build: #4eaf6b;
    --armory: #b06fd6;
    --upgrade: #f0c419;
    --mine: #d4af37;
    --wizard: #5b8dee;
}

* { box-sizing: border-box; }

body {
    background: var(--bg);
    color: var(--text);
    font-family: system-ui, sans-serif;
    margin: 0;
    padding: 0;
}

.wrap {
    max-width: 640px;
    margin: 2rem auto;
    padding: 0 1rem;
}

h1 { text-align: center; }

/* Title left + hand-tile picker upper-right, see game.php's header-row
   comment. Wraps to a stacked layout on very narrow screens instead of
   squeezing -- flex-wrap, not a fixed 2-column grid, since the title's
   own width varies by locale/font. */
.header-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 0.5rem;
}
.header-left h1 { text-align: left; margin: 0.2rem 0 0; }
.header-hand { flex: 0 0 auto; }
.header-hand .hand-tiles { margin: 0; gap: 0.4rem; }
.header-hand .hand-tile-visual { padding: 0.25rem; }
.header-hand .hand-tile-visual .tile-preview { width: 42px; height: 42px; }
.header-hand .hand-tile-visual .count { font-size: 0.65rem; }
.header-hand select {
    margin-top: 0.25rem;
    font-size: 0.75rem;
    padding: 0.15rem 0.3rem;
    width: 100%;
}

/* On phones the title was eating a disproportionate share of the
   above-the-fold space (real user complaint) -- shrink it and tighten
   the wrapper's top margin so more of the actual board/controls fit
   without scrolling.
   REVISED 2026-08-07 (user: "the tiles should be using that space to
   the right of the game title... tighten the whole thing up... on
   mobile I want everything on one screen so players dont have to
   scroll"): the title used to wrap onto its OWN row above the hand-
   tile picker at narrow widths (flex-wrap on .header-row), costing a
   whole extra row -- forced to stay side-by-side instead, with the
   title shrunk further and the hand-tile previews sized down slightly
   so both reliably fit the same row even on a small phone. */
@media (max-width: 480px) {
    .wrap { margin: 0.5rem auto; padding: 0 0.6rem; }
    h1 { font-size: 1.05rem; margin: 0.15rem 0 0; white-space: nowrap; }
    .header-row { flex-wrap: nowrap; align-items: center; gap: 0.4rem; }
    .header-left { min-width: 0; }
    .header-left .back { font-size: 0.75rem; }
    .header-hand .hand-tile-visual .tile-preview { width: 34px; height: 34px; }
    .card { padding: 0.9rem; }
    .hud { margin-bottom: 0.4rem; font-size: 0.8rem; }
    .action-bar { margin: 0.4rem 0; gap: 0.3rem; }
    .action-bar button { padding: 0.4rem 0.55rem; font-size: 0.8rem; }
    #action-hint { margin-bottom: 0.4rem; min-height: 0; }
}

.card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: 1rem;
}

/* lobby.php's 3 action forms (New Game / Play vs Alice / Watch Alice vs
   Bob) -- each form wraps its own button+select(s) instead of forcing
   them onto one unbreakable line, and the forms themselves wrap onto
   new rows once they run out of horizontal room, so nothing gets
   truncated on a narrow viewport. Below 480px each form becomes its own
   full-width stacked row instead (see that media block), since even
   wrapped inline forms were still cramped at phone widths. */
.lobby-actions { display: flex; flex-wrap: wrap; gap: 0.6rem; align-items: flex-start; }
.lobby-action-form { display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem; }
.lobby-action-form select { width: auto; }
.lobby-vs { color: var(--muted); font-size: 0.85rem; }

/* User-specified 2026-08-08 ("make this look tighter in mobile"), driven
   by a real screenshot of lobby.php on a phone: the 3 forms used to be
   plain inline-flex with no wrap, so a button's own text wrapped across
   2-4 lines and the Watch form's trailing <select>s got cut off past the
   viewport edge. Below 480px each form becomes its own full-width
   stacked row (wrapping internally is still not enough room at phone
   widths) with smaller controls so a row's button+selects reliably fit
   without truncation. */
@media (max-width: 480px) {
    .lobby-actions { flex-direction: column; align-items: stretch; gap: 0.5rem; }
    .lobby-action-form { width: 100%; }
    .lobby-action-form button { padding: 0.4rem 0.6rem; font-size: 0.85rem; }
    .lobby-action-form select { padding: 0.3rem 0.3rem; font-size: 0.8rem; }
}

label { display: block; margin: 0.75rem 0 0.25rem; font-size: 0.85rem; color: var(--muted); }

input, select {
    width: 100%;
    padding: 0.6rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
    font-size: 1rem;
}

button, .btn {
    display: inline-block;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 0.6rem 1.2rem;
    font-size: 1rem;
    cursor: pointer;
    text-decoration: none;
    margin-top: 0.75rem;
}

button:hover, .btn:hover { opacity: 0.9; }
button:disabled { opacity: 0.4; cursor: not-allowed; }

.error { background: rgba(214,69,69,.15); border: 1px solid var(--error); border-radius: 8px; padding: 0.75rem; margin-bottom: 0.75rem; }
.success { background: rgba(58,163,90,.15); border: 1px solid var(--success); border-radius: 8px; padding: 0.75rem; }

.game-list-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.6rem 0;
    border-bottom: 1px solid var(--border);
}
.game-list-item:last-child { border-bottom: none; }

/* Board */
.board {
    display: grid;
    /* grid-template-columns set inline per-page (game.php/watch.php) from
       BOARD_SIZE, 2026-08-06 ("choose amongst three board sizes") -- can't
       be a fixed repeat(6, ...) here anymore now that boards can be 5x5 or
       7x7 too. */
    /* User-specified 2026-08-06: "get rid of the strong borders on each
       tile edge so they flow seamlessly into each other" -- the visible
       grid lines were literally the board's own --border background
       showing through the grid gap between cells. Removing the gap lets
       adjacent tiles' art (road/grass textures) butt directly against
       each other. The outer frame border below is unrelated (a deliberate
       edge around the whole board, not a per-tile seam) and stays. */
    gap: 0;
    border: 2px solid var(--border);
    border-radius: 6px;
    overflow: hidden;
    aspect-ratio: 1;
    max-width: 480px;
    margin: 0 auto;
    position: relative; /* anchors .tt-arrow, which is absolutely positioned in board-pixel space, see ttFireArrow() in game.php */
}

/* Combat/tower-fire animations, see record_event() in inc/engine.php and
   the TURN_EVENTS-driven script in game.php. Absolutely-positioned
   children of a CSS Grid container (like .tt-arrow below) are excluded
   from grid placement entirely, so these never disturb the board layout. */
@keyframes tt-fade-death {
    0% { opacity: 1; transform: scale(1); }
    100% { opacity: 0; transform: scale(0.55); }
}
.tt-ghost-death {
    animation: tt-fade-death 700ms ease-in forwards;
    pointer-events: none;
}
/* Two pulses instead of one -- user-specified 2026-08-05 ("I can barely
   tell either happen... soldiers can bump twice") -- a single 350ms tap
   read as barely-there; two clearly-separated hits over a longer span
   reads as an actual exchange of blows. */
@keyframes tt-jab {
    0% { transform: scale(1); }
    20% { transform: scale(1.3); }
    40% { transform: scale(1); }
    60% { transform: scale(1.3); }
    80% { transform: scale(1); }
    100% { transform: scale(1); }
}
.tt-anim-jab {
    animation: tt-jab 650ms ease-out;
}
@keyframes tt-push {
    0% { transform: translate(0, 0); }
    20% { transform: translate(var(--push-dx, 0), var(--push-dy, 0)); }
    40% { transform: translate(0, 0); }
    60% { transform: translate(var(--push-dx, 0), var(--push-dy, 0)); }
    80% { transform: translate(0, 0); }
    100% { transform: translate(0, 0); }
}
.tt-anim-push {
    animation: tt-push 650ms ease-out;
}
/* Floating "-N ♥" that pops up and fades on EVERY hit that lands, lethal
   or not -- user-specified 2026-08-05 ("a heart animation when it
   removes 1 heart"). Previously only a kill showed any feedback at all
   (the death-ghost fade); a hit that merely chips hearts had NO visual
   signal whatsoever. Shared by soldier melee AND tower/archer fire (see
   ttSpawnDamageHeart() in game.php) -- one animation, reused everywhere
   damage is dealt, matching how the death-ghost fade is already shared
   across both. */
@keyframes tt-heart-pop {
    0% { opacity: 0; transform: translate(-50%, 0) scale(0.6); }
    25% { opacity: 1; transform: translate(-50%, -8px) scale(1.15); }
    100% { opacity: 0; transform: translate(-50%, -30px) scale(0.9); }
}
.tt-damage-heart {
    position: absolute;
    top: 50%;
    left: 50%;
    z-index: 4;
    font-size: 0.85rem;
    font-weight: bold;
    color: #ff5566;
    text-shadow: 0 1px 2px rgba(0,0,0,.8), 0 0 3px rgba(0,0,0,.6);
    pointer-events: none;
    animation: tt-heart-pop 750ms ease-out forwards;
    white-space: nowrap;
}
/* Gnoll Tower hits (see gnoll_phase() in inc/engine.php) have no arrow
   flight/source cell worth animating -- "unlimited range" -- so a fire
   emoji fading in place on the TARGET is the whole visual, user-
   specified 2026-08-08 ("animate the creature targeted with a fire
   emoji that fades away so it's clearer which guy is getting damaged"). */
@keyframes tt-fire-fade {
    0% { opacity: 0; transform: translate(-50%, -50%) scale(0.5); }
    20% { opacity: 1; transform: translate(-50%, -50%) scale(1.3); }
    100% { opacity: 0; transform: translate(-50%, -50%) scale(1); }
}
.tt-fire-hit {
    position: absolute;
    top: 50%;
    left: 50%;
    z-index: 5;
    font-size: 1.4rem;
    pointer-events: none;
    animation: tt-fire-fade 900ms ease-out forwards;
}
/* Real arrow artwork (assets/icons/arrow.png), replacing the old plain
   CSS border-triangle -- drawn pointing right in the source image, then
   rotated per-shot via inline style (see ttFireArrow() in game.php). */
.tt-arrow {
    position: absolute;
    width: 28px;
    height: auto;
    z-index: 3;
    pointer-events: none;
    filter: drop-shadow(0 1px 1px rgba(0,0,0,.6));
}
/* Magic bridges (MAGIC_BRIDGE_COST) connect ANY two placed tiles, not
   just adjacent ones -- see magic_bridges_svg_html() in inc/render.php,
   which renders one <line> per magic bridge in board-viewBox units (1
   unit per cell) inside a single SVG spanning the whole board. Above
   .tt-arrow (z-index 3) so a magic bridge is always clearly visible
   crossing over tiles/buildings/units, never possible to render an
   arrow animation ON one specifically since bridges/arrows aren't
   correlated in gameplay. pointer-events:none so it never blocks board
   clicks meant for the cells underneath it. */
.magic-bridge-overlay {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    z-index: 4;
    pointer-events: none;
    overflow: visible;
}
.magic-bridge-overlay line {
    stroke: var(--magic);
    stroke-width: 0.06;
    stroke-linecap: round;
    stroke-dasharray: 0.12 0.08;
    filter: drop-shadow(0 0 3px var(--magic)) drop-shadow(0 0 6px #7020a0);
}
.cell {
    background: #1a1a1a;
    position: relative;
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    color: var(--muted);
}
/* Actual tile art now lives in the embedded <svg> (see inc/svg_render.php,
   a simplified port of meeple-sisters' own road-curve + black-outline
   rendering technique) -- these are just fallback colors for the instant
   before/if that SVG loads. */
.cell.field { background: var(--field); }
.cell.home-0 { background: var(--seat0); }
.cell.home-1 { background: var(--seat1); }
.cell .tile-art {
    position: absolute;
    inset: 0;
    z-index: 0;
}
.cell .tile-art svg { width: 100%; height: 100%; display: block; }
.cell .road-bar {
    position: absolute;
    background: var(--road) url('/tower-tiles/assets/textures/roads.png');
    background-size: cover;
}
.cell .bridge-bar {
    position: absolute;
    /* Needs its OWN z-index layer, strictly between .tile-art (0) and
       .building-art/.home-base-art (2) -- not tied with either. None of
       the .cell elements establish their own stacking context (no
       z-index set on .cell itself), so every cell's children share ONE
       board-wide stacking order, not an isolated per-cell one: a bridge
       segment visually overflows past its own cell's box into the
       ADJACENT cell's rectangle (that's the whole point of a bridge bar),
       so it must out-rank every OTHER cell's .tile-art too, not just its
       own. Tied with .tile-art (both 0) briefly regressed to the bridge
       vanishing under a neighboring cell's plain grass -- and tied with
       .building-art (both 1) is the ORIGINAL bug this was written to fix
       (a bridge painting over a tower/armory/mine icon). This exact value
       only works because .building-art/.home-base-art were bumped to 2
       below, opening up a real gap at 1. */
    z-index: 1;
}
.cell .bridge-bar img { width: 100%; height: 100%; object-fit: contain; display: block; }
.cell .soldier, .cell .gnoll {
    position: absolute;
    width: 55%;
    height: 55%;
    z-index: 2;
    filter: drop-shadow(0 1px 1px rgba(0,0,0,.6));
}
/* Gnolls (neutral third faction, see gnoll_phase() in inc/engine.php)
   have no seat, so no left/right team anchor -- just centered, unlike a
   soldier's seat-0/seat-1 offset below. */
.cell .gnoll { left: 50%; transform: translateX(-50%); }
.cell .soldier img, .cell .gnoll img { width: 100%; height: 100%; object-fit: contain; display: block; }
.cell .soldier .badge, .cell .gnoll .badge {
    position: absolute;
    bottom: -4px;
    right: -4px;
    background: #000;
    color: #fff;
    border-radius: 50%;
    font-size: 0.55rem;
    font-weight: bold;
    min-width: 14px;
    height: 14px;
    line-height: 14px;
    text-align: center;
    padding: 0 2px;
}
.cell .soldier.seat-0 { left: 6%; }
.cell .soldier.seat-1 { right: 6%; }
/* A soldier sharing a cell with a tower/armory/mine used to default to
   vertical-center (from .cell's own flex centering, since .soldier sets
   no top/bottom) and collide hard with .building-art's bottom-right 72%
   box -- most of the soldier ended up hidden behind/within the
   structure's footprint. Pinned to the top-left corner instead
   (overriding seat-1's own right-anchor too, since .building-art is
   ALWAYS bottom-right regardless of which seat owns the structure) and
   shrunk slightly so it sits cleanly above the structure with minimal
   overlap. Must come after the seat-0/seat-1 rules above (equal
   specificity, last-wins) to actually override seat-1's right:6%. */
.cell .soldier.on-structure, .cell .gnoll.on-structure { top: 2%; left: 2%; right: auto; transform: none; width: 46%; height: 46%; }
.cell .building-art {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 72%; /* user-specified 2026-08-04: "make arrow towers bigger" -- was 50% */
    height: 72%;
    /* Bumped from 1 -> 2 (along with .home-base-art below) to open up a
       real gap at z-index 1 for .bridge-bar -- see its own comment. */
    z-index: 2;
    filter: drop-shadow(0 1px 1px rgba(0,0,0,.6));
}
.cell .building-art img { width: 100%; height: 100%; object-fit: contain; display: block; }
/* Gnoll Tower (see GNOLL_TOWER_APPEAR_TURN in inc/engine.php) reuses the
   Wizard Tower art with a hostile red/orange tint so it doesn't read as
   a real player-owned structure. */
.cell .gnoll-tower-art img {
    filter: sepia(1) saturate(6) hue-rotate(-30deg) brightness(0.85);
}
.building-flag {
    position: absolute;
    top: -4px;
    left: -2px;
    width: 40%;
    height: 40%;
    z-index: 2;
    filter: drop-shadow(0 1px 1px rgba(0,0,0,.6));
}
.upgrade-badge {
    position: absolute;
    bottom: -4px;
    right: -4px;
    width: 38%;
    height: 38%;
    z-index: 2;
    filter: drop-shadow(0 1px 1px rgba(0,0,0,.6));
}
/* Structure hit points, visible on the board itself instead of only in
   the hover title -- user-specified 2026-08-05 ("tower health should be
   visible like soldier/archer health"). Bottom-left corner: top-left is
   the owner flag, bottom-right is the upgrade star, so this is the one
   free corner. Same look as a soldier's own .badge for visual
   consistency (small black circle, white text).
   REAL BUG found 2026-08-08 (user: "im not seeing hp visible on
   homebase" -- after tt_hp_badge_html() was already fixed to always
   render): this selector only ever matched .building-art (tower/
   armory/wizard tower/gnoll cave), never .home-base-art -- the home
   base's own badge was genuinely present in the DOM the whole time
   (verified directly against cell_html() output before), just with
   ZERO styling applied, rendering as unpositioned plain text instead
   of the visible badge. */
.building-art .hp-badge, .home-base-art .hp-badge {
    position: absolute;
    bottom: -4px;
    left: -4px;
    background: #000;
    color: #fff;
    border-radius: 50%;
    font-size: 0.55rem;
    font-weight: bold;
    min-width: 14px;
    height: 14px;
    line-height: 14px;
    text-align: center;
    padding: 0 2px;
    z-index: 2;
}
.cell .home-base-art {
    position: absolute;
    inset: 4%;
    z-index: 2; /* see .cell .bridge-bar's comment -- bumped from 1 to open a gap for it */
}
.cell .home-base-art img { width: 100%; height: 100%; object-fit: contain; display: block; }
.cell.legal-target {
    cursor: pointer;
    box-shadow: inset 0 0 0 3px var(--accent);
}
.cell.legal-target:hover { background: rgba(90, 90, 214, .35); }
.cell.bridge-first { cursor: pointer; box-shadow: inset 0 0 0 3px var(--bridge); background: rgba(224, 169, 78, .35); }
.cell.bridge-target { cursor: pointer; box-shadow: inset 0 0 0 3px var(--bridge); }
.cell.bridge-target:hover { background: rgba(224, 169, 78, .35); }
#bridge-toggle-btn.selected { background: var(--bridge); }
.cell.magic-bridge-first { cursor: pointer; box-shadow: inset 0 0 0 3px var(--magic); background: rgba(166, 77, 255, .35); }
.cell.magic-bridge-target { cursor: pointer; box-shadow: inset 0 0 0 3px var(--magic); }
.cell.magic-bridge-target:hover { background: rgba(166, 77, 255, .35); }
#magic-bridge-toggle-btn.selected { background: var(--magic); }
.cell.build-target { cursor: pointer; box-shadow: inset 0 0 0 3px var(--build); }
.cell.build-target:hover { background: rgba(78, 175, 107, .35); }
#build-toggle-btn.selected { background: var(--build); }
.cell.armory-target { cursor: pointer; box-shadow: inset 0 0 0 3px var(--armory); }
.cell.armory-target:hover { background: rgba(176, 111, 214, .35); }
#armory-toggle-btn.selected { background: var(--armory); }
.cell.upgrade-tower-target { cursor: pointer; box-shadow: inset 0 0 0 3px var(--upgrade); }
.cell.upgrade-tower-target:hover { background: rgba(240, 196, 25, .35); }
#upgrade-tower-toggle-btn.selected { background: var(--upgrade); color: #2a2000; }
.cell.upgrade-armory-target { cursor: pointer; box-shadow: inset 0 0 0 3px var(--upgrade); }
.cell.upgrade-armory-target:hover { background: rgba(240, 196, 25, .35); }
#upgrade-armory-toggle-btn.selected { background: var(--upgrade); color: #2a2000; }
.cell.mine-tile-target { cursor: pointer; box-shadow: inset 0 0 0 3px var(--mine); }
.cell.mine-tile-target:hover { background: rgba(212, 175, 55, .35); }
#mine-tile-toggle-btn.selected { background: var(--mine); color: #2a2000; }
.cell.wizard-tower-target { cursor: pointer; box-shadow: inset 0 0 0 3px var(--wizard); }
.cell.wizard-tower-target:hover { background: rgba(91, 141, 238, .35); }
#wizard-tower-toggle-btn.selected { background: var(--wizard); }
.cell.upgrade-mine-target { cursor: pointer; box-shadow: inset 0 0 0 3px var(--upgrade); }
.cell.upgrade-mine-target:hover { background: rgba(240, 196, 25, .35); }
#upgrade-mine-toggle-btn.selected { background: var(--upgrade); color: #2a2000; }
.cell.upgrade-wizard-tower-target { cursor: pointer; box-shadow: inset 0 0 0 3px var(--upgrade); }
.cell.upgrade-wizard-tower-target:hover { background: rgba(240, 196, 25, .35); }
#upgrade-wizard-tower-toggle-btn.selected { background: var(--upgrade); color: #2a2000; }
#autoplay-toggle-btn.selected { background: var(--success); }
/* User-specified 2026-08-07: relocated out of the header (see game.php's
   own comment) -- a small, out-of-the-way footer row below everything
   else rather than a full-width button, since it's a rarely-touched
   toggle, not a primary action. */
.autoplay-footer { display: flex; justify-content: center; margin-top: 0.75rem; }
.autoplay-footer button { font-size: 0.8rem; padding: 0.4rem 0.8rem; opacity: 0.85; }

.hud { display: flex; justify-content: space-between; margin-bottom: 0.75rem; font-size: 0.9rem; }
.hud .you { color: var(--seat0); }
.hud .opp { color: var(--seat1); }

/* Compact single-row action bar, right under the board. Buttons wrap on
   narrow screens instead of stacking as separate full-width cards, and
   #action-hint has a reserved min-height so swapping its text between
   modes never shifts the board or buttons above it. */
.action-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin: 0.6rem 0;
}
.action-bar form { margin: 0; }
.action-bar button {
    font-size: 0.85rem;
    padding: 0.5rem 0.7rem;
    white-space: nowrap;
}
.action-bar select {
    font-size: 0.8rem;
    padding: 0.3rem;
    margin-right: 0.3rem;
    max-width: 40vw;
}
/* Build popup (user-specified 2026-08-07, "simplify the buttons") --
   Bridge/Tower collapse into one "Build ▾" trigger + a small anchored
   dropdown, same compact-button sizing as the rest of .action-bar. */
.build-popup-wrap { position: relative; }
.build-popup {
    position: absolute;
    top: 100%;
    /* Anchored from the RIGHT edge of the trigger button, not the left --
       "Build" is the last button in the action bar (rightmost), so a
       left-anchored popup grows off the right edge of the viewport on a
       phone-width screen (real bug found 2026-08-08 via a live mobile
       screenshot: the Bridge/Magic Bridge/Tower buttons were cut off,
       only a sliver visible). Growing leftward from the button's own
       right edge instead keeps it on-screen at every width. */
    right: 0;
    z-index: 5;
    margin-top: 0.3rem;
    padding: 0.4rem;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    max-width: calc(100vw - 2rem);
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,.4);
}
.build-popup form { margin: 0; }
.build-popup button { width: 100%; }
/* Structure upgrade hover popups (user-specified 2026-08-07: "make the
   upgrade buttons on towers when you hover over them as a popup") --
   JS-positioned (`position:fixed`, see ttShowHoverPopupForCell() in
   game.php), NOT a CSS :hover child of the cell, since `.board`'s own
   `overflow:hidden` would clip a popup anchored near the board's edge. */
.tt-floating-popup {
    position: fixed;
    z-index: 50;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,.4);
    padding: 0.4rem;
}
.tt-floating-popup-inner { display: flex; flex-direction: column; gap: 0.4rem; }
.tt-floating-popup form { margin: 0; }
.tt-floating-popup button { width: 100%; white-space: nowrap; }
/* A structure AND a soldier can share one cell (e.g. a unit standing on
   its own tower) -- 2 separate popup groups then stack in one floating
   popup (see ttShowHoverPopupForCell() in game.php); a divider between
   them makes clear they're two distinct things to upgrade. */
.tt-floating-popup-inner + .tt-floating-popup-inner {
    margin-top: 0.4rem;
    padding-top: 0.4rem;
    border-top: 1px solid var(--border);
}
#action-hint {
    min-height: 2.4em;
    margin: 0 0 0.75rem;
    font-size: 0.85rem;
    color: var(--muted);
}

.hand-tiles { display: flex; gap: 0.75rem; flex-wrap: wrap; margin: 0.5rem 0 1rem; }
.hand-tile-visual {
    display: flex;
    flex-direction: row-reverse; /* count to the LEFT of the tile art, see below */
    align-items: center;
    gap: 0.3rem;
    cursor: pointer;
    padding: 0.4rem;
    border: 2px solid transparent;
    border-radius: 8px;
}
.hand-tile-visual input { position: absolute; opacity: 0; pointer-events: none; }
.hand-tile-visual .tile-preview {
    width: 56px;
    height: 56px;
    border-radius: 4px;
    position: relative;
    /* .cell/.field already set background/position via the shared classes
       applied in game.php's markup -- this block only adds hand-specific
       sizing so the same road-bar markup renders identically whether it's
       on the board or in your hand. */
}
/* User-specified 2026-08-04: "orient the multiples piece to the left
   instead of below the tile" -- was a separate line below the art
   (flex-direction:column); row-reverse above plus this fixed width keeps
   it a compact left-hand label instead. */
.hand-tile-visual .count { font-size: 0.75rem; color: var(--muted); width: 1.4em; text-align: right; }
.hand-tile-visual.selected { border-color: var(--accent); background: rgba(90,90,214,.15); }
.hand-tile-visual .rotate-hint {
    display: none;
    position: absolute;
    top: -2px;
    right: -2px;
    font-size: 0.85rem;
    color: var(--accent);
    background: var(--card-bg);
    border-radius: 50%;
    line-height: 1;
    padding: 1px;
}
.hand-tile-visual.selected .rotate-hint { display: inline; }

.actions { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-top: 1rem; }
.log { max-height: 150px; overflow-y: auto; font-size: 0.75rem; color: var(--muted); font-family: monospace; }
.back { color: var(--muted); text-decoration: none; font-size: 0.85rem; }

/* Brief dim+disable while an action's fetch() is in flight -- 2026-08-06
   AJAX conversion (user-specified: "make this game flow nicely... not be
   a jerky experience"), a small guard against the board looking
   clickable while a submit is still resolving (also doubles as the
   double-submit prevention's visual counterpart -- see ttSubmitForm() in
   game.php). Transition is deliberately short; this is meant to read as
   "just a moment," not a real loading spinner. */
#game-root.tt-pending { opacity: 0.6; pointer-events: none; transition: opacity 150ms ease; }
