:root {
  --ink: #f8f1e3;
  --muted: #c9b8a0;
  --gold: #f4c95d;
  --gold-dark: #c4891a;
  --crimson: #e23d4a;
  --cyan: #4ee0c4;
  --magenta: #d946ef;
  --lime: #86efac;
  --bg: #120714;
  --card: rgba(22, 10, 28, 0.82);
  --line: rgba(244, 201, 93, 0.28);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html,
body,
#app {
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: "Nunito", system-ui, sans-serif;
  background: var(--bg);
  color: var(--ink);
  user-select: none;
}

body {
  background:
    radial-gradient(1100px 520px at 50% -8%, rgba(70, 90, 50, 0.22), transparent 55%),
    radial-gradient(900px 500px at 85% 115%, rgba(40, 70, 90, 0.22), transparent 50%),
    #08060a;
}

.hidden {
  display: none !important;
}

.screen {
  position: absolute;
  inset: 0;
  z-index: 2;
}

.bg-embers {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background-image:
    radial-gradient(2px 2px at 12% 30%, rgba(244, 201, 93, 0.55), transparent),
    radial-gradient(2px 2px at 78% 18%, rgba(226, 61, 74, 0.5), transparent),
    radial-gradient(1.5px 1.5px at 40% 70%, rgba(255, 255, 255, 0.35), transparent),
    radial-gradient(2px 2px at 88% 62%, rgba(244, 201, 93, 0.4), transparent),
    radial-gradient(1px 1px at 22% 82%, rgba(78, 224, 196, 0.4), transparent);
  animation: drift 9s linear infinite;
  z-index: 1;
}

@keyframes drift {
  from {
    transform: translateY(0);
  }
  to {
    transform: translateY(-40px);
  }
}

/* ——— Menu ——— */
.menu-music {
  position: absolute;
  top: 0.7rem;
  right: 0.7rem;
  z-index: 4;
  width: 2.15rem;
  height: 2.15rem;
  padding: 0;
  border: 1px solid rgba(255, 236, 200, 0.18);
  border-radius: 50%;
  background: rgba(8, 4, 10, 0.38);
  color: rgba(255, 236, 200, 0.7);
  font-size: 0.95rem;
  line-height: 1;
  cursor: pointer;
  display: grid;
  place-items: center;
}

.menu-music[aria-pressed="false"]::after {
  content: "";
  position: absolute;
  width: 1.15rem;
  height: 1.5px;
  background: currentColor;
  transform: rotate(-38deg);
}

.menu-music:hover {
  background: rgba(8, 4, 10, 0.55);
  color: rgba(255, 244, 220, 0.92);
}

.battle-music {
  position: relative;
  top: auto;
  right: auto;
  flex-shrink: 0;
}

.menu-music[aria-pressed="false"] {
  color: rgba(255, 236, 200, 0.38);
  border-color: rgba(255, 236, 200, 0.1);
}

#menu {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  overflow: auto;
  isolation: isolate;
  background-color: #08060a;
  background-image: url("assets/dungeon-menu.jpg");
  background-repeat: no-repeat;
  background-size: cover;
  background-position: center;
}

#menu::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(ellipse 72% 60% at 50% 42%, rgba(10, 6, 12, 0.2) 0%, rgba(8, 4, 10, 0.5) 50%, rgba(4, 2, 6, 0.84) 100%),
    linear-gradient(180deg, rgba(6, 3, 8, 0.52) 0%, rgba(6, 3, 8, 0.16) 24%, rgba(6, 3, 8, 0.28) 64%, rgba(4, 2, 6, 0.8) 100%);
}

.menu-shell {
  width: min(760px, 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.85rem;
  position: relative;
  z-index: 1;
}

#menu .subtitle,
#menu .credits-by,
#menu .plays-line,
#menu .hint {
  text-shadow: 0 1px 10px rgba(0, 0, 0, 0.92), 0 0 16px rgba(0, 0, 0, 0.65);
}

