:root {
  --ink: #f4f1e8; --dim: #b9b4a6; --panel: rgba(18, 20, 26, 0.86); --line: rgba(255, 255, 255, 0.14);
  --share: #3fbf6b; --grab: #e5484d; --gold: #f5d90a;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #0d1117; color: var(--ink);
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 14px; }
canvas { display: block; image-rendering: pixelated; }
button { font: inherit; color: var(--ink); background: #2a2f3a; border: 1px solid var(--line);
  padding: 8px 14px; cursor: pointer; }
button:hover { background: #394050; }
button.on { outline: 2px solid var(--gold); }
input { font: inherit; color: var(--ink); background: #161a22; border: 1px solid var(--line); padding: 8px; }
[hidden] { display: none !important; }

#join { position: fixed; inset: 0; z-index: 30; display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 12px; background: linear-gradient(#17202e, #0d1117); padding: 16px; text-align: center; }
#join h1 { font-size: 44px; margin: 0; letter-spacing: 2px; }
#join .tag { color: var(--dim); margin: 0 0 12px; }
#play { font-size: 20px; padding: 14px 34px; background: #2f6f43; }
#creds { display: flex; flex-direction: column; gap: 8px; width: min(340px, 100%); margin-top: 14px; }
.hint { color: var(--dim); font-size: 12px; margin: 0; }
.err { color: #ff8f8f; }
.keys { color: var(--dim); font-size: 12px; line-height: 1.6; white-space: pre-wrap; }

#hud > div, #hud > input { position: fixed; z-index: 5; }
#clock { top: 10px; left: 50%; transform: translateX(-50%); text-align: center; text-shadow: 0 1px 3px #000; }
#timer { font-size: 30px; font-weight: 700; }
#phase { display: block; font-size: 12px; color: var(--dim); }
#mutators { font-size: 12px; color: var(--gold); }
#place { top: 12px; left: 14px; text-shadow: 0 1px 3px #000; }
#feed { top: 12px; right: 14px; width: min(380px, 44vw); text-align: right; text-shadow: 0 1px 3px #000; font-size: 13px; }
#feed div { margin-bottom: 3px; }
#crosshair { top: 50%; left: 50%; transform: translate(-50%, -50%); font-size: 22px; text-shadow: 0 0 3px #000; pointer-events: none; }
#crosshair.hit { color: var(--grab); }
#target { top: calc(50% + 34px); left: 50%; transform: translateX(-50%); background: var(--panel);
  border: 1px solid var(--line); padding: 6px 10px; text-align: center; font-size: 13px; pointer-events: none; }
#target .title { color: var(--gold); }
#prompt { bottom: 150px; left: 50%; transform: translateX(-50%); text-shadow: 0 1px 3px #000; font-size: 16px; text-align: center; }
#bar { bottom: 124px; left: 50%; transform: translateX(-50%); width: 280px; height: 16px; background: rgba(0, 0, 0, 0.6); border: 1px solid var(--line); }
#barfill { height: 100%; width: 0; background: var(--gold); }
#barlabel { position: absolute; inset: 0; text-align: center; font-size: 11px; line-height: 15px; color: #000; mix-blend-mode: difference; filter: invert(1); }
#vitals { bottom: 18px; left: 16px; display: flex; align-items: center; gap: 8px; text-shadow: 0 1px 3px #000; }
#hp { width: 200px; height: 14px; background: rgba(0, 0, 0, 0.6); border: 1px solid var(--line); }
#hpfill { height: 100%; background: #3fbf6b; }
#carry { bottom: 44px; left: 16px; text-shadow: 0 1px 3px #000; }
#carry b { color: var(--gold); }
#weapon { bottom: 18px; right: 16px; text-align: right; text-shadow: 0 1px 3px #000; font-size: 16px; }
#chatlog { bottom: 84px; left: 16px; width: min(420px, 50vw); font-size: 13px; text-shadow: 0 1px 3px #000; }
#chat { bottom: 60px; left: 16px; width: min(420px, 50vw); }
#hurt { inset: 0; pointer-events: none; opacity: 0; box-shadow: inset 0 0 120px 40px rgba(229, 72, 77, 0.9); }
#dead { top: 34%; left: 50%; transform: translateX(-50%); text-align: center; background: var(--panel); padding: 18px 28px; border: 1px solid var(--line); }
#dead b { display: block; font-size: 30px; color: var(--grab); }

#lobby { position: fixed; z-index: 8; top: 70px; right: 14px; width: min(370px, 46vw); max-height: calc(100vh - 90px);
  overflow: auto; background: var(--panel); border: 1px solid var(--line); padding: 12px; }
#lobby h3, #panel h3, #scores h3 { margin: 12px 0 6px; font-size: 12px; letter-spacing: 1px; color: var(--dim); text-transform: uppercase; }
#lobby h3:first-child { margin-top: 0; }
.kits { display: flex; gap: 6px; }
.kit { flex: 1; padding: 8px; border: 1px solid var(--line); background: #1c212b; cursor: pointer; }
.kit.on { border-color: var(--gold); background: #2a2a18; }
.kit b { display: block; }
.kit span { font-size: 11px; color: var(--dim); }
.row { display: flex; justify-content: space-between; gap: 8px; padding: 2px 0; }
.row .num { color: var(--gold); white-space: nowrap; }
.share { color: var(--share); } .grab { color: var(--grab); } .dim { color: var(--dim); }
.bot::after { content: " bot"; color: var(--dim); font-size: 10px; }

#forge { position: fixed; inset: 0; z-index: 20; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; }
#forge.blind { background: radial-gradient(circle at 50% 50%, rgba(5, 6, 9, 0.97) 0, rgba(5, 6, 9, 0.985) 100%); cursor: pointer; }
#forge.waiting { inset: auto 0 190px 0; pointer-events: none; }
#forge .box { background: var(--panel); border: 1px solid var(--line); padding: 10px 16px; text-align: center; }
#flip { width: min(900px, 86vw); height: min(46vh, 420px); font-size: clamp(60px, 13vw, 170px); font-weight: 800;
  letter-spacing: 6px; border: 6px solid #000; color: #fff; user-select: none; }
#flip.grab { background: var(--grab); }
#flip.share { background: var(--share); }
#flip small { display: block; font-size: 18px; letter-spacing: 1px; font-weight: 400; }
#forge .outcomes { display: flex; gap: 18px; font-size: 15px; flex-wrap: wrap; justify-content: center; }
#forge .count { width: min(900px, 86vw); height: 14px; background: #222; }
#forge .count div { height: 100%; background: var(--gold); }

#reveal { position: fixed; z-index: 21; top: 16%; left: 50%; transform: translateX(-50%); width: min(620px, 92vw);
  background: var(--panel); border: 2px solid var(--gold); padding: 16px; text-align: center; }
#reveal h2 { margin: 0 0 10px; font-size: 26px; }
#reveal .who { display: flex; justify-content: space-between; gap: 10px; padding: 5px 0; border-top: 1px solid var(--line); text-align: left; }
#reveal .flips { font-size: 11px; color: var(--dim); }

#scores, #panel { position: fixed; z-index: 25; top: 50%; left: 50%; transform: translate(-50%, -50%);
  width: min(760px, 94vw); max-height: 88vh; overflow: auto; background: var(--panel); border: 1px solid var(--line); padding: 16px; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
td, th { text-align: left; padding: 3px 6px; border-bottom: 1px solid var(--line); }
th { color: var(--dim); font-weight: 400; }
td.num, th.num { text-align: right; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips button { padding: 5px 9px; font-size: 12px; }
.swatch { display: inline-block; width: 12px; height: 12px; vertical-align: -1px; margin-right: 5px; border: 1px solid #000; }
.code { font-size: 22px; letter-spacing: 3px; color: var(--gold); user-select: all; }

#choices { display: flex; flex-direction: column; align-items: center; gap: 12px; }
#watch { font-size: 13px; padding: 6px 14px; }
#resuming { color: var(--dim); font-size: 18px; }
#watch-status { display: none; bottom: 18px; left: 50%; transform: translateX(-50%); text-shadow: 0 1px 3px #000; white-space: nowrap; }
#help { position: fixed; z-index: 6; top: 12px; left: 14px; margin: 0; background: var(--panel); border: 1px solid var(--line);
  padding: 10px 14px; font-size: 12px; line-height: 1.6; }
/* Observer mode: no player readouts, just the clock, feed, chat log and the status line. */
body.observer #watch-status { display: block; }
body.observer #place, body.observer #crosshair, body.observer #target, body.observer #prompt, body.observer #bar,
body.observer #vitals, body.observer #carry, body.observer #weapon, body.observer #dead, body.observer #hurt,
body.observer #chat, body.observer #lobby, body.observer #forge, body.observer #reveal, body.observer #panel { display: none !important; }
