/* Dunehold: a dark tabletop. The board brings the colour; the interface stays quiet.
   Every colour, size and shadow comes from the tokens below. */
:root {
  /* environment */
  --ocean-deep: #102d40;
  --ocean: #18566b;
  --shallow: #4a9094;
  --sand: #d8c39a;
  /* interface */
  --surface: #172630;
  --surface-2: #233743;
  --surface-3: #2d4554;
  --surface-glass: rgba(23, 38, 48, .86);
  --line: rgba(239, 229, 210, .12);
  --line-strong: rgba(239, 229, 210, .22);
  --text: #efe5d2;
  --text-dim: rgba(239, 229, 210, .62);
  --text-faint: rgba(239, 229, 210, .4);
  --accent: #c6a36a;
  --accent-hi: #e4c78e;
  --accent-ink: #1b1408;
  --danger: #e2735a;
  --ok: #6fc28a;
  /* type */
  --font-display: "Cinzel", Georgia, "Times New Roman", serif;
  --font-ui: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  /* shape */
  --r-sm: 6px;
  --r: 10px;
  --r-lg: 14px;
  --gap: 8px;
  --shadow: 0 6px 18px rgba(0, 0, 0, .35);
  --shadow-lg: 0 18px 50px rgba(0, 0, 0, .55);
  --glow: 0 0 0 1px var(--accent), 0 0 18px rgba(198, 163, 106, .45);
  /* sizes that follow the screen instead of fixed pixels */
  --side-w: clamp(240px, 22vw, 320px);            /* the players sidebar */
  --token: clamp(40px, 6.6vh, 64px);              /* a resource token in the hand column */
  --piece: clamp(24px, 4vh, 36px);                /* a piece icon in the pieces column */
  --edge: clamp(8px, 1.2vw, 16px);                /* how far panels sit from the board's edges */
  --ease: cubic-bezier(.2, .8, .2, 1);
  font-family: var(--font-ui);
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--ocean-deep); color: var(--text); font-size: 14px; line-height: 1.4; display: flex; flex-direction: column; -webkit-font-smoothing: antialiased; }
[hidden] { display: none !important; }
small { color: var(--text-dim); }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: var(--surface-3); border-radius: 8px; }
::-webkit-scrollbar-track { background: transparent; }

/* ---------- buttons ---------- */
button.bga { font: inherit; font-weight: 600; font-size: 13px; padding: 8px 14px; border-radius: var(--r-sm); border: 1px solid var(--line-strong); background: var(--surface-2); color: var(--text); cursor: pointer; display: inline-flex; align-items: center; gap: 6px; transition: background .15s, border-color .15s, transform .1s, box-shadow .15s; white-space: nowrap; }
button.bga:hover:not(:disabled) { background: var(--surface-3); border-color: var(--accent); }
button.bga:active:not(:disabled) { transform: translateY(1px); }
button.bga.primary { background: linear-gradient(var(--accent-hi), var(--accent)); border-color: var(--accent-hi); color: var(--accent-ink); box-shadow: 0 2px 10px rgba(198, 163, 106, .3); }
button.bga.primary:hover:not(:disabled) { background: linear-gradient(#f0d6a2, var(--accent-hi)); }
button.bga:disabled { opacity: .38; cursor: default; }
button.bga.small { padding: 5px 10px; font-size: 12px; }
button.bga.big { padding: 12px 26px; font-size: 15px; }
button.bga.link { border: 0; background: none; color: var(--accent-hi); }
button.bga.link:hover:not(:disabled) { background: none; text-decoration: underline; }
.chip { display: inline-flex; margin-left: 2px; }
.chip .ri { filter: drop-shadow(0 1px 1px rgba(0, 0, 0, .4)); }
.ri, .art { vertical-align: middle; overflow: visible; }
input, select { font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--r-sm); padding: 8px 10px; }
input:focus, select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(198, 163, 106, .2); }
input::placeholder { color: var(--text-faint); }

/* ---------- top bar ---------- */
#topbar { height: 52px; flex: none; position: relative; z-index: 5; display: flex; align-items: center; gap: 18px; padding: 0 16px; background: var(--surface); border-bottom: 1px solid var(--line); }
.logo { display: flex; align-items: center; gap: 10px; }
.logo svg { width: 34px; height: 34px; }
.wordmark { font-family: var(--font-display); font-weight: 700; font-size: 18px; letter-spacing: 2px; color: var(--accent-hi); }
#topbar .meta { display: flex; gap: 16px; color: var(--text-dim); font-size: 12px; align-items: center; }
#topbar .meta b { color: var(--text); letter-spacing: 1.5px; }
#topbar .tools { margin-left: auto; display: flex; gap: 6px; }
.conn { padding: 2px 8px; border-radius: 99px; background: var(--surface-2); font-size: 11px; }
.conn.centrifugo { background: rgba(111, 194, 138, .16); color: var(--ok); }
.conn.local { background: rgba(198, 163, 106, .16); color: var(--accent-hi); }
.conn.down { background: rgba(226, 115, 90, .16); color: var(--danger); }
#turnBanner { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); white-space: nowrap; display: flex; align-items: center; gap: 10px; padding: 6px 16px; border-radius: 99px; background: rgba(198, 163, 106, .14); border: 1px solid var(--accent); box-shadow: 0 0 22px rgba(198, 163, 106, .25); animation: breathe 2.4s ease-in-out infinite; }
#turnMsg { font-family: var(--font-display); font-weight: 700; color: var(--accent-hi); font-size: 14px; letter-spacing: 1px; }
#turnClock { font-variant-numeric: tabular-nums; font-weight: 600; color: var(--text); font-size: 14px; }
#turnClock:empty { display: none; }
@keyframes breathe { 50% { box-shadow: 0 0 32px rgba(198, 163, 106, .45); } }