#menu .brand h1 {
  filter: drop-shadow(0 2px 10px rgba(0, 0, 0, 0.88));
}

.brand {
  text-align: center;
}

.kicker {
  font-weight: 800;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  font-size: 0.68rem;
  color: var(--gold);
}

h1,
.count-num,
#results-title {
  font-family: "Cinzel", serif;
  font-weight: 900;
}

.brand h1 {
  font-size: clamp(2rem, 6vw, 3.4rem);
  line-height: 1;
  margin: 0.2rem 0 0.35rem;
  background: linear-gradient(180deg, #fff6d8, #f4c95d 55%, #c4891a);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-shadow: 0 10px 30px rgba(244, 201, 93, 0.2);
}

.subtitle {
  color: var(--muted);
  font-weight: 800;
  font-size: 0.98rem;
}

.menu-roster {
  display: flex;
  justify-content: center;
  align-items: flex-end;
  gap: 0.15rem;
  margin: 0.55rem 0 0.15rem;
  min-height: 108px;
}

.menu-roster .count-hero {
  width: clamp(56px, 10vw, 84px);
}

.menu-roster .count-hero .hero-art-wrap {
  height: 96px;
}

.menu-roster .count-hero span {
  font-size: 0.62rem;
}

.menu-card,
.pause-card,
.results-card,
.how-card {
  width: 100%;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 1.4rem;
  padding: 1.1rem 1.15rem 1.2rem;
  backdrop-filter: blur(10px);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.35);
}

.menu-card h3,
.pause-card h2 {
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 0.55rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.dot {
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 50%;
  background: var(--gold);
  box-shadow: 0 0 8px var(--gold);
}

.dot.cyan {
  background: var(--cyan);
  box-shadow: 0 0 8px var(--cyan);
}
.dot.magenta {
  background: var(--magenta);
  box-shadow: 0 0 8px var(--magenta);
}
.dot.lime {
  background: var(--lime);
  box-shadow: 0 0 8px var(--lime);
}

.menu-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.85rem;
  margin: 0.9rem 0;
}

.chip-grid,
.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.chip {
  font-family: inherit;
  font-weight: 800;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.05);
  border: 2px solid rgba(255, 255, 255, 0.08);
  border-radius: 0.9rem;
  padding: 0.62rem 0.85rem;
  cursor: pointer;
  transition: transform 0.12s ease, background 0.12s ease, border-color 0.12s ease;
}

.chip.round {
  min-width: 3.1rem;
  justify-content: center;
}

.chip:hover {
  transform: translateY(-1px);
}

.chip.selected {
  background: linear-gradient(180deg, rgba(244, 201, 93, 0.28), rgba(244, 201, 93, 0.08));
  border-color: var(--gold);
  box-shadow: 0 0 16px rgba(244, 201, 93, 0.25);
}

.chip.selected.magenta {
  background: linear-gradient(180deg, rgba(217, 70, 239, 0.32), rgba(217, 70, 239, 0.08));
  border-color: var(--magenta);
  box-shadow: 0 0 16px rgba(217, 70, 239, 0.28);
}

.chip.selected.lime,
.chip.lime.selected {
  background: linear-gradient(180deg, rgba(134, 239, 172, 0.28), rgba(134, 239, 172, 0.08));
  border-color: var(--lime);
  box-shadow: 0 0 16px rgba(134, 239, 172, 0.25);
}

.start-btn,
.ghost-btn {
  width: 100%;
  font-family: inherit;
  font-weight: 900;
  font-size: 1.15rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  border: none;
  border-radius: 1rem;
  padding: 0.95rem;
  cursor: pointer;
}

