:root {
    --bg: #161412;            /* menus: charcoal with a little brown, to go with the boards */
    --panel: #201d1a;
    --panel-2: #302c27;
    --edge: #100e0c;          /* underside of the chunky buttons */
    --line: rgba(255, 240, 220, 0.08);
    --text: #eeeae4;
    --dim: #a8a29a;
    --disc: #303236;          /* the round buttons: charcoal in a light ring */
    --ring: #e6e4df;
    --green: #03cc35;         /* the game's done green (bgComplete.png) */
    --star: #ffd34d;
    --ink: #15171c;
    --shade: 0 1px 2px rgba(0, 0, 0, 0.9), 0 0 10px rgba(0, 0, 0, 0.55);
    font-family: system-ui, -apple-system, 'Segoe UI', sans-serif;
    color: var(--text);
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    height: 100%;
    overflow: hidden;
    -webkit-text-size-adjust: 100%;
    -webkit-tap-highlight-color: transparent;
    background: radial-gradient(120% 90% at 50% 35%, #172238 0%, #0a111e 70%);
    user-select: none;
    -webkit-user-select: none;
}

#map {
    position: fixed;
    inset: 0;
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    cursor: default;
    touch-action: none;
}

button {
    font: inherit;
    color: inherit;
    border: 0;
    background: none;
    cursor: pointer;
    padding: 0;
    touch-action: manipulation;
}

i.star {
    display: inline-block;
    width: 0.95em;
    height: 0.95em;
    margin: 0 0.18em 0 0;
    vertical-align: -0.1em;
    background: url(/textures/misc/resource.png) center / contain no-repeat;
}

.cost i.star, small i.star { margin: 0 0 0 0.1em; }

/* top: score, stars, turn, as in the game */
#hud {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 110px;
    padding-top: max(14px, env(safe-area-inset-top));
    display: flex;
    justify-content: center;
    align-items: flex-start;
    background: linear-gradient(rgba(8, 13, 30, 0.82), rgba(8, 13, 30, 0));
    pointer-events: none;
    text-shadow: var(--shade);
}

#stats { display: flex; }

.stat {
    padding: 0 26px;
    text-align: center;
    min-width: 112px;
}

.stat + .stat { border-left: 1px solid rgba(255, 255, 255, 0.4); }
.stat span { display: block; font-size: 13px; font-weight: 500; opacity: 0.9; white-space: nowrap; }
.stat b { display: block; font-size: 27px; font-weight: 700; line-height: 1.2; white-space: nowrap; }
.stat b small { font-size: 14px; font-weight: 600; opacity: 0.8; }
.stat .dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 6px; box-shadow: 0 0 0 1.5px rgba(0, 0, 0, 0.5); }
.stat .dot.on { box-shadow: 0 0 0 2px #fff; }

/* games of three or more AIs: one column per tribe, wrapping on narrow screens */
#stats.many { flex-wrap: wrap; justify-content: center; row-gap: 8px; max-width: calc(100vw - 32px); }
#stats.many .stat { padding: 0 16px; min-width: 0; }
#stats.many .stat b { font-size: 21px; }
#stats.many .stat.out { opacity: 0.45; }
.stat .peace { width: 15px; height: 15px; object-fit: contain; vertical-align: -3px; margin: 0 3px 0 7px; }
.stat .peace ~ .dot { width: 7px; height: 7px; margin-right: 3px; }

#foe { position: absolute; left: 16px; top: 14px; }

.foe {
    display: flex;
    align-items: center;
    gap: 9px;
    opacity: 0.85;
}

.foe.active { opacity: 1; }
.foe img { width: 38px; height: 38px; object-fit: contain; filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.7)); }
.foe span { display: block; font-size: 12px; font-weight: 500; opacity: 0.9; }
.foe b { display: block; font-size: 16px; font-weight: 700; }
.foe .dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 5px; box-shadow: 0 0 0 1.5px rgba(0, 0, 0, 0.5); }
.foe b small { font-size: 12px; opacity: 0.8; }

#odds { position: absolute; right: 16px; top: 14px; text-align: right; }
#odds span { display: block; font-size: 12px; font-weight: 500; opacity: 0.9; white-space: nowrap; }
#odds b { display: block; font-size: 16px; font-weight: 700; white-space: nowrap; font-variant-numeric: tabular-nums; }
#odds b small { font-size: 12px; font-weight: 600; opacity: 0.85; }
#odds .dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 5px; box-shadow: 0 0 0 1.5px rgba(0, 0, 0, 0.5); }

#kills { position: fixed; right: 16px; top: 50%; transform: translateY(-50%); z-index: 6; pointer-events: none; background: rgba(8, 13, 30, 0.55); border-radius: 10px; padding: 6px 10px 7px; text-shadow: var(--shade); color: #fff; min-width: 96px; }
#kills span { display: block; font-size: 11px; font-weight: 600; opacity: 0.85; margin-bottom: 2px; }
#kills b { display: flex; align-items: center; font-size: 13px; font-weight: 600; white-space: nowrap; }
#kills b em { font-style: normal; font-weight: 800; margin-left: auto; padding-left: 12px; font-variant-numeric: tabular-nums; }
#kills .dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 5px; box-shadow: 0 0 0 1.5px rgba(0, 0, 0, 0.5); }
.rb .disc.emoji { font-size: 24px; line-height: 1; text-shadow: none; }
.rb.small { width: 66px; }
#killsbtn[hidden] { display: none; }
#killsbtn { position: absolute; right: max(12px, env(safe-area-inset-right)); bottom: max(12px, env(safe-area-inset-bottom)); pointer-events: auto; }
.rb.small .disc { width: 46px; height: 46px; }
.rb.small .disc.emoji { font-size: 19px; }

/* notifications under the top bar */
#toasts {
    position: fixed;
    top: max(112px, calc(env(safe-area-inset-top) + 98px));
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    pointer-events: none;
    z-index: 5;
    width: max-content;
    max-width: calc(100vw - 32px);
}
.toast {
    background: rgba(8, 13, 30, 0.86);
    color: #fff;
    font-size: 15px;
    font-weight: 600;
    padding: 9px 18px;
    border-radius: 999px;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
    text-align: center;
    display: flex;
    align-items: center;
    gap: 9px;
    animation: toast-in 0.25s ease-out;
    transition: opacity 0.5s, transform 0.5s;
}
.toast img { height: 24px; max-width: 30px; object-fit: contain; }
.toast.out { opacity: 0; transform: translateY(-8px); }
@keyframes toast-in { from { transform: translateY(-8px); } to { transform: none; } } /* no fade: stays readable if frames are paused */

/* bottom: round buttons, as in the game */
#dock {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    padding: 46px 12px max(12px, env(safe-area-inset-bottom));
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    background: linear-gradient(rgba(8, 13, 30, 0), rgba(8, 13, 30, 0.86));
    pointer-events: none;
    text-shadow: var(--shade);
}

#info {
    padding: 8px 18px;
    border-radius: 14px;
    background: rgba(10, 16, 36, 0.8);
    text-align: center;
    text-shadow: none;
}

#info[hidden] { display: none; }
#info b { display: block; font-size: 16px; font-weight: 700; }
#info span { display: block; font-size: 12.5px; color: #c9d3e6; margin-top: 1px; }

#bar {
    display: flex;
    gap: 14px;
    align-items: flex-start;
    justify-content: center;
    flex-wrap: wrap;
    pointer-events: auto;
}

.rb {
    width: 84px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    font-size: 12.5px;
    font-weight: 600;
    line-height: 1.15;
    text-align: center;
    text-shadow: var(--shade);
}

.rb .disc {
    width: 62px;
    height: 62px;
    display: grid;
    place-items: center;
    background: radial-gradient(circle closest-side, var(--disc) 0 83%, var(--ring) 84% 95%, transparent 96.5%);
    filter: drop-shadow(0 2px 5px rgba(0, 0, 0, 0.5));
    transition: transform 0.08s;
}

