:root {
  color-scheme: dark;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --ink: #f6fbff;
  --muted: #a9b8cc;
  --panel: rgba(12, 18, 30, 0.78);
  --panel-strong: rgba(15, 24, 39, 0.94);
  --line: rgba(255, 255, 255, 0.14);
  --aqua: #78e3ff;
  --mint: #7cf8b9;
  --gold: #ffd166;
  --rose: #ff6b8a;
  --violet: #b8a1ff;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: #090e18;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  color: var(--ink);
  background: #090e18;
  overflow-x: hidden;
}

body.is-playing {
  overflow: hidden;
}

button {
  border: 0;
  font: inherit;
  color: inherit;
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.shell {
  width: 100%;
}

.game-stage {
  position: relative;
  height: 100svh;
  min-height: 100svh;
  width: 100vw;
  overflow: hidden;
  isolation: isolate;
}

body.is-playing .game-stage {
  position: fixed;
  inset: 0;
  z-index: 20;
  height: 100vh;
  min-height: 100vh;
}

body.is-playing .content-band {
  display: none;
}

#game-canvas {
  position: absolute;
  inset: 0;
  width: 100% !important;
  height: 100% !important;
  display: block;
}

.hud {
  position: fixed;
  z-index: 4;
  top: max(14px, env(safe-area-inset-top));
  left: max(14px, env(safe-area-inset-left));
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  max-width: calc(100vw - 112px);
  pointer-events: none;
}

.hud-chip {
  min-width: 88px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  background: rgba(9, 15, 27, 0.72);
  box-shadow: 0 12px 26px rgba(0, 0, 0, 0.24);
  backdrop-filter: blur(14px);
}

.hud-chip span {
  display: block;
  color: var(--muted);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0;
}

.hud-chip strong {
  display: block;
  margin-top: 2px;
  font-size: clamp(1rem, 2vw, 1.35rem);
}

.hud-chip.primary strong {
  color: var(--gold);
}

.hud-chip.phase {
  min-width: 160px;
}

.top-actions {
  position: fixed;
  z-index: 5;
  top: max(14px, env(safe-area-inset-top));
  right: max(14px, env(safe-area-inset-right));
  display: flex;
  gap: 8px;
}

.icon-button {
  width: 42px;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(9, 15, 27, 0.72);
  font-weight: 800;
  backdrop-filter: blur(14px);
}

.touch-controls {
  position: fixed;
  z-index: 5;
  right: 16px;
  bottom: 18px;
  display: none;
  gap: 10px;
}

.touch-controls button,
.primary-button,
.secondary-button,
.level-card button,
.uni-card button {
  min-height: 42px;
  border-radius: 8px;
  padding: 0 16px;
  font-weight: 800;
}

.touch-controls button,
.primary-button {
  background: linear-gradient(135deg, var(--mint), var(--aqua));
  color: #07111d;
}

.secondary-button,
.level-card button,
.uni-card button {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.08);
}

.secondary-button:disabled {
  background: rgba(255, 255, 255, 0.05);
}

.start-panel {
  position: absolute;
  z-index: 6;
  right: clamp(18px, 5vw, 72px);
  bottom: clamp(98px, 14vh, 150px);
  width: min(420px, calc(100vw - 36px));
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  background: rgba(9, 15, 27, 0.76);
  box-shadow: 0 18px 44px rgba(0, 0, 0, 0.24);
  backdrop-filter: blur(14px);
  transition: opacity 0.25s ease, transform 0.25s ease;
}

.start-panel.hidden {
  opacity: 0;
  transform: translateY(12px);
  pointer-events: none;
}

.death-panel {
  position: absolute;
  z-index: 9;
  left: 50%;
  top: 50%;
  width: min(420px, calc(100vw - 32px));
  transform: translate(-50%, -50%);
  border: 1px solid rgba(255, 209, 102, 0.35);
  border-radius: 8px;
  padding: 18px;
  background: rgba(9, 15, 27, 0.9);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.36);
  backdrop-filter: blur(16px);
}

.death-panel.hidden {
  display: none;
}

.death-panel h2 {
  margin: 0;
  font-size: clamp(2rem, 5vw, 3.5rem);
  line-height: 0.95;
}

.death-panel p:not(.eyebrow) {
  margin: 12px 0 0;
  color: #dce8f6;
  line-height: 1.45;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--aqua);
  font-size: 0.78rem;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0;
}

h1,
h2,
h3,
p {
  overflow-wrap: anywhere;
}