.start-btn {
  margin-top: 1rem;
  color: #2a1408;
  background: linear-gradient(180deg, #ffe08a, #f4c95d 40%, #d4921b);
  box-shadow: 0 8px 0 #8a5410, 0 14px 24px rgba(244, 201, 93, 0.28);
}

.start-btn:hover {
  filter: brightness(1.06);
}

.start-btn:active {
  transform: translateY(3px);
  box-shadow: 0 5px 0 #8a5410;
}

.how-btn {
  margin-top: 0.55rem;
  font-size: 1rem;
}

.hint {
  margin-top: 0.7rem;
  text-align: center;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 800;
}

.ghost-btn {
  background: transparent;
  color: var(--ink);
  border: 2px solid rgba(255, 255, 255, 0.14);
}

.credits {
  text-align: center;
}

.plays-line {
  margin: 0 0 0.45rem;
  font-weight: 900;
  font-size: 0.95rem;
  letter-spacing: 0.04em;
  color: var(--gold);
}

.plays-line strong {
  font-size: 1.15rem;
}

.credits-by {
  font-weight: 800;
  font-size: 0.9rem;
}

.social-links {
  display: flex;
  justify-content: center;
  gap: 0.5rem;
  margin: 0.5rem 0 0.35rem;
}

.social-link {
  width: 2.3rem;
  height: 2.3rem;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.95);
  color: #0f172a;
  text-decoration: none;
}

.social-link svg {
  width: 1.1rem;
  height: 1.1rem;
}

.social-link.instagram {
  color: #e1306c;
}
.social-link.facebook {
  color: #1877f2;
}
.social-link.youtube {
  color: #ff0000;
}
.social-link.web {
  color: #0284c7;
}

.credits-web {
  color: #f4c95d;
  font-weight: 800;
  font-size: 0.85rem;
  text-decoration: none;
}

/* ——— Countdown ——— */
#countdown {
  display: grid;
  place-items: center;
  background: radial-gradient(circle at 50% 40%, rgba(60, 90, 50, 0.28), transparent 52%);
}

.count-stage {
  text-align: center;
}

.count-kicker {
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--gold);
  font-weight: 800;
}

.count-num {
  font-size: clamp(4.2rem, 14vw, 8rem);
  line-height: 0.9;
  color: #fff6d8;
  text-shadow: 0 0 40px rgba(244, 201, 93, 0.7);
  animation: pop-count 0.7s ease;
}

@keyframes pop-count {
  0% {
    transform: scale(0.4);
    opacity: 0;
  }
  60% {
    transform: scale(1.12);
    opacity: 1;
  }
  100% {
    transform: scale(1);
  }
}

.count-sub {
  margin-top: 0.4rem;
  font-weight: 800;
  color: var(--muted);
}

.count-heroes {
  display: flex;
  justify-content: center;
  align-items: flex-end;
  gap: 0.35rem;
  margin-top: 0.9rem;
  min-height: 150px;
}

.count-hero {
  width: clamp(88px, 16vw, 130px);
  text-align: center;
}

.count-hero .hero-art-wrap {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  width: 100%;
  height: 132px;
  overflow: visible;
  animation: idle 1.3s ease-in-out infinite;
}

.count-hero .hero-art {
  filter: drop-shadow(0 8px 8px rgba(0, 0, 0, 0.35));
}

.count-hero .boss-art-wrap {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  width: 100%;
  height: 132px;
  overflow: visible;
  animation: idle 1.3s ease-in-out infinite;
}

.count-hero .boss-art {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: bottom center;
  filter: drop-shadow(0 8px 8px rgba(0, 0, 0, 0.35));
}

.count-hero .boss-art-wrap.boss-small .boss-art {
  width: 75%;
  height: 75%;
}

.count-hero span {
  display: block;
  margin-top: 0.15rem;
  font-weight: 900;
  font-size: 0.78rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--c);
}

.count-vs {
  font-family: "Cinzel", serif;
  font-weight: 900;
  font-size: clamp(1.1rem, 3vw, 1.7rem);
  color: var(--gold);
  text-shadow: 0 0 16px rgba(244, 201, 93, 0.55);
  align-self: center;
  padding: 0 0.35rem;
}

