:root{
  /* Restrained-premium board-game palette. The previous scheme -- deep purple
     #120b26 with saturated #ff7a3c orange and #54d6ff cyan plus var(--gold) gold --
     is the canonical generated combination: complementary neon on indigo.
     This is a warm walnut-and-brass room instead: near-neutral grounds, bone
     text, and team colours desaturated far enough to read as materials
     (terracotta and slate) rather than UI highlights. */
  --bg:#17140f;
  --panel:rgba(31,26,20,.84);
  --edge:rgba(214,199,171,.15);
  --ink:#ece4d6;
  --dim:#9c9184;
  --ember:#c05f3c;
  --ember-deep:#9c4830;
  --frost:#6f93ab;
  --frost-deep:#4e7288;
  --gold:#c4a265;
  --ok:#7f9a68;
  --bad:#ac5049;
  --font-ui:'Source Sans 3',system-ui,-apple-system,'Segoe UI',sans-serif;
  --font-title:'Source Serif 4',Georgia,'Times New Roman',serif;
}

[data-theme="light"]{
  /* Warm paper, not lavender. Same restraint as the dark theme. */
  --bg:#ece6da;
  --panel:rgba(253,250,244,.86);
  --edge:rgba(60,48,32,.16);
  --ink:#241d15;
  --dim:#6d6252;
  --ember:#a24428;
  --ember-deep:#82341d;
  --frost:#3f6a83;
  --frost-deep:#2d5266;
  --gold:#9a7833;
  --ok:#5c7a47;
  --bad:#9c3f39;
}
*{box-sizing:border-box;margin:0;padding:0}
html,body{height:100%;overflow:hidden;background:var(--bg);font-family:var(--font-ui);color:var(--ink)}
html[data-theme="light"],body[data-theme="light"]{color:var(--ink)}
#gl{position:fixed;inset:0;width:100%;height:100%;display:block}
#vignette{position:fixed;inset:0;pointer-events:none;background:radial-gradient(ellipse at center,transparent 55%,rgba(5,2,15,.55) 100%)}
.hidden{display:none !important}
button{font-family:inherit}

.glass{
  background:var(--panel);
  border:1px solid var(--edge);
  border-radius:14px;
  backdrop-filter:blur(14px);
  -webkit-backdrop-filter:blur(14px);
  box-shadow:0 8px 32px rgba(0,0,0,.45),inset 0 1px 0 rgba(255,255,255,.06);
}

