:root {
  color-scheme: dark;
  --bg: #140309;
  --panel: rgba(58, 7, 18, 0.94);
  --accent: #ff5d7a;
  --accent-2: #ff8a3d;
  --text: #fff4f6;
  --muted: #f2b0ba;
  --good: #ffd27a;
  --bad: #ff4d6d;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Benguiat Bold Condensed", "Benguiat", "Georgia", "Times New Roman", serif;
  color: var(--text);
  background:
    linear-gradient(180deg, rgba(20, 3, 9, 0.25), rgba(20, 3, 9, 0.8)),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160' viewBox='0 0 160 160'%3E%3Crect width='160' height='160' fill='%23140b13'/%3E%3Cpath d='M0 118C26 92 52 82 80 90C108 98 132 122 160 118V160H0Z' fill='%232c1e20'/%3E%3Cpath d='M0 94C24 74 40 70 60 76C78 82 86 102 110 104C132 106 144 88 160 78V160H0Z' fill='%233a2b2f'/%3E%3Cpath d='M40 0C58 24 58 54 42 78L24 54L40 0Z' fill='%23221b1e'/%3E%3Cpath d='M102 0C116 24 124 44 126 64L102 46L102 0Z' fill='%23211a1c'/%3E%3C/svg%3E") center/cover;
  display: grid;
  place-items: start center;
  padding: 6px;
  overflow-x: hidden;
  overflow-y: auto;
}

.game-shell {
  width: min(100vw - 12px, 1100px);
  display: grid;
  grid-template-columns: minmax(280px, 0.8fr) minmax(360px, 1fr);
  gap: 12px;
  position: relative;
  overflow: visible;
  transition: width 280ms ease, grid-template-columns 280ms ease;
}

.game-shell.game-started {
  width: min(100vw - 12px, 1320px);
  grid-template-columns: minmax(0, 1fr);
}

.game-shell.game-started .intro-panel {
  display: none;
}

.game-shell.game-started .board-panel {
  min-height: calc(100vh - 24px);
  padding: 14px;
}

.background-face {
  position: absolute;
  inset: auto -80px -80px auto;
  width: min(320px, 42vw);
  opacity: 0.16;
  pointer-events: none;
  filter: saturate(1.2) brightness(1.08);
  z-index: 0;
}

.background-face img {
  width: 100%;
  height: auto;
  display: block;
}

.fx-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 3;
}

.fx-burst {
  position: absolute;
  animation: burstOut 900ms ease-out forwards;
  font-size: 1.8rem;
  filter: drop-shadow(0 0 8px rgba(255, 255, 255, 0.35));
  text-transform: none;
}