.count-hero.enemy {
  width: clamp(110px, 22vw, 170px);
}

.count-hero.enemy .hero-art-wrap,
.count-hero.enemy .boss-art-wrap {
  height: 148px;
}

.count-hero.enemy span {
  color: #fecaca;
}

/* ——— Battle HUD ——— */
#battle {
  display: flex;
  flex-direction: column;
}

.hud {
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 0.45rem 0.7rem 0.2rem;
  z-index: 5;
}

.hud-right {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 0.45rem;
}

.icon-btn {
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 0.8rem;
  border: 2px solid rgba(255, 255, 255, 0.1);
  background: rgba(0, 0, 0, 0.28);
  color: var(--ink);
  font-size: 1.05rem;
  cursor: pointer;
}

.timer {
  min-width: 6.4rem;
  text-align: center;
  font-weight: 900;
  font-size: 1.05rem;
  letter-spacing: 0.04em;
  padding: 0.42rem 1rem;
  border-radius: 999px;
  background: #38bdf8;
  color: #082f49;
  box-shadow: 0 0 0 4px rgba(8, 12, 28, 0.55), 0 8px 20px rgba(56, 189, 248, 0.35);
  transition: background 0.25s ease, color 0.25s ease;
}

.timer.warn {
  background: #f59e0b;
  color: #3b2204;
}

.timer.danger {
  background: #ef4444;
  color: #fff;
  animation: pulse-timer 0.7s ease-in-out infinite;
}

@keyframes pulse-timer {
  50% {
    transform: scale(1.06);
  }
}

.wave-badge {
  font-weight: 900;
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--gold);
  background: rgba(244, 201, 93, 0.12);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.35rem 0.7rem;
}

/* ——— Dungeon stage ——— */
.arena {
  position: relative;
  flex: 0 0 34%;
  min-height: 170px;
  margin: 0 0.7rem;
  border-radius: 1.2rem;
  overflow: hidden;
  isolation: isolate;
  background: #05060a;
  box-shadow: inset 0 0 0 2px rgba(20, 24, 28, 0.45);
  transform-origin: center;
}

.dungeon {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background-color: #05060a;
  background-image: url("assets/dungeon-hall.png");
  background-repeat: repeat-x;
  background-size: auto 100%;
  background-position: center bottom;
}

#fx {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 6;
}

.heroes {
  position: absolute;
  left: 2%;
  bottom: 4%;
  height: 78%;
  max-width: 56%;
  display: flex;
  align-items: flex-end;
  gap: 0.15rem;
  z-index: 4;
}

.hero {
  flex: 1 1 auto;
  width: clamp(110px, 20vw, 200px);
  max-width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  --c: #e23d4a;
}

.hero .hero-art-wrap {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  width: 100%;
  flex: 1 1 auto;
  min-height: 0;
  transform-origin: 50% 90%;
  animation: idle 1.4s ease-in-out infinite;
}

.hero-art {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: bottom center;
  pointer-events: none;
  filter: drop-shadow(0 8px 8px rgba(0, 0, 0, 0.45));
}

.hero-art-wrap.hero-small .hero-art {
  width: 90%;
  height: 90%;
}

.hero.attack .hero-art-wrap {
  animation: lunge 0.32s ease;
}

.hero.hurt .hero-art-wrap {
  animation: stumble 0.35s ease;
}

.hero.combo .hero-art {
  filter: drop-shadow(0 0 14px var(--c)) drop-shadow(0 8px 8px rgba(0, 0, 0, 0.45));
}

.hero.struck .hero-art-wrap {
  animation: stumble 0.4s ease;
}

.hero.flee {
  z-index: 2;
  animation: hero-flee 0.72s ease-in forwards;
}

.hero.flee .hero-art-wrap {
  animation: none;
  transform: scaleX(-1);
  transform-origin: 50% 90%;
}