/* ---------- buttons ---------- */
.btn{
  display:inline-block;border:1px solid var(--edge);border-radius:10px;
  background:rgba(236,228,214,.055);
  color:var(--ink);font-weight:600;font-size:15px;letter-spacing:.4px;
  padding:10px 22px;cursor:pointer;transition:all .18s ease;
}
.btn:hover{border-color:rgba(214,199,171,.38);background:rgba(236,228,214,.10)}
.btn:active{transform:translateY(0)}
.btn.primary{
  background:var(--ember);border-color:var(--ember-deep);color:#1b0f09;
}
.btn.primary:hover{background:linear-gradient(180deg,#ffae79,#ff6b4a);box-shadow:0 4px 22px rgba(255,110,60,.45)}
.btn.quant-btn{
  background:linear-gradient(180deg,#3a2f14,#241c0a);
  border:1px solid rgba(230,190,90,.65);
  color:#f0d898;font-weight:700;letter-spacing:1.5px;font-size:12px;
  position:relative;
  animation:qkpulse 2.6s ease-in-out infinite;
}
.btn.quant-btn:hover{background:linear-gradient(180deg,#5a4718,#332809);box-shadow:0 4px 26px rgba(240,200,90,.5)}
/* Pulse via compositable transform+opacity on a pseudo-element: animating the
   box-shadow blur radius repaints forever, even while the menu sits idle. */
.btn.quant-btn::after{
  content:'';position:absolute;inset:-2px;border-radius:inherit;pointer-events:none;
  box-shadow:0 1px 6px rgba(0,0,0,.35);
  opacity:.25;animation:qkglow 2.6s ease-in-out infinite;
}
@keyframes qkpulse{0%,100%{transform:scale(1)}50%{transform:scale(1.012)}}
@keyframes qkglow{0%,100%{opacity:.22}50%{opacity:.85}}
.qk-tagline{margin:8px 0 2px;font-size:11px;opacity:.75;text-align:center;font-family:var(--font-ui);letter-spacing:.4px}
.qk-tagline b{color:var(--gold)}
.btn.danger{border-color:rgba(255,95,109,.5);color:var(--bad)}
.btn.danger:hover{background:linear-gradient(180deg,rgba(255,80,100,.35),rgba(160,30,50,.4));box-shadow:0 4px 18px rgba(255,60,80,.3)}
.btn.ghost{background:transparent}
.btn.tiny{padding:7px 12px;font-size:13px}
.btn:disabled{opacity:.4;cursor:not-allowed;transform:none}

textarea,input[type=text]{
  width:100%;background:rgba(8,5,22,.8);border:1px solid var(--edge);border-radius:8px;
  color:var(--ink);font-family:'JetBrains Mono',ui-monospace,monospace;font-size:12px;
  padding:8px 10px;resize:none;outline:none;
}
textarea:focus,input:focus{border-color:var(--frost)}
select{
  width:100%;background:rgba(8,5,22,.8);border:1px solid var(--edge);border-radius:8px;
  color:var(--ink);font-family:var(--font-ui);font-size:14px;padding:8px 10px;outline:none;
}
select:focus{border-color:var(--frost)}
label{font-size:12px;color:var(--dim);text-transform:uppercase;letter-spacing:1px;display:block;margin:10px 0 4px}

/* ---------- menu / overlays ---------- */
.overlay{
  position:fixed;inset:0;display:flex;align-items:center;justify-content:center;
  background:radial-gradient(ellipse at 50% 30%,rgba(30,18,70,.25),rgba(6,3,18,.72));
  z-index:40;padding:20px;
}
/* nested prompts must stack above the panels they are opened from (shop, checkout, …) */
#checkout{z-index:50}
#dialog{z-index:55}

/* Worlds picker: dock it to the right so the island stays visible while you pick a realm */
#themes.overlay{
  align-items:stretch;justify-content:flex-end;padding:0;pointer-events:none;
  background:linear-gradient(to left,rgba(6,3,18,.6),rgba(6,3,18,.12) 46%,transparent 72%);
}
#themes .panel{
  pointer-events:auto;height:100%;max-height:none;max-width:min(400px,94vw);
  border-radius:0;border-right:none;display:flex;flex-direction:column;gap:6px;
}
#themes .th-grid{grid-template-columns:1fr 1fr;overflow-y:auto;flex:1;margin-top:10px}
#themes .menu-btns{margin-top:12px;flex:none}
@media (max-width:560px){#themes .panel{max-width:100vw}}
.panel{max-width:560px;width:100%;padding:34px 38px;max-height:92vh;overflow-y:auto}
.panel.center{text-align:center}
.title{
  /* Was a three-stop gradient clipped to text (var(--ink)/var(--ember)/#b46bff) with a
     24px glow, 6px tracking, weight 800, and a cyan second line carrying its
     own 18px glow. That combination -- neon gradient type plus bloom -- is the
     clearest single "generated" signal in the whole interface. A serif set in
     one colour with restrained tracking and no glow reads as a printed plate
     on a good board-game box, which is the register we want. */
  font-family:var(--font-title);font-weight:700;font-size:clamp(32px,4.6vw,48px);
  letter-spacing:.5px;text-align:center;line-height:1.05;color:var(--ink);
}
.title span{
  display:block;font-family:var(--font-ui);font-weight:600;
  font-size:.30em;letter-spacing:5.5px;text-transform:uppercase;
  color:var(--gold);margin-top:8px;
}
.tag{text-align:center;color:var(--dim);margin:14px 0 26px;font-size:16px;line-height:1.5}
.menu-btns{display:flex;gap:12px;justify-content:center;flex-wrap:wrap;margin-top:18px}
.panel h2{font-family:var(--font-title);font-weight:700;letter-spacing:0;margin-bottom:14px;color:var(--ink);font-size:20px}
.howto{max-width:620px}
.howto h4{color:var(--frost);font-size:12px;letter-spacing:2px;text-transform:uppercase;margin:16px 0 6px}
.howto h4:first-of-type{margin-top:4px}
.howto ul{margin-left:18px;color:var(--ink);font-size:15px;line-height:1.6}
.howto b{color:var(--gold)}
.ok-l{color:var(--ok)}
.bad-l{color:var(--bad)}
.rules{margin:6px 0 4px 18px;color:var(--ink);font-size:15px;line-height:1.65}
.rules b{color:var(--gold)}

/* ---------- menu hub (mobile-first tabbed menu) ---------- */
/* One short page per tab: the panel never scrolls past a thumb-reach. Tab taps
   swap pages instead of stacking submenus below the fold. */
.menu-panel{display:flex;flex-direction:column;gap:0}
/* Underline tabs rather than a filled pill. The selected tab was a full
   ember gradient with a 14px coloured bloom, which made navigation shout
   louder than the primary action beneath it -- and it competed with the
   Pass & Play button for the same visual weight. */
.hub-tabs{
  display:flex;gap:26px;margin:6px 0 18px;padding:0 2px;
  border-bottom:1px solid var(--edge);
}
.hub-tab{
  border:0;background:transparent;padding:9px 1px 11px;cursor:pointer;
  color:var(--dim);font-family:var(--font-ui);font-weight:600;font-size:14px;
  letter-spacing:.2px;position:relative;min-height:40px;
  transition:color .16s ease;-webkit-tap-highlight-color:transparent;
}
.hub-tab:hover{color:var(--ink)}
.hub-tab.on{color:var(--ink)}
.hub-tab.on::after{
  content:'';position:absolute;left:0;right:0;bottom:-1px;height:2px;
  background:var(--gold);border-radius:1px;
}
.hub-page{display:none;flex-direction:column;gap:10px}
.hub-page.on{display:flex}
.hub-page .btn.big{
  width:100%;padding:15px 18px;font-size:16px;letter-spacing:1.2px;min-height:52px;
  text-align:center;
}
.hub-page .menu-row2{gap:10px}
.hub-page .menu-row2 .btn.small{padding:13px 8px;font-size:13.5px;min-height:48px}
.kb{
  display:inline-block;margin-left:7px;padding:1px 6px;border-radius:5px;
  border:1px solid var(--edge);background:rgba(8,5,22,.6);
  font-family:var(--font-title);font-size:10px;letter-spacing:1px;color:var(--gold);
  vertical-align:1px;
}
@media (max-width:560px){
  #menu.overlay{align-items:flex-end;padding:0}
  #menu .panel.menu-panel{
    max-width:100vw;max-height:94dvh;border-radius:22px 22px 0 0;padding:14px 14px calc(12px + env(safe-area-inset-bottom));
    overflow-y:auto;overscroll-behavior:contain;
  }
  .menu-panel .title{font-size:27px;letter-spacing:3px}
  .menu-panel .tag{margin:6px 0 10px;font-size:13px;line-height:1.45}
  .hub-tabs{gap:18px;margin:2px 0 12px}
  .hub-tab{padding:8px 1px 10px;font-size:13px}
  .hub-page{gap:8px}
  .hub-page .btn.big{padding:12px 14px;font-size:15px;min-height:46px;letter-spacing:1px}
  .hub-page .menu-row2 .btn.small{padding:11px 6px;min-height:44px}
  .menu-panel .profile-line{margin-top:10px}
}
@media (hover:none) and (pointer:coarse){
  .btn:active{transform:translateY(1px)}
}

/* ---------- lobby ---------- */
#lobby{margin-top:22px;border-top:1px solid var(--edge);padding-top:16px;text-align:left}
#lobby .status{margin-top:12px;font-size:14px;color:var(--frost);min-height:20px}
#lobby .status.err{color:var(--bad)}
#lobby .row{display:flex;gap:8px;margin-top:10px;flex-wrap:wrap}
#lobby .hint{font-size:13px;color:var(--dim);margin-top:8px;line-height:1.5}
.codebig{font-family:ui-monospace,monospace;font-size:26px;letter-spacing:8px;text-align:center;color:var(--gold);padding:12px;background:rgba(0,0,0,.35);border-radius:8px;border:1px dashed var(--edge)}
.spinner{display:inline-block;width:12px;height:12px;border:2px solid var(--frost);border-top-color:transparent;border-radius:50%;animation:spin .8s linear infinite;vertical-align:-2px;margin-right:6px}
@keyframes spin{to{transform:rotate(360deg)}}

/* ---------- HUD ---------- */
#hud{position:fixed;inset:0;pointer-events:none;z-index:30}
#hud button,.pips,#chat{pointer-events:auto}
#turn-card{
  position:absolute;top:14px;left:50%;transform:translateX(-50%);
  display:flex;align-items:center;gap:12px;padding:10px 22px;min-width:260px;justify-content:center;
}
/* HUD cards that mutate every frame (turn clock, log feed, capture tally) skip
   backdrop-filter: sampling the live WebGL canvas behind them repaints at 60Hz.
   Modal/overlay panels keep the frosted look — they're static while open.
   Visual trade: slightly flatter panels during play; confirm before shipping. */
#turn-card.glass,#log-panel.glass,#cap-panel.glass{backdrop-filter:none;-webkit-backdrop-filter:none}
#turn-emblem{width:22px;height:22px;border-radius:50%;box-shadow:0 0 8px rgba(0,0,0,.35) inset;background:currentColor;flex:none}
#turn-emblem.red{color:var(--ember)}.frost{color:var(--frost)}
#turn-text{font-size:18px;font-weight:600;letter-spacing:.2px;white-space:nowrap}
#timer-wrap{width:110px;height:8px;background:rgba(0,0,0,.5);border-radius:4px;overflow:hidden}
#timer-bar{height:100%;width:100%;background:linear-gradient(90deg,var(--ok),var(--gold));border-radius:4px}
/* no width transition: style.width is written every frame, and re-targeting a
   200ms transition 60x/sec is pure waste — the per-frame write IS the animation */
#timer-bar.low{background:linear-gradient(90deg,var(--bad),var(--ember))}
#turn-meta{display:flex;align-items:center;gap:10px;font-family:var(--font-ui)}
#move-count{font-size:12px;letter-spacing:1.5px;text-transform:uppercase;color:var(--dim);white-space:nowrap}
#timer-secs{font-size:16px;font-weight:700;color:var(--gold);min-width:44px;text-align:center;font-variant-numeric:tabular-nums}
#timer-secs.low{color:var(--bad)}

#log-panel{position:absolute;top:14px;left:14px;width:190px;max-height:38vh;padding:12px 14px;overflow:hidden;display:flex;flex-direction:column}
#cap-panel{position:absolute;top:calc(38vh + 34px);left:14px;width:190px;padding:12px 14px}
#hud h3{font-size:11px;letter-spacing:2px;text-transform:uppercase;color:var(--dim);margin-bottom:8px}
#log{list-style:none;overflow-y:auto;font-size:14px;line-height:1.7;font-family:ui-monospace,monospace}
#log li{white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
#log li .n{color:var(--dim)}
#log li.red i{color:var(--ember);font-style:normal;font-weight:700}
#log li.black i{color:var(--frost);font-style:normal;font-weight:700}
.cap-row{display:flex;align-items:center;gap:8px;margin:4px 0}
.cap-label{font-size:12px;width:44px;text-transform:uppercase;letter-spacing:1px}
.ember-l{color:var(--ember)}.frost-l{color:var(--frost)}
.pips{display:flex;flex-wrap:wrap;gap:3px;min-height:12px}
.pip{width:10px;height:10px;border-radius:50%}
.pip.red{background:radial-gradient(circle at 35% 30%,var(--ember),var(--ember-deep));box-shadow:0 1px 2px rgba(0,0,0,.5)}
.pip.black{background:radial-gradient(circle at 35% 30%,var(--frost),var(--frost-deep));box-shadow:0 1px 2px rgba(0,0,0,.5)}

#side-btns{position:absolute;left:14px;bottom:14px;display:flex;gap:8px;pointer-events:auto}

#chat{position:absolute;right:14px;bottom:14px;width:270px;padding:12px 14px;display:flex;flex-direction:column}
#chat-msgs{max-height:180px;min-height:60px;overflow-y:auto;font-size:14px;line-height:1.5;display:flex;flex-direction:column;gap:4px}
#chat-msgs .me{color:var(--ok)}
#chat-msgs .peer{color:var(--gold)}
#chat-msgs .sys{color:var(--dim);font-style:italic}
#chat form{display:flex;gap:6px;margin-top:8px}
#chat input{flex:1}
#chat button{border:1px solid var(--edge);border-radius:8px;background:rgba(90,90,200,.3);color:var(--ink);padding:0 12px;cursor:pointer}

/* ---------- toasts ---------- */
#toasts{position:fixed;top:76px;left:50%;transform:translateX(-50%);z-index:60;display:flex;flex-direction:column;gap:8px;align-items:center;pointer-events:none}
.toast{
  background:rgba(18,12,40,.92);border:1px solid var(--edge);border-radius:10px;
  padding:9px 20px;font-size:15px;font-weight:600;letter-spacing:.5px;
  animation:toast 2.6s ease forwards;box-shadow:0 6px 24px rgba(0,0,0,.5);
}
.toast.bad{border-color:rgba(255,95,109,.6);color:var(--bad)}
.toast.good{border-color:rgba(110,242,176,.6);color:var(--ok)}
@keyframes toast{0%{opacity:0;transform:translateY(-12px)}10%,85%{opacity:1;transform:translateY(0)}100%{opacity:0;transform:translateY(-8px)}}

/* result */
#result-emblem{width:64px;height:64px;border-radius:50%;margin:0 auto 14px;box-shadow:0 2px 18px rgba(0,0,0,.45);background:radial-gradient(circle at 35% 30%,#fff8,currentColor 60%)}
#result-title{font-family:var(--font-title);font-size:34px;letter-spacing:4px;text-align:center}
#result-sub{color:var(--dim);text-align:center;margin-top:8px;font-size:16px}

/* ---------- themes picker ---------- */
.th-grid{display:grid;grid-template-columns:repeat(3,1fr);gap:9px;margin-top:16px}
.th-btn{
  display:flex;flex-direction:column;align-items:stretch;gap:7px;padding:10px 11px;
  border:1px solid var(--edge);border-radius:10px;background:rgba(40,32,80,.3);
  color:var(--ink);cursor:pointer;font-family:var(--font-ui);
  font-size:13px;font-weight:600;letter-spacing:.3px;transition:all .15s ease;text-align:left;
}
.th-btn:hover{border-color:var(--frost);transform:translateY(-1px);background:rgba(64,54,120,.4)}
.th-btn.on{border-color:var(--gold);box-shadow:inset 0 0 0 1px var(--gold),0 0 14px rgba(255,215,94,.18)}
.th-sw{height:12px;border-radius:6px;border:1px solid rgba(255,255,255,.12)}
@media (max-width:640px){.th-grid{grid-template-columns:repeat(2,1fr)}}

::-webkit-scrollbar{width:8px;height:8px}

/* ---------- clocks ---------- */
#clocks{display:flex;gap:6px;align-items:center;justify-content:center;margin-top:6px;font-family:'Orbitron',sans-serif;font-size:15px;letter-spacing:1px}
.clk{padding:2px 8px;border-radius:6px;background:rgba(10,8,26,.6);border:1px solid rgba(255,255,255,.08)}
.clk.red{color:var(--ember)}
.clk.black{color:var(--frost)}
.clk.live{border-color:var(--gold);background:rgba(196,162,101,.12)}
.clk.low{color:#ff4a4a;animation:clkpulse .8s infinite}
@keyframes clkpulse{50%{background:rgba(255,60,60,.25)}}
.clksep{opacity:.5}

/* ---------- banners / wallet / taunt ---------- */
#mode-banner{margin-top:6px;font-family:var(--font-ui);font-size:12px;letter-spacing:1.5px;color:var(--gold);text-transform:uppercase}
#wallet-chip{position:absolute;top:12px;right:12px;padding:7px 14px;border-radius:20px;font-family:var(--font-ui);font-size:14px;color:var(--gold)}
#taunt{position:absolute;top:15%;left:50%;transform:translateX(-50%);max-width:440px;padding:10px 20px;border-radius:14px;background:rgba(12,8,30,.85);border:1px solid rgba(255,215,94,.35);color:#f0e2b8;font-family:var(--font-ui);font-size:16px;text-align:center;animation:tauntin .3s ease}
@keyframes tauntin{from{opacity:0;transform:translateX(-50%) translateY(-8px)}to{opacity:1}}

/* ---------- emotes ---------- */
#emote-bar{position:absolute;bottom:18px;left:50%;transform:translateX(-50%);display:flex;gap:8px}
.emote{width:42px;height:42px;border-radius:10px;border:1px solid var(--edge);background:rgba(20,14,44,.75);font-size:19px;cursor:pointer;transition:transform .12s,background .12s}
.emote:hover{transform:translateY(-3px);background:rgba(60,46,120,.8)}

/* ---------- seat placement ---------- */
#seat-place{position:absolute;bottom:18px;left:50%;transform:translateX(-50%);display:flex;align-items:center;gap:14px;padding:9px 16px;border-radius:14px;font-family:var(--font-ui);letter-spacing:.6px}
#seat-place .sp-hint{font-size:13px;color:var(--dim);white-space:nowrap}
@media (max-width:560px){#seat-place{flex-direction:column;gap:8px;max-width:88vw}#seat-place .sp-hint{text-align:center;white-space:normal}}

/* ---------- menu extras ---------- */
.menu-row2{display:flex;gap:8px;flex-wrap:wrap}
.btn.small{flex:1;padding:9px 8px;font-size:13px}
.profile-line{margin-top:12px;text-align:center;font-family:var(--font-ui);font-size:13px;color:#c8bfa8}
.profile-line b{color:var(--gold)}

/* ---------- shop ---------- */
/* Marketplace: dock it to the right so the island stays visible while you shop —
   equipping a shape/palette/theme re-renders the board live and you can see it. */
#shop.overlay{
  align-items:stretch;justify-content:flex-end;padding:0;pointer-events:none;
  background:linear-gradient(to left,rgba(6,3,18,.62),rgba(6,3,18,.14) 48%,transparent 74%);
}
#shop .panel{
  pointer-events:auto;height:100%;max-height:none;max-width:min(430px,94vw);
  border-radius:0;border-right:none;display:flex;flex-direction:column;gap:6px;overflow-y:auto;
}
#shop .shop-grid{grid-template-columns:repeat(auto-fill,minmax(150px,1fr))}
#shop .menu-btns{margin-top:12px;flex:none}
@media (max-width:560px){#shop .panel{max-width:100vw}}
.shop-panel{max-height:82vh;overflow:auto;width:min(680px,94vw)}
.shop-wallet{float:right;font-size:15px;color:var(--gold)}
.shop-tabs{display:flex;gap:6px;flex-wrap:wrap;margin:10px 0 14px}
.shop-tabs button{padding:7px 13px;border-radius:16px;border:1px solid var(--edge);background:rgba(20,14,44,.6);color:var(--ink);font-family:var(--font-ui);font-size:13px;cursor:pointer}
.shop-tabs button.on{border-color:var(--gold);color:var(--gold)}
.shop-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(190px,1fr));gap:10px}
.shop-card{border:1px solid var(--edge);border-radius:12px;padding:12px;background:rgba(24,16,52,.55);display:flex;flex-direction:column;gap:8px}
.shop-card h4{margin:0;font-family:var(--font-title);font-size:15px;color:#efe8d0}
.shop-card .desc{font-size:12px;color:var(--dim);flex:1}
.shop-card .price{font-size:13px;color:var(--gold)}
.shop-card button{padding:7px;border-radius:8px;border:1px solid var(--edge);background:rgba(64,48,130,.55);color:#fff;font-family:var(--font-ui);cursor:pointer}
.shop-card button:disabled{opacity:.45;cursor:default}
.shop-card button.owned{border-color:var(--ok);color:var(--ok)}
.shop-card button.equipped{border-color:var(--gold);color:var(--gold)}
.pass-lvl{margin:4px 0 10px;font-family:var(--font-ui);font-size:13px;color:var(--ink)}
.pass-bar{height:8px;border-radius:4px;background:rgba(255,255,255,.08);overflow:hidden}
.pass-bar>div{height:100%;background:linear-gradient(90deg,#8a5cff,var(--gold))}

/* ---------- ladder ---------- */
#ladder-table{width:100%;border-collapse:collapse;font-family:var(--font-ui);font-size:14px}
#ladder-table th,#ladder-table td{padding:6px 8px;text-align:left;border-bottom:1px solid rgba(255,255,255,.06)}
#ladder-table th{color:var(--dim);font-weight:600;font-size:12px;text-transform:uppercase;letter-spacing:1px}

/* ---------- spectate ---------- */
#spectate-bar{position:absolute;bottom:18px;left:50%;transform:translateX(-50%);display:flex;align-items:center;gap:14px;padding:8px 16px;border-radius:14px;font-family:var(--font-ui);letter-spacing:1px}
#timepiece-bar{position:absolute;bottom:18px;left:50%;transform:translateX(-50%);display:flex;align-items:center;gap:12px;padding:9px 18px;border-radius:14px;font-family:var(--font-ui);letter-spacing:1px}
#timepiece-bar #tp-name{color:var(--gold);font-weight:700}
#timepiece-bar .tp-hint{opacity:.55;font-size:11px;letter-spacing:.5px}
#spec-reactions{display:flex;gap:6px}
.speed-l{font-family:var(--font-ui);font-size:13px;color:var(--ink)}
.speed-l select{width:auto;padding:4px 8px}
#rp-track{width:100%;margin:12px 0}

/* replay: dock controls to the bottom so the board stays visible */
#replay.overlay{align-items:flex-end;background:linear-gradient(to top,rgba(6,3,18,.62),rgba(6,3,18,0) 36%);pointer-events:none;padding:16px}
#replay .panel{pointer-events:auto;display:flex;flex-wrap:wrap;align-items:center;justify-content:center;gap:8px 14px;max-width:min(940px,97vw);width:auto;padding:12px 18px}
#replay .panel h2{margin:0;font-size:15px}
#rp-info{font-family:var(--font-ui);color:var(--dim);letter-spacing:1px;white-space:nowrap;min-width:104px;text-align:center}
#replay #rp-track{width:auto;flex:1 1 200px;margin:0}
#replay .menu-row2,#replay .menu-btns{margin:0;flex-wrap:nowrap}
::-webkit-scrollbar-thumb{background:rgba(130,140,255,.3);border-radius:4px}
::-webkit-scrollbar-track{background:transparent}

@media (max-width:760px){
  #log-panel,#cap-panel{display:none}
  #chat{width:200px}
  .panel{padding:22px}
}

/* ---- daily hub ---- */
#hub .panel{max-height:86vh;overflow:auto}
.hub-hero{display:flex;gap:10px;margin:6px 0 14px}
.hub-hero>div{flex:1;text-align:center;background:rgba(255,255,255,.05);border-radius:12px;padding:10px 6px}
.hub-hero b{display:block;font-size:1.5rem;color:var(--gold)}
.hub-hero span{font-size:.66rem;opacity:.7;text-transform:uppercase;letter-spacing:.04em}
.hub h4{margin:16px 0 6px;font-size:.72rem;text-transform:uppercase;letter-spacing:.08em;opacity:.6}
.hub-q{background:rgba(0,0,0,.22);border-radius:10px;padding:9px 11px;margin:6px 0}
.hub-q.done{outline:1px solid rgba(120,220,150,.5)}
.hub-q>span{display:block;font-size:.9rem}
.hub-q>em{display:block;font-size:.72rem;opacity:.7;font-style:normal;margin-top:2px}
.hub-bar{height:5px;background:rgba(255,255,255,.1);border-radius:3px;margin-top:6px;overflow:hidden}
.hub-bar i{display:block;height:100%;background:linear-gradient(90deg,var(--ember),var(--gold));border-radius:3px}
.hub-stats{display:grid;grid-template-columns:repeat(4,1fr);gap:8px}
.hub-stat{background:rgba(255,255,255,.05);border-radius:10px;padding:8px;text-align:center}
.hub-stat b{display:block;font-size:1.1rem;color:var(--frost)}
.hub-stat span{font-size:.6rem;text-transform:uppercase;letter-spacing:.04em;opacity:.6}
.hub-ms{list-style:none;padding:0;margin:0;font-size:.86rem;line-height:1.7}
.hub-wotd{display:flex;align-items:center;justify-content:space-between;gap:10px;background:rgba(255,255,255,.05);border-radius:10px;padding:10px 12px}
.hub-wotd b{font-size:1.05rem}

.fog-opt{display:flex;align-items:center;gap:8px;margin:10px 0;flex-wrap:wrap;font-size:.9rem}
.fog-opt em{flex:1 1 100%;font-style:normal;opacity:.6;font-size:.78rem;line-height:1.3}
.corr-new{margin:8px 0 14px}
.corr-new .row{gap:8px}
.corr-new input{flex:1;min-width:0}
.corr-list{display:flex;flex-direction:column;gap:8px;max-height:44vh;overflow:auto;margin-bottom:12px}
.corr-row{display:flex;justify-content:space-between;align-items:center;gap:10px;padding:10px 12px;border:1px solid rgba(255,255,255,.12);border-radius:10px;background:rgba(255,255,255,.04)}
.corr-info{display:flex;align-items:center;gap:8px;flex-wrap:wrap}
.corr-tag{font-size:.7rem;text-transform:uppercase;letter-spacing:.06em;opacity:.65}
.corr-badge{font-size:.7rem;font-weight:700;color:#04121a;background:var(--gold,var(--gold));padding:2px 7px;border-radius:999px}
.corr-act{display:flex;gap:6px}
.board-tabs{display:flex;flex-wrap:wrap;gap:6px;margin:8px 0 12px}
/* Universal route back to the main menu. z-index 58 puts it above every
   overlay (40) and #checkout (50) but below #dialog (55)... deliberately NOT:
   57 would sit under the confirm dialog this button itself raises, which would
   look broken. 58 keeps it clickable everywhere except behind toasts (60).
   main.js hides it while #menu is up, since it would be a no-op there. */
#btn-menu{
  position:fixed;top:14px;left:14px;z-index:58;
  padding:8px 14px;border-radius:10px;
  border:1px solid var(--edge);background:rgba(18,12,34,.62);
  color:var(--frost);font-family:inherit;font-size:13px;font-weight:700;
  letter-spacing:.6px;text-transform:uppercase;cursor:pointer;
  transition:background .15s,color .15s,border-color .15s;
}
#btn-menu:hover{background:rgba(40,28,70,.86);color:#fff;border-color:var(--gold)}
#btn-menu:active{transform:translateY(1px)}
#btn-menu:focus-visible{outline:2px solid var(--gold);outline-offset:2px}
@media (max-width:560px){#btn-menu{top:10px;left:10px;padding:7px 11px;font-size:12px}}

/* Drawn icons instead of emoji. Emoji come from the OS font: their colour,
   weight and optical size are outside our control, they differ per platform,
   and they never match the surrounding type -- which is why they read as
   pasted in. These inherit currentColor and the stroke weight is tuned to the
   UI font's. */
.ico{width:17px;height:17px;display:inline-block;vertical-align:-3px;
  fill:none;stroke:currentColor;stroke-width:1.7;
  stroke-linecap:round;stroke-linejoin:round}
.btn.tiny .ico{width:16px;height:16px;vertical-align:-3px}
/* Toggle buttons show state by pressed styling, never by swapping the icon
   for a glyph -- the icon is the control's identity. */
.btn[aria-pressed="true"]{border-color:rgba(196,162,101,.62);background:rgba(196,162,101,.16);color:var(--gold)}
.btn .ico-pause{opacity:0;transition:opacity .2s}
.btn[aria-pressed="true"] .ico-pause{opacity:1}
.btn.muted .ico{opacity:.45}
#roam-hint{position:absolute;left:50%;transform:translateX(-50%);bottom:66px;
  padding:7px 14px;border-radius:999px;pointer-events:none;z-index:6;
  background:rgba(23,20,15,.72);border:1px solid rgba(214,199,171,.22);
  color:var(--dim);font-size:12.5px;letter-spacing:.02em}
#roam-hint b{color:var(--ink);font-weight:600}

/* Menu auth row: a text link rather than another big button, so it reads as
   secondary to the play actions while still being the first thing under the
   tagline. */
#menu-auth{display:flex;align-items:center;justify-content:center;gap:10px;
  margin:-2px 0 14px;min-height:22px;flex-wrap:wrap}
#menu-auth-me{color:var(--dim);font-size:13px;font-variant-numeric:tabular-nums}
#menu-auth-me b{color:var(--gold);font-weight:600}
.btn.link{background:none;border:none;padding:2px 4px;font-size:13.5px;
  color:var(--gold);letter-spacing:.01em;text-decoration:underline;
  text-underline-offset:3px;text-decoration-thickness:1px;
  text-decoration-color:rgba(196,162,101,.45);cursor:pointer;width:auto}
.btn.link:hover{background:none;border-color:transparent;
  text-decoration-color:var(--gold)}
.btn.link.dim{color:var(--dim);text-decoration-color:rgba(156,145,132,.4)}
.btn.link.dim:hover{color:var(--ink);text-decoration-color:var(--ink)}
#wallet-chip .ico,.shop-wallet .ico{width:15px;height:15px;color:var(--gold)}

/* Emote glyphs match the chrome icons: same 24px grid, same stroke weight, so
   the emote bar belongs to the interface rather than to the OS emoji font.
   (The spectator reaction bar keeps emoji deliberately -- those are messages
   from people, not controls.) */
.emote .ico{width:20px;height:20px;vertical-align:-4px}

/* Digits that change must not reflow the layout around them. Clocks, ratings,
   move counters and coin totals all tick, and proportional figures make the
   surrounding text shuffle on every update. */
#clk-red,#clk-black,#move-count,#wallet-amt,#shop-coins,#timer-secs,
#ladder-table td,.hub-stat b,.corr-tag{font-variant-numeric:tabular-nums}

/* Every control gets a visible keyboard focus ring, not just #btn-menu. */
.btn:focus-visible,.hub-tab:focus-visible,.emote:focus-visible,
select:focus-visible,input:focus-visible{
  outline:2px solid var(--gold);outline-offset:2px;
}

/* Respect the OS setting. The scene keeps rendering -- it is the game -- but
   nothing in the interface should animate at someone who asked it not to. */
@media (prefers-reduced-motion:reduce){
  *,*::before,*::after{
    animation-duration:.001ms!important;animation-iteration-count:1!important;
    transition-duration:.001ms!important;scroll-behavior:auto!important;
  }
}