.fx-burst.waffle { color: var(--good); }
.fx-burst.demogorgon { color: var(--bad); }
.fx-burst.power { color: #fff; }

@keyframes burstOut {
  0% { transform: scale(0.2) translateY(0); opacity: 0; }
  40% { transform: scale(1.1) translateY(-8px); opacity: 1; }
  100% { transform: scale(1.05) translateY(-48px); opacity: 0; }
}

@keyframes screenSweep {
  0% { transform: translateX(-120%) skewX(-18deg); opacity: 0; }
  20% { opacity: 1; }
  100% { transform: translateX(120%) skewX(-18deg); opacity: 0; }
}

.victory-overlay {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(10, 2, 4, 0.78);
  z-index: 20;
}

.victory-card {
  position: relative;
  padding: 30px 32px;
  border-radius: 24px;
  background: linear-gradient(135deg, rgba(255, 93, 122, 0.95), rgba(255, 138, 61, 0.95));
  color: white;
  text-align: center;
  box-shadow: 0 16px 50px rgba(0, 0, 0, 0.45);
  min-width: min(450px, 86vw);
  overflow: hidden;
}

.victory-card h2 {
  font-size: 2.2rem;
  margin-bottom: 8px;
}

.wizard-hat {
  position: absolute;
  font-size: 2rem;
  animation: floatHat 2.2s ease-in-out infinite;
}

.confetti {
  position: absolute;
  font-size: 1.2rem;
  animation: confettiFall 2.2s linear forwards;
}

@keyframes floatHat {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  50% { transform: translateY(-14px) rotate(8deg); }
}

@keyframes confettiFall {
  0% { transform: translateY(-20px) rotate(0deg); opacity: 1; }
  100% { transform: translateY(180px) rotate(360deg); opacity: 0; }
}

.panel {
  position: relative;
  z-index: 1;
  background: var(--panel);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
  padding: 12px;
}

.eyebrow {
  margin: 0 0 8px;
  text-transform: uppercase;
  letter-spacing: 0.24em;
  color: var(--accent);
  font-size: 0.74rem;
}

h1,
h2 {
  margin: 0 0 10px;
  font-family: inherit;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

h1 {
  font-size: clamp(1.85rem, 3vw, 2.7rem);
}

.intro-panel p {
  line-height: 1.6;
  color: var(--muted);
}

.selection-card {
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 18px;
  padding: 16px;
  margin: 18px 0;
  background: rgba(255, 255, 255, 0.04);
}

.character-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin: 12px 0 14px;
}

.character-btn {
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 14px;
  padding: 10px 8px;
  text-align: center;
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  cursor: pointer;
  font-weight: 700;
  text-transform: uppercase;
  transition: transform 140ms ease, box-shadow 140ms ease;
}

.character-btn:hover {
  transform: translateY(-2px);
}

.character-btn.active {
  border-color: var(--accent);
  background: rgba(255, 93, 122, 0.2);
  box-shadow: inset 0 0 0 1px rgba(255, 93, 122, 0.35);
}

.power-card {
  padding: 12px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.05);
  margin-bottom: 12px;
}

.hud {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin: 16px 0 12px;
}

.stat {
  background: rgba(255, 255, 255, 0.05);
  border-radius: 14px;
  padding: 12px;
  text-align: center;
}

.label {
  display: block;
  font-size: 0.72rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 6px;
}

strong {
  font-size: 1.02rem;
}

.actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

button {
  border: none;
  border-radius: 999px;
  padding: 12px 18px;
  font-weight: 700;
  cursor: pointer;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #1f0509;
  transition: transform 160ms ease, box-shadow 160ms ease;
}

button:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 20px rgba(255, 93, 122, 0.24);
}

button:disabled {
  opacity: 0.65;
  cursor: wait;
}

button.secondary {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
}

.status {
  min-height: 60px;
  padding: 14px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  line-height: 1.5;
}

.hidden {
  display: none;
}

.board-panel {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.board-header {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.radio-widget {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 4px;
}

.radio-antenna {
  width: 24px;
  height: 14px;
  border-top: 3px solid rgba(255, 255, 255, 0.4);
  border-right: 3px solid rgba(255, 255, 255, 0.4);
  transform: skewX(-20deg);
}

.radio-shell {
  border-radius: 18px;
  padding: 8px 12px;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.12);
  animation: radioPulse 2.2s ease-in-out infinite;
}

.radio-face {
  display: flex;
  align-items: center;
  gap: 8px;
}

.radio-speaker {
  width: 38px;
  height: 24px;
  border-radius: 999px;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.2), rgba(20, 3, 9, 0.4));
}

.radio-knob {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.18);
}

.radio-knob.tiny {
  width: 10px;
  height: 10px;
}

.radio-clue {
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--good);
  font-weight: 700;
}