.hero.flee .hero-tag {
  opacity: 0;
}

@keyframes hero-flee {
  0% {
    transform: translateX(0);
    opacity: 1;
  }
  100% {
    transform: translateX(-180%);
    opacity: 0;
  }
}

.hero-tag {
  font-size: 0.68rem;
  font-weight: 900;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--c);
  text-shadow: 0 1px 0 #000;
}

@keyframes idle {
  50% {
    transform: translateY(-5px);
  }
}

@keyframes lunge {
  0% {
    transform: translate(0, 0) rotate(0);
  }
  40% {
    transform: translate(18%, -8%) rotate(8deg) scale(1.08);
  }
  100% {
    transform: translate(0, 0) rotate(0);
  }
}

@keyframes stumble {
  30% {
    transform: translateX(-10%) rotate(-8deg);
  }
}

.boss {
  position: absolute;
  right: 2%;
  bottom: 2%;
  width: clamp(170px, 36vw, 360px);
  height: 90%;
  z-index: 3;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.boss-art-wrap {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  transform-origin: 50% 90%;
  animation: boss-idle 2.2s ease-in-out infinite;
}

.boss-art {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: bottom center;
  pointer-events: none;
  filter: drop-shadow(0 10px 12px rgba(0, 0, 0, 0.5));
}

.boss-art-wrap.boss-small .boss-art {
  width: 75%;
  height: 75%;
}

.boss.hurt .boss-art-wrap {
  animation: boss-hurt 0.28s ease;
}

.boss.down .boss-art-wrap {
  animation: boss-down 0.7s ease forwards;
}

.boss.advance {
  z-index: 5;
  animation: boss-rush 0.75s cubic-bezier(0.28, 0.08, 0.22, 1) forwards;
}

.boss.advance .boss-art-wrap {
  animation: none;
}

@keyframes boss-rush {
  0% {
    transform: translateX(0) scale(1);
  }
  82% {
    transform: translateX(-46vw) scale(1.12) rotate(-8deg);
  }
  100% {
    transform: translateX(-44vw) scale(1.04) rotate(-3deg);
  }
}

@keyframes boss-idle {
  50% {
    transform: translateY(-7px) scale(1.03);
  }
}

@keyframes boss-hurt {
  0%,
  100% {
    filter: none;
    transform: translateX(0);
  }
  40% {
    filter: brightness(2.2);
    transform: translateX(8%) scale(1.04);
  }
}

@keyframes boss-down {
  to {
    transform: translateY(18%) rotate(12deg);
    opacity: 0.15;
  }
}

.boss-hud {
  position: absolute;
  right: 4%;
  top: 8%;
  width: min(280px, 42%);
  z-index: 5;
}

.boss-name {
  font-family: "Cinzel", serif;
  font-size: 0.78rem;
  font-weight: 900;
  color: #fecaca;
  margin-bottom: 0.25rem;
  text-align: right;
}

.hp-track {
  height: 10px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.45);
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.15);
}

.hp-fill {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, #ef4444, #f97316 70%, #facc15);
  transform-origin: left;
  transition: transform 0.25s ease;
}

.boss-hp-label {
  margin-top: 0.2rem;
  text-align: right;
  font-weight: 900;
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  color: #fecaca;
}

.banner {
  position: absolute;
  left: 50%;
  top: 42%;
  transform: translate(-50%, -50%);
  z-index: 8;
  font-family: "Cinzel", serif;
  font-weight: 900;
  font-size: clamp(1.4rem, 4vw, 2.4rem);
  color: #fff6d8;
  text-shadow: 0 0 18px rgba(244, 201, 93, 0.8);
  pointer-events: none;
  animation: banner-in 0.9s ease forwards;
}

@keyframes banner-in {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.6);
  }
  25% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1.08);
  }
  80% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -70%) scale(1);
  }
}