/* ---------- title and lobby ---------- */
.screen { flex: 1; display: grid; place-items: center; padding: 16px; background:
  url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 1200 300' preserveAspectRatio='none'%3E%3Cpath d='M0 170 Q200 60 420 150 T820 120 T1200 150 V300 H0Z' fill='%23234a5c'/%3E%3Cpath d='M0 220 Q260 120 520 210 T1000 180 T1200 200 V300 H0Z' fill='%231a3a4a'/%3E%3Cpath d='M0 262 Q300 200 620 260 T1200 240 V300 H0Z' fill='%23102d40'/%3E%3C/svg%3E") bottom / 100% 46% no-repeat,
  radial-gradient(circle at 70% 28%, rgba(228, 199, 142, .9) 0 5%, rgba(228, 199, 142, .14) 5.3% 12%, transparent 12.5%),
  linear-gradient(#0c1f2c, #18566b 60%, #2f6f78); }
.titlecard { background: var(--surface-glass); backdrop-filter: blur(10px); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 30px 34px; box-shadow: var(--shadow-lg); width: min(440px, 100%); text-align: center; }
.titlecard.wide { width: min(560px, 100%); text-align: left; }
.titlecard h1 { font-family: var(--font-display); font-size: 40px; letter-spacing: 4px; margin: 0 0 6px; color: var(--accent-hi); }
.titlecard h2 { font-family: var(--font-display); letter-spacing: 1px; margin: 0 0 16px; color: var(--accent-hi); }
.titlecard .tag { color: var(--text-dim); margin: 0 0 22px; }
.biglogo { width: 104px; height: 104px; display: block; margin: 0 auto 10px; filter: drop-shadow(0 6px 16px rgba(0, 0, 0, .5)); }
#titleForm { display: flex; gap: 8px; }
#nameIn { flex: 1; min-width: 0; }
.invite { display: flex; gap: 8px; margin-bottom: 14px; }
.invite input { flex: 1; min-width: 0; color: var(--text-dim); }
.sw { width: 12px; height: 12px; border-radius: 50%; display: inline-block; box-shadow: 0 0 0 2px rgba(255, 255, 255, .15); }
.settings { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 8px; }
.settings label { display: inline-flex; gap: 6px; align-items: center; color: var(--text-dim); }
#lobbyNote { color: var(--text-dim); }

/* ---------- the table ---------- */
#table { flex: 1; display: flex; min-height: 0; }
#main { flex: 1; display: flex; flex-direction: column; min-width: 0; position: relative; }
#boardArea { flex: 1; position: relative; min-height: 0; overflow: hidden; background: radial-gradient(ellipse at 50% 45%, var(--ocean), var(--ocean-deep) 75%); }
#board { position: absolute; top: var(--inset-t, 0px); bottom: var(--inset-b, 0px); left: var(--inset-l, 0px); right: var(--inset-r, 0px); touch-action: none; cursor: grab; user-select: none; }
body.three #board { inset: 0; }
#board2d { width: 100%; height: 100%; display: block; }
#board canvas.board3d { width: 100%; height: 100%; display: block; touch-action: none; }
body.three #board2d, body.three #dice { display: none; }
body.three #boardArea { background: var(--ocean-deep); }

/* The status bar: a full-width strip under the top bar, with the actions in it. */
#status { flex: none; min-height: 56px; padding: 8px 16px; display: flex; align-items: center; justify-content: center; gap: 12px; flex-wrap: wrap; text-align: center; font-size: 16px; font-weight: 500; background: var(--surface-2); border-bottom: 3px solid var(--accent); box-shadow: 0 2px 10px rgba(0, 0, 0, .3); position: relative; z-index: 4; }
#status.mine { background: linear-gradient(var(--surface-3), var(--surface-2)); }
#status .phase { font-family: var(--font-display); font-weight: 700; color: var(--accent-hi); letter-spacing: .5px; margin-right: 4px; }
#status .you { color: var(--accent-hi); font-weight: 700; }
#status small { font-weight: 400; }
#status .pn { filter: brightness(1.25); }
#statusBtns { display: inline-flex; gap: 6px; flex-wrap: wrap; justify-content: center; }
.for { color: var(--text-dim); font-weight: 400; }

/* The left column: zoom, the deck, and your hand as a column of round tokens. */
#leftcol { position: absolute; top: var(--edge); left: var(--edge); max-height: calc(100% - 2 * var(--edge)); z-index: 3; display: flex; flex-direction: column; align-items: center; gap: clamp(6px, 1.2vh, 10px); overflow: hidden; padding-right: 12px; }
.zoomctl { align-self: flex-start; display: flex; background: var(--surface-glass); backdrop-filter: blur(8px); border: 1px solid var(--line); border-radius: var(--r-sm); overflow: hidden; box-shadow: var(--shadow); }
.zoomctl button { background: none; color: var(--text); border: 0; width: 34px; height: 32px; font-size: 17px; cursor: pointer; }
.zoomctl button + button { border-left: 1px solid var(--line); }
.zoomctl button:hover { background: var(--surface-3); color: var(--accent-hi); }
#deck { align-self: flex-start; display: flex; align-items: center; gap: 8px; padding: 6px 10px; border-radius: var(--r); background: var(--surface-glass); border: 1px solid var(--line); box-shadow: var(--shadow); font-weight: 700; color: var(--text); }
.deckcard { width: 40px; height: 48px; filter: drop-shadow(0 3px 4px rgba(0, 0, 0, .45)); }
.handtitle { margin: 4px 0 0; width: 100%; text-align: center; font-family: var(--font-display); font-weight: 600; font-size: 15px; letter-spacing: 1px; color: var(--accent-hi); border-bottom: 1px solid var(--line-strong); padding-bottom: 4px; text-shadow: 0 1px 3px rgba(0, 0, 0, .6); }

/* Building costs: always on the table, bottom right. */
/* The right column stacks the dice (2D board), your pieces left and the costs card, top to bottom,
   so they share the height whatever the screen. */
#rightcol { position: absolute; top: var(--edge); right: var(--edge); bottom: calc(var(--edge) + var(--chat-h, 0px)); z-index: 3; display: flex; flex-direction: column; align-items: flex-end; gap: clamp(8px, 2vh, 18px); pointer-events: none; }
#rightcol > * { pointer-events: auto; }
#costCard { margin-top: auto; z-index: 3; width: clamp(180px, 15vw, 232px); overflow-y: auto; min-height: 0; padding: 9px 11px; font-size: 12.5px; background: var(--surface-glass); backdrop-filter: blur(8px); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow); }
#costRows h4 { margin: 0 0 6px; text-align: center; font-family: var(--font-display); font-size: 12px; letter-spacing: 1.5px; text-transform: uppercase; color: var(--accent-hi); }
.crow { display: grid; grid-template-columns: 1fr auto; border-top: 1px solid var(--line); padding: 5px 0; gap: 2px; }
.crow > div { grid-column: 1 / -1; }
.crow span:first-child { font-weight: 600; }
.cvp { color: var(--accent); font-size: 12px; }
#rates { border-top: 1px solid var(--line); margin-top: 2px; padding-top: 6px; display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; font-size: 11px; color: var(--text-dim); }
#rates .rlabel { width: 100%; text-align: center; font-weight: 600; text-transform: uppercase; letter-spacing: .5px; }
#rates span { display: inline-flex; align-items: center; gap: 2px; }

/* 2D board only: the dice and the board's own type. */
#dice { display: flex; gap: 8px; }
.die { width: 42px; height: 42px; border-radius: 9px; display: grid; grid-template-columns: repeat(3, 1fr); padding: 5px; gap: 1px; box-shadow: inset 0 -4px 0 rgba(0, 0, 0, .22), inset 0 2px 0 rgba(255, 255, 255, .35), 0 4px 10px rgba(0, 0, 0, .45); }
.die.a { background: #b8533a; }
.die.b { background: #e3c27a; }
.die.dim { opacity: .4; }
.die i { display: block; border-radius: 50%; margin: 2px; }
.die i.on { background: #fff8ea; box-shadow: inset 0 1.5px 1px rgba(0, 0, 0, .35); }
.die.b i.on { background: #4a2c0c; }
#board text { font-family: Georgia, serif; text-anchor: middle; pointer-events: none; }
#board .num { font-family: var(--font-display); font-size: 14px; font-weight: 700; fill: #2a2016; }
#board .num.hot { fill: #a8321f; }
#board .hb { font-family: var(--font-ui); font-size: 8.5px; font-weight: 700; fill: #2a2016; }
.pick-v { fill: rgba(255, 248, 230, .9); stroke: var(--accent-ink); stroke-width: 2; cursor: pointer; animation: pulse 1s ease-in-out infinite alternate; }
.pick-vg { cursor: pointer; }
.pick-vg:hover .pick-v { fill: var(--accent-hi); }
.pick-edge { stroke: rgba(255, 248, 230, .75); stroke-width: 12; stroke-linecap: round; cursor: pointer; animation: pulse 1s ease-in-out infinite alternate; }
.pick-edge:hover { stroke: var(--c); }
.pick-hex { fill: rgba(255, 255, 255, .1); stroke: var(--accent-hi); stroke-width: 3; cursor: pointer; }
.pick-hex:hover { fill: rgba(228, 199, 142, .3); }
@keyframes pulse { from { opacity: .55; } to { opacity: 1; } }
.robber { animation: sway 2.6s ease-in-out infinite alternate; transform-box: fill-box; transform-origin: 50% 100%; }
@keyframes sway { from { transform: rotate(-5deg); } to { transform: rotate(5deg); } }

/* ---------- your hand, cards and pieces, round the board ---------- */
#handRes { display: flex; flex-direction: column; gap: clamp(6px, 1.2vh, 10px); align-items: center; }
.token { --c: #888; width: var(--token); height: var(--token); border-radius: 50%; position: relative; display: grid; place-items: center; background: radial-gradient(circle at 38% 32%, color-mix(in srgb, var(--c) 45%, var(--surface-3)), color-mix(in srgb, var(--c) 18%, var(--surface)) 75%); border: 2px solid color-mix(in srgb, var(--c) 60%, var(--line-strong)); box-shadow: inset 0 1px 0 rgba(255, 255, 255, .1), 0 4px 10px rgba(0, 0, 0, .45); transition: transform .2s var(--ease), opacity .2s; }
.token svg { width: calc(var(--token) * .8); height: calc(var(--token) * .8); overflow: visible; filter: drop-shadow(0 2px 2px rgba(0, 0, 0, .45)); }
.token b { position: absolute; right: -10px; top: 50%; transform: translateY(-50%); min-width: calc(var(--token) * .44); height: calc(var(--token) * .44); padding: 0 6px; border-radius: 99px; display: grid; place-items: center; font-size: calc(var(--token) * .22); font-weight: 700; background: var(--accent-hi); color: var(--accent-ink); box-shadow: 0 2px 6px rgba(0, 0, 0, .45); }
.token.zero { opacity: .55; filter: saturate(.6); }
.watching { color: var(--text-dim); font-size: 13px; text-align: center; }

/* Development cards: a fanned row at the bottom left; the one under the pointer lifts. */
#handDevs { position: absolute; left: calc(var(--inset-l, 0px) + var(--edge)); bottom: var(--edge); z-index: 3; display: flex; align-items: flex-end; }
.card.dev { position: relative; width: 96px; height: 128px; flex: none; display: flex; flex-direction: column; overflow: hidden; border-radius: var(--r-sm); background: var(--surface); border: 1px solid var(--line-strong); color: var(--text); box-shadow: 0 6px 14px rgba(0, 0, 0, .45); transition: transform .2s var(--ease), box-shadow .2s; }
.card.dev + .card.dev { margin-left: -42px; }
.card.dev:hover { transform: translateY(-16px) rotate(-1deg); z-index: 2; }
.card.dev .otitle { font-family: var(--font-display); font-size: 10px; font-weight: 700; letter-spacing: .5px; text-align: center; padding: 5px 3px; color: var(--accent-hi); background: var(--surface-2); border-bottom: 1px solid var(--line); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card.dev .oart { line-height: 0; border-bottom: 1px solid var(--line); }
.card.dev .oart svg { width: 100%; height: 54px; display: block; }
.card.dev .otext { font-size: 9px; line-height: 1.25; padding: 5px; color: var(--text-dim); }
.card.dev.playable { border-color: var(--accent); box-shadow: var(--glow), 0 6px 14px rgba(0, 0, 0, .45); cursor: pointer; }
.card.dev em { position: absolute; top: 3px; right: 3px; font-style: normal; font-size: 9px; font-weight: 700; padding: 1px 5px; border-radius: 99px; background: var(--accent-hi); color: var(--accent-ink); }

/* Your pieces left: a column on the right of the board. */
#myPieces { display: flex; flex-direction: column; align-items: flex-end; gap: clamp(6px, 1.6vh, 14px); }
.mp { display: flex; align-items: center; gap: 6px; filter: drop-shadow(0 2px 3px rgba(0, 0, 0, .5)); }
.mp svg { width: var(--piece); height: var(--piece); }
.mpn { min-width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; font-size: 13px; font-weight: 700; background: var(--surface-2); border: 1px solid var(--line-strong); color: var(--text); font-variant-numeric: tabular-nums; }

/* ---------- sidebar: players, log, chat ---------- */
#side { width: var(--side-w); flex: none; display: flex; flex-direction: column; gap: 8px; padding: 10px; background: var(--surface); border-left: 1px solid var(--line); overflow-y: auto; }
#panels { display: flex; flex-direction: column; gap: 8px; }
.panel { position: relative; padding: 10px 12px; border-radius: var(--r); background: var(--surface-2); border: 1px solid var(--line); transition: border-color .3s, box-shadow .3s; }
.panel.current::before { content: ''; position: absolute; left: 0; top: 10px; bottom: 10px; width: 3px; border-radius: 0 3px 3px 0; background: var(--accent); }
.panel.turn { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent), 0 0 20px rgba(198, 163, 106, .22); }
.phead { display: flex; align-items: center; gap: 10px; }
.avatar { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; flex: none; color: #fff; font-weight: 700; font-size: 15px; box-shadow: inset 0 -3px 0 rgba(0, 0, 0, .25), 0 0 0 2px var(--surface), 0 0 0 3px rgba(255, 255, 255, .15); }
.pid { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.pname { font-weight: 700; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; filter: brightness(1.3) saturate(.9); }
.pname small { font-weight: 400; }
.vp { font-weight: 700; color: var(--accent-hi); font-size: 13px; }
.vp sup { font-size: 9px; }
.pright { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.pclock { font-size: 11px; color: var(--accent-hi); font-variant-numeric: tabular-nums; min-height: 14px; }
.dot { width: 8px; height: 8px; border-radius: 50%; }
.dot.on { background: var(--ok); box-shadow: 0 0 6px var(--ok); }
.dot.off { background: var(--surface-3); }
.bigrow { display: grid; grid-template-columns: repeat(4, 1fr); margin: 10px 0 6px; padding: 6px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.big { display: flex; align-items: center; justify-content: center; gap: 4px; }
.big b { font-size: 16px; font-weight: 700; font-variant-numeric: tabular-nums; }
.ic { font-style: normal; width: 24px; height: 24px; display: grid; place-items: center; color: var(--text-dim); }
.ic svg { width: 22px; height: 22px; }
.ic.round { color: var(--text-dim); border-radius: 50%; }
.ic.round.won { color: var(--accent-ink); background: var(--accent-hi); box-shadow: 0 0 10px rgba(228, 199, 142, .6); }
.big.on b { color: var(--accent-hi); }
.prow { display: flex; gap: 10px; align-items: center; font-size: 12px; color: var(--text-dim); flex-wrap: wrap; }
.prow.pieces { justify-content: space-around; font-weight: 600; }
.pc { display: inline-flex; align-items: center; gap: 3px; }
.award { background: var(--accent-hi); color: var(--accent-ink); border-radius: 4px; padding: 0 5px; font-size: 11px; font-weight: 700; }
.pnote { font-size: 11px; color: var(--text-dim); margin-top: 6px; }
.panel button { margin-top: 8px; }
#watchers { font-size: 12px; color: var(--text-faint); padding: 0 4px; }
#watchers:empty { display: none; }
.sidebox { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r); padding: 10px 12px; }
.sidebox h4, #chatHead { margin: 0 0 6px; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 1px; color: var(--text-faint); }
.logbox { flex: 1; min-height: 140px; display: flex; flex-direction: column; }
#log { flex: 1; overflow-y: auto; font-size: 12.5px; color: var(--text-dim); }
#log .entry { padding: 5px 0; border-bottom: 1px solid var(--line); }
#log .entry:first-child { color: var(--text); }
#log .pn, #chatLog .pn { filter: brightness(1.3) saturate(.9); }
.mini-dice { background: var(--surface-3); color: var(--text); border-radius: 4px; padding: 0 5px; font-size: 11px; font-variant-numeric: tabular-nums; }
#chatBar { position: absolute; right: var(--edge); bottom: 0; width: min(340px, 60%); z-index: 10; background: var(--surface-2); border: 1px solid var(--line-strong); border-bottom: 0; border-radius: var(--r) var(--r) 0 0; padding: 9px 12px; box-shadow: 0 -6px 18px rgba(0, 0, 0, .35); }
#chatHead { margin: 0; cursor: pointer; user-select: none; }
#chatHead::after { content: ' ▸'; }
#chatBar.open #chatHead::after { content: ' ▾'; }
#chatBody { display: none; padding-top: 8px; }
#chatBar.open #chatBody { display: block; }
#chatLog { max-height: 160px; overflow-y: auto; font-size: 12.5px; margin-bottom: 6px; }
#chatIn { width: 100%; }

/* ---------- modal and toast ---------- */
#modal { position: fixed; inset: 0; background: rgba(6, 14, 20, .66); backdrop-filter: blur(3px); display: grid; place-items: center; z-index: 20; padding: 16px; }
#modalBox { background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--r-lg); padding: 22px 26px; width: min(620px, 100%); max-height: 90vh; overflow-y: auto; box-shadow: var(--shadow-lg); animation: rise .25s var(--ease); }
@keyframes rise { from { opacity: 0; transform: translateY(12px) scale(.98); } }
#modalBox h2 { font-family: var(--font-display); letter-spacing: .5px; margin: 0 0 10px; color: var(--accent-hi); }
#modalBox h3 { margin: 16px 0 6px; font-size: 13px; text-transform: uppercase; letter-spacing: 1px; color: var(--text-dim); }
#modalBox p { color: var(--text); }
#modalBox b { color: var(--accent-hi); }
.mbtns { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; flex-wrap: wrap; }
.stepper { display: flex; flex-direction: column; gap: 6px; }
.st { display: flex; align-items: center; gap: 8px; }
.st button { width: 28px; height: 28px; border-radius: 50%; border: 1px solid var(--line-strong); background: var(--surface-2); color: var(--text); cursor: pointer; font-weight: 700; }
.st button:hover:not(:disabled) { border-color: var(--accent); color: var(--accent-hi); }
.st button:disabled { opacity: .35; }
.st b { min-width: 18px; text-align: center; }
.offer { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.bankrow { display: flex; align-items: center; gap: 4px; margin-bottom: 6px; flex-wrap: wrap; }
.bankrow > span { width: 30px; font-weight: 700; }
.respick { display: flex; gap: 8px; flex-wrap: wrap; }
.respick button { flex-direction: column; min-width: 84px; }
table.scores, table.costs { border-collapse: collapse; width: 100%; }
table.scores td, table.costs td { padding: 8px 6px; border-bottom: 1px solid var(--line); }
#toast { position: fixed; left: 50%; bottom: 60px; transform: translateX(-50%) translateY(16px); background: var(--surface-2); color: var(--text); border: 1px solid var(--line-strong); padding: 10px 18px; border-radius: 99px; box-shadow: var(--shadow); opacity: 0; pointer-events: none; transition: .25s var(--ease); z-index: 30; }
#toast.on { opacity: 1; transform: translateX(-50%); }

/* ---------- narrower screens ----------
   Sizes are fluid (see the size tokens at the top) and the board measures the panels over it,
   so these only choose which panels to show. */
@media (max-width: 1100px) {
  #topbar .meta span:not(:first-child) { display: none; }
}
/* A narrow window: the board gets the room; the build buttons already show the costs. */
@media (max-width: 1000px), (max-height: 600px) {
  #costCard { display: none; }
}
@media (max-width: 800px) {
  :root { --token: clamp(36px, 5.5vh, 48px); }
  #table { flex-direction: column; overflow-y: auto; }
  #main { flex: none; height: 82vh; }
  #side { width: 100%; border-left: 0; }
  #status { font-size: 14px; }
  #leftcol #deck, .handtitle { display: none; }
  /* The hand runs along the top of the board as a row; the board measures it and fits below. */
  #leftcol { right: var(--edge); flex-direction: row; align-items: center; max-height: none; padding-right: 0; }
  #handRes { flex-direction: row; flex-wrap: wrap; justify-content: center; flex: 1; gap: 14px; }
  #topbar { gap: 8px; padding: 0 10px; }
  #topbar .meta { display: none; }
  #turnBanner { padding: 4px 10px; gap: 6px; }
  #turnMsg { font-size: 11px; letter-spacing: .5px; }
  #turnClock { font-size: 12px; }
  #copyBtn2 { display: none; }
  #myPieces { display: none; }
  #chatBar { width: calc(100% - 2 * var(--edge)); }
  .wordmark { display: none; }
  #turnBanner { position: static; transform: none; padding: 4px 10px; }
  .offer { grid-template-columns: 1fr; }
}

/* ---------- Phase 4: motion and feedback (src/fx.js) ---------- */
button.bga.icon { padding: 5px 8px; }
#muteBtn .cross { display: none; }
#muteBtn.off .cross { display: inline; }
#muteBtn.off .waves { display: none; }
#muteBtn.off { color: var(--text-faint); }

/* Resources flying from a tile into the hand. */
.flyer { position: fixed; left: -22px; top: -22px; width: 44px; height: 44px; z-index: 40; pointer-events: none; filter: drop-shadow(0 4px 6px rgba(0, 0, 0, .5)); }
.flyer svg { width: 100%; height: 100%; overflow: visible; }
.token.bump { animation: bump .45s var(--ease); }
@keyframes bump { 30% { transform: translateY(-8px) scale(1.12); box-shadow: 0 0 0 2px var(--accent-hi), 0 0 18px rgba(228, 199, 142, .6); } }

/* The dice result: pops in over the board, then fades. */
#rollChip { position: absolute; left: 50%; top: 16px; z-index: 5; transform: translateX(-50%); display: flex; align-items: center; gap: 10px; padding: 8px 18px; border-radius: 99px; background: var(--surface-glass); backdrop-filter: blur(8px); border: 1px solid var(--accent); box-shadow: var(--shadow), 0 0 24px rgba(198, 163, 106, .3); opacity: 0; pointer-events: none; }
#rollChip b { font-family: var(--font-display); font-size: 30px; line-height: 1; color: var(--accent-hi); }
#rollChip .rc-dice { font-size: 12px; color: var(--text-dim); font-variant-numeric: tabular-nums; }
#rollChip .rc-note { font-family: var(--font-display); font-weight: 700; color: var(--danger); letter-spacing: .5px; }
#rollChip.seven { border-color: var(--danger); box-shadow: var(--shadow), 0 0 24px rgba(226, 115, 90, .35); }
#rollChip.seven b { color: var(--danger); }
#rollChip.on { animation: chip 2.4s var(--ease) both; }
@keyframes chip { 0% { opacity: 0; transform: translateX(-50%) translateY(-10px) scale(.8); } 12% { opacity: 1; transform: translateX(-50%) scale(1.06); } 20% { transform: translateX(-50%) scale(1); } 80% { opacity: 1; transform: translateX(-50%); } 100% { opacity: 0; transform: translateX(-50%) translateY(-6px); } }

/* Your turn: the banner and the turn notice arrive rather than just appear. */
#turnBanner:not([hidden]) { animation: arrive .5s var(--ease), breathe 2.4s ease-in-out .5s infinite; }
@keyframes arrive { from { opacity: 0; transform: translate(-50%, -50%) scale(.85); } }
#status { animation: none; }
.panel.turn { transition: border-color .4s, box-shadow .4s, transform .4s var(--ease); }
#statusBtns button.bga { animation: rise .25s var(--ease) both; }
#statusBtns button.bga:nth-child(2) { animation-delay: .03s; } #statusBtns button.bga:nth-child(3) { animation-delay: .06s; }
#statusBtns button.bga:nth-child(4) { animation-delay: .09s; } #statusBtns button.bga:nth-child(5) { animation-delay: .12s; } #statusBtns button.bga:nth-child(6) { animation-delay: .15s; }
#log .entry:first-child { animation: rise .3s var(--ease); }

@media (max-width: 800px) { #turnBanner:not([hidden]) { animation: none; } }
/* Players who ask for less motion get none of it. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001s !important; animation-iteration-count: 1 !important; transition-duration: .001s !important; }
}

/* ---------- the trade builder (main.js, modal 'trade') ---------- */
#modalBox:has(.tb) { width: min(760px, 100%); }
.tb { display: grid; gap: 6px; }
.tb-side h3 { margin: 4px 0 8px !important; }
.tb-cards { display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; }
.tcard { --c: #888; position: relative; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 10px 4px 8px; border-radius: var(--r); cursor: pointer; user-select: none;
  background: linear-gradient(170deg, color-mix(in srgb, var(--c) 22%, var(--surface-2)), var(--surface)); border: 1px solid color-mix(in srgb, var(--c) 40%, var(--line)); transition: transform .15s var(--ease), border-color .15s, box-shadow .15s; }
.tcard:hover { transform: translateY(-2px); border-color: var(--accent); }
.tcard:focus-visible { outline: 2px solid var(--accent-hi); outline-offset: 2px; }
.tcard.on { border-color: var(--accent-hi); box-shadow: 0 0 0 1px var(--accent-hi), 0 0 14px rgba(228, 199, 142, .3); }
.tcard.off:not(.on) { opacity: .4; cursor: default; filter: saturate(.5); }
.tcard.off:not(.on):hover { transform: none; border-color: color-mix(in srgb, var(--c) 40%, var(--line)); }
.tcard.off.on { cursor: default; }
.tcard .ri { filter: drop-shadow(0 2px 3px rgba(0, 0, 0, .45)); }
.tname { font-weight: 600; font-size: 13px; }
.tnote { font-size: 11px; color: var(--text-dim); }
.trate { position: absolute; top: 6px; left: 6px; font-size: 10px; font-weight: 700; padding: 1px 6px; border-radius: 99px; background: var(--surface-3); color: var(--text-dim); }
.trate.good { background: rgba(111, 194, 138, .18); color: var(--ok); }
.tcount { position: absolute; top: -9px; right: -9px; min-width: 26px; height: 26px; padding: 0 7px; border-radius: 99px; display: grid; place-items: center; font-size: 14px; background: var(--accent-hi); color: var(--accent-ink); box-shadow: 0 2px 6px rgba(0, 0, 0, .45); }
.tminus { position: absolute; top: -9px; left: -9px; width: 24px; height: 24px; border-radius: 50%; border: 1px solid var(--line-strong); background: var(--surface); color: var(--text); font-weight: 700; cursor: pointer; line-height: 1; }
.tminus:hover { border-color: var(--accent); color: var(--accent-hi); }
.tb-swap { text-align: center; font-size: 18px; color: var(--accent); margin: 2px 0; }
.tb-summary { margin: 14px 0 4px; padding: 10px 14px; border-radius: var(--r); background: var(--surface-2); border: 1px solid var(--line); color: var(--text-dim) !important; }
.tb-summary b { color: var(--text) !important; }
.tb-quick { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 10px; }
.tb-quick > span { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 1px; color: var(--text-faint); margin-right: 4px; }
.tb-actions { margin-top: 14px; }
.tb-hint { margin: 8px 0 0; text-align: right; font-size: 12px; color: var(--text-dim) !important; min-height: 16px; }
@media (max-width: 640px) {
  .tb-cards { grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 6px; }
  .tcard { padding: 8px 2px 6px; }
  .tnote, .tname { font-size: 10px; }
  .tcard .ri { width: 32px; height: 32px; }
}

/* ---------- trade: two guided tabs (main.js, modal 'trade') ---------- */
#modalBox:has(.tt-tabs) { width: min(760px, 100%); }
.tt-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; padding: 4px; margin: 4px 0 12px; border-radius: var(--r); background: var(--surface-2); border: 1px solid var(--line); }
.tt-tab { font: inherit; display: flex; flex-direction: column; align-items: center; gap: 1px; padding: 9px 8px; border-radius: var(--r-sm); border: 1px solid transparent; background: none; color: var(--text-dim); cursor: pointer; }
.tt-tab b { font-size: 14px; color: var(--text); }
.tt-tab small { font-size: 11px; }
.tt-tab:hover { background: var(--surface-3); }
.tt-tab.on { background: var(--surface); border-color: var(--accent); box-shadow: 0 0 12px rgba(198, 163, 106, .2); }
.tt-tab.on b { color: var(--accent-hi); }
.tt-help { margin: 0 0 12px; padding: 9px 12px; border-left: 3px solid var(--accent); border-radius: 0 var(--r-sm) var(--r-sm) 0; background: rgba(198, 163, 106, .07); font-size: 13px; color: var(--text-dim) !important; }
.tt-help b { color: var(--text) !important; }
.tt-step { margin-bottom: 12px; transition: opacity .2s; }
.tt-step.dim { opacity: .45; }
.tt-step h3 { display: flex; align-items: center; gap: 8px; margin: 0 0 8px !important; }
.tt-step h3 span { width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center; background: var(--accent); color: var(--accent-ink); font-size: 11px; letter-spacing: 0; }
.tc-row { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 10px; }
.tc { --c: #888; font: inherit; color: var(--text); position: relative; display: flex; flex-direction: column; align-items: center; gap: 1px; padding: 10px 4px 9px; border-radius: var(--r); cursor: pointer; user-select: none;
  background: linear-gradient(170deg, color-mix(in srgb, var(--c) 22%, var(--surface-2)), var(--surface)); border: 1px solid color-mix(in srgb, var(--c) 40%, var(--line)); transition: transform .15s var(--ease), border-color .15s, box-shadow .15s, opacity .15s; }
.tc:hover:not(:disabled):not(.off) { transform: translateY(-2px); border-color: var(--accent); }
.tc:focus-visible { outline: 2px solid var(--accent-hi); outline-offset: 2px; }
.tc.on { border-color: var(--accent-hi); box-shadow: 0 0 0 1px var(--accent-hi), 0 0 16px rgba(228, 199, 142, .35); }
.tc:disabled, .tc.off { opacity: .38; cursor: default; filter: saturate(.5); }
.tc .ri { filter: drop-shadow(0 2px 3px rgba(0, 0, 0, .45)); }
.tc-name { font-weight: 600; font-size: 13px; }
.tc-main { font-weight: 700; font-size: 12px; color: var(--accent-hi); }
.tc-sub { font-size: 11px; color: var(--text-dim); }
.tc-flag { position: absolute; top: 5px; left: 5px; font-size: 9px; font-weight: 700; padding: 1px 6px; border-radius: 99px; background: rgba(111, 194, 138, .18); color: var(--ok); }
.tc-count { position: absolute; top: -9px; right: -9px; min-width: 26px; height: 26px; padding: 0 7px; border-radius: 99px; display: grid; place-items: center; font-size: 14px; background: var(--accent-hi); color: var(--accent-ink); box-shadow: 0 2px 6px rgba(0, 0, 0, .45); }
.tc-minus { position: absolute; top: -9px; left: -9px; width: 26px; height: 26px; border-radius: 50%; border: 1px solid var(--line-strong); background: var(--surface); color: var(--text); font-weight: 700; font-size: 15px; cursor: pointer; line-height: 1; }
.tc-minus:hover { border-color: var(--accent); color: var(--accent-hi); }
.tt-times { display: flex; align-items: center; gap: 10px; }
.tt-times b { font-size: 18px; min-width: 34px; text-align: center; }
.tt-times small { color: var(--text-faint); }
.tt-preview { display: flex; align-items: center; justify-content: center; gap: 14px; flex-wrap: wrap; min-height: 64px; padding: 10px 14px; border-radius: var(--r); background: var(--surface-2); border: 1px dashed var(--line-strong); }
.tt-preview.empty { color: var(--text-faint); font-size: 13px; }
.tp-stack { display: inline-flex; align-items: center; }
.tp-stack .ri + .ri { margin-left: -12px; }
.tp-stack b { margin-left: 4px; color: var(--text-dim); }
.tp-arrow { font-size: 22px; color: var(--accent-hi); }
.tt-actions { margin-top: 14px; }
.tt-go { min-width: 220px; justify-content: center; }
@media (max-width: 640px) {
  .tc-row { gap: 6px; }
  .tc { padding: 8px 2px 6px; }
  .tc-name, .tc-sub, .tc-main { font-size: 10px; }
  .tc .ri { width: 32px; height: 32px; }
  .tt-go { min-width: 0; flex: 1; }
}
/* The modal's "bold is gold" rule must not reach these. */
#modalBox .tc-count { color: var(--accent-ink); }
#modalBox .tt-tab b { color: var(--text); }
#modalBox .tt-tab.on b { color: var(--accent-hi); }
#modalBox .tp-stack b { color: var(--text-dim); }
/* "Play" sits along the bottom of a playable card, clear of its title. */
.card.dev em { top: auto !important; bottom: 4px !important; left: 50% !important; right: auto !important; transform: translateX(-50%); padding: 2px 10px !important; font-size: 10px !important; box-shadow: 0 2px 6px rgba(0, 0, 0, .45); }
.card.dev.playable .otext { padding-bottom: 20px; }

/* ---------- sidebar: player cards and the log (main.js renderPanels, renderLog) ---------- */
.pcard { --pc: #888; position: relative; overflow: hidden; padding: 11px 12px 10px 15px; border-radius: var(--r);
  background: linear-gradient(115deg, color-mix(in srgb, var(--pc) 16%, var(--surface-2)) 0%, var(--surface-2) 55%);
  border: 1px solid var(--line); box-shadow: 0 2px 8px rgba(0, 0, 0, .25); transition: border-color .3s, box-shadow .3s, transform .3s var(--ease); }
.pcard::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--pc); }
.pcard.turn { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent), 0 0 22px rgba(198, 163, 106, .28); }
.pc-head { display: flex; align-items: center; gap: 10px; }
.pc-avatar { width: 38px; height: 38px; flex: none; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 16px; color: #fff;
  background: radial-gradient(circle at 35% 30%, color-mix(in srgb, var(--pc) 70%, #fff), var(--pc) 60%, color-mix(in srgb, var(--pc) 60%, #000));
  box-shadow: 0 0 0 2px var(--surface), 0 0 0 3.5px var(--pc), 0 3px 8px rgba(0, 0, 0, .4); text-shadow: 0 1px 2px rgba(0, 0, 0, .4); }
.pc-id { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.pc-name { font-weight: 700; font-size: 14.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pc-name small { font-weight: 500; color: var(--text-faint); }
.pc-tags { display: flex; align-items: center; gap: 6px; font-size: 11px; color: var(--text-dim); }
.pc-tags em { font-style: normal; font-weight: 600; font-size: 10px; letter-spacing: .4px; text-transform: uppercase; padding: 1px 6px; border-radius: 99px; background: var(--surface-3); color: var(--text-dim); }
.pc-vp { flex: none; min-width: 46px; padding: 4px 8px; border-radius: var(--r-sm); text-align: center; line-height: 1; background: linear-gradient(var(--accent-hi), var(--accent)); color: var(--accent-ink); box-shadow: 0 2px 8px rgba(198, 163, 106, .3); }
.pc-vp b { display: block; font-family: var(--font-display); font-size: 20px; }
.pc-vp b sup { font-size: 10px; }
.pc-vp small { font-size: 9px; font-weight: 700; letter-spacing: 1px; color: rgba(27, 20, 8, .7); }
.pc-turnbar { display: none; }
.pcard.turn .pc-turnbar { display: flex; justify-content: space-between; align-items: center; margin: 9px 0 0; padding: 4px 10px; border-radius: 99px; background: rgba(198, 163, 106, .14); font-size: 11px; font-weight: 700; letter-spacing: .6px; text-transform: uppercase; color: var(--accent-hi); }
.pcard.turn .pc-turnbar .pclock { font-size: 12px; letter-spacing: 0; min-height: 0; }
.pc-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin: 10px 0 8px; }
.pc-stat { display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto; align-items: center; column-gap: 5px; padding: 5px 7px; border-radius: var(--r-sm); background: rgba(0, 0, 0, .18); border: 1px solid var(--line); }
.pc-sic { grid-row: span 2; display: grid; place-items: center; color: var(--text-dim); }
.pc-sic svg { display: block; }
.pc-stat b { font-size: 15px; line-height: 1.05; font-variant-numeric: tabular-nums; }
.pc-stat small { font-size: 9px; color: var(--text-faint); text-transform: uppercase; letter-spacing: .4px; line-height: 1.1; }
.pc-stat.won { border-color: var(--accent); background: rgba(198, 163, 106, .14); }
.pc-stat.won .pc-sic, .pc-stat.won b { color: var(--accent-hi); }
.pc-foot { display: flex; align-items: center; justify-content: space-between; gap: 6px; flex-wrap: wrap; }
.pc-pieces { display: flex; gap: 10px; }
.pc-piece { display: inline-flex; align-items: center; gap: 2px; font-size: 12px; color: var(--text-dim); }
.pc-piece b { font-weight: 700; color: var(--text); font-variant-numeric: tabular-nums; }
.pc-awards { display: flex; gap: 4px; flex-wrap: wrap; }
.pc-award { font-size: 10px; font-weight: 700; padding: 2px 7px; border-radius: 99px; background: var(--accent-hi); color: var(--accent-ink); }
.pcard .pnote { margin-top: 6px; }
.pcard > button { margin-top: 8px; }

.logbox h4 { margin: 0 0 4px; }
#log .entry { position: relative; padding: 5px 0 5px 14px; border-bottom: 1px solid var(--line); line-height: 1.35; }
#log .entry::before { content: ''; position: absolute; left: 2px; top: 11px; width: 6px; height: 6px; border-radius: 50%; background: var(--dot); box-shadow: 0 0 0 2px rgba(0, 0, 0, .25); }
#log .entry.roll { color: var(--text); }
#log .entry .mini-dice { margin-left: 4px; padding: 1px 7px; border-radius: 99px; background: var(--surface-3); border: 1px solid var(--line-strong); font-weight: 700; font-size: 11px; color: var(--accent-hi); }
#log .entry:first-child { color: var(--text); }
@media (max-width: 1100px) {
  .pc-stat { grid-template-columns: 1fr; justify-items: center; padding: 4px; }
  .pc-sic { grid-row: auto; }
}
/* Stats: icon and number on one line, the label centred underneath, so labels never clip. */
.pc-stat { grid-template-columns: auto auto; grid-template-areas: "ic n" "l l"; justify-content: center; justify-items: center; row-gap: 1px; padding: 5px 4px; }
.pc-stat .pc-sic { grid-area: ic; grid-row: auto; }
.pc-stat b { grid-area: n; }
.pc-stat small { grid-area: l; letter-spacing: .3px; white-space: nowrap; }
@media (max-width: 1100px) { .pc-stat { grid-template-columns: auto auto; } .pc-sic { grid-row: auto; } }
/* The stats follow the sidebar's own width: four across when there is room, two by two when not. */
#side { container-type: inline-size; container-name: side; }
@container side (max-width: 285px) {
  .pc-stats { grid-template-columns: repeat(2, 1fr); }
  .pc-stat { grid-template-columns: auto auto auto; grid-template-areas: "ic n l"; column-gap: 5px; justify-content: start; padding: 4px 8px; }
  .pc-stat small { align-self: center; }
}



/* ---------- lobby: a full-screen room dashboard (Kart Drift's room lobby, in our palette) ---------- */
#lobby { display: block; overflow-y: auto; padding: clamp(14px, 3vh, 32px) clamp(14px, 3vw, 40px); }
.ld { width: min(1180px, 100%); min-height: 100%; margin: 0 auto; display: grid; grid-template-columns: minmax(280px, 340px) 1fr; gap: 18px; align-content: center; }
.ld-col { display: grid; gap: 14px; align-content: start; }
.lp { padding: 18px; border-radius: var(--r-lg); background: var(--surface-glass); backdrop-filter: blur(12px); border: 1px solid var(--line-strong); box-shadow: var(--shadow); }
.lb-kicker { display: block; font-size: 11px; font-weight: 600; letter-spacing: 2px; text-transform: uppercase; color: var(--text-faint); }
#lbCode { margin: 0 0 6px; font-family: var(--font-display); font-size: clamp(30px, 4vw, 44px); letter-spacing: 6px; line-height: 1.05; color: var(--accent-hi); }
.lb-h { display: flex; align-items: baseline; gap: 8px; margin: 12px 0 8px; font-size: 11px; font-weight: 600; letter-spacing: 1.5px; text-transform: uppercase; color: var(--text-faint); }
.lp > .lb-h:first-child { margin-top: 0; }
.lb-h span { color: var(--accent-hi); letter-spacing: .5px; }
#invite { width: 100%; font-size: 12px; color: var(--text-dim); }
.ld-wide { width: 100%; justify-content: center; margin-top: 8px; }
.lb-sub { margin: 10px 0 0; font-size: 12px; color: var(--text-dim); }
.ls-list { display: grid; gap: 6px; }
.ls { --pc: #888; display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 7px 10px; border-radius: var(--r-sm); background: rgba(0, 0, 0, .22); border: 1px solid var(--line); }
.ls i { width: 14px; height: 14px; flex: none; border-radius: 50%; background: var(--pc); box-shadow: 0 0 0 2px rgba(0, 0, 0, .35), 0 0 10px color-mix(in srgb, var(--pc) 60%, transparent); }
.ls b { font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ls.bot b, .ls.open b { color: var(--text-dim); font-weight: 500; font-style: italic; }
.ls.open { border-style: dashed; background: transparent; }
.ls.open i { background: none; box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--pc) 70%, transparent); }
.ls-tags { display: flex; gap: 4px; }
.ls-tags em { font-style: normal; font-weight: 700; font-size: 10px; letter-spacing: .4px; text-transform: uppercase; padding: 1px 7px; border-radius: 99px; background: var(--surface-3); color: var(--text); white-space: nowrap; }
.ls-tags em.host { background: rgba(198, 163, 106, .2); color: var(--accent-hi); }
.ls small { margin-left: auto; font-size: 11px; color: var(--text-faint); }
.ls .bga.small { padding: 3px 8px; font-size: 11px; }
.lb-watch { margin: 8px 0 0; font-size: 12px; color: var(--text-faint); }
.lb-watch:empty { display: none; }
.ld-island { position: relative; height: clamp(190px, 32vh, 330px); border-radius: var(--r); overflow: hidden; background: radial-gradient(ellipse at 50% 50%, var(--ocean), var(--ocean-deep) 75%); border: 1px solid var(--line); display: grid; place-items: center; }
.ld-island > span { font-size: 12px; color: var(--text-dim); padding: 6px 12px; border-radius: 99px; background: rgba(10, 18, 24, .6); }
.ld-island.live > span { position: absolute; bottom: 10px; left: 50%; transform: translateX(-50%); z-index: 2; white-space: nowrap; }
.ld-island canvas { position: absolute; inset: 0; width: 100% !important; height: 100% !important; }
.ld-row { display: flex; align-items: center; gap: 12px; margin-top: 12px; font-size: 13px; color: var(--text-dim); flex-wrap: wrap; }
.ld-row > span:first-child { width: 110px; }
.ld-row small { color: var(--text-faint); }
.seg { display: inline-flex; padding: 3px; border-radius: 99px; background: var(--surface); border: 1px solid var(--line-strong); }
.seg-b { font: inherit; font-weight: 700; font-size: 13px; min-width: 44px; padding: 6px 12px; border: 0; border-radius: 99px; background: none; color: var(--text-dim); cursor: pointer; transition: background .15s, color .15s; }
.seg-b:hover:not(:disabled):not(.on) { color: var(--text); background: var(--surface-3); }
.seg-b.on { background: linear-gradient(var(--accent-hi), var(--accent)); color: var(--accent-ink); box-shadow: 0 2px 8px rgba(198, 163, 106, .3); }
.seg-b:disabled { cursor: default; }
.lb-toggle { display: inline-flex; align-items: center; gap: 10px; color: var(--text); cursor: pointer; user-select: none; }
.lb-toggle input { position: absolute; opacity: 0; pointer-events: none; }
.lb-track { position: relative; width: 40px; height: 22px; border-radius: 99px; background: var(--surface-3); border: 1px solid var(--line-strong); transition: background .2s; }
.lb-track::after { content: ''; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: var(--text-dim); transition: transform .2s var(--ease), background .2s; }
.lb-toggle input:checked + .lb-track { background: var(--accent); border-color: var(--accent-hi); }
.lb-toggle input:checked + .lb-track::after { transform: translateX(18px); background: var(--accent-ink); }
.lb-toggle input:focus-visible + .lb-track { outline: 2px solid var(--accent-hi); outline-offset: 2px; }
#lobby.guest .seg, #lobby.guest .lb-toggle { opacity: .7; }
.ld-how { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px 14px; }
.ld-how > div { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--text-dim); }
.ld-how > div span { display: flex; flex-direction: column; line-height: 1.25; }
.ld-how b { color: var(--text); font-size: 13px; }
.ld-how p { grid-column: 1 / -1; margin: 6px 0 0; font-size: 12.5px; color: var(--text-dim); }
.ld-how p b { color: var(--accent-hi); }
.ld-btns { display: flex; gap: 10px; }
.ld-btns .bga { flex: 1; justify-content: center; padding: 13px; }
.ld-btns #startBtn { flex: 2; font-size: 17px; }
.ld-note { margin: -4px 0 0; text-align: right; font-size: 12.5px; color: var(--text-dim); }
@media (max-width: 860px) {
  .ld { grid-template-columns: 1fr; align-content: start; }
  .ld-btns { position: sticky; bottom: 0; padding: 10px 0; background: linear-gradient(transparent, var(--ocean-deep) 40%); z-index: 3; }
  .ld-note { text-align: left; }
}

/* ---------- home: a menu card over a live island (main.js, title screen) ---------- */
#title { position: relative; display: block; overflow: hidden auto; padding: 0; }
#homeIsland { position: absolute; inset: 0; z-index: 0; }
#homeIsland canvas { width: 100% !important; height: 100% !important; display: block; }
#title::after { content: ''; position: absolute; inset: 0; z-index: 1; pointer-events: none;
  background: linear-gradient(90deg, rgba(8, 18, 26, .94) 0, rgba(8, 18, 26, .78) 30%, rgba(8, 18, 26, 0) 58%), radial-gradient(ellipse at 70% 120%, rgba(8, 18, 26, .6), transparent 60%); }
.home { position: relative; z-index: 2; width: min(440px, 100%); min-height: 100%; padding: clamp(20px, 6vh, 64px) clamp(18px, 5vw, 72px); display: flex; flex-direction: column; justify-content: center; gap: 14px; }
.home-brand { display: flex; align-items: center; gap: 14px; }
.home .biglogo { width: 76px; height: 76px; margin: 0; flex: none; }
.home h1 { margin: 0; font-family: var(--font-display); font-size: clamp(40px, 5.4vw, 60px); letter-spacing: 5px; line-height: .95; color: var(--accent-hi); text-shadow: 0 4px 24px rgba(0, 0, 0, .6); }
.home-kick { margin: 6px 0 0; font-size: 12px; font-weight: 600; letter-spacing: 3px; text-transform: uppercase; color: var(--text-dim); }
.home .tag { margin: 4px 0 0; font-size: 14px; line-height: 1.55; color: var(--text-dim); }
.home-facts { display: flex; flex-wrap: wrap; gap: 6px; }
.home-facts span { font-size: 11px; font-weight: 600; padding: 4px 10px; border-radius: 99px; background: rgba(198, 163, 106, .12); border: 1px solid rgba(198, 163, 106, .35); color: var(--accent-hi); }
.home label { display: block; margin: 0 0 6px; font-size: 11px; font-weight: 600; letter-spacing: 1.5px; text-transform: uppercase; color: var(--text-faint); }
.home-form { display: grid; gap: 8px; margin-top: 8px; padding: 16px; border-radius: var(--r-lg); background: var(--surface-glass); backdrop-filter: blur(12px); border: 1px solid var(--line-strong); box-shadow: var(--shadow); }
.home-form label { margin: 0; }
.home-form input { width: 100%; font-size: 15px; padding: 11px 12px; }
.home-form input.want { border-color: var(--danger); box-shadow: 0 0 0 3px rgba(226, 115, 90, .2); }
.home-form .bga { width: 100%; justify-content: center; }
.home-form .bga.big { font-size: 16px; padding: 13px; }
.home-join div { display: flex; gap: 8px; }
.home-join input { flex: 1; min-width: 0; text-transform: uppercase; letter-spacing: 4px; font-weight: 700; }
.home-join input::placeholder { letter-spacing: 4px; }
.home > .bga.link { align-self: flex-start; padding-left: 0; }
@media (max-width: 860px) {
  #title::after { background: linear-gradient(180deg, rgba(8, 18, 26, .35) 0, rgba(8, 18, 26, .85) 55%, rgba(8, 18, 26, .95)); }
  .home { width: 100%; max-width: 480px; margin: 0 auto; justify-content: flex-end; }
}
#title { place-items: normal; justify-items: start; }
#title #titleForm.home-form { display: grid; }

/* ---------- sign-in on the home page (main.js showAccount, as in Kart Drift) ---------- */
#play { display: grid; gap: 14px; }
#play[hidden] { display: none !important; }
.home-signin { display: grid; gap: 8px; margin-top: 8px; padding: 16px; border-radius: var(--r-lg); background: var(--surface-glass); backdrop-filter: blur(12px); border: 1px solid var(--accent); box-shadow: var(--shadow), 0 0 20px rgba(198, 163, 106, .2); }
.home-signin p { margin: 0 0 4px; font-size: 13px; color: var(--text-dim); }
.home-signin .bga { width: 100%; justify-content: center; }
.home-account { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-radius: 99px; background: var(--surface-glass); border: 1px solid var(--line); align-self: flex-start; }
.home-account img { width: 28px; height: 28px; border-radius: 50%; box-shadow: 0 0 0 2px var(--accent); }
.home-account .who { font-size: 13px; color: var(--text-dim); }
.home-account .who b { color: var(--text); }
.home-account .bga.link { padding: 0 0 0 6px; font-size: 12px; }

/* ---------- your record and the leaderboards (records.js) ---------- */
.home-record { display: grid; gap: 4px; padding: 12px 14px; border-radius: var(--r-lg); background: var(--surface-glass); backdrop-filter: blur(12px); border: 1px solid var(--line); }
.home-record .rec-stats { font-size: 14px; color: var(--text-dim); }
.home-record .rec-more { font-size: 12px; color: var(--text-faint); }
.home-record b { color: var(--accent-hi); font-weight: 700; }
.home-record .bga.link { justify-self: start; padding: 4px 0 0; font-size: 12px; }
#boards { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; padding: 16px; background: rgba(4, 10, 14, .62); backdrop-filter: blur(4px); }
#boards[hidden] { display: none; }
.boards-card { width: min(460px, 100%); max-height: min(640px, 100%); display: flex; flex-direction: column; gap: 12px; padding: 18px 20px; border-radius: var(--r-lg); background: var(--surface-glass); border: 1px solid var(--line); box-shadow: var(--shadow-lg); }
.boards-head { display: flex; align-items: center; justify-content: space-between; }
.boards-head b { font-family: var(--font-display); font-size: 20px; letter-spacing: 2px; color: var(--accent-hi); }
.boards-tabs { display: flex; flex-wrap: wrap; gap: 4px; padding: 3px; border-radius: 10px; background: rgba(0, 0, 0, .25); }
.boards-tabs button { flex: 1 1 auto; padding: 7px 10px; border: 0; border-radius: 8px; background: none; color: var(--text-dim); font: inherit; font-size: 12px; font-weight: 600; cursor: pointer; }
.boards-tabs button.on { background: var(--accent); color: #1a1408; }
.boards-body { overflow: auto; min-height: 120px; }
.boards-body table { width: 100%; border-collapse: collapse; font-size: 14px; }
.boards-body td { padding: 7px 6px; border-bottom: 1px solid var(--line); }
.boards-body td.r { width: 2em; color: var(--text-faint); text-align: right; }
.boards-body td.n { color: var(--text); }
.boards-body td.v { text-align: right; font-variant-numeric: tabular-nums; color: var(--accent-hi); font-weight: 700; }
.boards-body td.v small { font-weight: 400; color: var(--text-faint); }
.boards-body tr.you td { background: rgba(198, 163, 106, .14); }
#boards .why { margin: 0; font-size: 12px; color: var(--text-faint); }