h1 {
  margin: 0;
  max-width: 12ch;
  font-size: clamp(2.25rem, 5vw, 4.25rem);
  line-height: 0.92;
  text-shadow: 0 12px 24px rgba(0, 0, 0, 0.34);
}

.intro {
  max-width: 42ch;
  margin: 14px 0 0;
  color: #dce8f6;
  font-size: 0.98rem;
  line-height: 1.45;
}

.panel-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 18px;
}

.toast {
  position: fixed;
  z-index: 8;
  left: 50%;
  bottom: 24px;
  max-width: min(560px, calc(100vw - 32px));
  transform: translate(-50%, 24px);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 14px;
  background: var(--panel-strong);
  color: var(--ink);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

.content-band {
  position: relative;
  z-index: 2;
  width: 100%;
  padding: clamp(42px, 7vw, 86px) clamp(16px, 5vw, 74px);
  background: #0d1422;
}

.levels-band {
  background: linear-gradient(180deg, #0b111d 0%, #111c2b 100%);
}

.booster-band {
  background: #101827;
}

.endless-band {
  background: #0d1625;
}

.endless-card {
  max-width: 560px;
}

.uni-band {
  background: linear-gradient(180deg, #101827, #090e18);
}

.section-heading {
  max-width: 820px;
  margin-bottom: 24px;
}

.section-heading h2 {
  margin: 0;
  font-size: clamp(2rem, 5vw, 4.4rem);
  line-height: 0.95;
}

.section-heading p:last-child {
  max-width: 70ch;
  color: var(--muted);
  line-height: 1.55;
}

.level-grid,
.booster-grid,
.uni-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr));
  gap: 14px;
}

.level-card,
.booster-card,
.uni-card,
.result-strip > div {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.055);
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.22);
}

.level-card,
.uni-card {
  display: flex;
  min-height: 270px;
  flex-direction: column;
  gap: 12px;
  padding: 18px;
}

.level-card.active {
  border-color: rgba(124, 248, 185, 0.6);
  box-shadow: 0 0 0 1px rgba(124, 248, 185, 0.18), 0 18px 40px rgba(0, 0, 0, 0.22);
}

.level-card.locked {
  filter: grayscale(0.85);
}

.level-card.locked button {
  opacity: 0.48;
}

.level-top,
.level-meta,
.uni-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: space-between;
  color: var(--muted);
  font-size: 0.84rem;
}

.level-number,
.uni-rank {
  color: var(--gold);
  font-weight: 900;
}

.level-card h3,
.uni-card h3,
.booster-card h3 {
  margin: 0;
  font-size: 1.25rem;
}

.level-card p,
.booster-card p {
  flex: 1;
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.booster-card {
  display: grid;
  grid-template-columns: 68px 1fr;
  gap: 14px;
  align-items: center;
  min-height: 150px;
  padding: 16px;
}

.booster-icon {
  display: grid;
  width: 64px;
  height: 64px;
  place-items: center;
  border-radius: 8px;
  background: rgba(120, 227, 255, 0.14);
  color: var(--aqua);
  font-weight: 900;
}

.booster-card span {
  display: inline-block;
  margin-top: 8px;
  color: var(--gold);
  font-size: 0.9rem;
  font-weight: 800;
}

.result-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 190px), 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.result-strip > div {
  padding: 14px;
}

.result-strip span {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
  text-transform: uppercase;
}

.result-strip strong {
  display: block;
  margin-top: 3px;
  color: var(--mint);
  font-size: 1.15rem;
}

.uni-card.elite {
  border-color: rgba(255, 209, 102, 0.34);
}

.uni-card.accepted {
  background: rgba(124, 248, 185, 0.12);
}

.uni-stats {
  display: grid;
  grid-template-columns: 1fr;
  justify-content: stretch;
}

.uni-card button,
.level-card button {
  margin-top: auto;
}

@media (max-width: 720px) {
  .hud {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    width: calc(100vw - 138px);
    max-width: none;
  }

  .hud-chip {
    min-width: 0;
    padding: 7px 8px;
  }

  .hud-chip.phase {
    grid-column: 1 / -1;
    min-width: 0;
  }

  .touch-controls {
    display: flex;
  }

  .toast {
    bottom: 92px;
  }

  .start-panel {
    right: 14px;
    bottom: 104px;
    width: calc(100vw - 28px);
    padding: 14px;
  }

  .booster-card {
    grid-template-columns: 1fr;
  }
}