.banner.celebrate {
  font-size: clamp(1.55rem, 4.2vw, 2.7rem);
  color: #f4c95d;
  text-align: center;
  max-width: 92%;
  line-height: 1.15;
  animation: banner-celebrate 1.4s ease forwards;
}

@keyframes banner-celebrate {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.7);
  }
  18% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1.08);
  }
  82% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -58%) scale(1);
  }
}

.hero.cheer .hero-art-wrap {
  animation: hero-cheer 0.5s ease-in-out infinite;
}

@keyframes hero-cheer {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-16%) scale(1.06);
  }
}

/* ——— Matching boards ——— */
.boards-shell {
  flex: 1;
  min-height: 0;
  position: relative;
  display: flex;
}

.boards {
  flex: 1;
  min-height: 0;
  display: flex;
  gap: 0.55rem;
  padding: 0.55rem 0.7rem 0.75rem;
}

.board-celebrate {
  position: absolute;
  inset: 0.55rem 0.7rem 0.75rem;
  z-index: 8;
  display: grid;
  place-content: center;
  place-items: center;
  gap: 0.55rem;
  padding: 1rem 1.2rem;
  text-align: center;
  background: rgba(8, 3, 14, 0.88);
  border: 2px solid rgba(244, 201, 93, 0.55);
  border-radius: 1.1rem;
  box-shadow: 0 0 28px rgba(244, 201, 93, 0.18);
}

.board-celebrate.hidden {
  display: none;
}

.board-celebrate.on {
  animation: board-celebrate-in 0.35s ease;
}

.board-celebrate-title {
  margin: 0;
  font-family: "Cinzel", serif;
  font-weight: 900;
  font-size: clamp(1.45rem, 4.2vw, 2.6rem);
  color: #f4c95d;
  text-shadow: 0 0 18px rgba(244, 201, 93, 0.55);
  line-height: 1.15;
}

.board-celebrate-next {
  margin: 0;
  min-height: 1.2em;
  font-weight: 900;
  font-size: clamp(1.05rem, 2.8vw, 1.7rem);
  color: #fff6d8;
}

.board-celebrate.next .board-celebrate-next {
  animation: board-celebrate-in 0.3s ease;
}

