: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;
    --build: #4eaf6b;
    --armory: #b06fd6;
}

* { 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. */
@media (max-width: 480px) {
    .wrap { margin: 0.75rem auto; }
    h1 { font-size: 1.3rem; margin: 0.5rem 0; }
}

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

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: repeat(6, 1fr);
    gap: 3px;
    background: var(--border);
    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;
}
@keyframes tt-jab {
    0% { transform: scale(1); }
    35% { transform: scale(1.3); }
    100% { transform: scale(1); }
}
.tt-anim-jab {
    animation: tt-jab 350ms ease-out;
}
@keyframes tt-push {
    0% { transform: translate(0, 0); }
    35% { transform: translate(var(--push-dx, 0), var(--push-dy, 0)); }
    100% { transform: translate(0, 0); }
}
.tt-anim-push {
    animation: tt-push 350ms ease-out;
}
.tt-arrow {
    position: absolute;
    width: 0;
    height: 0;
    border-top: 5px solid transparent;
    border-bottom: 5px solid transparent;
    border-left: 12px solid currentColor;
    z-index: 3;
    pointer-events: none;
    filter: drop-shadow(0 1px 1px rgba(0,0,0,.6));
}
.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;
    z-index: 1;
}
.cell .bridge-bar img { width: 100%; height: 100%; object-fit: contain; display: block; }
.cell .soldier {
    position: absolute;
    width: 55%;
    height: 55%;
    z-index: 2;
    filter: drop-shadow(0 1px 1px rgba(0,0,0,.6));
}
.cell .soldier img { width: 100%; height: 100%; object-fit: contain; display: block; }
.cell .soldier .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%; }
.cell .building-art {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 72%; /* user-specified 2026-08-04: "make arrow towers bigger" -- was 50% */
    height: 72%;
    z-index: 1;
    filter: drop-shadow(0 1px 1px rgba(0,0,0,.6));
}
.cell .building-art img { width: 100%; height: 100%; object-fit: contain; display: block; }
.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));
}
.cell .home-base-art {
    position: absolute;
    inset: 4%;
    z-index: 1;
}
.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.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); }

.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-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; }
