/* Sleep Token · Ritual Dice (3D Three.js Gothic Relic Dice) */
:root {
  --bg-0: #040308;
  --obsidian: #0a0812;
  --plum: #1a0d22;
  --silver: #d4d0de;
  --crimson: #e61c3a;
  --crimson-hi: #ff4f6b;
  --gold: #d9b15f;
  --gold-hi: #ffe8a8;
  --gold-lo: #7a5418;
  --violet: #a855f7;
  --green: #20e38c;
  --ink: #f3effa;
  --muted: #a69db9;
  --f-ui: 'Oswald', 'Arial Narrow', system-ui, sans-serif;
  --f-goth: 'Cinzel', Georgia, serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--bg-0); overflow-x: clip; }
body {
  background: radial-gradient(960px 640px at 50% 6%, rgba(126, 18, 42, .28) 0%, rgba(24, 12, 36, .7) 42%, #050409 82%, #020205 100%);
  color: var(--ink);
  font-family: var(--f-ui);
  letter-spacing: .02em;
  -webkit-tap-highlight-color: transparent;
}
#embers { position: fixed; inset: 0; z-index: 0; pointer-events: none; }
a { color: inherit; }
button { font-family: inherit; }
[hidden] { display: none !important; }

/* Topbar */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 10px;
  padding: 8px clamp(10px, 2.5vw, 24px);
  background: linear-gradient(180deg, rgba(6, 5, 11, .95), rgba(6, 5, 11, .72));
  backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(212, 208, 222, .18);
}
.top-left { justify-self: start; display: flex; gap: 6px; }
.top-right { justify-self: end; display: flex; align-items: center; gap: 7px; }
.brand-main {
  font-family: var(--f-goth); font-size: clamp(13px, 1.8vw, 19px); font-weight: 900; letter-spacing: .24em;
  color: #fff; text-shadow: 0 0 14px rgba(230, 28, 58, .55); white-space: nowrap;
}
.pill-btn {
  padding: 6px 12px; border-radius: 999px; background: rgba(14, 10, 22, .9); color: var(--ink);
  border: 1px solid rgba(212, 208, 222, .38); font-size: 11.5px; letter-spacing: .15em;
  text-transform: uppercase; text-decoration: none; cursor: pointer; white-space: nowrap;
}
.pill-btn:hover { border-color: var(--crimson-hi); color: #fff; }
.credits {
  display: flex; align-items: center; gap: 7px; padding: 4px 12px 4px 6px;
  border-radius: 999px; background: rgba(10, 8, 16, .95);
  border: 1px solid rgba(217, 177, 95, .62);
  transition: box-shadow .25s, transform .25s;
}
.credits.up { box-shadow: 0 0 22px rgba(230, 28, 58, .65); transform: scale(1.04); }
.credits-orb {
  width: 20px; height: 20px; border-radius: 50%;
  background: radial-gradient(circle at 38% 35%, #ffe6eb 0%, #e61c3a 48%, #4a0410 100%);
  border: 1px solid rgba(255, 220, 225, .65);
}
.credits-num { font-weight: 700; font-size: 18px; color: var(--gold-hi); font-variant-numeric: tabular-nums; }
.credits-lbl { font-size: 10px; letter-spacing: .18em; color: var(--muted); text-transform: uppercase; }
.icon-btn {
  width: 34px; height: 34px; border-radius: 50%; border: 1px solid rgba(212, 208, 222, .35);
  background: rgba(12, 10, 20, .9); color: var(--ink); font-size: 15px; cursor: pointer;
}
.icon-btn.off { opacity: .55; }

main { position: relative; z-index: 1; padding: 12px clamp(10px, 2.5vw, 24px) 32px; }

.game-head { text-align: center; margin-bottom: 12px; }
.game-head h1 {
  margin: 0; font-family: var(--f-goth); font-size: clamp(24px, 3vw, 36px); font-weight: 900;
  background: linear-gradient(180deg, #fff 0%, #ffe6a6 55%, #b88228 100%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 0 12px rgba(230, 28, 58, .42));
}
.game-head .sub { font-size: 12px; letter-spacing: .24em; text-transform: uppercase; color: var(--muted); margin-top: 2px; }

/* Main 2-column layout (matches Grid Dice ergonomics) */
.dice-layout {
  display: grid; grid-template-columns: 1.2fr 1fr; gap: 16px;
  max-width: 1260px; margin: 0 auto; align-items: start;
}

.dice-stage {
  position: relative; aspect-ratio: 16 / 10.6; min-height: 360px;
  border-radius: 16px; overflow: hidden;
  border: 2px solid rgba(218, 214, 228, .62);
  background: #07040c;
  box-shadow: 0 0 0 5px #07050c, 0 26px 64px rgba(0, 0, 0, .88);
}
body.offering-on .dice-stage {
  border-color: var(--crimson-hi);
  box-shadow: 0 0 0 5px #07050c, 0 0 38px rgba(230, 28, 58, .55), 0 26px 64px rgba(0, 0, 0, .88);
}
.dice-canvas { width: 100%; height: 100%; display: block; }

.stage-banner {
  position: absolute; top: 10px; left: 50%; transform: translateX(-50%); z-index: 4;
  padding: 4px 16px; border-radius: 999px;
  background: rgba(8, 5, 14, .86); border: 1px solid rgba(217, 177, 95, .58);
  font-size: 11px; letter-spacing: .2em; text-transform: uppercase; color: var(--gold-hi);
  white-space: nowrap; pointer-events: none;
}

.dice-rail {
  position: absolute; top: 44px; left: 10px; right: 10px; z-index: 4;
  display: flex; justify-content: center; gap: 8px; flex-wrap: wrap; pointer-events: none;
}
.dr-pill {
  display: flex; align-items: center; gap: 6px; padding: 3px 10px 3px 4px;
  border-radius: 999px; background: rgba(7, 5, 13, .85);
  border: 1px solid rgba(212, 208, 222, .32); font-size: 11px;
  transition: transform .25s, border-color .25s;
}
.dr-pill.win { border-color: var(--gold-hi); box-shadow: 0 0 14px rgba(217, 177, 95, .55); transform: scale(1.05); }
.dr-pill.empty { opacity: .45; padding: 3px 10px; color: var(--muted); }
.dr-dot {
  width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center;
  font-size: 9.5px; font-weight: 700; color: #fff; border: 1px solid rgba(255, 255, 255, .4);
}
.dr-copy { display: flex; flex-direction: column; line-height: 1.05; }
.dr-copy b { font-size: 11px; color: #fff; }
.dr-copy span { font-size: 9.5px; color: var(--muted); }

.vl-hud {
  position: absolute; top: 46px; left: 50%; transform: translateX(-50%); z-index: 5;
  display: flex; align-items: center; gap: 14px; padding: 6px 18px; border-radius: 999px;
  background: rgba(34, 6, 18, .94); border: 1.5px solid var(--crimson-hi);
  box-shadow: 0 0 24px rgba(230, 28, 58, .65);
  font-size: 13px; letter-spacing: .16em; text-transform: uppercase;
}
.vl-hud b { color: var(--crimson-hi); font-family: var(--f-goth); }
.vl-hud em { font-style: normal; color: var(--gold-hi); font-weight: 700; font-size: 17px; }
.vl-hud.bump { animation: pop .35s ease; }
@keyframes pop { 50% { transform: translateX(-50%) scale(1.1); } }

.roll-readout {
  position: absolute; left: 12px; right: 12px; bottom: 12px; z-index: 4;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  opacity: 0; transform: translateY(8px); transition: opacity .28s, transform .28s;
  pointer-events: none;
}
.roll-readout.show { opacity: 1; transform: none; }
.rr-faces { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.rr-faces span {
  display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px 3px 4px;
  border-radius: 999px; background: rgba(7, 5, 14, .92);
  border: 1.5px solid var(--c, #d9b15f); color: #fff; font-size: 12.5px;
}
.rr-faces b {
  width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center;
  background: var(--c, #8f0b22); color: var(--i, #fff); font-size: 11px;
}
.rr-line {
  padding: 4px 14px; border-radius: 999px; background: rgba(7, 5, 14, .92);
  border: 1px solid rgba(212, 208, 222, .42); font-size: 13px; color: var(--ink);
}
.rr-line .up { color: var(--green); }
.rr-line .dn { color: #ff7a92; }

.stage-loading {
  position: absolute; inset: 0; z-index: 6; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 12px;
  background: rgba(6, 4, 12, .9); color: var(--muted); letter-spacing: .2em; text-transform: uppercase;
}
.stage-loading span {
  width: 38px; height: 38px; border-radius: 50%;
  border: 3px solid rgba(217, 177, 95, .2); border-top-color: var(--crimson-hi);
  animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Betting Board */
.dice-board {
  padding: 14px; border-radius: 16px;
  background: linear-gradient(180deg, rgba(22, 13, 32, .92), rgba(8, 6, 14, .96));
  border: 1.5px solid rgba(218, 214, 228, .48);
  box-shadow: 0 22px 54px rgba(0, 0, 0, .78);
}
.board-head {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  margin-bottom: 10px; flex-wrap: wrap;
}
.board-head > span { font-size: 12px; letter-spacing: .16em; text-transform: uppercase; color: var(--muted); }
.chip-pick { display: flex; gap: 6px; }
.cp {
  width: 44px; height: 44px; padding: 0; border-radius: 50%; border: 2px solid transparent;
  background: transparent; cursor: pointer; transition: transform .18s, border-color .18s, box-shadow .18s;
}
.cp img { width: 100%; height: 100%; display: block; border-radius: 50%; }
.cp.on { border-color: var(--gold-hi); transform: translateY(-3px) scale(1.08); box-shadow: 0 0 14px rgba(217, 177, 95, .65); }

.spots { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.spot {
  position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; padding: 10px 6px 8px; min-height: 112px; border-radius: 10px; cursor: pointer;
  background: linear-gradient(180deg, #161022, #0a0712);
  border: 1.5px solid rgba(212, 208, 222, .32); color: var(--ink);
  transition: transform .15s, border-color .2s, box-shadow .2s;
}
.spot:hover { border-color: var(--gold); transform: translateY(-2px); }
.spot.has { border-color: var(--gold-hi); box-shadow: inset 0 0 16px rgba(217, 177, 95, .2); }
.spot.won {
  border-color: var(--crimson-hi);
  background: radial-gradient(circle, rgba(230, 28, 58, .35), #110918);
  box-shadow: 0 0 18px rgba(230, 28, 58, .75);
}
.spot-num {
  position: absolute; top: 5px; left: 7px; font-size: 10px; font-weight: 700;
  color: var(--gold); opacity: .85;
}
.spot-ai {
  position: absolute; top: 5px; right: 5px; display: flex; gap: 2px;
}
.spot-ai i {
  font-style: normal; width: 16px; height: 16px; border-radius: 50%;
  display: grid; place-items: center; font-size: 8px; font-weight: 700; color: #fff;
  border: 1px solid rgba(255, 255, 255, .45);
}
.spot-ic { width: 52px; height: 52px; object-fit: contain; border-radius: 8px; filter: drop-shadow(0 4px 8px rgba(0, 0, 0, .75)); }
.spot-name { font-size: 13px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: #fff; }
.spot-pay { font-size: 11px; color: var(--gold-hi); font-weight: 600; }
.spot-cond { font-size: 10px; color: var(--muted); }
.spot-stack { position: absolute; bottom: 5px; right: 5px; display: flex; }
.spot-stack img { width: 22px; height: 22px; margin-left: -12px; filter: drop-shadow(0 2px 4px rgba(0, 0, 0, .7)); }
.spot-stack img:first-child { margin-left: 0; }
.spot-amt {
  position: absolute; bottom: 5px; left: 7px; font-size: 11px; font-weight: 700;
  color: var(--gold-hi); font-variant-numeric: tabular-nums;
}

.spot.wide { min-height: 78px; flex-direction: row; gap: 8px; padding: 8px; justify-content: flex-start; text-align: left; }
.spot.wide .spot-ic { width: 42px; height: 42px; flex: none; }
.spot-copy { display: flex; flex-direction: column; line-height: 1.12; }
.spot.podium { border-color: rgba(230, 28, 58, .68); background: linear-gradient(180deg, #290e1c, #110710); }

.board-foot {
  display: flex; align-items: center; gap: 8px; margin-top: 12px; flex-wrap: wrap;
}
.stake {
  margin-right: auto; padding: 6px 12px; border-radius: 8px;
  background: #06040c; border: 1px solid rgba(212, 208, 222, .35);
  font-size: 12px; letter-spacing: .14em; text-transform: uppercase; color: var(--muted);
}
.stake b { color: var(--gold-hi); font-size: 17px; margin-left: 6px; font-variant-numeric: tabular-nums; }
.btn {
  appearance: none; border: 1.5px solid rgba(255, 255, 255, .42); cursor: pointer;
  border-radius: 10px; padding: 10px 16px; min-width: 78px;
  font-family: var(--f-ui); font-weight: 700; font-size: 14px; letter-spacing: .16em; text-transform: uppercase;
  color: #120902; background: linear-gradient(180deg, #fff2c2, #d9b15f 55%, #996d1e);
  box-shadow: 0 4px 0 #4d3307; transition: transform 70ms, filter .18s;
}
.btn.dark { background: linear-gradient(180deg, #272235, #120f1c); color: var(--ink); box-shadow: 0 4px 0 #050409; }
.btn.crimson { background: linear-gradient(180deg, #ff5c77, #cf102e 55%, #750417); color: #fff; box-shadow: 0 4px 0 #42010c, 0 0 18px rgba(230, 28, 58, .48); }
.btn:active:not(:disabled) { transform: translateY(3px); }
.btn:disabled { opacity: .35; cursor: not-allowed; }

.board-note { margin: 10px 0 0; font-size: 12px; color: var(--muted); line-height: 1.4; }
.board-note b { color: var(--gold-hi); }

/* Modals & Toast */
.toast {
  position: fixed; left: 50%; bottom: 24px; z-index: 60; transform: translate(-50%, 30px); opacity: 0;
  padding: 11px 18px; border-radius: 10px; background: rgba(9, 7, 16, .96); border: 1px solid var(--silver);
  color: #fff; transition: all .3s; pointer-events: none;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.bad { border-color: var(--crimson-hi); }

.modal-wrap {
  position: fixed; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center; padding: 14px;
  background: rgba(3, 2, 7, .85); backdrop-filter: blur(7px); opacity: 0; transition: opacity .3s;
}
.modal-wrap.in { opacity: 1; }
.modal {
  position: relative; width: min(660px, 100%); max-height: calc(100vh - 28px); overflow: auto;
  padding: clamp(16px, 2.8vw, 28px); border-radius: 16px; text-align: center;
  background: radial-gradient(560px 260px at 50% 0, rgba(230, 28, 58, .24), transparent 72%), linear-gradient(180deg, #130e20, #06050c);
  border: 1.5px solid rgba(218, 214, 228, .62); box-shadow: 0 30px 80px rgba(0, 0, 0, .88);
}
.modal .kicker { margin: 0 0 5px; letter-spacing: .32em; font-size: 11px; text-transform: uppercase; color: var(--crimson-hi); }
.modal h2 { margin: 0 0 8px; font-family: var(--f-goth); font-size: clamp(22px, 3.6vw, 34px); color: #fff; }
.modal p { color: var(--muted); font-size: 14px; line-height: 1.5; }
.modal .big-win { font-family: var(--f-goth); font-weight: 900; font-size: clamp(38px, 6.5vw, 60px); color: var(--gold-hi); text-shadow: 0 0 22px rgba(230, 28, 58, .65); margin: 8px 0; }
.dice-legend { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 12px 0; }
.dice-legend > div {
  padding: 8px; border-radius: 10px; background: rgba(7, 5, 13, .88); border: 1px solid rgba(212, 208, 222, .24);
  display: flex; flex-direction: column; align-items: center; gap: 3px; font-size: 12px;
}
.dice-legend img { width: 48px; height: 48px; object-fit: contain; }
.dice-legend b { color: #fff; }
.dice-legend span { color: var(--muted); font-size: 11px; }
.vl-dice { display: flex; justify-content: center; gap: 12px; margin: 12px 0; }
.vl-dice img { width: 64px; height: 64px; object-fit: contain; border-radius: 10px; border: 1.5px solid var(--gold); background: #090612; padding: 4px; }
.modal .row { display: flex; justify-content: center; gap: 10px; margin-top: 12px; }

@media (max-width: 960px) {
  .dice-layout { grid-template-columns: 1fr; }
  .dice-stage { aspect-ratio: 16 / 11; min-height: 290px; }
}
@media (max-width: 640px) {
  .topbar { display: flex; justify-content: space-between; gap: 5px; padding: 6px 8px; }
  .brand, .credits-lbl { display: none; }
  .pill-btn { padding: 5px 8px; font-size: 10px; }
  .spots { gap: 6px; }
  .spot { min-height: 94px; padding: 7px 4px; }
  .spot-ic { width: 42px; height: 42px; }
  .spot-name { font-size: 11px; }
  .spot.wide { flex-direction: column; text-align: center; min-height: 86px; }
  .spot.wide .spot-ic { width: 34px; height: 34px; }
  .dice-legend { grid-template-columns: repeat(2, 1fr); }
}