@keyframes board-celebrate-in {
  from {
    opacity: 0;
    transform: scale(0.88);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.player-board {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  background: rgba(10, 4, 16, 0.55);
  border: 2px solid color-mix(in srgb, var(--c) 55%, transparent);
  border-radius: 1.1rem;
  overflow: hidden;
  --c: #38bdf8;
}

.board-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.4rem 0.7rem;
  background: color-mix(in srgb, var(--c) 18%, transparent);
}

.board-head .name {
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.72rem;
  color: var(--c);
}

.score-pill {
  font-weight: 900;
  font-size: 0.82rem;
  color: var(--c);
  background: color-mix(in srgb, var(--c) 16%, #000);
  border: 2px solid var(--c);
  border-radius: 999px;
  padding: 0.15rem 0.6rem;
}

.combo-pill {
  margin-left: 0.35rem;
  font-weight: 900;
  font-size: 0.75rem;
  color: #2a1408;
  background: var(--gold);
  border-radius: 999px;
  padding: 0.12rem 0.45rem;
  opacity: 0;
}

.combo-pill.on {
  opacity: 1;
  animation: combo-pop 0.25s ease;
}

@keyframes combo-pop {
  from {
    transform: scale(0.6);
  }
}

.match {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.45rem;
  padding: 0.45rem;
}

.col {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  min-height: 0;
}

.col.answers {
  display: grid;
  grid-template-columns: 1fr 1fr;
  place-items: center;
  align-content: center;
  gap: 0.15rem 0.1rem;
}

.col.answers .tile.answer:last-child:nth-child(odd) {
  grid-column: 1 / -1;
}

.tile {
  flex: 1;
  min-height: 0;
  border: 3px solid rgba(255, 255, 255, 0.08);
  border-radius: 1rem;
  background: #1a2238;
  color: #fff;
  font-family: inherit;
  font-weight: 900;
  font-size: clamp(1.05rem, 2.6vw, 2rem);
  cursor: pointer;
  transition: transform 0.1s ease, border-color 0.1s ease, background 0.1s ease;
}

.tile.answer {
  color: #38bdf8;
}

.player-board .tile.answer {
  flex: 0 0 auto;
  position: relative;
  width: clamp(64px, 12vw, 118px);
  height: clamp(64px, 12vw, 118px);
  aspect-ratio: 1;
  padding: 0;
  border: none;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  color: var(--c);
  overflow: visible;
  filter: drop-shadow(0 3px 4px rgba(0, 0, 0, 0.45));
  container-type: size;
}

.tile.answer:hover {
  transform: translateY(-2px) scale(1.04);
}

.d20-art {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
  user-select: none;
}

.d20-num {
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 1;
  width: 58%;
  transform: translate(-50%, -54%);
  display: grid;
  place-items: center;
  font-family: "Nunito", system-ui, sans-serif;
  font-weight: 900;
  font-size: 40cqmin;
  line-height: 0.85;
  letter-spacing: -0.05em;
  color: var(--dice, var(--c));
  -webkit-text-stroke: 0.045em #120714;
  paint-order: stroke fill;
  text-shadow:
    0 0 5px #fff,
    0 1px 0 #fff,
    0 -1px 0 #fff,
    1px 0 0 #fff,
    -1px 0 0 #fff;
  pointer-events: none;
}

.d20-num.d20-md {
  font-size: 32cqmin;
  width: 64%;
}

.d20-num.d20-lg {
  font-size: 24cqmin;
  width: 70%;
  letter-spacing: -0.07em;
}

.d20-num.d20-xl {
  font-size: 18cqmin;
  width: 74%;
  letter-spacing: -0.08em;
}

.tile.answer.selected {
  transform: scale(1.08);
  filter: drop-shadow(0 0 10px var(--c)) drop-shadow(0 3px 4px rgba(0, 0, 0, 0.5));
}

.tile.answer.good {
  animation: d20-pop 0.38s ease;
  filter: drop-shadow(0 0 12px #4ade80);
}

.tile.answer.bad {
  animation: d20-shake 0.38s ease;
  filter: drop-shadow(0 0 10px #f87171);
}

@keyframes d20-pop {
  0% {
    transform: scale(1);
  }
  40% {
    transform: scale(1.16);
  }
  100% {
    transform: scale(1);
  }
}

@keyframes d20-shake {
  0%,
  100% {
    transform: translateX(0);
  }
  25% {
    transform: translateX(-5px) rotate(-4deg);
  }
  75% {
    transform: translateX(5px) rotate(4deg);
  }
}

.tile:active {
  transform: scale(0.97);
}

.tile.selected {
  border-color: var(--gold);
  background: #24304d;
  box-shadow: 0 0 0 3px rgba(244, 201, 93, 0.25), 0 0 18px rgba(244, 201, 93, 0.25);
  transform: scale(1.02);
}

.tile.good {
  background: #14532d;
  border-color: #86efac;
  animation: flash-good 0.35s ease;
}

.tile.bad {
  background: #7f1d1d;
  border-color: #fca5a5;
  animation: shake-bad 0.35s ease;
}

.tile.answer,
.tile.answer.selected,
.tile.answer.good,
.tile.answer.bad {
  background: transparent;
  border: none;
  box-shadow: none;
  border-radius: 0;
}

.tile.answer.selected {
  transform: scale(1.08);
  filter: drop-shadow(0 0 10px var(--c)) drop-shadow(0 3px 4px rgba(0, 0, 0, 0.5));
}

.tile.answer.good {
  animation: d20-pop 0.38s ease;
  filter: drop-shadow(0 0 12px #4ade80);
}

.tile.answer.bad {
  animation: d20-shake 0.38s ease;
  filter: drop-shadow(0 0 10px #f87171);
}

.tile.in {
  animation: tile-in 0.28s ease;
}

@keyframes flash-good {
  50% {
    transform: scale(1.05);
  }
}

@keyframes shake-bad {
  25% {
    transform: translateX(-6px);
  }
  75% {
    transform: translateX(6px);
  }
}

@keyframes tile-in {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.92);
  }
}

/* ——— Overlays ——— */
.overlay-screen,
#results {
  display: grid;
  place-items: center;
  background: rgba(8, 3, 12, 0.72);
  z-index: 20;
}

.pause-card,
.results-card,
.how-card {
  width: min(520px, calc(100% - 2rem));
  text-align: center;
}

.how-card {
  width: min(720px, calc(100% - 2rem));
  text-align: left;
}

.how-card h2 {
  margin: 0 0 0.6rem;
  text-align: center;
}

.how-shared {
  margin: 0 0 1rem;
  color: var(--muted);
  font-weight: 800;
  text-align: center;
}

.how-modes {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.how-modes article {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(244, 201, 93, 0.22);
  border-radius: 1rem;
  padding: 0.85rem 0.9rem;
}

.how-modes h3 {
  margin: 0 0 0.4rem;
  font-family: "Cinzel", serif;
  font-size: 1.05rem;
  color: var(--gold);
  text-transform: none;
  letter-spacing: 0.02em;
}

.how-modes p {
  margin: 0;
  font-weight: 800;
  font-size: 0.92rem;
  line-height: 1.35;
}

.how-card .start-btn {
  margin-top: 0.2rem;
}

.pause-card h2,
.results-card h1 {
  margin: 0.2rem 0 0.35rem;
}

.final-scores {
  display: grid;
  gap: 0.5rem;
  margin: 1rem 0 1.1rem;
  text-align: left;
}

.final-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 1rem;
  padding: 0.75rem 0.95rem;
  font-weight: 800;
}

.final-row.team {
  background: rgba(244, 201, 93, 0.16);
  outline: 2px solid var(--gold);
}

.final-row .pts {
  font-size: 1.35rem;
  font-weight: 900;
  color: var(--gold);
}

.gameover-actions {
  display: grid;
  gap: 0.55rem;
}

.stats-line {
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 800;
}

#battle.players-1 .arena {
  flex-basis: 38%;
}

#battle.players-3 .hero,
#battle.players-4 .hero {
  width: clamp(72px, 14vw, 140px);
}

#battle.players-4 .boards {
  gap: 0.35rem;
}

