:root {
  color-scheme: dark;
  --bg: #080712;
  --panel: #1d1730;
  --panel-2: #282044;
  --ink: #fff7df;
  --muted: #b9abc9;
  --accent: #67f7ff;
  --danger: #ff4fd8;
  --data: #9ccfff;
  --gold: #ffd166;
  --line: rgba(255, 255, 255, 0.14);
  --pixel-line: rgba(103, 247, 255, 0.22);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 18% 12%, rgba(103, 247, 255, 0.22), transparent 28rem),
    radial-gradient(circle at 82% 8%, rgba(255, 79, 216, 0.20), transparent 26rem),
    linear-gradient(135deg, rgba(255, 209, 102, 0.07), transparent 36rem),
    var(--bg);
  color: var(--ink);
}
button { font: inherit; }
.shell { width: min(1180px, calc(100% - 28px)); margin: 0 auto; padding: 22px 0 34px; }
.hud-panel { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 18px; align-items: end; }
.hud-panel { margin-bottom: 10px; }
.eyebrow { margin: 0 0 5px; color: var(--accent); font-size: 12px; font-weight: 900; letter-spacing: 0.11em; text-transform: uppercase; }
h1, h2, p { margin: 0; }
h1 { font-size: clamp(32px, 5vw, 62px); line-height: 0.92; letter-spacing: -0.06em; text-shadow: 0 0 26px rgba(103, 247, 255, 0.34); }
.subtitle { max-width: 760px; margin-top: 8px; color: var(--muted); }
.content-status { max-width: 760px; margin-top: 8px; color: var(--gold); font-size: 13px; font-weight: 800; }
.stat-grid { display: grid; grid-template-columns: repeat(5, 82px); gap: 8px; }
.stat-grid span, .notes article {
  min-height: 68px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(29, 23, 48, 0.78);
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.24), inset 0 0 28px rgba(103, 247, 255, 0.03);
}
.stat-grid strong { display: block; color: var(--gold); font-size: 24px; line-height: 1; font-variant-numeric: tabular-nums; }
.stat-grid span { color: var(--muted); font-size: 11px; font-weight: 800; text-transform: uppercase; }
.buildcraft-panel {
  display: grid;
  grid-template-columns: minmax(220px, 0.72fr) minmax(0, 1.28fr);
  gap: 10px;
  margin-bottom: 12px;
  padding: 12px;
  border: 1px solid rgba(103, 247, 255, 0.18);
  border-radius: 18px;
  background: linear-gradient(90deg, rgba(103, 247, 255, 0.075), rgba(255, 79, 216, 0.045));
}
.buildcraft-panel h2 { font-size: 17px; letter-spacing: -0.02em; }
.buildcraft-panel p { margin-top: 4px; color: var(--muted); font-size: 12px; line-height: 1.35; }
.buildcraft-status { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.buildcraft-status span {
  min-height: 72px;
  padding: 10px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 14px;
  background: rgba(5, 4, 12, 0.52);
}
.buildcraft-status strong { display: block; color: var(--gold); font-size: 13px; line-height: 1.24; }
.buildcraft-status em { display: block; margin-top: 6px; color: var(--accent); font-size: 10px; font-style: normal; font-weight: 900; letter-spacing: 0.08em; text-transform: uppercase; }
.xp-stat { position: relative; overflow: hidden; }
.xp-fill {
  position: absolute;
  inset: auto 10px 8px;
  width: 0%;
  height: 5px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--data), var(--accent), var(--gold));
  box-shadow: 0 0 16px rgba(156, 207, 255, 0.36);
  transition: width 160ms ease-out;
}
.xp-stat.is-pulsing {
  border-color: rgba(156, 207, 255, 0.78);
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.24), 0 0 24px rgba(156, 207, 255, 0.26), inset 0 0 28px rgba(103, 247, 255, 0.08);
}
.xp-stat.is-near-level strong { color: var(--data); text-shadow: 0 0 16px rgba(156, 207, 255, 0.48); }
.hp-stat.is-damaged {
  border-color: rgba(255, 91, 138, 0.82);
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.24), 0 0 22px rgba(255, 91, 138, 0.24), inset 0 0 24px rgba(255, 79, 216, 0.08);
}
.hp-stat.is-damaged strong { color: #ff5b8a; text-shadow: 0 0 14px rgba(255, 91, 138, 0.42); }
.game-frame { position: relative; border: 1px solid var(--line); border-radius: 24px; overflow: hidden; background: #05040c; box-shadow: 0 24px 90px rgba(0,0,0,0.38), 0 0 80px rgba(255,79,216,0.10); }
canvas { display: block; width: 100%; height: auto; image-rendering: pixelated; }
.overlay { position: absolute; inset: 0; display: grid; place-items: center; padding: 20px; background: rgba(8, 6, 18, 0.72); backdrop-filter: blur(3px); isolation: isolate; }
.overlay.hidden { display: none; }
#upgrade-panel {
  background:
    radial-gradient(circle at 50% 44%, rgba(255, 209, 102, 0.34), transparent 12rem),
    radial-gradient(circle at 50% 44%, rgba(255, 79, 216, 0.18), transparent 20rem),
    radial-gradient(circle at 18% 18%, rgba(103, 247, 255, 0.22), transparent 15rem),
    radial-gradient(circle at 82% 78%, rgba(255, 79, 216, 0.20), transparent 16rem),
    rgba(8, 6, 18, 0.80);
}
#upgrade-panel::before,
#upgrade-panel::after {
  position: absolute;
  content: "";
  pointer-events: none;
  z-index: 0;
}
#upgrade-panel::before {
  inset: -18%;
  background: repeating-conic-gradient(from -12deg at 50% 44%, rgba(255, 209, 102, 0.095) 0deg 3deg, transparent 3deg 13deg);
  opacity: 0.52;
  mix-blend-mode: screen;
  animation: jackpotRayRotate 18s linear infinite;
}
#upgrade-panel::after {
  inset: 0;
  background:
    radial-gradient(circle at 16% 24%, rgba(255, 209, 102, 0.58) 0 2px, transparent 3px),
    radial-gradient(circle at 28% 72%, rgba(103, 247, 255, 0.52) 0 2px, transparent 3px),
    radial-gradient(circle at 74% 19%, rgba(255, 79, 216, 0.58) 0 2px, transparent 3px),
    radial-gradient(circle at 86% 68%, rgba(255, 209, 102, 0.48) 0 2px, transparent 3px),
    linear-gradient(90deg, transparent 0 8%, rgba(255, 209, 102, 0.09) 8% 9%, transparent 9% 91%, rgba(255, 209, 102, 0.09) 91% 92%, transparent 92%);
  opacity: 0.54;
  animation: jackpotSparkKick 820ms ease-out both;
}
.card { position: relative; z-index: 1; width: min(650px, 100%); border: 1px solid var(--line); border-radius: 22px; background: linear-gradient(180deg, rgba(40,32,68,0.97), rgba(20,15,35,0.97)); padding: 22px; text-align: center; box-shadow: 0 26px 80px rgba(0,0,0,0.38); }
.card h2 { font-size: 32px; letter-spacing: -0.04em; }
.card p { color: var(--muted); margin-top: 8px; }
#summary {
  color: var(--ink);
  line-height: 1.65;
  white-space: pre-line;
  font-size: 18px;
}
.lore-line { color: rgba(255, 247, 223, 0.72) !important; font-size: 13px; font-weight: 800; letter-spacing: 0.04em; text-transform: uppercase; line-height: 1.35; }
.upgrade-card {
  position: relative;
  overflow: hidden;
  width: min(900px, 100%);
  border-radius: 22px;
  border-color: rgba(255, 209, 102, 0.36);
  background:
    linear-gradient(135deg, rgba(255, 209, 102, 0.16), transparent 24%, rgba(255, 79, 216, 0.13) 72%, rgba(103, 247, 255, 0.13)),
    linear-gradient(180deg, rgba(18, 13, 34, 0.98), rgba(9, 7, 18, 0.98));
  box-shadow:
    0 28px 90px rgba(0, 0, 0, 0.56),
    0 0 46px rgba(255, 209, 102, 0.20),
    0 0 110px rgba(255, 79, 216, 0.16),
    inset 0 0 0 2px rgba(255, 209, 102, 0.08);
  animation: jackpotCardPop 820ms cubic-bezier(.16, 1, .3, 1) both;
}
.upgrade-card::before,
.upgrade-card::after {
  position: absolute;
  content: "";
  pointer-events: none;
}
.upgrade-card::before {
  inset: 12px;
  border: 1px solid rgba(255, 209, 102, 0.30);
  border-radius: 18px;
  box-shadow: inset 0 0 22px rgba(103, 247, 255, 0.08);
}
.upgrade-card::after {
  inset: -40% auto auto 50%;
  width: 220px;
  height: 220px;
  border-radius: 999px;
  background: conic-gradient(from 0deg, transparent, rgba(255, 209, 102, 0.62), transparent, rgba(103, 247, 255, 0.38), transparent, rgba(255, 79, 216, 0.34), transparent);
  opacity: 0.72;
  transform: translateX(-50%);
  animation: jackpotSweep 780ms ease-out both;
}
.upgrade-card > * { position: relative; z-index: 1; }
.upgrade-card .eyebrow { color: var(--gold); }
.lore-line { white-space: pre-line; }
.upgrade-options { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-top: 16px; align-items: stretch; }
.upgrade-options button, #restart {
  position: relative;
  border: 1px solid color-mix(in srgb, var(--upgrade-color, var(--line)) 48%, var(--line));
  border-radius: 18px;
  background:
    linear-gradient(90deg, color-mix(in srgb, var(--upgrade-color, var(--accent)) 24%, transparent), transparent 12%, transparent 88%, color-mix(in srgb, var(--upgrade-color, var(--accent)) 20%, transparent)),
    radial-gradient(circle at 50% 18%, color-mix(in srgb, var(--upgrade-color, var(--accent)) 24%, transparent), transparent 72px),
    linear-gradient(180deg, rgba(26, 20, 45, 0.98), rgba(11, 9, 22, 0.98));
  color: var(--ink);
  min-height: 312px;
  padding: 14px 13px;
  text-align: center;
  cursor: pointer;
  transition: transform 120ms ease, border-color 120ms ease, box-shadow 120ms ease, filter 120ms ease;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
  aspect-ratio: 0.68;
}
.upgrade-options button:hover, .upgrade-options button:focus-visible, #restart:hover { border-color: var(--upgrade-color, var(--accent)); transform: translateY(-2px); filter: brightness(1.08); box-shadow: 0 0 24px color-mix(in srgb, var(--upgrade-color, var(--accent)) 28%, transparent); }
.upgrade-frame-label { color: rgba(255, 247, 223, 0.68); font-size: 10px; font-weight: 950; letter-spacing: 0.14em; text-transform: uppercase; }
.upgrade-icon { display: grid; place-items: center; min-height: 60px; margin: 8px 0 6px; color: var(--upgrade-color, var(--accent)); font-size: 54px; font-weight: 900; text-shadow: 0 0 22px color-mix(in srgb, var(--upgrade-color, var(--accent)) 56%, transparent); }
.upgrade-copy { display: contents; }
.upgrade-copy strong { display: block; color: var(--upgrade-color, var(--accent)); font-size: 18px; line-height: 1.05; }
.upgrade-kicker { display: block; color: var(--muted); font-size: 11px; font-weight: 900; letter-spacing: 0.06em; text-transform: uppercase; }
.upgrade-fantasy { display: block; min-height: 48px; color: rgba(255, 247, 223, 0.78); font-size: 12px; font-weight: 760; line-height: 1.25; }
.upgrade-copy em { display: block; min-height: 42px; color: var(--gold); font-size: 18px; line-height: 1.08; font-style: normal; font-weight: 950; }
.upgrade-payoff, .upgrade-combo {
  display: block;
  margin-top: 10px;
  padding: 9px;
  border: 1px solid color-mix(in srgb, var(--upgrade-color, var(--accent)) 32%, rgba(255, 255, 255, 0.10));
  border-radius: 12px;
  background: rgba(5, 4, 12, 0.36);
  color: rgba(255, 247, 223, 0.78);
  font-size: 11px;
  font-weight: 800;
  line-height: 1.22;
  text-align: left;
}
.upgrade-payoff { margin-top: auto; }
.upgrade-payoff b, .upgrade-combo b { display: block; color: var(--upgrade-color, var(--accent)); font-size: 10px; letter-spacing: 0.10em; text-transform: uppercase; }
.upgrade-options button:hover .upgrade-payoff, .upgrade-options button:focus-visible .upgrade-payoff { box-shadow: inset 0 0 18px color-mix(in srgb, var(--upgrade-color, var(--accent)) 18%, transparent); }
#restart { margin-top: 18px; text-align: center; font-weight: 900; background: var(--accent); color: #06120f; display: block; width: 100%; }
.play-strip {
  margin-top: 10px;
  padding: 10px 14px;
  border: 1px solid rgba(103, 247, 255, 0.14);
  border-radius: 14px;
  background: rgba(5, 4, 12, 0.52);
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  text-align: center;
}
.notes { margin-top: 10px; color: var(--muted); }
.notes summary {
  cursor: pointer;
  color: var(--gold);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.notes-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; margin-top: 10px; align-items: stretch; }
