:root {
  color-scheme: dark;
  --bg: #030305;
  --ink: #fff8df;
  --muted: #c9bfa7;
  --dim: rgba(255, 248, 223, 0.7);
  --panel: rgba(8, 6, 9, 0.74);
  --panel-strong: rgba(8, 6, 9, 0.88);
  --line: rgba(255, 221, 112, 0.27);
  --gold: #ffd54a;
  --cyan: #1be7ff;
  --magenta: #ff2aa1;
  --yellow: #fff157;
  --danger: #ff4b5f;
  --shadow: 0 18px 48px rgba(0, 0, 0, 0.48);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: "Trebuchet MS", "Arial Narrow", system-ui, sans-serif;
  letter-spacing: 0;
}

body {
  min-height: 100vh;
  overflow-x: hidden;
}

button,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

button:focus-visible,
select:focus-visible,
summary:focus-visible {
  outline: 3px solid var(--cyan);
  outline-offset: 3px;
}

noscript {
  position: fixed;
  inset: auto 16px 16px;
  z-index: 10;
  padding: 12px 14px;
  background: #17080d;
  border: 1px solid var(--danger);
  border-radius: var(--radius);
}

.screen-art,
#app-canvas {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
}

.screen-art {
  object-fit: cover;
  z-index: 0;
  filter: saturate(1.1) contrast(1.05);
}

#app-canvas {
  z-index: 1;
  pointer-events: none;
  mix-blend-mode: screen;
  opacity: 0.72;
}

#app-root {
  position: relative;
  z-index: 2;
  min-height: 100vh;
}

#app-root::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    linear-gradient(90deg, rgba(0, 0, 0, 0.76), rgba(0, 0, 0, 0.22) 48%, rgba(0, 0, 0, 0.66)),
    repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.035) 0, rgba(255, 255, 255, 0.035) 1px, transparent 1px, transparent 4px);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 4;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px clamp(16px, 3vw, 34px);
  background: linear-gradient(180deg, rgba(3, 3, 5, 0.92), rgba(3, 3, 5, 0.48));
  backdrop-filter: blur(10px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  text-decoration: none;
  font-size: 18px;
  font-weight: 900;
  white-space: nowrap;
}

.brand-mark {
  width: 28px;
  height: 28px;
  border: 3px solid var(--gold);
  border-left-color: var(--magenta);
  border-bottom-color: var(--cyan);
  border-radius: 50%;
  box-shadow: 0 0 16px rgba(255, 213, 74, 0.45);
}

.nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.nav-btn,
.btn {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(6, 5, 8, 0.72);
  color: var(--ink);
  padding: 10px 13px;
  font-size: 14px;
  font-weight: 800;
  text-transform: uppercase;
  box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.26);
}