#battle.players-4 .tile {
  font-size: clamp(0.85rem, 1.7vw, 1.3rem);
  border-width: 2px;
  border-radius: 0.7rem;
}

#battle.players-1 .tile.answer {
  width: clamp(86px, 14vw, 136px);
  height: clamp(86px, 14vw, 136px);
}

#battle.players-2 .tile.answer {
  width: clamp(68px, 11vw, 108px);
  height: clamp(68px, 11vw, 108px);
}

#battle.players-3 .tile.answer,
#battle.players-4 .tile.answer {
  width: clamp(50px, 8.5vw, 82px);
  height: clamp(50px, 8.5vw, 82px);
  border: none;
  border-radius: 0;
}

@media (max-width: 820px) {
  .menu-row {
    grid-template-columns: 1fr;
  }

  .how-modes {
    grid-template-columns: 1fr;
  }

  .arena {
    flex-basis: 30%;
    min-height: 150px;
  }

  .boss-hud {
    width: 48%;
  }

  #battle.players-3 .boards,
  #battle.players-4 .boards {
    flex-wrap: wrap;
  }

  #battle.players-3 .player-board,
  #battle.players-4 .player-board {
    flex: 1 1 46%;
  }
}

@media (max-height: 700px) {
  .brand h1 {
    font-size: 2rem;
  }
  .arena {
    flex-basis: 28%;
    min-height: 130px;
  }
}