.notes h2 { font-size: 14px; color: var(--gold); text-transform: uppercase; letter-spacing: 0.08em; }
.notes p { color: var(--muted); margin-top: 6px; line-height: 1.5; }
.talent-note { color: var(--data); font-size: 12px; }
.talent-grid-preview {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
  margin-top: 12px;
}
.talent-branch {
  min-height: 190px;
  padding: 12px;
  border: 1px solid rgba(103, 247, 255, 0.15);
  background: linear-gradient(180deg, rgba(103, 247, 255, 0.06), rgba(255, 79, 216, 0.035));
}
.talent-branch h4 { margin: 0 0 6px; color: var(--accent); font-size: 13px; }
.talent-branch p { margin: 0 0 8px; color: var(--muted); font-size: 11px; }
.talent-branch ul { display: grid; gap: 7px; margin: 0; padding: 0; list-style: none; }
.talent-branch li { padding-top: 6px; border-top: 1px solid rgba(255, 255, 255, 0.06); }
.talent-branch strong { display: block; color: var(--ink); font-size: 11px; }
.talent-branch span { display: block; color: var(--gold); font-size: 10px; }
@media (max-width: 980px) {
  .hud-panel { grid-template-columns: 1fr; }
  .stat-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .buildcraft-panel { grid-template-columns: 1fr; }
  .buildcraft-status { grid-template-columns: 1fr; }
  .upgrade-options { grid-template-columns: 1fr; }
  .upgrade-options button { min-height: 190px; aspect-ratio: auto; }
  .notes-grid { grid-template-columns: 1fr; }
  .talent-grid-preview { grid-template-columns: 1fr; }
}