.nav-btn.active,
.btn.primary {
  background: linear-gradient(135deg, var(--magenta), #9d38ff 45%, var(--cyan));
  border-color: rgba(255, 255, 255, 0.34);
  color: white;
}

.btn.ghost {
  color: var(--gold);
}

.app-main {
  min-height: calc(100vh - 72px);
  padding: clamp(18px, 3vw, 42px);
}

.screen {
  min-height: calc(100vh - 132px);
  display: grid;
  align-items: center;
}

.intro-screen,
.tutorial-screen,
.settings-screen,
.credits-screen {
  grid-template-columns: minmax(0, 680px) 1fr;
}

.copy-stack {
  display: grid;
  gap: 18px;
  max-width: 720px;
}

.hero-copy {
  padding-block: 5vh;
}

h1,
p,
dl,
dd,
ul {
  margin: 0;
}

h1 {
  max-width: 12ch;
  color: var(--ink);
  font-size: clamp(48px, 8vw, 116px);
  line-height: 0.88;
  text-transform: uppercase;
  text-shadow: 5px 5px 0 rgba(0, 0, 0, 0.54), 0 0 22px rgba(255, 42, 161, 0.36);
}

.panel h1,
.cutscene-caption h1 {
  max-width: 18ch;
  font-size: clamp(32px, 5vw, 58px);
  line-height: 0.98;
}

p {
  max-width: 62ch;
  color: var(--dim);
  font-size: clamp(17px, 2vw, 22px);
  line-height: 1.45;
}

.hero-actions,
.game-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.stat-strip,
.stat-grid {
  display: grid;
  gap: 10px;
}

.stat-strip {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  align-self: end;
  max-width: 820px;
}

.stat-strip > div,
.stat-grid > div,
.panel,
.cutscene-caption {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.stat-strip > div,
.stat-grid > div {
  padding: 14px;
}

dt,
.section-heading span,
label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

dd,
.section-heading strong {
  color: var(--ink);
  font-size: clamp(22px, 3vw, 34px);
  font-weight: 900;
}

.panel {
  padding: clamp(16px, 2vw, 24px);
  background: var(--panel-strong);
}

.panel.narrow {
  max-width: 560px;
}

.step-meter {
  display: flex;
  gap: 8px;
}

.step-meter span {
  width: 34px;
  height: 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
}

.step-meter .active {
  background: var(--gold);
  box-shadow: 0 0 16px rgba(255, 213, 74, 0.65);
}

.cutscene-screen {
  align-items: end;
  gap: 18px;
  grid-template-columns: minmax(220px, 430px) minmax(0, 760px);
}

.cutscene-frame {
  margin: 0;
  width: min(100%, 980px);
  aspect-ratio: 557 / 941;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(0, 0, 0, 0.58);
  box-shadow: var(--shadow);
}

.cutscene-art {
  display: block;
  width: 300%;
  height: auto;
  max-width: none;
  transform-origin: 0 0;
}

.crop-left .cutscene-art {
  transform: translateX(0);
}

.crop-center .cutscene-art {
  transform: translateX(-33.3333%);
}

.crop-right .cutscene-art {
  transform: translateX(-66.6667%);
}

.cutscene-caption {
  display: grid;
  gap: 14px;
  max-width: 760px;
  padding: clamp(16px, 2vw, 24px);
}

.main-screen {
  align-items: stretch;
}

.main-grid {
  display: grid;
  grid-template-columns: minmax(360px, 1.15fr) minmax(340px, 1fr) minmax(260px, 0.62fr);
  gap: 16px;
  align-items: stretch;
}

.game-panel,
.data-panel,
.info-panel {
  display: grid;
  gap: 14px;
  align-content: start;
}

.section-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 12px;
}

.game-lane {
  position: relative;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: var(--radius);
  background:
    linear-gradient(180deg, rgba(2, 2, 4, 0.18), rgba(2, 2, 4, 0.86)),
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.16) 0 26px, rgba(0, 0, 0, 0.82) 26px 36px);
}

.lane-canvas {
  display: block;
  width: 100%;
  height: 100%;
  aspect-ratio: 16 / 9;
}

.timeline-ruler {
  position: absolute;
  left: 20px;
  right: 20px;
  bottom: 54px;
  height: 4px;
  background: linear-gradient(90deg, var(--magenta), var(--gold), var(--cyan));
  box-shadow: 0 0 18px rgba(27, 231, 255, 0.55);
}

.sprite {
  position: absolute;
  background-image: url("../assets/generated/sprites/sprite-atlas.png");
  background-repeat: no-repeat;
  background-size: 1536px 1024px;
  image-rendering: auto;
}

.hero {
  bottom: 62px;
  width: 138px;
  height: 202px;
  transition: left 180ms ease;
}

.hero.apprentice {
  background-position: -92px -36px;
}

.hero.rhythm-reader {
  background-position: -94px -284px;
}

.hero.bandleader {
  background-position: -96px -538px;
}

.pickup {
  bottom: 72px;
  width: 104px;
  height: 110px;
}

.note-one {
  left: 21%;
  background-position: -74px -792px;
}

.note-two {
  left: 62%;
  background-position: -334px -792px;
}

.hazard {
  bottom: 86px;
  width: 116px;
  height: 118px;
}

.hazard-one {
  left: 42%;
  background-position: -714px -780px;
}

.hazard-two {
  left: 74%;
  background-position: -990px -780px;
}

.goal {
  right: 6%;
  bottom: 48px;
  width: 132px;
  height: 238px;
  background-position: -1286px -688px;
}

.year-pin {
  position: absolute;
  top: 16px;
  translate: -50% 0;
  display: grid;
  gap: 2px;
  min-width: 94px;
  padding: 8px 10px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: var(--radius);
  background: rgba(0, 0, 0, 0.72);
  color: var(--ink);
  text-align: center;
}

