:root {
  --bg: #14100c;
  --panel: rgba(24, 16, 10, 0.86);
  --panel-edge: rgba(217, 164, 65, 0.35);
  --ink: #f5ead6;
  --ink-dim: #c8b18c;
  --gold: #ffcf6e;
  --brass: #d9a441;
  --green: #46c07a;
  --red: #e05a4f;
  --outline: #1a0f06;
  --display: "Fraunces", Georgia, serif;
  --body: "Inter", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--body);
  overflow: hidden;
}

#scene-wrap { position: fixed; inset: 0; }
#scene { width: 100%; height: 100%; display: block; touch-action: none; }
#vignette {
  position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(ellipse at 50% 42%, transparent 46%, rgba(8, 5, 3, 0.55) 100%);
}
#badges { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
#toasts {
  position: absolute; left: 50%; bottom: 96px; transform: translateX(-50%);
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  pointer-events: none;
}

/* ---------- UI kit ---------- */
.panel {
  background: var(--panel);
  border: 1px solid var(--panel-edge);
  border-radius: 16px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255, 220, 150, 0.12);
  backdrop-filter: blur(8px);
}

.btn {
  font-family: var(--body);
  font-weight: 600;
  font-size: 15px;
  color: var(--ink);
  background: linear-gradient(180deg, #54350f 0%, #33200f 100%);
  border: 1px solid rgba(255, 207, 110, 0.45);
  border-radius: 12px;
  padding: 12px 20px;
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease, filter 0.12s ease;
}
.btn:hover { transform: translateY(-1px); filter: brightness(1.12); box-shadow: 0 6px 18px rgba(217, 164, 65, 0.25); }
.btn:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.btn:active { transform: translateY(1px) scale(0.99); }
.btn.primary {
  background: linear-gradient(180deg, #ffcf6e 0%, #d9a441 60%, #a87424 100%);
  color: #2a1a08;
  border-color: #ffe3a1;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.35);
}
.btn.ghost { background: rgba(255, 220, 150, 0.07); border-color: rgba(255, 220, 150, 0.22); }

.keycap {
  display: inline-block;
  min-width: 22px;
  text-align: center;
  padding: 1px 6px;
  border-radius: 6px;
  background: #241708;
  border: 1px solid rgba(255, 207, 110, 0.5);
  border-bottom-width: 3px;
  font-weight: 700;
  font-size: 12px;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border-radius: 999px;
  background: rgba(20, 13, 7, 0.85);
  border: 1px solid var(--panel-edge);
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
}

.badge {
  position: absolute;
  transform: translate(-50%, -50%);
  min-width: 30px;
  height: 30px;
  padding: 0 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: rgba(18, 11, 6, 0.88);
  border: 1.5px solid rgba(255, 207, 110, 0.65);
  color: var(--gold);
  font-size: 15px;
  font-weight: 700;
  pointer-events: none;
}
.badge.store { min-width: 40px; height: 40px; font-size: 19px; border-width: 2px; }
.badge.playable { border-color: var(--green); color: #c9f5da; box-shadow: 0 0 12px rgba(70, 192, 122, 0.45); }
.badge.last { border-color: #fff; color: #fff; }

.toast {
  padding: 10px 22px;
  border-radius: 999px;
  background: rgba(24, 15, 7, 0.92);
  border: 1px solid var(--brass);
  color: var(--gold);
  font-family: var(--display);
  font-size: 20px;
  font-weight: 700;
  animation: toast 2.2s ease forwards;
}
.toast.small { font-family: var(--body); font-size: 13px; color: var(--ink); }
@keyframes toast {
  0% { opacity: 0; transform: translateY(14px) scale(0.9); }
  12% { opacity: 1; transform: translateY(0) scale(1.04); }
  22% { transform: translateY(0) scale(1); }
  80% { opacity: 1; }
  100% { opacity: 0; transform: translateY(-18px); }
}

/* ---------- HUD ---------- */
#hud {
  position: absolute;
  top: 12px; left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 16px;
  max-width: min(96vw, 860px);
  z-index: 5;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark { color: var(--gold); font-size: 26px; line-height: 1; }
.brand-name { font-family: var(--display); font-weight: 700; font-size: 19px; letter-spacing: 1px; }
.brand-sub { font-size: 11px; color: var(--ink-dim); letter-spacing: 2px; text-transform: uppercase; }
#turn-pill.turn-you { border-color: var(--green); color: #c9f5da; }
#turn-pill.turn-foe { border-color: var(--red); color: #ffd9d4; }
.scores { display: flex; gap: 10px; }
.score { font-size: 14px; color: var(--ink-dim); display: flex; align-items: center; gap: 6px; }
.score b { color: var(--ink); font-size: 17px; }
.score .dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.score.you .dot { background: var(--green); }
.score.foe .dot { background: var(--red); }
.hud-btns { display: flex; gap: 8px; }
.hud-btns .btn { padding: 8px 12px; font-size: 13px; }

#hint {
  position: absolute;
  bottom: 22px; left: 50%;
  transform: translateX(-50%);
  z-index: 4;
}
#hint.shake { animation: shake 0.4s ease; }
@keyframes shake {
  0%, 100% { transform: translateX(-50%); }
  25% { transform: translateX(calc(-50% - 7px)); }
  75% { transform: translateX(calc(-50% + 7px)); }
}

/* ---------- Overlays ---------- */
.overlay {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: rgba(10, 6, 3, 0.45);
  z-index: 10;
  padding: 20px;
}
.overlay.hidden, .hidden { display: none !important; }
.card {
  max-width: 520px;
  width: 100%;
  text-align: center;
  padding: 40px 38px 34px;
  background: linear-gradient(180deg, rgba(46, 29, 14, 0.96), rgba(22, 13, 7, 0.97));
  border: 1px solid rgba(217, 164, 65, 0.5);
  border-radius: 22px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.65), inset 0 1px 0 rgba(255, 220, 150, 0.15);
}
.card.wide { max-width: 600px; text-align: left; }
.kicker { font-size: 11px; letter-spacing: 3px; color: var(--brass); font-weight: 700; }
.card h1 {
  font-family: var(--display);
  font-size: clamp(44px, 8vw, 64px);
  margin: 8px 0 6px;
  color: var(--gold);
}
.card h1 span {
  background: linear-gradient(180deg, #ffe9b8, #d9a441);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.card h2 { font-family: var(--display); font-size: 38px; margin: 8px 0; color: var(--gold); }
.lede { color: var(--ink-dim); font-size: 15px; line-height: 1.6; }
.title-btns { display: flex; gap: 10px; justify-content: center; margin-top: 22px; flex-wrap: wrap; }
.facts { display: flex; justify-content: center; gap: 34px; margin-top: 26px; }
.facts div { display: flex; flex-direction: column; }
.facts b { font-family: var(--display); font-size: 30px; color: var(--gold); }
.facts span { font-size: 11px; color: var(--ink-dim); text-transform: uppercase; letter-spacing: 1px; }
.stats { width: 100%; margin-top: 18px; border-collapse: collapse; font-size: 15px; }
.stats th, .stats td { padding: 9px 12px; border-bottom: 1px solid rgba(217, 164, 65, 0.2); }
.stats th { color: var(--ink-dim); font-weight: 600; }
.stats td { font-weight: 700; }
.rules { line-height: 1.75; font-size: 14.5px; color: var(--ink); padding-left: 22px; }
.rules b { color: var(--gold); }

#err {
  position: absolute; left: 50%; top: 14px; transform: translateX(-50%);
  background: #5c1414; color: #fff; padding: 10px 18px; border-radius: 10px;
  font-size: 13px; z-index: 50; max-width: 90vw;
}

@media (max-width: 720px) {
  #hud { flex-wrap: wrap; justify-content: center; gap: 8px; padding: 8px 10px; top: 8px; }
  .brand-sub { display: none; }
  .brand-name { font-size: 15px; }
  .hud-btns .btn { padding: 6px 9px; font-size: 12px; }
  #toasts { bottom: 120px; }
  .card { padding: 28px 22px; }
}