@keyframes jackpotRayRotate {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

@keyframes jackpotCardPop {
  0% { opacity: 0; transform: scale(0.92); filter: brightness(1.8); }
  42% { opacity: 1; transform: scale(1.035); filter: brightness(1.28); }
  100% { opacity: 1; transform: scale(1); filter: brightness(1); }
}

@keyframes jackpotSweep {
  from { transform: translateX(-50%) rotate(0deg) scale(0.7); opacity: 0.9; }
  to { transform: translateX(-50%) rotate(160deg) scale(1.75); opacity: 0; }
}

@keyframes jackpotRimPulse {
  0% { opacity: 0; transform: scale(0.86); filter: brightness(1.5); }
  46% { opacity: 1; transform: scale(1.015); filter: brightness(1.25); }
  100% { opacity: 0.78; transform: scale(1); filter: brightness(1); }
}

@keyframes jackpotSparkKick {
  0% { opacity: 0; transform: scale(0.9); }
  38% { opacity: 0.84; transform: scale(1.02); }
  100% { opacity: 0.48; transform: scale(1); }
}

@media (prefers-reduced-motion: reduce) {
  .upgrade-card,
  .upgrade-card::after,
  #upgrade-panel::before,
  #upgrade-panel::after {
    animation: none;
  }
}