.year-pin span {
  color: var(--cyan);
  font-size: 12px;
  font-weight: 900;
}

.data-chart {
  width: 100%;
  min-height: 250px;
}

.chart-axis {
  stroke: rgba(255, 248, 223, 0.22);
  stroke-width: 3;
}

.chart-life,
.chart-death {
  fill: none;
  stroke-width: 8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.chart-life {
  stroke: var(--cyan);
}

.chart-death {
  stroke: var(--gold);
}

.chart-marker {
  stroke: var(--magenta);
  stroke-width: 5;
  stroke-dasharray: 12 8;
}

.chart-label,
.chart-year {
  fill: var(--ink);
  font-size: 28px;
  font-weight: 900;
}

.chart-label-death {
  fill: var(--gold);
}

.stat-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.info-panel label {
  display: grid;
  gap: 6px;
}

select {
  min-height: 42px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(0, 0, 0, 0.72);
  color: var(--ink);
  padding: 8px 10px;
}

details {
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  padding-top: 12px;
}

summary {
  color: var(--gold);
  font-weight: 900;
  text-transform: uppercase;
  cursor: pointer;
}

.milestones,
.credit-lines {
  display: grid;
  gap: 10px;
  padding: 0;
  list-style: none;
}

.milestones li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--dim);
}

.milestones strong {
  color: var(--ink);
}

.settings-list {
  display: grid;
  gap: 10px;
}

.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  width: 100%;
  min-height: 54px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(0, 0, 0, 0.5);
  color: var(--ink);
  padding: 12px 14px;
  font-weight: 900;
}

.toggle {
  width: 54px;
  height: 28px;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  position: relative;
  flex: 0 0 auto;
}

.toggle::after {
  content: "";
  position: absolute;
  top: 4px;
  left: 4px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--ink);
  transition: transform 160ms ease;
}

.toggle.on {
  background: linear-gradient(90deg, var(--magenta), var(--cyan));
}

.toggle.on::after {
  transform: translateX(25px);
}

.storage-note {
  color: var(--muted);
  font-size: 14px;
}

.credit-lines li {
  border-left: 3px solid var(--gold);
  padding-left: 12px;
  color: var(--dim);
  line-height: 1.45;
}

[data-contrast="high"] {
  --panel: rgba(0, 0, 0, 0.9);
  --panel-strong: rgba(0, 0, 0, 0.96);
  --line: rgba(255, 255, 255, 0.48);
}

[data-motion="reduced"] .hero,
[data-motion="reduced"] .toggle::after {
  transition: none;
}

@media (max-width: 1100px) {
  .main-grid {
    grid-template-columns: 1fr 1fr;
  }

  .info-panel {
    grid-column: 1 / -1;
  }
}

@media (max-width: 760px) {
  .topbar {
    position: relative;
    align-items: flex-start;
    flex-direction: column;
  }

  .brand {
    font-size: 16px;
  }

  .nav {
    justify-content: flex-start;
  }

  .nav-btn,
  .btn {
    min-height: 40px;
    padding: 9px 10px;
    font-size: 12px;
  }

  .app-main {
    min-height: auto;
    padding: 14px;
  }

  .screen {
    min-height: auto;
  }

  .intro-screen,
  .tutorial-screen,
  .settings-screen,
  .credits-screen,
  .cutscene-screen,
  .main-grid {
    grid-template-columns: 1fr;
  }

  .stat-strip,
  .stat-grid {
    grid-template-columns: 1fr;
  }

  h1 {
    font-size: clamp(42px, 16vw, 72px);
  }

  .panel h1,
  .cutscene-caption h1 {
    font-size: clamp(30px, 10vw, 44px);
  }

  p {
    font-size: 16px;
  }

  .game-lane {
    min-height: 0;
  }

  .hero {
    scale: 0.7;
    transform-origin: bottom left;
  }

  .pickup,
  .hazard {
    scale: 0.72;
    transform-origin: bottom left;
  }

  .goal {
    scale: 0.68;
    transform-origin: bottom right;
  }

  .year-pin {
    min-width: 78px;
    font-size: 12px;
  }

  .cutscene-frame {
    width: min(100%, 360px);
  }

  .section-heading {
    align-items: start;
    flex-direction: column;
  }
}