@media (hover: hover) { .rb:hover .disc { transform: scale(1.07); } }
.rb:active .disc { transform: scale(0.96); }
.rb .disc svg { width: 28px; height: 28px; fill: none; stroke: #fff; stroke-width: 2.3; stroke-linecap: round; stroke-linejoin: round; }
.rb .disc svg.fill { fill: #fff; stroke: none; }
.rb .pic { width: 42px; height: 42px; background: center / contain no-repeat; }
.rb .pic.zoom { width: 56px; height: 56px; background-size: 185%; background-position: 50% 46%; border-radius: 50%; }
.rb.green .disc { background-image: url(/textures/misc/bgComplete.png); }
.rb.off { opacity: 0.45; pointer-events: none; }
.rb .cost { color: var(--star); font-weight: 700; }
.rb.speed { width: 170px; padding-top: 22px; gap: 22px; }
#speed { width: 150px; accent-color: #e6e4df; pointer-events: auto; }

/* overlays */
#overlay {
    position: fixed;
    inset: 0;
    z-index: 10;
    display: grid;
    place-items: center;
    background: rgba(6, 10, 18, 0.6);
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
}

#overlay[hidden] { display: none !important; }
#overlay.clear { background: none; backdrop-filter: none; -webkit-backdrop-filter: none; pointer-events: none; place-items: end center; padding-bottom: 150px; }
#overlay.clear .card { pointer-events: auto; }
#overlay.full { display: block; place-items: normal; background: none; backdrop-filter: none; -webkit-backdrop-filter: none; }

.card {
    position: relative;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 0;
    padding: 28px 30px;
    max-width: calc(100vw - 40px);
    max-height: calc(100vh - 40px);
    overflow: auto;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05), 0 24px 70px rgba(0, 0, 0, 0.5);
}

.card h1 { margin: 0 0 6px; font-size: 22px; font-weight: 750; letter-spacing: -0.015em; }
.card .lead { margin: 0 0 20px; font-size: 14px; line-height: 1.45; color: var(--dim); }
.card h2 { margin: 20px 0 9px; font-size: 11.5px; font-weight: 650; letter-spacing: 0.09em; text-transform: uppercase; color: var(--dim); }

.seg { display: inline-flex; padding: 4px; border-radius: 0; background: var(--bg); border: 1px solid var(--line); gap: 2px; flex-wrap: wrap; }
.seg button { padding: 8px 14px; border-radius: 0; font-size: 13.5px; font-weight: 650; color: var(--dim); transition: color 0.15s, background 0.15s; }
.seg button.on { background: var(--panel-2); color: var(--text); box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.07), 0 2px 6px rgba(0, 0, 0, 0.35); }

/* setup: the two sides, each with its tribe */
.cols { display: grid; grid-template-columns: 1fr auto 1fr; gap: 22px; }
.vs {
    align-self: start;
    margin-top: 13px;
    width: 42px;
    height: 42px;
    border-radius: 0;
    display: grid;
    place-items: center;
    font-size: 13px;
    font-weight: 800;
    letter-spacing: 0.04em;
    color: var(--dim);
    background: var(--bg);
    border: 1px solid var(--line);
}
.pick { display: flex; align-items: center; gap: 12px; margin: 0 0 14px; min-height: 64px; }
.pick img { width: 58px; height: 58px; object-fit: contain; filter: drop-shadow(0 4px 3px rgba(0, 0, 0, 0.45)); }
.pick span { display: block; font-size: 11.5px; font-weight: 650; letter-spacing: 0.09em; text-transform: uppercase; color: var(--dim); }
.pick b { display: flex; align-items: center; gap: 8px; margin-top: 2px; font-size: 21px; font-weight: 750; letter-spacing: -0.01em; }
.pick b i { width: 11px; height: 11px; border-radius: 0; background: var(--c); box-shadow: 0 0 0 1.5px rgba(0, 0, 0, 0.4); }
.tribes { display: grid; grid-template-columns: repeat(4, 76px); gap: 7px; }

.tribe {
    height: 76px;
    border-radius: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    padding-bottom: 6px;
    font-size: 11px;
    font-weight: 650;
    color: var(--dim);
    background: var(--panel-2) center 8px / 44px no-repeat;
    box-shadow: 0 3px 0 var(--edge);
    transition: transform 0.08s, background-color 0.15s;
}

