/* Carcassonne: Hub palette (dark slate, blue + gold accents), phone first. */
:root {
  --bg: #0f1117; --bg-soft: #161923; --card: #1a1e2b; --card-hover: #212636; --line: #2a3042;
  --text: #e8eaf0; --muted: #969db4; --accent: #6ea8fe; --warm: #f0b354; --good: #6ee7a8; --bad: #f08c8c;
  --felt: #233024; --radius: 12px;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg); color: var(--text); overflow: hidden; overscroll-behavior: none;
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent; touch-action: manipulation;
}
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; padding: 0; }
input, select { font: inherit; font-size: 16px; color: var(--text); }
[hidden] { display: none !important; }

.app { height: 100dvh; display: grid; grid-template-rows: 1fr auto; overflow: hidden; }
.view { min-height: 0; overflow: hidden; grid-row: 1; }

/* ---------------------------------------------------------------- tabs */
.tabs {
  grid-row: 2; display: flex; background: var(--bg-soft); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabs button {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 7px 0 6px;
  color: var(--muted); font-size: 11.5px; font-weight: 600; transition: color .15s;
}
.tabs svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tabs svg .dim { opacity: .45; }
.tabs button[aria-current="page"] { color: var(--accent); }
.tabs button:active { transform: scale(.96); }

/* ---------------------------------------------------------------- buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 42px;
  background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 8px 14px;
  font-weight: 650; transition: background .12s, border-color .12s, transform .08s, opacity .15s;
}
.btn:hover:not(:disabled) { background: var(--card-hover); }
.btn:active:not(:disabled) { transform: scale(.97); }
.btn:disabled { opacity: .38; cursor: default; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #0d1424; }
.btn.primary:disabled { background: var(--card); border-color: var(--line); color: var(--muted); opacity: .75; }
.btn.warm { background: var(--warm); border-color: var(--warm); color: #23180a; }
.btn.small { min-height: 34px; padding: 5px 11px; font-size: 13.5px; border-radius: 8px; }
.btn.ghost { background: transparent; }
.q {
  display: inline-flex; width: 18px; height: 18px; border-radius: 50%; border: 1px solid var(--line);
  align-items: center; justify-content: center; font-size: 11px; color: var(--muted); vertical-align: 1px; margin-left: 4px;
}
.q:hover { color: var(--text); border-color: var(--muted); }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); }

/* ================================================================ PLAY: a real table seen from your seat */
/* The whole Play screen is a dark wooden table (css/table.css). Far side: the other
   players' score plates + meeples, and the face-down tile stack. Middle: the tile map.
   Your edge: the tile in your hand, your meeples, then the turn text and buttons. */
#view-play { display: flex; flex-direction: column; --wood-ink: #f3ead8; --wood-mute: rgba(243,234,216,.68); color: var(--wood-ink); }
#view-play[hidden] { display: none; }
.far { display: flex; align-items: center; gap: 8px; padding: 8px 10px 4px; flex: none; }
.players { display: flex; gap: 6px; flex: 1; min-width: 0; }
.pchip { flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; align-items: center; gap: 3px; }
.pchip .plate {
  display: flex; align-items: center; gap: 5px; width: 100%; max-width: 170px; padding: 3px 8px 3px 5px; border-radius: 5px;
  background: linear-gradient(#3b2a1a, #24180d); border: 1px solid #7a5a2e; color: #f6efdc;
  box-shadow: inset 0 1px 0 rgba(255,220,150,.22), 0 2px 4px rgba(0,0,0,.45); transition: border-color .2s, box-shadow .2s;
}
.pchip.turn .plate { border-color: #f0c35a; box-shadow: 0 0 0 2px rgba(240,195,90,.45), 0 2px 4px rgba(0,0,0,.45); }
.pchip .plate svg { width: 18px; height: 18px; flex: none; filter: drop-shadow(0 1px 1px rgba(0,0,0,.5)); }
.pchip .nm { flex: 1; min-width: 0; font-size: 12px; font-weight: 600; color: rgba(246,239,220,.78); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; line-height: 1.1; }
.pchip .sc { font-size: 17px; font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1.1; }
.sup { display: flex; justify-content: center; align-items: flex-end; min-height: 15px; }
/* the meeples left: a small loose crowd of standing pieces (app.js supply()) */
.crowd { position: relative; display: block; flex: none; }
.crowd .tbl-meeple { position: absolute; }
/* The kit's drop-shadow filter on 20-30 masked meeples drops WebKit to ~2 frames a second
   (measured); a plain shadow ellipse under each one looks the same and costs nothing. */
#view-play .tbl-meeple { filter: none; }
#view-play .tbl-meeple::after { content: ""; position: absolute; left: 12%; right: -8%; bottom: -2px; height: 4px; border-radius: 50%; background: rgba(0,0,0,.45); z-index: -1; }
.sup .none { font-size: 10.5px; color: var(--wood-mute); }
/* 5-6 players on a phone: colour + score, meeples packed tighter, no name (Results has names) */
@media (max-width: 899px) {
  .players.many .pchip .nm { display: none; }
  .players.many .pchip .plate { justify-content: space-between; padding: 3px 5px 3px 3px; gap: 2px; }
  /* 5-6 players: the plate's coloured edge is the player marker, so a 3-digit score has room */
  .players.many { gap: 4px; }
  .players.many .pchip .plate { justify-content: center; padding: 3px 3px 3px 4px; border-left: 4px solid var(--pc); }
  .players.many .pchip .plate svg { display: none; }
  .players.many .pchip .sc { font-size: 15px; }
  .players.many ~ .stack-box .deck2 { margin-right: -26px; }
}
/* the score track on a phone: the real loop of 50 squares, squeezed to a strip of 25 x 2 */
.ptrack { flex: none; padding: 2px 10px 0; }
.ptrack svg { width: 100%; max-width: 560px; display: block; margin: 0 auto; border-radius: 4px; box-shadow: 1px 2px 0 #2e1d0d, 2px 5px 8px rgba(0,0,0,.45); }
.ptrack .tm, .track .tm { transition: transform .6s cubic-bezier(.3,.7,.3,1); }
/* the face-down tile stack */
.stack-box { flex: none; padding: 10px 6px 4px 0; display: flex; align-items: flex-end; gap: 6px; }
.deck2 { rotate: -6deg; margin-right: -12px; translate: 0 -3px; }   /* a second stack, half behind the first */
@media (max-width: 899px) { .deck { --card-w: 34px; } }
.deck2.is-empty { visibility: hidden; }   /* (the stack rises by its thickness) */
.deck { --card-w: 40px; --ratio: 1 / 1; display: block; }
.deck .tbl-back, .tile-back {
  --back: #4b3a27; --back-frame: #4b3a27; --ink: rgba(255,226,170,.07); border-radius: 3px; border-color: rgba(0,0,0,.45);
}
.deck .tbl-back::after { content: ""; position: absolute; inset: 28%; border-radius: 50%; border: 1.5px solid rgba(255,226,170,.22); }
.deck.is-empty { border-radius: 3px; border-color: rgba(255,240,210,.25); }
.deck .tbl-badge { right: -8px; bottom: -8px; }

.board-wrap { position: relative; flex: 1; min-height: 0; overflow: hidden; touch-action: none; }
.board { width: 100%; height: 100%; display: block; user-select: none; -webkit-user-select: none; }
.board #world { transition: transform .35s ease; }
.board.dragging #world { transition: none; }
/* cardboard: each tile is ~2 mm thick, so the map has a dark edge and a soft shadow */
.board .t-shadow { fill: #000; }
.board .t-edge { fill: #3b2b19; }
.board .cand rect { fill: rgba(240,179,84,.07); stroke: var(--warm); stroke-opacity: .6; stroke-width: 2; stroke-dasharray: 6 6; }
.board .cand.top rect { fill: rgba(240,179,84,.16); stroke-opacity: 1; stroke-width: 3; stroke-dasharray: none; }
.board .cand.on rect { fill: rgba(240,179,84,.22); }
.board .cand.dead rect { fill: rgba(240,140,140,.08); stroke: var(--bad); stroke-dasharray: 3 6; }
.board .cand text { font-weight: 800; font-size: 30px; text-anchor: middle; dominant-baseline: central; paint-order: stroke; stroke: rgba(0,0,0,.7); stroke-width: 5px; }
.board .placed { animation: drop .32s ease-out; transform-box: fill-box; transform-origin: center; }
@keyframes drop { from { opacity: 0; transform: scale(1.18); } to { opacity: 1; transform: scale(1); } }
.board .incoming { opacity: 0; }
.board .last { fill: none; stroke-width: 4; }
.board .ghost { opacity: .97; }
.board .ghost.spin, .hand svg.spin { transform-box: fill-box; transform-origin: center; animation: spin .22s ease-out; }
@keyframes spin { from { transform: rotate(var(--from)); } to { transform: rotate(0deg); } }
.board .ghost-ring { fill: none; stroke: #fff; stroke-width: 3.5; }
.board .best-ring { fill: none; stroke: var(--good); stroke-width: 5; stroke-dasharray: 10 6; }
.board-tools { position: absolute; right: 8px; top: 8px; display: flex; flex-direction: column; gap: 6px; }
/* zoom: three round wooden tokens lying on the table, the sign burnt in */
.board-tools button {
  width: 42px; height: 42px; border-radius: 50%; border: 1px solid #5a3d1c;
  background: radial-gradient(circle at 34% 28%, #e2c08a, #b98d55 52%, #94693a);
  font-weight: 800; font-size: 21px; line-height: 1; color: #4a2f12; text-shadow: 0 1px 0 rgba(255,236,196,.55);
  box-shadow: inset 0 1px 1px rgba(255,244,214,.6), inset 0 -2px 3px rgba(70,42,14,.45), 0 3px 0 #5e3f1d, 0 5px 8px rgba(0,0,0,.45);
}
.board-tools #zoom-fit { font-size: 12.5px; opacity: .55; transition: opacity .15s, box-shadow .15s; }
.board-tools #zoom-fit.lit { opacity: 1; box-shadow: 0 0 0 2.5px var(--accent), inset 0 1px 1px rgba(255,244,214,.6), inset 0 -2px 3px rgba(70,42,14,.45), 0 3px 0 #5e3f1d, 0 5px 8px rgba(0,0,0,.45); }
/* The tokens have a strip of their own (app.js fitBox): a column down the right, or a row
   along the top when that leaves the map bigger (a wide map on a short board area). */
.board-wrap.tools-row .board-tools { flex-direction: row; }
.board-tools button:active { transform: translateY(2px); box-shadow: inset 0 1px 1px rgba(255,244,214,.6), inset 0 -2px 3px rgba(70,42,14,.45), 0 1px 0 #5e3f1d, 0 2px 4px rgba(0,0,0,.45); }
.floaters { position: absolute; inset: 0; pointer-events: none; }
.floater {
  position: absolute; transform: translate(-50%, -50%); font-weight: 800; font-size: 20px;
  text-shadow: 0 2px 6px rgba(0,0,0,.8); animation: floatup 1.6s ease-out forwards;
}
@keyframes floatup { 0% { opacity: 0; transform: translate(-50%, -30%); } 15% { opacity: 1; } 100% { opacity: 0; transform: translate(-50%, -150%); } }

/* your edge of the table */
.dock { flex: none; display: grid; grid-template-columns: auto 1fr; gap: 12px; padding: 8px 12px 10px; }
.hand-box { display: flex; flex-direction: column; align-items: center; gap: 5px; }
.hand { width: 100px; height: 100px; border-radius: 3px; position: relative; transform-origin: 50% 60%;
  /* a 2 mm cardboard tile: light top-left, dark edge bottom-right, shadow on the table */
  box-shadow: 1px 1px 0 #6b5236, 2px 2px 0 #4f3b25, 3px 3px 0 #3b2b19, 4px 9px 16px rgba(0,0,0,.55); }
.hand svg { width: 100%; height: 100%; display: block; border-radius: 3px; transition: transform .25s ease; }
.hand.theirs { box-shadow: 1px 1px 0 #6b5236, 2px 2px 0 #4f3b25, 3px 3px 0 #3b2b19, 4px 9px 16px rgba(0,0,0,.55), 0 0 0 3px var(--who); }
.hand.await { visibility: hidden; }
.hand.flipin { animation: flipin .26s cubic-bezier(.3,.7,.3,1); }
@keyframes flipin { from { transform: perspective(500px) rotateY(-90deg); } to { transform: perspective(500px) rotateY(0); } }
.hand .spot { cursor: pointer; }
.hand .spot circle.halo { fill: none; stroke: rgba(0,0,0,.45); stroke-width: 5.5; }
.hand .spot circle.ring { fill: rgba(255,255,255,.25); stroke: #fff; stroke-width: 2.4; }
.hand .spot.on circle.halo { stroke-opacity: .3; }
.hand .spot.on circle.ring { fill: none; stroke: var(--warm); }
.hand.empty { box-shadow: none; border: 2px dashed rgba(255,240,210,.25); background: rgba(0,0,0,.08); }
.mine { display: flex; justify-content: center; align-items: flex-end; min-height: 18px; }
.left { font-size: 11.5px; color: var(--wood-mute); font-variant-numeric: tabular-nums; }
.left:empty { display: none; }
.dock-main { min-width: 0; display: flex; flex-direction: column; justify-content: space-between; gap: 6px; }
.status { font-weight: 700; font-size: 15px; line-height: 1.25; height: 19px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-shadow: 0 1px 2px rgba(0,0,0,.5); }
.sub { font-size: 13px; color: var(--wood-mute); height: 36px; line-height: 1.35; overflow: hidden; }
.sub b.g { color: var(--good); } .sub b.r { color: var(--bad); } .sub b.w { color: var(--warm); }
.sub .q { border-color: rgba(255,226,170,.3); color: var(--wood-mute); }
.dock-btns { display: flex; gap: 7px; }
/* Fixed height: a two-line "Place + big meeple" never pushes the dock around */
.dock-btns .btn { flex: 0 0 auto; min-width: 64px; height: 46px; min-height: 0; padding: 4px 10px; line-height: 1.12; }
.dock-btns #btn-place { flex: 1; }
#view-play .btn:not(.primary) { background: rgba(24,16,9,.62); border-color: rgba(255,226,170,.2); color: var(--wood-ink); box-shadow: 0 2px 5px rgba(0,0,0,.35); }
#view-play .btn:not(.primary):hover:not(:disabled) { background: rgba(24,16,9,.8); }
#view-play .btn.primary:disabled { background: rgba(24,16,9,.5); border-color: rgba(255,226,170,.16); color: var(--wood-mute); }
.side { display: none; }
/* Small phones (320 px): a smaller tile so Place keeps its room */
@media (max-width: 359px) {
  .dock { gap: 9px; padding: 8px 9px 10px; }
  .hand { width: 80px; height: 80px; }
  .dock-btns { gap: 5px; }
  .dock-btns .btn { min-width: 54px; padding: 4px 8px; }
}
/* Phone on its side: the map takes the whole left side under the score track; the score
   plates, the stack and your edge share the column on the right */
@media (orientation: landscape) and (max-height: 500px) and (max-width: 899px) {
  #view-play { display: grid; grid-template-columns: minmax(0, 1fr) 260px; grid-template-rows: auto auto 1fr auto; }
  .ptrack { grid-column: 1; grid-row: 1; }
  .board-wrap { grid-column: 1; grid-row: 2 / 5; }
  .far { grid-column: 2; grid-row: 1 / 3; align-self: start; align-items: flex-start; padding: 6px 10px 2px 2px; gap: 4px; }
  .players { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 4px 5px; }
  .players[data-n="3"], .players[data-n="5"], .players[data-n="6"] { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .players.many ~ .stack-box .deck2 { margin-right: -12px; }
  .dock { grid-column: 2; grid-row: 4; align-self: end; grid-template: "h s" auto "h u" 1fr "b b" auto / auto minmax(0, 1fr); gap: 6px 10px; padding: 6px 10px 8px 4px; }
  .dock-main { display: contents; }
  .hand-box { grid-area: h; }
  .hand { width: 76px; height: 76px; }
  .status { grid-area: s; white-space: normal; height: auto; max-height: 38px; }
  .sub { grid-area: u; height: auto; max-height: 52px; font-size: 12px; }
  .sub:has(#btn-new2) { max-height: none; }   /* game over: Results + New game wrap to two rows, both whole */
  .dock-btns { grid-area: b; }
  .stack-box { padding-bottom: 2px; }
  .deck { --card-w: 30px; }

}

/* end-of-game */
.final h2 { margin: 0 0 2px; font-size: 22px; }
.final table { width: 100%; table-layout: fixed; border-collapse: collapse; font-variant-numeric: tabular-nums; font-size: 14px; margin: 10px 0; }
.final th, .final td { padding: 5px 4px; text-align: right; border-bottom: 1px solid var(--line); }
.final th:first-child, .final td:first-child { text-align: left; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.final th { color: var(--muted); font-weight: 600; font-size: 12px; }
.final td.tot { font-weight: 800; }
.race { width: 100%; height: 130px; display: block; margin: 4px 0 8px; }

/* ================================================================ TILES (companion) */
#view-tiles { display: flex; flex-direction: column; padding: 10px 12px 8px; gap: 10px; }
#view-tiles[hidden] { display: none; }
.tt-head { display: flex; align-items: center; gap: 14px; flex: none; }
.big-num { display: flex; align-items: baseline; gap: 6px; }
.big-num b { font-size: 34px; font-weight: 850; font-variant-numeric: tabular-nums; line-height: 1; }
.big-num span { color: var(--muted); font-size: 13px; }
.tt-next { display: flex; flex-direction: column; line-height: 1.15; margin-left: auto; text-align: right; }
.tt-next .lbl { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; font-weight: 700; }
.tt-next b { font-size: 15px; }
.tt-body { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 10px; }
.need { display: flex; gap: 12px; padding: 10px; align-items: center; flex: none; }
.need-pick { position: relative; width: 92px; height: 92px; flex: none; }
.need-mid { position: absolute; left: 22px; top: 22px; width: 48px; height: 48px; border-radius: 4px; background: #2a3a2a; border: 1px solid var(--line); }
.ns { position: absolute; border-radius: 6px; background: var(--bg-soft); border: 1px solid var(--line); font-size: 10.5px; font-weight: 700; color: var(--muted); }
.ns.n, .ns.s { left: 22px; width: 48px; height: 20px; } .ns.n { top: 0; } .ns.s { bottom: 0; }
.ns.e, .ns.w { top: 22px; width: 20px; height: 48px; writing-mode: vertical-rl; } .ns.e { right: 0; } .ns.w { left: 0; }
.ns.C { background: #a8773d; color: #fff; border-color: #c9945a; }
.ns.R { background: #e9e0c9; color: #3a3326; border-color: #fff; }
.ns.F { background: #4f7f35; color: #fff; border-color: #6ea84d; }
.need-out { flex: 1; min-width: 0; }
.need-out .big { font-size: 30px; font-weight: 850; line-height: 1; font-variant-numeric: tabular-nums; }
.need-out .lbl { font-size: 12.5px; color: var(--muted); }
.need-out .row { display: flex; gap: 14px; margin-top: 6px; font-size: 13px; color: var(--muted); flex-wrap: wrap; }
.need-out .row b { color: var(--text); font-variant-numeric: tabular-nums; }
.tgrid-wrap { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 6px; }
.hint-line { font-size: 12.5px; color: var(--muted); }
.tgrid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 7px; overflow-y: auto; align-content: start; padding: 6px 5px 2px 2px; }
.tbtn { position: relative; aspect-ratio: 1; border-radius: 6px; transition: transform .1s, opacity .2s, box-shadow .2s; box-shadow: 0 2px 6px rgba(0,0,0,.45); }
.tbtn svg { width: 100%; height: 100%; display: block; border-radius: 6px; }
.tbtn:active { transform: scale(.93); }
.tbtn .cnt {
  position: absolute; z-index: 1; right: -4px; top: -5px; min-width: 21px; height: 21px; border-radius: 11px; padding: 0 5px;
  background: #0f1117; border: 1.5px solid var(--line); font-size: 12px; font-weight: 800; display: flex; align-items: center; justify-content: center; font-variant-numeric: tabular-nums;
}
.tbtn.out { opacity: .22; }
.tbtn.match::after { content: ""; position: absolute; inset: 0; border: 3px solid var(--warm); border-radius: 6px; pointer-events: none; }
.tbtn.match .cnt { border-color: var(--warm); color: var(--warm); }
.tbtn.bump { animation: bump .3s; }
@keyframes bump { 50% { transform: scale(.88); } }

/* ================================================================ SCORES */
#view-scores { padding: 10px 12px; }
.sc-wrap { height: 100%; display: flex; flex-direction: column; gap: 10px; }
.sc-list { padding: 4px 10px; flex: none; }
.sc-row { display: flex; align-items: center; gap: 10px; padding: 7px 0; border-bottom: 1px solid var(--line); }
.sc-row:last-child { border-bottom: 0; }
.sc-row svg { width: 22px; height: 22px; flex: none; }
.sc-row .nm { flex: 1; min-width: 0; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sc-row .me { font-size: 11px; color: var(--warm); font-weight: 700; margin-left: 4px; }
.sc-row .pts { font-size: 24px; font-weight: 850; font-variant-numeric: tabular-nums; min-width: 48px; text-align: right; }
.sc-row .step { width: 34px; height: 34px; border-radius: 8px; background: var(--bg-soft); border: 1px solid var(--line); font-weight: 800; font-size: 17px; }
.sc-add { padding: 10px; flex: none; }
.kinds { display: flex; gap: 5px; flex-wrap: wrap; }
.kinds button { padding: 6px 10px; border-radius: 8px; background: var(--bg-soft); border: 1px solid var(--line); font-size: 13px; font-weight: 600; color: var(--muted); }
.kinds button[aria-pressed="true"] { color: var(--accent); border-color: var(--accent); background: rgba(110,168,254,.12); }
.calc { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 12px; margin-top: 10px; align-items: center; }
.stepper { display: flex; align-items: center; justify-content: space-between; gap: 6px; background: var(--bg-soft); border: 1px solid var(--line); border-radius: 9px; padding: 3px; }
.stepper .lbl { font-size: 12.5px; color: var(--muted); padding-left: 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stepper .v { font-weight: 800; min-width: 22px; text-align: center; font-variant-numeric: tabular-nums; }
.stepper button { width: 30px; height: 30px; border-radius: 7px; background: var(--card); font-weight: 800; }
.stepper .ctl { display: flex; align-items: center; gap: 4px; }
.who-row { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
.who {
  display: flex; align-items: center; gap: 5px; padding: 5px 9px 5px 6px; border-radius: 9px; background: var(--bg-soft);
  border: 1px solid var(--line); font-size: 13px; font-weight: 600;
}
.who svg { width: 18px; height: 18px; }
.who .n { min-width: 14px; text-align: center; font-weight: 800; color: var(--muted); }
.who.on { border-color: var(--warm); }
.who.on .n { color: var(--warm); }
.add-row { display: flex; align-items: center; gap: 10px; margin-top: 10px; }
.add-row .res { flex: 1; font-size: 13.5px; color: var(--muted); }
.add-row .res b { color: var(--text); font-size: 18px; }
.sc-log { flex: 1; min-height: 0; display: flex; flex-direction: column; padding: 8px 10px; }
.sc-log h3, .side-extra h3, .set-wrap h3 { margin: 0 0 6px; font-size: 11px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.sc-log ul { list-style: none; margin: 0; padding: 0; overflow-y: auto; flex: 1; font-size: 13px; color: var(--muted); }
.sc-log li { display: flex; justify-content: space-between; gap: 8px; padding: 3px 0; border-bottom: 1px solid rgba(42,48,66,.5); }
.sc-log li b { color: var(--text); }
.sc-log .undo { color: var(--accent); font-size: 12.5px; }

/* ================================================================ SETTINGS */
#view-settings { overflow-y: auto; }
.set-wrap { padding: 12px; display: grid; gap: 12px; max-width: 1100px; margin: 0 auto; }
.set-sec { padding: 12px; }
.set-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 7px 0; border-bottom: 1px solid rgba(42,48,66,.6); min-height: 44px; }
.set-row:last-child { border-bottom: 0; }
.set-row .l { font-size: 14.5px; }
.str { width: 100%; border-collapse: collapse; font-size: 14px; }
.str th { text-align: left; font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); font-weight: 600; padding: 4px 0; }
.str td { padding: 6px 0; border-top: 1px solid rgba(42,48,66,.6); }
.str td:nth-child(2) { font-weight: 800; color: var(--warm); }
.net-in { max-width: 170px; }
.net-in.code { text-transform: uppercase; letter-spacing: .15em; max-width: 120px; }
.net-code { font-size: 30px; font-weight: 800; letter-spacing: .2em; color: var(--warm); }
.net-err { color: #f08c8c; font-size: 13.5px; padding: 6px 0; }
.seg { display: inline-flex; background: var(--bg-soft); border: 1px solid var(--line); border-radius: 9px; padding: 2px; }
.seg button { min-height: 36px; padding: 5px 11px; border-radius: 7px; font-size: 13px; font-weight: 600; color: var(--muted); }
.seg button[aria-pressed="true"] { background: var(--card-hover); color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,.4); }
.switch { width: 46px; height: 28px; border-radius: 14px; background: #3a4155; position: relative; transition: background .2s; flex: none; }
.switch::after { content: ""; position: absolute; left: 3px; top: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; transition: transform .2s; }
.switch[aria-checked="true"] { background: var(--good); }
.switch[aria-checked="true"]::after { transform: translateX(18px); }
.seat { display: flex; align-items: center; gap: 8px; padding: 6px 0; }
.seat svg { width: 22px; height: 22px; flex: none; }
.seat [data-me] { min-width: 68px; }
.seat input, .net-in { flex: 1; min-width: 0; background: var(--bg-soft); border: 1px solid var(--line); border-radius: 8px; padding: 6px 9px; }
.strength { width: 100%; border-collapse: collapse; font-size: 13px; font-variant-numeric: tabular-nums; }
.strength td, .strength th { padding: 4px; border-bottom: 1px solid var(--line); text-align: right; }
.strength td:first-child, .strength th:first-child { text-align: left; }
.muted { color: var(--muted); font-size: 13px; }
/* Sound & effects rows (js/fx.js): same rows and switch as the rest of Settings. */
.fx-set .fx-row { border-top: 0; }
.fx-set .fx-lab { font-size: 14.5px; }
.fx-set .switch { display: inline-block; width: 46px; height: 28px; }
.fx-set .seg { display: inline-flex; gap: 0; border-radius: 9px; padding: 2px; }
.fx-set .seg button { min-height: 36px; padding: 5px 11px; font-size: 13px; font-weight: 600; }
.fx-set .q { display: inline-flex; font-size: 11px; vertical-align: 1px; margin-left: 4px; }
.fx-set .switch span { display: none; }
.fx-set .switch.on { background: var(--good); }
.fx-set .switch.on::after { transform: translateX(18px); }
.fx-set .switch input { opacity: 0; position: absolute; inset: 0; margin: 0; cursor: pointer; z-index: 1; }
.fx-set .fx-test { min-height: 36px; }

/* Animations off (Settings): everything is instant. Fast: about half as long. */
.fx-still *, .fx-still *::after { animation: none !important; transition: none !important; }
.fx-fast .board #world { transition-duration: .2s; }
.fx-fast .board .placed { animation-duration: .18s; }
.fx-fast .board .ghost.spin, .fx-fast .hand svg.spin { animation-duration: .12s; }
.fx-fast .floater { animation-duration: .9s; }
.fx-fast .sheet { animation-duration: .14s; }

/* ================================================================ sheet + pop */
.sheet-back { position: fixed; inset: 0; background: rgba(0,0,0,.55); z-index: 40; display: flex; align-items: flex-end; justify-content: center; animation: fade .2s; }
.sheet {
  width: 100%; max-height: 88dvh; overflow-y: auto; background: var(--card); border: 1px solid var(--line);
  border-radius: 16px 16px 0 0; padding: 16px 16px calc(16px + env(safe-area-inset-bottom)); animation: up .25s ease-out;
}
@keyframes up { from { transform: translateY(40px); opacity: .4; } }
@keyframes fade { from { opacity: 0; } }
.sheet .acts { display: flex; gap: 8px; justify-content: flex-end; margin-top: 12px; position: sticky; bottom: calc(-16px - env(safe-area-inset-bottom)); padding: 8px 0 calc(8px + env(safe-area-inset-bottom)); background: var(--card); }
.pop {
  position: fixed; z-index: 60; max-width: min(320px, calc(100vw - 24px)); background: #232838; border: 1px solid #3a4258;
  border-radius: 10px; padding: 10px 12px; font-size: 13.5px; box-shadow: 0 10px 30px rgba(0,0,0,.5); animation: fade .15s;
}

/* ================================================================ laptop */
@media (min-width: 900px) {
  .app { grid-template-columns: 88px 1fr; grid-template-rows: 1fr; }
  .tabs { grid-row: 1; grid-column: 1; flex-direction: column; justify-content: flex-start; gap: 4px; padding: 14px 0; border-top: 0; border-right: 1px solid var(--line); }
  .tabs button { flex: none; padding: 12px 0; font-size: 12px; }
  .view { grid-column: 2; grid-row: 1; }
  /* laptop: your edge along the bottom of the table, the score track and helpers in a slim side panel */
  #view-play { display: grid; grid-template-columns: minmax(0, 1fr) 340px; grid-template-rows: auto 1fr auto; }
  .ptrack { display: none; }
  .far { grid-column: 1; grid-row: 1; padding: 10px 14px 6px; gap: 14px; }
  .players { gap: 10px; }
  .pchip { flex: 0 1 190px; }
  .pchip .plate { padding: 4px 10px 4px 6px; max-width: none; }
  .pchip .plate svg { width: 22px; height: 22px; }
  .pchip .sc { font-size: 21px; }
  .pchip .nm { font-size: 13px; }
  .sup { min-height: 18px; }
  .deck { --card-w: 50px; }
  /* the map takes the full height of the table; your edge (tile, meeples, buttons) sits at
     the foot of the side panel, under the score track and the bag */
  .board-wrap { grid-column: 1; grid-row: 2 / 4; }
  .dock { grid-column: 2; grid-row: 3; grid-template: "h s" auto "h u" 1fr "b b" auto / auto minmax(0, 1fr); gap: 8px 14px; padding: 12px 16px 16px; }
  .dock-main { display: contents; }
  .hand-box { grid-area: h; }
  /* fixed heights: a longer message never moves the panel */
  .status { grid-area: s; white-space: normal; height: 46px; line-height: 23px; align-self: start; }
  .sub { grid-area: u; height: 57px; line-height: 19px; }
  .dock-btns { grid-area: b; }
  .side, .dock { background: rgba(12,8,4,.42); border-left: 1px solid rgba(255,226,170,.12); box-shadow: inset 8px 0 18px -10px rgba(0,0,0,.6); }
  .dock { border-top: 1px solid rgba(255,226,170,.12); }   /* your edge is its own part, not the end of the scoring list */
  .hand { width: 118px; height: 118px; }
  .mine { min-height: 22px; }
  .status { font-size: 18px; }
  .sub { font-size: 14px; }
  .dock-btns .btn { font-size: 15px; padding: 4px 16px; }
  .side { grid-column: 2; grid-row: 1 / 3; display: flex; flex-direction: column; gap: 14px; min-height: 0; padding: 16px 16px 4px; }
  .track svg { width: 100%; display: block; border-radius: 6px; box-shadow: 1px 2px 0 #2e1d0d, 3px 7px 12px rgba(0,0,0,.5); }
  .side-extra { display: flex; flex-direction: column; gap: 12px; min-height: 0; overflow-y: auto; }
  .side-extra h3 { color: rgba(243,234,216,.82); }
  .side-extra .muted { color: rgba(243,234,216,.82); }
  .side-extra .log { list-style: none; margin: 0; padding: 0; font-size: 13.5px; color: rgba(243,234,216,.9); }
  .side-extra .log li { padding: 2px 0; }
  .side-extra .bag { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; }
  .side-extra .bag div { position: relative; }
  .side-extra .bag svg { width: 100%; display: block; border-radius: 2px; box-shadow: 1px 1px 0 #3b2b19, 2px 3px 4px rgba(0,0,0,.4); }
  .side-extra .bag span { position: absolute; right: -3px; top: -4px; font-size: 11.5px; font-weight: 800; background: #1b1b1f; color: #fff; border-radius: 8px; padding: 0 4px; }
  .side-extra .bag .z { opacity: .22; }

  #view-tiles { padding: 18px 22px; }
  .tt-body { flex-direction: row-reverse; gap: 18px; }
  .need { flex-direction: column; align-items: stretch; width: 320px; padding: 16px; align-self: flex-start; }
  .need-pick { width: 140px; height: 140px; align-self: center; }
  .need-mid { left: 30px; top: 30px; width: 80px; height: 80px; }
  .ns.n, .ns.s { left: 30px; width: 80px; height: 26px; }
  .ns.e, .ns.w { top: 30px; width: 26px; height: 80px; }
  /* 6 x 4 tiles, as big as the screen height allows */
  .tgrid { grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 14px; width: min(100%, calc((100dvh - 130px) * 1.45)); }

  #view-scores { padding: 18px 22px; }
  .sc-wrap { display: grid; grid-template-columns: 1fr 1fr; grid-template-rows: auto 1fr; }
  .sc-list { grid-column: 1; grid-row: 1; }
  .sc-add { grid-column: 2; grid-row: 1 / 3; align-self: start; }
  .sc-log { grid-column: 1; grid-row: 2; }
  .set-wrap { grid-template-columns: 1fr 1fr; padding: 22px; align-items: start; }
  .sheet-back { align-items: center; }
  .sheet { max-width: 480px; border-radius: 16px; }
}
