:root {
  --ink: #fffaf2;
  --dim: rgba(255, 250, 242, 0.74);
  --panel: rgba(43, 31, 22, 0.86);
  --edge: rgba(255, 236, 210, 0.16);
  --accent: #d8fd71;
  --gold: #ffd76a;
  --baba: #9fb4ff;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #3b2a1e; color: var(--ink);
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, sans-serif; -webkit-tap-highlight-color: transparent; }
#stage, #stage canvas { position: fixed; inset: 0; display: block; touch-action: none; }
button { font: inherit; color: inherit; cursor: pointer; }
[hidden] { display: none !important; }

.loading { position: fixed; inset: 0; display: grid; place-items: center; z-index: 20; background: #3b2a1e; font-size: 18px; color: var(--dim); text-align: center; }
.loading-track { width: min(260px, 70vw); height: 8px; margin: 12px auto 0; border-radius: 999px; background: rgba(255,255,255,.1); overflow: hidden; }
#loading-bar { width: 0; height: 100%; background: var(--gold); transition: width .2s; }

/* start.ng profile card */
.card { position: fixed; top: 16px; left: 16px; z-index: 5; display: flex; align-items: center; gap: 12px;
  padding: 8px 16px 8px 8px; border-radius: 999px; background: #292a23; color: #fffefa; max-width: calc(100vw - 130px); }
.card img, .card-initial { width: 48px; height: 48px; border-radius: 50%; background: #d8fd71; flex: none; }
.card-initial { display: grid; place-items: center; font-weight: 800; font-size: 20px; color: #292a23; }
.card-text { min-width: 0; }
.card b { display: block; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card span { font-size: 12px; opacity: .7; }
.card button { margin-left: 4px; border: 0; border-radius: 999px; padding: 6px 12px; background: #d8fd71; color: #292a23; font-weight: 700; }

.corner { position: fixed; top: 20px; right: 16px; z-index: 5; display: flex; gap: 8px; }
.round { width: 42px; height: 42px; border-radius: 50%; border: 1px solid var(--edge); background: var(--panel); font-size: 18px; font-weight: 800; }

/* HUD */
.hud { position: fixed; inset: 0; pointer-events: none; z-index: 4; }
.scoreboard { position: absolute; top: 16px; left: 50%; transform: translateX(-50%); display: flex; align-items: center; gap: 10px;
  background: var(--panel); border: 1px solid var(--edge); border-radius: 16px; padding: 6px 14px; }
.scoreboard div { text-align: center; min-width: 64px; }
.scoreboard small { display: block; font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--dim); max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.scoreboard b { font-size: 26px; font-variant-numeric: tabular-nums; }
.vs { font-size: 12px; color: var(--dim); text-align: center; }
.vs em { display: block; font-style: normal; color: var(--gold); font-weight: 700; }
.turn { position: absolute; left: 50%; bottom: 58px; transform: translateX(-50%); margin: 0; padding: 8px 16px; border-radius: 999px;
  background: var(--panel); border: 1px solid var(--edge); font-weight: 700; white-space: nowrap; }
.turn:empty { display: none; }
.hint { position: absolute; left: 50%; bottom: 22px; transform: translateX(-50%); margin: 0; font-size: 13px; color: var(--dim); text-shadow: 0 1px 3px rgba(0,0,0,.7); white-space: nowrap; }

/* seed counts beside each pit */
#counts { position: fixed; inset: 0; pointer-events: none; z-index: 3; }
.count { position: absolute; left: 0; top: 0; min-width: 24px; padding: 1px 6px; border-radius: 999px; text-align: center;
  font-size: 13px; font-weight: 800; font-variant-numeric: tabular-nums; background: rgba(30, 22, 15, .78); color: var(--ink); border: 1px solid var(--edge); }
.count.his { color: var(--baba); }
.count.store { font-size: 16px; padding: 2px 9px; background: rgba(30, 22, 15, .9); }
.count.playable { background: var(--gold); color: #2b1f16; border-color: transparent; }
.count.captured { background: #ff7a59; color: #fff; transform-origin: center; }
/* move preview: pits the seeds pass through, where the last one lands, what it captures */
.count.path { box-shadow: 0 0 0 2px rgba(127, 200, 255, .75); }
.count.land { background: #7fc8ff; color: #10202b; }
.count.gain { background: #ff7a59; color: #fff; }
.count.gain::after { content: attr(data-gain); margin-left: 4px; font-size: 11px; }
.skip { position: absolute; right: 16px; bottom: 18px; pointer-events: auto; border: 1px solid var(--edge); border-radius: 999px;
  padding: 7px 14px; background: var(--panel); font-weight: 700; font-size: 13px; }
.spaced { margin-top: 14px; }
/* How to play */
.panel.guide { width: min(560px, calc(100vw - 32px)); max-height: calc(100dvh - 32px); display: flex; flex-direction: column; padding: 18px; }
.panel.guide > * { min-width: 0; }
.guide-tabs { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 8px; margin-bottom: 8px; border-bottom: 1px solid var(--edge); flex: none; }
.guide-tabs button { flex: none; border: 1px solid var(--edge); border-radius: 999px; padding: 6px 12px; background: rgba(255,255,255,.06); font-size: 13px; font-weight: 700; }
.guide-tabs button[aria-selected="true"] { background: var(--gold); color: #2b1f16; border-color: transparent; }
.guide-body { overflow-y: auto; flex: 1; padding-right: 4px; }
.guide-body h2 { margin: 4px 0 6px; }
.guide-body h3 { margin: 16px 0 6px; color: var(--gold); text-transform: none; letter-spacing: 0; font-size: 16px; }
.guide-body p, .guide-body li { color: var(--dim); line-height: 1.5; font-size: 14px; }
.guide-body ul { padding-left: 20px; margin: 6px 0; }
.guide-body b { color: var(--ink); }
.guide-body a { color: var(--gold); }
.guide-body code { font-size: 12px; color: var(--ink); }
.guide-body svg { display: block; width: 100%; height: auto; margin: 8px 0; border-radius: 10px; }
/* the host's lesson, under the scoreboard */
.tip { position: absolute; top: 84px; left: 50%; transform: translateX(-50%); width: min(460px, calc(100vw - 32px)); pointer-events: auto;
  background: var(--panel); border: 1px solid var(--gold); border-radius: 14px; padding: 10px 14px; box-shadow: 0 6px 24px rgba(0,0,0,.35); }
.tip:not([hidden]) { animation: tip-in .25s ease-out; }
.tip p { margin: 0; line-height: 1.45; font-size: 14px; }
.tip b { color: var(--gold); }
.tip .link { font-size: 12px; margin-top: 4px; padding: 0; }
@keyframes tip-in { from { opacity: 0; transform: translate(-50%, 6px); } }
/* the table picker */
.table-list { list-style: none; margin: 0 0 12px; padding: 0; display: grid; gap: 6px; }
.table-list button { width: 100%; display: flex; align-items: center; gap: 10px; text-align: left; border: 1px solid var(--edge); border-radius: 12px;
  padding: 10px 12px; background: rgba(255,255,255,.05); }
.table-list button:hover { background: rgba(255,255,255,.1); }
.table-list .icon { font-size: 22px; width: 30px; text-align: center; }
.table-list .what { flex: 1; min-width: 0; }
.table-list .what b { display: block; }
.table-list .what small { color: var(--dim); }
.table-list .rec { color: var(--gold); font-weight: 800; font-variant-numeric: tabular-nums; font-size: 13px; }
.another { display: block; margin: 10px auto 0; }
.controls-line { font-size: 12px; }
/* the mini-map */
.minimap { position: absolute; left: 16px; bottom: 44px; pointer-events: auto; }
.minimap canvas { display: block; width: 220px; height: 150px; border-radius: 12px; border: 1px solid var(--edge); background: rgba(30, 22, 15, .78); cursor: pointer; }
.minimap.folded canvas { display: none; }
.minimap-toggle { margin-top: 6px; border: 1px solid var(--edge); border-radius: 999px; padding: 4px 12px; background: var(--panel); font-size: 12px; font-weight: 700; }
.tour-end { position: absolute; right: 16px; bottom: 52px; pointer-events: auto; border: 1px solid var(--edge); border-radius: 999px; padding: 9px 16px; background: var(--panel); font-weight: 700; }
@media (max-width: 640px) {
  .minimap { left: 10px; bottom: 96px; }
  .minimap canvas { width: 150px; height: 102px; }
}

/* the other tables */
#table-menu, #table-over { place-items: center end; }
#table-over { place-items: center; }
.rules.compact { margin: 12px 0 0; font-size: 13px; gap: 4px; }
.table-actions { position: absolute; left: 50%; bottom: 104px; transform: translateX(-50%); display: flex; gap: 8px; pointer-events: auto; }
.table-actions button { border: 0; border-radius: 999px; padding: 11px 18px; background: var(--accent); color: #1f2a12; font-weight: 800; font-size: 15px;
  box-shadow: 0 8px 22px rgba(0,0,0,.35); white-space: nowrap; }
.table-actions button.alt { background: var(--panel); color: var(--ink); border: 1px solid var(--edge); }
.table-actions button:disabled { opacity: .45; cursor: default; }
.scoreboard .seat { text-align: center; min-width: 56px; }
.scoreboard .seat.active b { color: var(--gold); }
.scoreboard .seat.active small { color: var(--gold); }
@media (max-width: 640px) { .table-actions { bottom: 92px; flex-wrap: wrap; justify-content: center; width: 94vw; } }

/* walking about the joint */
.walk-hud { position: fixed; inset: 0; z-index: 4; pointer-events: none; }
.walk-hud .hint { position: absolute; left: 50%; bottom: 16px; transform: translateX(-50%); margin: 0; font-size: 13px; color: var(--dim);
  text-shadow: 0 1px 3px rgba(0,0,0,.8); white-space: nowrap; }
.sit { position: absolute; left: 50%; bottom: 52px; transform: translateX(-50%); pointer-events: auto; border: 0; border-radius: 999px;
  padding: 12px 22px; background: var(--accent); color: #1f2a12; font-size: 16px; font-weight: 800; box-shadow: 0 8px 24px rgba(0,0,0,.35);
  animation: toast-in .25s ease-out; white-space: nowrap; }
.sit:disabled { background: var(--panel); color: var(--ink); border: 1px solid var(--edge); cursor: default; font-weight: 700; }
body.cover .walk-hud, body.cover .toast { display: none !important; }
@media (max-width: 640px) {
  .walk-hud .hint { white-space: normal; width: 92vw; text-align: center; }
  .sit { font-size: 14px; max-width: 92vw; white-space: normal; text-align: center; }
}
.record { margin-top: 14px; padding: 10px 12px; border-radius: 12px; background: rgba(255,255,255,.05); border: 1px solid var(--edge); }
.record .label { margin-bottom: 6px; }
.record ul { margin: 0; padding: 0; list-style: none; display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.record li { display: flex; justify-content: space-between; gap: 6px; font-size: 13px; color: var(--dim); }
.record li b { color: var(--ink); font-variant-numeric: tabular-nums; }
.record .note { margin-top: 6px; }
.proverb { margin: 14px 0 4px; padding: 10px 14px; border-left: 3px solid var(--gold); background: rgba(255, 215, 106, .07); border-radius: 0 10px 10px 0; }
.proverb p { margin: 0; font-weight: 700; line-height: 1.4; }
.proverb .meaning { margin-top: 4px; font-weight: 400; font-size: 13px; color: var(--dim); }
.proverb cite { display: block; margin-top: 4px; font-size: 11px; font-style: normal; letter-spacing: .08em; text-transform: uppercase; color: var(--gold); }
.toast { position: fixed; top: 92px; left: 50%; transform: translateX(-50%); z-index: 7; max-width: min(420px, 90vw); padding: 8px 14px; border-radius: 12px;
  background: var(--panel); border: 1px solid var(--edge); font-size: 14px; text-align: center; pointer-events: none; animation: toast-in .3s ease-out; }
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, -6px); } }
.levels.small button { padding: 7px; font-size: 13px; }
.wide { width: 100%; margin-top: 12px; }

.bubble { position: fixed; left: 0; top: 0; z-index: 6; max-width: 240px; padding: 8px 12px; border-radius: 14px; background: #fffaf2; color: #2b1f16;
  font-weight: 700; font-size: 14px; box-shadow: 0 6px 18px rgba(0,0,0,.3); pointer-events: none; }
.bubble::after { content: ""; position: absolute; left: 50%; bottom: -7px; margin-left: -7px; border: 7px solid transparent; border-bottom: 0; border-top-color: #fffaf2; }

/* Screens: only the panel takes clicks, so the card and corner buttons stay usable */
.screen { position: fixed; inset: 0; z-index: 6; display: grid; place-items: center end; padding: 88px max(16px, 6vw) 16px 16px; overflow-y: auto; pointer-events: none; }
.screen .panel { pointer-events: auto; }
#over { place-items: center; }
.sheet { position: fixed; inset: 0; z-index: 10; display: grid; place-items: center; padding: 16px; background: rgba(20, 14, 9, .55); overflow-y: auto; }
.panel { width: min(440px, 100%); background: var(--panel); border: 1px solid var(--edge); border-radius: 20px; padding: 24px;
  backdrop-filter: blur(8px); box-shadow: 0 20px 50px rgba(0,0,0,.4); }
.kicker { margin: 0; color: var(--accent); font-weight: 700; letter-spacing: .12em; text-transform: uppercase; font-size: 12px; }
h1 { margin: 4px 0 8px; font-size: clamp(40px, 8vw, 56px); line-height: 1; font-weight: 900; letter-spacing: -.02em; }
h1 span { color: var(--gold); }
h2 { margin: 0 0 14px; font-size: 26px; }
h3 { margin: 18px 0 8px; font-size: 13px; letter-spacing: .08em; text-transform: uppercase; color: var(--dim); }
.lead { margin: 0 0 16px; color: var(--dim); line-height: 1.5; }
.label { margin: 0 0 8px; font-weight: 700; font-size: 14px; }
.levels { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-bottom: 8px; }
.levels button { border: 1px solid var(--edge); border-radius: 12px; padding: 10px; background: rgba(255,255,255,.06); font-weight: 700; }
.levels button[aria-pressed="true"] { background: var(--gold); color: #2b1f16; border-color: transparent; }
.big { width: 100%; margin-top: 12px; border: 0; border-radius: 14px; padding: 14px; background: var(--accent); color: #1f2a12; font-size: 18px; font-weight: 800; }
.big:hover { filter: brightness(1.05); }
.secondary { border: 1px solid var(--edge); border-radius: 12px; padding: 10px 14px; background: rgba(255,255,255,.08); font-weight: 700; }
.link { border: 0; padding: 0; background: none; color: var(--accent); font-weight: 700; text-decoration: underline; }
.note { margin: 10px 0 0; font-size: 13px; color: var(--dim); line-height: 1.45; }
.result { display: flex; gap: 10px; }
.result div { flex: 1; background: rgba(255,255,255,.06); border: 1px solid var(--edge); border-radius: 12px; padding: 8px; text-align: center; }
.result small { display: block; font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--dim); }
.result b { font-size: 30px; }
.streak { margin: 12px 0 0; color: var(--gold); font-weight: 800; }
.status { margin: 6px 0 10px; font-weight: 600; }
.board { margin: 0 0 6px; padding: 0; list-style: none; display: grid; gap: 4px; max-height: 30vh; overflow-y: auto; }
.board li { display: flex; align-items: center; gap: 8px; padding: 6px 10px; border-radius: 10px; background: rgba(255,255,255,.05); font-size: 14px; }
.board li.me { background: rgba(216, 253, 113, .18); outline: 1px solid rgba(216, 253, 113, .5); }
.board .dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.board .name { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.board .score { color: var(--dim); font-variant-numeric: tabular-nums; }
.rules { margin: 0 0 4px; padding-left: 20px; display: grid; gap: 8px; line-height: 1.45; color: var(--dim); }
.rules b { color: var(--ink); }

@media (max-width: 640px) {
  .screen { place-items: end center; padding: 88px 12px 12px; }
  .card { top: 12px; left: 12px; gap: 8px; padding: 6px 10px 6px 6px; }
  .card img, .card-initial { width: 38px; height: 38px; font-size: 16px; }
  .card b { font-size: 14px; }
  .card span { display: block; font-size: 11px; white-space: nowrap; }
  .card button { padding: 5px 10px; font-size: 13px; white-space: nowrap; }
  .corner { top: 14px; right: 12px; }
  .round { width: 38px; height: 38px; font-size: 16px; }
  .scoreboard { top: 70px; }
  .panel { padding: 18px; }
  .lead { font-size: 14px; }
  .turn { bottom: 44px; font-size: 14px; }
  .hint { bottom: 16px; }
}

/* Cover-picture mode (?cover) */
body.cover .card, body.cover .corner, body.cover .screen, body.cover .hud, body.cover #counts, body.cover .bubble { display: none !important; }
.cover-title { display: none; }
body.cover .cover-title { display: block; position: fixed; right: 5%; bottom: 6%; z-index: 7; text-align: right; }
.cover-title h1 { font-family: Georgia, 'Times New Roman', serif; font-size: 120px; line-height: 1; margin: 0; text-shadow: 0 8px 30px rgba(0,0,0,.5); }
.cover-title p { margin: 6px 0 0; font-family: Georgia, 'Times New Roman', serif; font-style: italic; font-size: 44px; color: var(--gold); text-shadow: 0 4px 16px rgba(0,0,0,.6); }
.cover-title small { display: block; margin-top: 4px; font-size: 26px; font-weight: 800; color: var(--ink); text-shadow: 0 3px 12px rgba(0,0,0,.7); }