.leaderboard {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.leaderboard .entry {
  padding: 8px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  font-size: 0.92rem;
}

.board {
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  gap: 4px;
  max-width: 100%;
}

.cell {
  aspect-ratio: 1;
  border-radius: 8px;
  padding: 3px;
  position: relative;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  align-items: flex-start;
  justify-content: flex-start;
  color: var(--muted);
  font-size: 0.75rem;
  transition: transform 200ms ease, box-shadow 200ms ease;
}

.cell .value {
  position: absolute;
  top: 6px;
  left: 6px;
}

.cell.player {
  outline: 2px solid var(--accent);
  box-shadow: inset 0 0 0 2px rgba(255, 93, 122, 0.25);
}

.cell.visited {
  border-color: rgba(255, 210, 122, 0.45);
  background: rgba(255, 210, 122, 0.16);
}

.cell.waffle {
  border-color: rgba(255, 210, 122, 0.55);
  background: rgba(255, 210, 122, 0.18);
}

.cell.risk {
  border-color: rgba(255, 93, 122, 0.65);
  background: rgba(255, 93, 122, 0.18);
}

.cell.pulse {
  animation: cellPulse 600ms ease-out;
}

@keyframes cellPulse {
  0% { transform: scale(0.96); box-shadow: 0 0 0 rgba(255, 255, 255, 0.2); }
  60% { transform: scale(1.04); box-shadow: 0 0 16px rgba(255, 255, 255, 0.18); }
  100% { transform: scale(1); box-shadow: 0 0 0 rgba(255, 255, 255, 0.0); }
}

.cell .marker {
  position: absolute;
  right: 4px;
  bottom: 4px;
  font-size: 0.8rem;
}

.token {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 0.9rem;
  color: white;
  animation: tokenFloat 650ms ease-in-out infinite alternate;
}

@keyframes tokenFloat {
  from { transform: translateY(0); }
  to { transform: translateY(-2px); }
}

.narrator-panel {
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  margin-bottom: 10px;
}

.narrator-label {
  font-size: 0.72rem;
  letter-spacing: 0.22em;
  color: var(--accent);
  margin-bottom: 6px;
  text-transform: uppercase;
}

.narrator-text {
  color: var(--text);
  line-height: 1.45;
  min-height: 44px;
}

.dice-wrap {
  display: flex;
  justify-content: center;
}

.die {
  width: 62px;
  height: 62px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  font-size: 1.4rem;
  font-weight: 800;
  background: linear-gradient(135deg, rgba(255,255,255,0.16), rgba(255,255,255,0.06));
  border: 1px solid rgba(255,255,255,0.12);
  box-shadow: inset 0 0 0 2px rgba(255,255,255,0.08);
  transition: transform 140ms ease;
}

.d20 {
  position: fixed;
  z-index: 30;
  width: 64px;
  height: 64px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  font-size: 1.35rem;
  font-weight: 800;
  background: linear-gradient(135deg, rgba(255, 93, 122, 0.95), rgba(255, 138, 61, 0.95));
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.3);
  pointer-events: none;
  transform: translate(-50%, -50%) scale(0.8);
  transition: left 700ms cubic-bezier(.2, .8, .2, 1), top 700ms cubic-bezier(.2, .8, .2, 1), transform 700ms cubic-bezier(.2, .8, .2, 1);
}

.die.rolling {
  animation: dieSpin 260ms linear infinite;
}

.die.result {
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.18), 0 0 24px rgba(255, 210, 122, 0.45);
  transform: scale(1.08);
}

@keyframes dieSpin {
  0% { transform: rotate(0deg) scale(1); }
  25% { transform: rotate(90deg) scale(1.04); }
  50% { transform: rotate(180deg) scale(1.08); }
  75% { transform: rotate(270deg) scale(1.04); }
  100% { transform: rotate(360deg) scale(1); }
}

@keyframes radioPulse {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-2px); }
}

@keyframes d20Fly {
  0% { transform: translate(-50%, -50%) scale(0.8); opacity: 0; }
  50% { transform: translate(-50%, -50%) scale(1.05); opacity: 1; }
  100% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
}

@media (max-width: 900px) {
  body {
    padding: 6px;
  }

  .game-shell {
    grid-template-columns: 1fr;
    width: min(100%, 100vw - 12px);
  }

  .game-shell.game-started {
    width: min(100%, 100vw - 12px);
  }

  .character-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .board {
    gap: 4px;
  }

  .cell {
    padding: 3px;
    border-radius: 8px;
  }
}