.hero-select { background: rgba(4, 3, 10, 0.82); }
.hero-select-card { width: min(980px, 100%); }
.hero-options { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-top: 16px; }
.hero-options button {
  min-height: 244px;
  padding: 14px 12px;
  border: 1px solid color-mix(in srgb, var(--hero-color) 58%, rgba(255,255,255,0.14));
  border-radius: 18px;
  background:
    radial-gradient(circle at 50% 16%, color-mix(in srgb, var(--hero-color) 32%, transparent), transparent 78px),
    linear-gradient(180deg, rgba(25, 19, 42, 0.98), rgba(7, 6, 16, 0.98));
  color: var(--ink);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  justify-content: flex-start;
  text-align: center;
  box-shadow: inset 0 0 28px color-mix(in srgb, var(--hero-color) 12%, transparent);
}
.hero-options button:hover, .hero-options button:focus-visible {
  transform: translateY(-2px);
  border-color: var(--hero-color);
  box-shadow: 0 0 26px color-mix(in srgb, var(--hero-color) 34%, transparent), inset 0 0 32px color-mix(in srgb, var(--hero-color) 15%, transparent);
}
.hero-sigil { display: grid; place-items: center; width: 58px; height: 58px; color: var(--hero-color); font-size: 42px; font-weight: 950; text-shadow: 0 0 24px var(--hero-color); }
.hero-options strong { color: var(--hero-color); font-size: 21px; line-height: 1; }
.hero-options em { color: var(--gold); font-size: 10px; font-style: normal; font-weight: 950; letter-spacing: 0.12em; text-transform: uppercase; }
.hero-options span:not(.hero-sigil) { color: rgba(255, 247, 223, 0.82); font-size: 13px; font-weight: 850; }
.hero-options small { color: var(--muted); font-size: 11px; line-height: 1.28; }