@media (hover: hover) { .tribe:hover { background-color: #3b362f; color: var(--text); } }
.tribe:active { transform: translateY(2px); }
.tribe.on {
    color: var(--text);
    background-color: color-mix(in srgb, var(--c) 24%, var(--panel-2));
    box-shadow: inset 0 0 0 2px var(--c), 0 3px 0 var(--edge);
}
.row { display: flex; column-gap: 24px; row-gap: 0; flex-wrap: wrap; }

/* setup with three or more tribes: the players in a row, one tribe list below */
.slots { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; margin-bottom: 14px; }
.pick.slot { margin: 0; min-height: 0; padding: 8px 10px; text-align: left; border: 1px solid var(--line); background: var(--bg); }
.pick.slot.on { border-color: var(--c); box-shadow: inset 0 0 0 1px var(--c); background: var(--panel-2); }
.pick.slot img { width: 40px; height: 40px; }
.pick.slot b { font-size: 16px; }
.tribes.wide { grid-template-columns: repeat(auto-fill, minmax(76px, 1fr)); }
.tribe:disabled { opacity: 0.35; cursor: default; }
.lead.small { font-size: 13px; margin-top: 10px; }
.lead.error { color: #ff8a7a; }

/* the game's chunky buttons: a flat face on a darker edge that sinks when pressed */
.primary {
    margin-top: 26px;
    height: 52px;
    width: 100%;
    border-radius: 0;
    background: #e9e3d9;
    color: #18191b;
    font-size: 16px;
    font-weight: 750;
    letter-spacing: 0.01em;
    box-shadow: 0 4px 0 #8d8478;
    transition: transform 0.08s, box-shadow 0.08s, filter 0.15s;
}
.primary:active { transform: translateY(3px); box-shadow: 0 1px 0 #8d8478; }

@media (hover: hover) {
    .primary:hover { filter: brightness(1.08); }
    .ghost:hover { color: var(--text); background: rgba(255, 255, 255, 0.05); }
    .choice:hover { filter: brightness(1.12); }
    .mode:hover { filter: brightness(1.1); }
    .tnode:hover { transform: scale(1.08); z-index: 2; }
}
.ghost { margin-top: 10px; height: 42px; width: 100%; border-radius: 0; color: var(--dim); font-size: 14px; font-weight: 650; }

/* menu pages: start, skill, setup, over a picture of a real board; the notice sits at the bottom */
#overlay.pages {
    display: block;
    place-items: normal;   /* newer browsers also centre (and shrink) block children */
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    background: radial-gradient(110% 85% at 50% 40%, #2a2621 0%, var(--bg) 62%);
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
}
.page {
    position: relative;
    isolation: isolate;
    min-height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: max(24px, env(safe-area-inset-top)) 16px max(16px, env(safe-area-inset-bottom));
    overflow: hidden;
}
.page .card { margin: auto 0; max-height: none; }
.art { position: absolute; inset: 0; z-index: -1; pointer-events: none; overflow: hidden; }
.art img {
    position: absolute;
    left: 50%;
    top: 50%;
    width: min(1600px, 125vw);
    transform: translate(-50%, -50%);
    opacity: 0.13;
    filter: blur(2px) saturate(0.7);
}
.notice {
    max-width: 560px;
    margin: 22px 0 0;
    padding: 9px 16px;
    border: 7px solid transparent;
    border-image: repeating-linear-gradient(-45deg, #f2c200 0 10px, #111 10px 20px) 7;
    background: var(--panel);
    font-size: 11.5px;
    line-height: 1.5;
    text-align: center;
    color: #fff;
}

.card.start { width: 420px; }
.card.home { overflow: visible; }
.card.home h1 { font-size: 30px; font-weight: 800; letter-spacing: -0.03em; }
/* the start card is boarded up: four planks nailed along its sides */
.card.home { padding: 38px 38px 36px; border: 0; }
.plank {
    position: absolute;
    z-index: 2;
    pointer-events: none;
    background:
        radial-gradient(circle, #d6d4cf 0 1px, #8d8a84 2px, #4d4a45 3.2px, #2a2825 4px, transparent 4.6px) 0 0 / 10px 10px no-repeat,
        radial-gradient(circle, #d6d4cf 0 1px, #8d8a84 2px, #4d4a45 3.2px, #2a2825 4px, transparent 4.6px) 0 0 / 10px 10px no-repeat,
        var(--grain),
        linear-gradient(var(--wood-dir), #7b6553, #67533f 55%, #574534);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.12), inset 0 -1px 0 rgba(0, 0, 0, 0.3), 0 2px 5px rgba(0, 0, 0, 0.45);
}
.plank.t, .plank.b {
    height: 22px;
    --wood-dir: 180deg;
    --grain: repeating-linear-gradient(180deg, rgba(40, 26, 14, 0.25) 0 1px, transparent 1px 4px, rgba(40, 26, 14, 0.12) 4px 5px, transparent 5px 7px);
    background-position: 8px 50%, calc(100% - 8px) 50%, 0 0, 0 0;
}
.plank.l, .plank.r {
    width: 22px;
    z-index: 1;
    --wood-dir: 90deg;
    --grain: repeating-linear-gradient(90deg, rgba(40, 26, 14, 0.25) 0 1px, transparent 1px 4px, rgba(40, 26, 14, 0.12) 4px 5px, transparent 5px 7px);
    background-position: 50% 8px, 50% calc(100% - 8px), 0 0, 0 0;
}
.plank.t { top: -8px; left: -14px; right: -9px; transform: rotate(-0.8deg); }
.plank.b { bottom: -8px; left: -8px; right: -15px; transform: rotate(0.6deg); }
.plank.l { left: -8px; top: -12px; bottom: -15px; transform: rotate(0.7deg); }
.plank.r { right: -8px; top: -15px; bottom: -11px; transform: rotate(-0.5deg); }
.card.home h1 .bot { font-size: 0.9em; margin-left: 8px; }
.modes { display: flex; flex-direction: column; gap: 14px; }
.mode {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 16px 18px 16px 20px;
    border-radius: 0;
    background: var(--panel-2);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06), 0 4px 0 var(--edge);
    text-align: left;
    transition: transform 0.08s, box-shadow 0.08s, filter 0.15s;
}
.mode:active { transform: translateY(3px); box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06), 0 1px 0 var(--edge); }
.mode.main { background: #e9e3d9; color: #18191b; box-shadow: 0 4px 0 #8d8478; }
.mode.main:active { box-shadow: 0 1px 0 #8d8478; }
.mode .txt { flex: 1; min-width: 0; }
.mode b { display: block; font-size: 17px; font-weight: 750; }
.mode .txt span { display: block; margin-top: 3px; font-size: 13.5px; color: var(--dim); }
.mode.main .txt span { color: #555; }
.mode .chev { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; opacity: 0.75; }
/* start screen: the bot in Polytopia itself, and the Discord link */
.elsewhere { margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 14px; }
.ingame b { display: block; font-size: 15px; font-weight: 750; }
.ingame span { display: block; margin-top: 4px; font-size: 13.5px; line-height: 1.6; color: var(--dim); }
.ingame strong { color: var(--text); font-weight: 700; }
.ingame .code { display: inline; padding: 1px 7px; border-radius: 0; background: var(--panel-2); color: var(--text);
    font: 650 12.5px ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: 0.04em; cursor: copy; user-select: all; }
.discord { display: flex; align-items: center; justify-content: center; gap: 10px; height: 44px; background: var(--panel-2);
    color: var(--text); font-size: 14.5px; font-weight: 700; text-decoration: none;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06), 0 4px 0 var(--edge); transition: transform 0.08s, box-shadow 0.08s; }
.discord:active { transform: translateY(3px); box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06), 0 1px 0 var(--edge); }
.discord svg { width: 20px; height: 20px; fill: currentColor; }
.cardtop { display: flex; align-items: center; gap: 12px; margin-bottom: 4px; }
.cardtop h1 { margin: 0; }
.back { width: 36px; height: 36px; border-radius: 0; display: grid; place-items: center; background: var(--panel-2); box-shadow: 0 2px 0 var(--edge); flex: none; }
.back svg { width: 18px; height: 18px; fill: none; stroke: #fff; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }

/* game over */
.card.over { width: 380px; text-align: center; }
.card.over .head { display: block; width: 84px; height: 84px; margin: 0 auto 10px; object-fit: contain; filter: drop-shadow(0 6px 4px rgba(0, 0, 0, 0.45)); }
.card.over h1 { font-size: 28px; }

/* reward choice */
.choices { display: flex; gap: 12px; }
.choice { width: 172px; padding: 16px 14px; border-radius: 0; background: var(--panel-2); text-align: left; box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06), 0 4px 0 var(--edge); transition: transform 0.08s, filter 0.15s; }
.choice:active { transform: translateY(3px); }
.choice b { display: block; font-size: 14.5px; margin-bottom: 4px; }
.choice img { display: block; height: 52px; max-width: 72px; object-fit: contain; margin-bottom: 8px; }
.choice span { font-size: 12.5px; color: var(--dim); line-height: 1.35; }

/* tech tree: a wheel around the tribe, as in the game */
.tech {
    position: absolute;
    inset: 0;
    background: radial-gradient(90% 80% at 50% 50%, #303236 0%, #222326 55%, #161719 100%);
    overflow: hidden;
}

.tech h1 { margin: 18px 0 2px; text-align: center; font-size: 22px; font-weight: 700; }
.tech .hint { margin: 0 64px; text-align: center; font-size: 13px; color: #c8c7c3; }

.tclose {
    position: absolute;
    top: 16px;
    right: 18px;
    width: 42px;
    height: 42px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    background: rgba(255, 255, 255, 0.12);
}

.tclose:hover { background: rgba(255, 255, 255, 0.22); }
.tclose svg { width: 20px; height: 20px; stroke: #fff; stroke-width: 2.4; stroke-linecap: round; fill: none; }

.tree {
    position: absolute;
    left: 50%;
    top: calc(50% + 14px);
    width: 0;
    height: 0;
    transform: scale(var(--k, 1));
}

.tlines { position: absolute; left: -540px; top: -540px; width: 1080px; height: 1080px; pointer-events: none; }
.tlines line { stroke: rgba(255, 255, 255, 0.28); stroke-width: 5; stroke-linecap: round; }
.tlines line.on { stroke: #6fe07a; }

.thub {
    position: absolute;
    left: -52px;
    top: -52px;
    width: 104px;
    height: 104px;
    border-radius: 50%;
    background: #1d1e21 center / 74% no-repeat;
    box-shadow: 0 0 0 5px rgba(255, 255, 255, 0.85);
}

.tnode {
    position: absolute;
    width: 86px;
    height: 86px;
    margin: -43px 0 0 -43px;
    display: grid;
    place-items: center;
    background: url(/textures/misc/bgUnavailable.png) center / contain no-repeat;
    transition: transform 0.08s;
}

.tnode.open { background-image: radial-gradient(circle closest-side, var(--disc) 0 80%, var(--ring) 81% 91%, transparent 92.5%); }
.tnode.done { background-image: url(/textures/misc/bgComplete.png); }
.tnode.dear { background-image: radial-gradient(circle closest-side, var(--disc) 0 80%, #e5533d 81% 91%, transparent 92.5%); }
.tnode.sel { filter: drop-shadow(0 0 10px #fff); }
.tnode .pic { width: 54px; height: 54px; background: center / contain no-repeat; }
.tnode .pic.zoom { width: 76px; height: 76px; background-size: 185%; background-position: 50% 46%; border-radius: 50%; }
.tnode.locked .pic { opacity: 0.38; filter: grayscale(0.9); }

.tname {
    position: absolute;
    top: 88px;
    left: 50%;
    transform: translateX(-50%);
    white-space: nowrap;
    font-size: 15px;
    font-weight: 650;
    text-align: center;
    text-shadow: var(--shade);
    line-height: 1.15;
}

.tname small { display: block; font-size: 14px; font-weight: 700; color: var(--star); }
.tnode.locked .tname { color: #a3a4a6; }
.tnode.locked .tname small { opacity: 0.7; }

.tcard {
    position: absolute;
    left: 50%;
    bottom: 22px;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 22px;
    padding: 14px 16px 14px 22px;
    border-radius: 18px;
    background: rgba(29, 30, 33, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.16);
    box-shadow: 0 16px 50px rgba(0, 0, 0, 0.5);
    white-space: nowrap;
}

.tcard b { display: block; font-size: 17px; }
.tcard span { display: block; font-size: 13px; color: #c8c7c3; margin-top: 2px; min-height: 16px; }
.tcard button { height: 44px; padding: 0 22px; border-radius: 22px; font-size: 14.5px; font-weight: 700; }
.tcard button.go { background: #37b24d; color: #fff; }
.tcard button.go:hover { filter: brightness(1.12); }
.tcard button.no { background: rgba(255, 255, 255, 0.1); color: #c8c7c3; cursor: default; }

/* tech tree while watching (AI games, replays): a tab per player, its techs in the order it got them */
.ttabs { display: flex; justify-content: center; flex-wrap: wrap; gap: 6px; margin: 10px 64px 0; }
.ttab { display: flex; align-items: center; gap: 7px; padding: 4px 12px 4px 6px; border: 1px solid rgba(255, 255, 255, 0.16); background: rgba(255, 255, 255, 0.05); font-size: 13.5px; font-weight: 650; color: #c8c7c3; }
.ttab img { width: 26px; height: 26px; object-fit: contain; }
.ttab.on { color: #fff; border-color: var(--c); box-shadow: inset 0 0 0 1px var(--c); background: rgba(255, 255, 255, 0.12); }
.hint.order { margin: 9px 64px 0; white-space: nowrap; overflow-x: auto; scrollbar-width: none; }
.hint.order::-webkit-scrollbar { display: none; }
.hint.order b { color: #fff; font-weight: 700; }
.hint.order i { margin: 0 9px; font-style: normal; opacity: 0.5; }
.tname small.when { color: #bdf0c4; font-weight: 650; }

/* tech tree on phones: one row per branch */
.tlist {
    position: absolute;
    top: 84px;
    left: 0;
    right: 0;
    bottom: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 4px 10px 150px;
}
.tbranch {
    display: grid;
    grid-template-columns: 1fr 2fr;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}
.tbranch .troot { grid-row: span 2; }
.trow { display: grid; grid-template-columns: 1fr 1fr; }
.tlist .tnode {
    position: relative;
    width: 100%;
    height: auto;
    margin: 0;
    padding: 4px 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    background: none;
}
.tlist .tnode::before {
    content: '';
    position: absolute;
    top: 4px;
    left: 50%;
    width: 58px;
    height: 58px;
    margin-left: -29px;
    background: url(/textures/misc/bgUnavailable.png) center / contain no-repeat;
}
.tlist .tnode.open::before { background-image: radial-gradient(circle closest-side, var(--disc) 0 80%, var(--ring) 81% 91%, transparent 92.5%); }
.tlist .tnode.done::before { background-image: url(/textures/misc/bgComplete.png); }
.tlist .tnode.dear::before { background-image: radial-gradient(circle closest-side, var(--disc) 0 80%, #e5533d 81% 91%, transparent 92.5%); }
.tlist .tnode .pic { position: relative; width: 58px; height: 58px; background-size: 64%; background-position: center; }
.tlist .tnode .pic.zoom { background-size: 150%; background-position: 50% 46%; border-radius: 50%; }
.tlist .tname { position: static; transform: none; margin-top: 3px; font-size: 12px; white-space: normal; max-width: 100%; }
.tlist .tname small { font-size: 11.5px; }

/* narrow windows */
@media (max-width: 760px) {
    .card { padding: 22px 18px; }
    .cols { grid-template-columns: 1fr; gap: 0; }
    .vs { display: none; }
    .pick { min-height: 0; margin: 4px 0 10px; }
    .pick img { width: 44px; height: 44px; }
    .pick b { font-size: 18px; }
    .cols > div + div + div .pick { margin-top: 18px; }
    .tribes { grid-template-columns: repeat(auto-fill, minmax(62px, 1fr)); }
    .tribe { height: 66px; background-size: 38px; font-size: 10.5px; }

    .choices { flex-direction: column; }
    .choice { width: 100%; }
    .stat { padding: 0 14px; min-width: 0; }
    .stat b { font-size: 22px; }
    .stat span { font-size: 12px; }
    #foe { top: 74px; left: 12px; }
    #odds { top: 74px; right: 12px; }
    #toasts { top: max(142px, calc(env(safe-area-inset-top) + 134px)); }
    .toast { font-size: 13.5px; padding: 8px 14px; }
    .rb { width: 70px; font-size: 11.5px; flex: none; }
    .rb .disc { width: 54px; height: 54px; }
    .rb.small .disc { width: 42px; height: 42px; }
    .rb .pic { width: 36px; height: 36px; }
    .rb .pic.zoom { width: 48px; height: 48px; }
    /* one row that scrolls sideways when a city offers many units */
    #bar { gap: 6px; flex-wrap: nowrap; max-width: 100%; overflow-x: auto; scrollbar-width: none; justify-content: flex-start; }
    #bar::-webkit-scrollbar { display: none; }
    #bar > :first-child { margin-left: auto; }
    #bar > :last-child { margin-right: auto; }
    #dock { padding-top: 30px; gap: 8px; }
    #info { max-width: calc(100vw - 24px); padding: 6px 14px; }
    #info b { font-size: 15px; }
    #info span { font-size: 12px; }
    .card h1 { font-size: 19px; }
    .tribes { gap: 5px; }
}

/* phones: six tribes per row so both sides fit on one screen */
@media (max-width: 480px) {
    /* phones: no kill counter at all (his choice) */
    #killsbtn, #kills { display: none; }
    .card.home { padding: 34px 26px 32px; }
    .card { padding: 18px 14px; }
    .card h2 { margin: 14px 0 6px; }
    .tribes { grid-template-columns: repeat(6, 1fr); gap: 4px; }
    .tribe { height: 54px; background-size: 30px; background-position: center 5px; font-size: 9.5px; padding-bottom: 4px; border-radius: 0; letter-spacing: -0.01em; }
    .seg button { padding: 7px 11px; }
    .primary { margin-top: 18px; }
    .rb.speed { width: 132px; }
    #speed { width: 122px; }
    #odds span { white-space: normal; max-width: 140px; margin-left: auto; }
    .tcard { flex-direction: column; gap: 10px; white-space: normal; text-align: center; width: calc(100vw - 32px); }
    /* watching: Menu, Play, Speed, Fog, Techs fit one row */
    #bar.watch { gap: 4px; }
    #bar.watch .rb { width: 58px; }
    #bar.watch .rb.speed { width: 96px; }
    #bar.watch #speed { width: 88px; }
    .ttabs, .hint.order { margin-left: 16px; margin-right: 16px; }
    .ttabs { margin-right: 64px; justify-content: flex-start; }
    .ttab { font-size: 12.5px; padding-right: 9px; }
}

/* phones held sideways: slimmer bars so the map keeps some height */
@media (max-height: 500px) {
    #hud { height: 74px; padding-top: max(6px, env(safe-area-inset-top)); }
    .stat span { font-size: 11px; }
    .stat b { font-size: 20px; }
    #foe { top: 8px; }
    #odds { top: 8px; }
    #toasts { top: 70px; }
    .foe img { width: 30px; height: 30px; }
    #dock { padding: 18px 12px max(6px, env(safe-area-inset-bottom)); gap: 4px; }
    .rb { width: 64px; font-size: 11px; }
    .rb .disc { width: 46px; height: 46px; }
    .rb.small .disc { width: 36px; height: 36px; }
    .rb .pic { width: 32px; height: 32px; }
    .rb .pic.zoom { width: 42px; height: 42px; }
    .rb .disc svg { width: 22px; height: 22px; }
}

/* the narrowest phones */
@media (max-width: 360px) {
    .rb { width: 62px; font-size: 10.5px; }
    .rb .disc { width: 48px; height: 48px; }
    .rb.small .disc { width: 38px; height: 38px; }
    .rb .pic { width: 32px; height: 32px; }
    .rb .pic.zoom { width: 42px; height: 42px; }
}

/* replays */
.card.replays .modes { max-height: min(60vh, 520px); overflow-y: auto; padding: 2px 4px 6px 0; }
.mode .txt .comment { font-style: italic; color: var(--dim); overflow-wrap: anywhere; }
.share { margin-top: 6px; }
.share textarea { display: block; width: 100%; box-sizing: border-box; margin: 0 0 10px; padding: 10px 12px; font: inherit; font-size: 14px; color: inherit; background: var(--panel-2); border: 1px solid var(--line); border-radius: 0; resize: vertical; }
.lead.shared { margin: 14px 0 0; }

/* ---- Nov 12 2026: setup on phones, turn slider, win-chance graph, hint, daily map, replay list ---- */

/* setup: the strength row takes the full width, one line says what the picked strength is */
.row .wide { flex-basis: 100%; }
.note { margin: 8px 0 0; font-size: 13px; line-height: 1.4; color: var(--dim); min-height: 18px; }

/* narrow screens: each side's tribe is a button that opens its list */
.pick.tap {
    width: 100%;
    margin: 0 0 10px;
    padding: 8px 10px 8px 8px;
    text-align: left;
    background: var(--panel-2);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06), 0 3px 0 var(--edge);
}
.pick.tap.open { box-shadow: inset 0 0 0 2px var(--c), 0 3px 0 var(--edge); }
.pick.tap em { margin-left: auto; padding: 6px 10px; font-style: normal; font-size: 12.5px; font-weight: 650; color: var(--dim); background: var(--bg); border: 1px solid var(--line); }
.pick.tap + .tribes { margin-bottom: 12px; }

/* watching: a side of the top bar */
.stat.side em { font-style: normal; }
.stat.side .role { display: none; }

/* the turn slider of a replay, over the round buttons */
#timeline {
    width: min(560px, calc(100vw - 24px));
    padding: 7px 14px 5px;
    border-radius: 14px;
    background: rgba(10, 16, 36, 0.72);
    pointer-events: auto;
    text-shadow: none;
}
#timeline[hidden] { display: none; }
.tl-top { display: flex; justify-content: center; align-items: baseline; gap: 6px; }
.tl-top b { font-size: 15px; font-weight: 750; font-variant-numeric: tabular-nums; }
.tl-top span { font-size: 12px; color: #c9d3e6; }
.tl-track { position: relative; }
.tl-curve { display: none; position: absolute; left: 10px; top: 4px; width: calc(100% - 20px); height: 32px; overflow: visible; pointer-events: none; }
#timeline.curve .tl-curve { display: block; }
#timeline.curve .tl-track { padding-top: 38px; }
.tl-curve path { fill: none; stroke-width: 2; stroke-linejoin: round; vector-effect: non-scaling-stroke; }
.tl-curve .mid { stroke: rgba(255, 255, 255, 0.3); stroke-width: 1; stroke-dasharray: 2 3; vector-effect: non-scaling-stroke; }
#timeline input { -webkit-appearance: none; appearance: none; display: block; width: 100%; height: 24px; margin: 0; background: none; cursor: pointer; touch-action: none; }
#timeline input::-webkit-slider-runnable-track { height: 5px; background: linear-gradient(90deg, var(--ring) var(--p, 0%), rgba(255, 255, 255, 0.25) var(--p, 0%)); }
#timeline input::-webkit-slider-thumb { -webkit-appearance: none; width: 20px; height: 20px; margin-top: -7.5px; border-radius: 50%; background: var(--disc); border: 2.5px solid var(--ring); box-shadow: 0 2px 5px rgba(0, 0, 0, 0.5); }
#timeline input::-moz-range-track { height: 5px; background: rgba(255, 255, 255, 0.25); }
#timeline input::-moz-range-progress { height: 5px; background: var(--ring); }
#timeline input::-moz-range-thumb { width: 16px; height: 16px; border-radius: 50%; background: var(--disc); border: 2.5px solid var(--ring); box-shadow: 0 2px 5px rgba(0, 0, 0, 0.5); }

/* the win-chance graph on the game-over card */
.card.over { width: 400px; }
.graph h2 { margin: 0 0 8px; }
.graph { margin: 2px 0 2px; padding: 12px 12px 10px; background: var(--bg); border: 1px solid var(--line); text-align: left; }
.gtop { display: flex; align-items: baseline; flex-wrap: wrap; column-gap: 12px; row-gap: 2px; margin-bottom: 6px; }
.gtop b { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 700; }
.gtop .dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; }
.gsvg svg { display: block; width: 100%; height: auto; touch-action: manipulation; }
.gsvg svg.jump { cursor: pointer; }
.gsvg .grid { stroke: rgba(255, 240, 220, 0.1); stroke-width: 1; }
.gsvg .mid { stroke: rgba(255, 240, 220, 0.3); stroke-width: 1; stroke-dasharray: 3 4; }
.gsvg .ax { font-size: 9.5px; fill: var(--dim); font-variant-numeric: tabular-nums; }
.gsvg .line { fill: none; stroke-width: 2.4; stroke-linejoin: round; stroke-linecap: round; }
.gsvg .under { fill: none; stroke: rgba(0, 0, 0, 0.55); stroke-width: 5; stroke-linejoin: round; stroke-linecap: round; }
.gsvg .area { opacity: 0.13; stroke: none; }
.gsvg .tail { fill: none; stroke-width: 1.6; stroke-dasharray: 3 3; opacity: 0.75; }
.gsvg .swing { stroke: var(--bg); stroke-width: 2; }
.gsvg .probe line { stroke: rgba(255, 255, 255, 0.55); stroke-width: 1; }
.gsvg .probe rect { fill: #e9e3d9; }
.gsvg .probe text { font-size: 9.5px; font-weight: 700; fill: #18191b; }
.swings { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 10px; }
.swings span { width: 100%; font-size: 11px; font-weight: 650; letter-spacing: 0.09em; text-transform: uppercase; color: var(--dim); }
.swings button { padding: 6px 10px; background: var(--panel-2); font-size: 12.5px; font-weight: 700; box-shadow: 0 2px 0 var(--edge); }
.swings button:active { transform: translateY(2px); box-shadow: none; }
.swings button small { margin-left: 5px; font-size: 12px; font-weight: 650; font-variant-numeric: tabular-nums; color: var(--dim); }
.swings button.down small { color: #ff9a8a; }
.swings button.up small { color: #8fe39a; }
.ghint { margin: 8px 0 0; font-size: 11.5px; color: var(--dim); }

/* the daily map */
.card.daily { width: 470px; }
.duel { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 10px; margin: 0 0 10px; }
.duel > div { display: grid; grid-template-columns: auto 1fr; column-gap: 10px; align-items: center; padding: 10px 12px 10px 13px; background: var(--bg); border: 1px solid var(--line); box-shadow: inset 4px 0 0 var(--a); min-width: 0; }
.duel > div:last-child { box-shadow: inset 4px 0 0 var(--b); }
.duel img { grid-row: span 2; width: 46px; height: 46px; object-fit: contain; filter: drop-shadow(0 3px 2px rgba(0, 0, 0, 0.45)); }
.duel span { align-self: end; font-size: 11px; font-weight: 650; letter-spacing: 0.09em; text-transform: uppercase; color: var(--dim); }
.duel b { align-self: start; font-size: 17px; font-weight: 750; overflow: hidden; text-overflow: ellipsis; }
.duel > i { font-style: normal; font-size: 12px; font-weight: 800; letter-spacing: 0.04em; color: var(--dim); }
.facts { margin: 0 0 14px; font-size: 13px; line-height: 1.45; color: var(--dim); }
.table + .facts { margin: 8px 0 0; }
.field { display: block; }
.field span { display: block; margin-bottom: 7px; font-size: 11.5px; font-weight: 650; letter-spacing: 0.09em; text-transform: uppercase; color: var(--dim); }
.field input { display: block; width: 100%; height: 44px; padding: 0 12px; font: inherit; font-size: 15px; font-weight: 600; color: var(--text); background: var(--panel-2); border: 1px solid var(--line); border-radius: 0; user-select: text; -webkit-user-select: text; }
.field input::placeholder { color: var(--dim); opacity: 0.7; font-weight: 500; }
.field input:focus { outline: 2px solid #e9e3d9; outline-offset: -1px; }
.card.daily .primary { margin-top: 14px; }
.table { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 3px; }
.table li { display: grid; grid-template-columns: 30px 1fr auto 74px; align-items: center; gap: 8px; padding: 9px 12px 9px 6px; background: var(--bg); border: 1px solid var(--line); font-size: 14px; }
.table li i { font-style: normal; font-weight: 800; text-align: center; color: var(--dim); font-variant-numeric: tabular-nums; }
.table:not(.past) li:first-child i { color: var(--star); }
.table li b { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.table li span { font-weight: 700; white-space: nowrap; font-variant-numeric: tabular-nums; }
.table li em { font-style: normal; font-size: 12px; text-align: right; white-space: nowrap; color: var(--dim); }
.table li.me { border-color: #e9e3d9; box-shadow: inset 0 0 0 1px #e9e3d9; }
.table.past li { grid-template-columns: 34px auto 1fr 84px; }
.table.past b { display: flex; align-items: center; }
.table.past b small { margin-left: 4px; font-size: 12px; font-weight: 600; color: var(--dim); }
.table.past span { text-align: right; font-weight: 600; overflow: hidden; text-overflow: ellipsis; }
.hd { width: 22px; height: 22px; object-fit: contain; vertical-align: -5px; margin-right: 5px; }
.empty { margin: 0; padding: 14px; text-align: center; font-size: 13.5px; color: var(--dim); background: var(--bg); border: 1px dashed rgba(255, 240, 220, 0.16); }
.smallprint { margin: 16px 0 0; font-size: 12px; line-height: 1.5; color: var(--dim); }
.dailyres { display: grid; grid-template-columns: 1fr auto; column-gap: 12px; align-items: center; margin: 0 0 10px; padding: 10px 10px 10px 12px; background: var(--bg); border: 1px solid var(--line); text-align: left; }
.dailyres b { font-size: 13px; font-weight: 750; }
.dailyres span { grid-column: 1; font-size: 13px; line-height: 1.4; color: var(--dim); }
.dailyres .ghost { grid-column: 2; grid-row: 1 / span 2; width: auto; height: 36px; margin: 0; padding: 0 12px; background: var(--panel-2); color: var(--text); font-size: 13px; }

/* the replay list */
.card.replays { width: 660px; }
.seg.tabs { margin: 12px 0; }
.seg.tabs[hidden] { display: none; }
.seg.tabs small { margin-left: 3px; font-weight: 600; opacity: 0.65; }
.rlist { display: flex; flex-direction: column; gap: 8px; max-height: min(64vh, 640px); overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 2px 6px 6px 0; }
.rrow { flex: none; display: grid; grid-template-columns: 136px 1fr 20px; gap: 14px; align-items: center; padding: 8px 14px 8px 8px; background: var(--panel-2); text-align: left; box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06), 0 3px 0 var(--edge); transition: transform 0.08s, filter 0.15s; }
.rrow:active { transform: translateY(2px); }
@media (hover: hover) { .rrow:hover { filter: brightness(1.1); } .swings button:hover { filter: brightness(1.15); } }
.rrow .thumb { width: 136px; aspect-ratio: 5 / 3; overflow: hidden; background: var(--bg); }
.rrow .thumb img { display: block; width: 100%; height: 100%; object-fit: cover; }
.rrow .thumb.heads { display: flex; justify-content: center; align-items: center; gap: 2px; }
.rrow .thumb.heads img { width: 42px; height: 42px; margin: 0; object-fit: contain; filter: drop-shadow(0 3px 2px rgba(0, 0, 0, 0.45)); }
.rrow .txt { min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.rrow q { quotes: '“' '”'; font-size: 15px; font-weight: 700; line-height: 1.3; overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.rrow b { display: flex; align-items: center; flex-wrap: wrap; font-size: 15px; font-weight: 700; }
.rrow q + b { font-size: 13px; font-weight: 600; color: var(--dim); }
.rrow q + b .hd { width: 18px; height: 18px; vertical-align: -4px; }
.rrow b .sd { white-space: nowrap; }
.rrow b i { margin: 0 8px; font-style: normal; font-size: 11px; font-weight: 800; color: var(--dim); }
.rrow b small { margin-left: 5px; font-size: 12px; font-weight: 600; color: var(--dim); }
.rrow .meta { font-size: 12.5px; color: var(--dim); }
.rrow .meta em { font-style: normal; font-weight: 700; color: var(--text); }
.rrow .chev { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; opacity: 0.6; }

/* a replay's picture (?shot): the last board alone, a caption at the bottom */
body.shot #hud, body.shot #dock, body.shot #toasts, body.shot #kills, body.shot #overlay { display: none !important; }
#shotcap { position: fixed; left: 0; right: 0; bottom: 0; display: flex; align-items: baseline; gap: 20px; padding: 70px 36px 26px; background: linear-gradient(rgba(12, 10, 8, 0), rgba(12, 10, 8, 0.93) 58%); color: #fff; }
#shotcap b { font-size: 36px; font-weight: 800; letter-spacing: -0.03em; white-space: nowrap; }
#shotcap b span { margin-left: 8px; font-size: 0.85em; }
#shotcap > span { font-size: 21px; font-weight: 600; line-height: 1.3; color: #e4ded4; }

@media (max-width: 760px) {
    /* the Play button stays in reach while a tribe list is open */
    .page { overflow: clip; }
    .page .card { overflow: visible; }
    .page .card > .primary { position: sticky; bottom: max(10px, env(safe-area-inset-bottom)); z-index: 3; box-shadow: 0 4px 0 #8d8478, 0 -8px 16px 8px var(--panel); }
    .cols > div + div + div .pick.tap { margin-top: 0; }
    .stat.side { max-width: calc(50vw - 40px); }
    .stat.side span { overflow: hidden; text-overflow: ellipsis; }
    .stat.side .r, .stat.side .sc { display: none; }
    .stat.side .role { display: block; margin-top: 1px; font-size: 10.5px; font-weight: 600; line-height: 1.15; opacity: 0.78; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
    .card.over, .card.daily, .card.replays { width: auto; }
    .rrow { grid-template-columns: 96px 1fr; gap: 10px; padding: 7px 10px 7px 7px; }
    .rrow .thumb { width: 96px; }
    .rrow .thumb.heads img { width: 32px; height: 32px; }
    .rrow .chev { display: none; }
    .rrow q { font-size: 14px; }
    .rlist { max-height: none; overflow: visible; padding-right: 0; }
}
@media (max-width: 480px) {
    /* play: Menu, Fog, Tech Tree, Hint, End Turn fit one row */
    #bar.five { gap: 2px; }
    #bar.five .rb { width: 64px; }
    .duel { grid-template-columns: 1fr; gap: 6px; }
    .duel > i { display: none; }
    .table li { grid-template-columns: 26px 1fr auto 62px; gap: 6px; padding-right: 8px; font-size: 13.5px; }
    .table.past li { grid-template-columns: 30px auto 1fr; }
    .table.past li em { display: none; }
    .dailyres { grid-template-columns: 1fr; row-gap: 8px; }
    .dailyres .ghost { grid-column: 1; grid-row: auto; }
    #timeline { padding: 6px 10px 3px; }
    .swings button { padding: 5px 8px; font-size: 12px; }
    .swings button small { margin-left: 3px; font-size: 11.5px; }
    .card.over .head { width: 64px; height: 64px; margin-bottom: 6px; }
    .card.over h1 { font-size: 24px; }
}

/* ---- Nov 12 2026, design pass (his "Can you improve the design as well?"), then stripped back the same evening
   (his "a bit too loaded"): fewer parts, more of the board, no planks, a quiet notice ---- */

/* keyboard focus is visible; scrollbars are thin and dark */
:focus-visible { outline: 2px solid #e9e3d9; outline-offset: 2px; }
#map:focus-visible, input[type=range]:focus-visible { outline: none; }
#overlay.pages, .rlist, .card { scrollbar-width: thin; scrollbar-color: #4a443c transparent; }

/* a card slides in when its page opens (no fade, so it is readable from the first frame) */
@keyframes card-in { from { transform: translateY(12px); } to { transform: none; } }
#overlay.enter .card { animation: card-in 0.2s cubic-bezier(0.2, 0.8, 0.3, 1); }
@media (prefers-reduced-motion: reduce) { #overlay.enter .card { animation: none; } }

/* the board behind the menus is shown clearly; it darkens towards the edges and under the card */
#overlay.pages { background: var(--bg); }
.art img { opacity: 0.62; filter: saturate(0.92); }
.art::after { content: ''; position: absolute; inset: 0; background: radial-gradient(85% 75% at 50% 45%, rgba(22, 20, 18, 0.25) 0%, rgba(22, 20, 18, 0.9) 100%); }
.page .card { box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05), 0 18px 60px rgba(0, 0, 0, 0.7); }

/* the notice: a plain small line at the bottom of each menu page */
.notice { max-width: 640px; margin: 20px 0 0; padding: 7px 14px; border: 1px solid var(--line); border-image: none; background: rgba(22, 20, 18, 0.82); font-size: 11.5px; line-height: 1.5; color: #c4beb5; }

/* start: a plain card (no planks); today's two tribes beside "Daily map"; Polytopia and Discord as two quiet lines */
.card.start { width: 400px; }
.card.home { padding: 30px 30px 24px; border: 1px solid var(--line); overflow: auto; }
.card.home h1 { font-size: 28px; }
.modes { gap: 12px; }
.mode b .today { display: inline-flex; margin-left: 9px; vertical-align: -5px; }
.mode .today .hd { width: 22px; height: 22px; margin: 0 0 0 -3px; vertical-align: 0; filter: drop-shadow(0 2px 2px rgba(0, 0, 0, 0.5)); }
.elsewhere { margin-top: 20px; padding-top: 14px; gap: 8px; }
.ingame { margin: 0; font-size: 12.5px; line-height: 1.65; color: var(--dim); }
.ingame .code { font-size: 11.5px; padding: 1px 6px; }
.discord { justify-content: flex-start; align-self: flex-start; gap: 7px; height: auto; background: none; box-shadow: none; color: var(--dim); font-size: 12.5px; font-weight: 650; }
.discord:active { transform: none; box-shadow: none; }
.discord svg { width: 16px; height: 16px; }
@media (hover: hover) { .discord:hover { color: var(--text); } }

/* setup: each side is one row with its tribe; "Change" opens the list. Wide screens: both sides in one line,
   the list across the card, the settings as a table (names left, choices right) */
.pick.tap { box-shadow: inset 3px 0 0 var(--c), inset 0 1px 0 rgba(255, 255, 255, 0.06), 0 3px 0 var(--edge); padding-left: 11px; }
.pick.tap.open { box-shadow: inset 0 0 0 2px var(--c), 0 3px 0 var(--edge); }
@media (hover: hover) { .pick.tap:hover { filter: brightness(1.1); } }
@media (min-width: 761px) {
    .card.setup { width: 700px; }
    .card.setup .cols { grid-template-columns: 1fr 42px 1fr; column-gap: 12px; row-gap: 12px; margin-top: 14px; align-items: center; }
    .card.setup .side { display: contents; }
    .card.setup .side .pick { grid-row: 1; margin: 0; }
    .card.setup .side:first-child .pick { grid-column: 1; }
    .card.setup .side:last-child .pick { grid-column: 3; }
    .card.setup .vs { grid-column: 2; grid-row: 1; margin: 0; }
    .card.setup .side .tribes { grid-column: 1 / -1; grid-row: 2; grid-template-columns: repeat(8, 1fr); gap: 6px; margin: 0; }
    .card.setup .tribe { height: 66px; background-size: 40px; background-position: center 6px; padding-bottom: 5px; }
    .card.setup .slots { margin-top: 14px; }
    .card.setup .seg button { padding: 8px 11px; }
    .card.setup .row { display: grid; grid-template-columns: max-content 1fr; column-gap: 18px; row-gap: 8px; align-items: center; margin-top: 20px; }
    .card.setup .row > div { display: contents; }
    .card.setup .row h2 { margin: 0; }
    .card.setup .row .seg { justify-self: start; }
    .card.setup .row .note { grid-column: 2; margin: -2px 0 0; }
    .card.setup .primary { margin-top: 22px; }
}

/* game over: the winner's head, the result, turn and scores in one strip, the graph, one main button; the rest
   is a row of quiet links */
.ostats { display: flex; margin: 12px 0 14px; background: var(--bg); border: 1px solid var(--line); }
.ostats > div { flex: 1 1 0; min-width: 0; padding: 9px 8px 8px; }
.ostats > div:first-child { flex: 0 0 68px; }
.ostats > div + div { border-left: 1px solid var(--line); }
.ostats span { display: block; font-size: 11px; font-weight: 650; letter-spacing: 0.07em; text-transform: uppercase; color: var(--dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ostats .dot { display: inline-block; width: 8px; height: 8px; margin-right: 6px; border-radius: 50%; background: var(--c); }
.ostats b { display: block; margin-top: 2px; font-size: 19px; font-weight: 750; font-variant-numeric: tabular-nums; color: var(--dim); }
.ostats > div:first-child b, .ostats .win b { color: var(--text); }
.ostats.many { flex-wrap: wrap; }
.ostats.many > div { flex: 1 0 30%; border-left: 0; box-shadow: inset 1px 0 0 var(--line), inset 0 1px 0 var(--line); }
.ostats.many > div:first-child { flex: 1 0 100%; }
.ostats.many b { font-size: 16px; }
.card.over .primary { margin-top: 16px; }
.links { display: flex; flex-wrap: wrap; justify-content: center; column-gap: 20px; margin-top: 12px; }
.links .ghost { width: auto; height: 34px; margin: 0; padding: 0 4px; font-size: 13.5px; }
.links:empty { display: none; }
.share { margin-top: 12px; }
.share textarea[hidden] { display: none; }
.second { display: block; width: 100%; height: 44px; background: var(--panel-2); font-size: 14.5px; font-weight: 700; box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06), 0 4px 0 var(--edge); transition: transform 0.08s, box-shadow 0.08s, filter 0.15s; }
.second:active { transform: translateY(3px); box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06), 0 1px 0 var(--edge); }
@media (hover: hover) { .second:hover { filter: brightness(1.12); } }
.card.over .lead.shared { margin: 14px 0 0; }

/* replay list: the picture appears when it has loaded; a dot says who won */
.rrow .thumb { outline: 1px solid rgba(255, 240, 220, 0.1); outline-offset: -1px; }
.rrow .thumb:not(.heads) img { opacity: 0; transition: opacity 0.2s; }
.rrow .thumb:not(.heads) img.in { opacity: 1; }
.rrow .meta em::before { content: ''; display: inline-block; width: 7px; height: 7px; margin-right: 6px; border-radius: 50%; vertical-align: 1px; background: var(--dim); }
.rrow .meta em.won::before { background: #7fd68a; }
.rrow .meta em.lost::before { background: #e9e3d9; }

@media (max-width: 480px) {
    .card.home { padding: 24px 20px 20px; }
    .ostats b { font-size: 17px; }
    /* the replay tabs in one row */
    .seg.tabs { display: flex; }
    .seg.tabs button { flex: 1 1 auto; padding: 8px 6px; font-size: 13px; }
    .seg.tabs small { display: none; }
}

/* watch setup (Nov 12 2026): one tile per AI, a cross to take it out, a "+" tile to add one */
.slots { grid-template-columns: repeat(auto-fill, minmax(148px, 1fr)); }
.slotw { position: relative; display: flex; }
.slotw .pick.slot { flex: 1; min-width: 0; }
.pick.slot { box-shadow: inset 3px 0 0 var(--c); }
.pick.slot.on { box-shadow: inset 0 0 0 2px var(--c); }
.pick.slot b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pick.slot > div { min-width: 0; }
.slotw .rm { position: absolute; top: 0; right: 0; width: 24px; height: 24px; display: grid; place-items: center; color: var(--dim); }
.slotw .rm svg { width: 11px; height: 11px; fill: none; stroke: currentColor; stroke-width: 3; stroke-linecap: round; }
.pick.slot.add { justify-content: center; gap: 10px; min-height: 58px; border-style: dashed; border-color: rgba(255, 240, 220, 0.22); background: none; box-shadow: none; color: var(--dim); }
.pick.slot.add .plus { font-size: 26px; font-weight: 300; line-height: 1; }
.pick.slot.add b { font-size: 14px; font-weight: 650; }
@media (hover: hover) {
    .slotw .rm:hover { color: var(--text); background: rgba(255, 255, 255, 0.08); }
    .pick.slot:hover { filter: brightness(1.15); }
    .pick.slot.add:hover { color: var(--text); border-color: rgba(255, 240, 220, 0.45); filter: none; }
}
.card.setup .slots + .tribes.wide { margin-bottom: 4px; }
.slotopt { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 18px; margin: 10px 0 2px; }
.slotopt h2 { margin: 0; }
.pick.slot span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.slots { grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); }
.pick.slot b small { margin-left: 2px; font-size: 12px; font-weight: 600; color: var(--dim); }
@media (min-width: 761px) { .card.setup .tribes.wide { grid-template-columns: repeat(8, 1fr); gap: 6px; } }
.slots.many { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 6px; }
.slots.many .pick.slot { padding: 6px 8px; }
.slots.many .pick.slot img { width: 32px; height: 32px; }
.slots.many .pick.slot b { font-size: 14.5px; }
/* games of many AIs: the top bar's columns a little tighter, the notes below its second row */
#stats.many.crowd .stat { padding: 0 11px; }
#stats.many.crowd .stat b { font-size: 18px; }
#stats.many.crowd .stat span { font-size: 12px; }
.stat .nm { font-style: normal; }
@media (max-width: 760px) {
    /* watch setup: two AI tiles per row */
    .slots, .slots.many { grid-template-columns: 1fr 1fr; gap: 6px; }
    .pick.slot { padding: 6px 8px; gap: 8px; }
    .pick.slot img { width: 32px; height: 32px; }
    .pick.slot b { font-size: 15px; }
    .pick.slot.add { min-height: 48px; }
    /* a game of five or more AIs: the top bar shows a dot and a score for each tribe, several to a row */
    #stats.many.packed { row-gap: 3px; column-gap: 0; }
    #stats.many.packed .stat { display: flex; align-items: center; gap: 3px; padding: 0 7px; border-left: 0; }
    #stats.many.packed .stat span { display: inline-flex; align-items: center; font-size: 12px; }
    #stats.many.packed .stat b { font-size: 14px; line-height: 1.3; }
    #stats.many.packed .stat .nm, #stats.many.packed .stat .peace, #stats.many.packed .stat .peace ~ .dot, #stats.many.packed .stat b small { display: none; }
    #stats.many.packed .stat .dot { margin-right: 2px; }
    #stats.many.packed .stat:first-child span { margin-right: 2px; }
}
@media (max-width: 480px) { .tribes.wide { grid-template-columns: repeat(6, 1fr); } }

/* ---- Nov 13 2026: analysis of a recorded game ---- */
/* the turn slider's top row: previous / next difference around the turn, the analysis switch at the right */
.tl-top { position: relative; min-height: 24px; align-items: center; }
.tl-top button { font-size: 12px; font-weight: 650; color: #c9d3e6; padding: 3px 7px; border: 1px solid rgba(255, 255, 255, 0.18); }
.tl-top button[hidden] { display: none; }
.tl-top .tl-nav { margin: 0 6px; }
.tl-top .tl-nav em { font-style: normal; }
.tl-top .tl-an { position: absolute; right: 0; top: 0; }
.tl-top .tl-an.on { color: #15171c; background: #e6e4df; border-color: #e6e4df; }
@media (hover: hover) { .tl-top button:hover { color: #fff; border-color: rgba(255, 255, 255, 0.5); } .tl-top .tl-an.on:hover { color: #15171c; } }
.tl-curve .tick { stroke-width: 3; }
#timeline.curve.ticks .tl-track { padding-top: 52px; }
/* the card at the end: each side next to the AI's choices */
.ansum { margin: 10px 0 0; padding: 12px 12px 12px; background: var(--bg); border: 1px solid var(--line); text-align: left; }
.ansum h2 { margin: 0 0 8px; }
.ansum p { margin: 0 0 6px; font-size: 13px; line-height: 1.45; color: var(--dim); }
.ansum p b { color: var(--text); font-weight: 700; }
.ansum p .dot { display: inline-block; width: 8px; height: 8px; margin-right: 6px; border-radius: 50%; }
.ansum .second { margin-top: 8px; height: 38px; font-size: 13.5px; }
.card.analyze .primary { margin-top: 14px; }
@media (max-width: 480px) {
    .tl-top { justify-content: flex-start; }
    .tl-top .tl-nav { margin: 0 4px; padding: 3px 9px; }
    .tl-top .tl-nav em { display: none; }
}
/* narrow windows: the two difference buttons show only their arrows, so they do not run into the switch */
@media (max-width: 620px) {
    .tl-top { justify-content: flex-start; }
    .tl-top .tl-nav { margin: 0 4px; padding: 3px 9px; }
    .tl-top .tl-nav em { display: none; }
}
/* Nov 13 2026: the slider of a replay that is just watched is slim; the analysis shows each side's chance in percent */
#timeline.plain { padding: 5px 14px 3px; background: rgba(10, 16, 36, 0.55); }
.tl-pct { display: flex; justify-content: center; gap: 18px; margin: 4px 0 0; font-size: 13px; color: #c9d3e6; }
.tl-pct[hidden] { display: none; }
.tl-pct .dot { display: inline-block; width: 8px; height: 8px; margin-right: 6px; border-radius: 50%; }
.tl-pct b { font-weight: 750; color: #fff; font-variant-numeric: tabular-nums; }
