:root {
  color-scheme: dark;
  --bg: #05050a;
  --panel: rgba(5, 5, 10, 0.82);
  --panel-strong: rgba(5, 5, 10, 0.93);
  --text: #fff8e9;
  --muted: #bfc7d7;
  --ink: #05050a;
  --cyan: #18dfff;
  --magenta: #ff3fad;
  --yellow: #f7ee28;
  --red: #ff365c;
  --paper: #fff8e9;
  --line: rgba(255, 248, 233, 0.22);
  --shadow: 0 16px 44px rgba(0, 0, 0, 0.42);
  --radius: 8px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  overflow-x: hidden;
  overflow-y: auto;
  background: var(--bg);
  color: var(--text);
  letter-spacing: 0;
}

html[data-text-size="large"] {
  font-size: 18px;
}

button {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 248, 233, 0.08);
  color: var(--text);
  font: inherit;
  font-weight: 800;
  letter-spacing: 0;
  cursor: pointer;
}

button:hover,
button:focus-visible {
  border-color: var(--yellow);
  outline: 2px solid transparent;
  background: rgba(247, 238, 40, 0.16);
}

#app-canvas {
  position: fixed;
  inset: 0;
  display: block;
  width: 100vw;
  height: 100vh;
  z-index: 0;
}

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

.hud {
  position: fixed;
  left: 14px;
  bottom: 14px;
  z-index: 5;
  display: flex;
  gap: 10px;
  align-items: center;
  max-width: calc(100vw - 28px);
  padding: 8px 10px;
  border: 1px solid rgba(255, 248, 233, 0.16);
  border-radius: var(--radius);
  background: rgba(5, 5, 10, 0.72);
  color: var(--text);
  font-size: 0.78rem;
}

.hud span {
  color: var(--muted);
}

.screen-shell {
  position: relative;
  display: grid;
  min-height: 100vh;
  padding: 6rem clamp(1rem, 5vw, 4.5rem) 3rem;
  align-items: center;
}

.screen-art,
.screen-vignette {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
}

.screen-art {
  object-fit: cover;
  z-index: -3;
  filter: saturate(1.08) contrast(1.04);
}

.screen-vignette {
  z-index: -2;
  background:
    linear-gradient(90deg, rgba(5, 5, 10, 0.9), rgba(5, 5, 10, 0.55) 42%, rgba(5, 5, 10, 0.2)),
    linear-gradient(0deg, rgba(5, 5, 10, 0.84), transparent 45%, rgba(5, 5, 10, 0.2));
}

.screen-panel {
  width: min(680px, 100%);
  padding: 0;
  text-shadow: 0 2px 14px rgba(0, 0, 0, 0.52);
}

.screen-panel h1,
.stage-copy h1 {
  margin: 0;
  max-width: 11ch;
  font-family: Impact, "Arial Black", Haettenschweiler, sans-serif;
  font-size: 4.6rem;
  line-height: 0.92;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

.screen-panel p,
.stage-copy p {
  max-width: 58ch;
  margin: 1.1rem 0 0;
  color: var(--paper);
  font-size: 1.08rem;
  line-height: 1.55;
  font-weight: 700;
}

.button-row,
.topbar-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  align-items: center;
}

.button-row {
  margin-top: 1.4rem;
}

.button {
  padding: 0.72rem 1rem;
  min-width: 112px;
  background: var(--paper);
  color: var(--ink);
  box-shadow: 5px 5px 0 var(--magenta);
  text-transform: uppercase;
}

.button-primary {
  background: var(--yellow);
  box-shadow: 5px 5px 0 var(--cyan);
}

.headline-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.75rem;
  margin-top: 1.6rem;
  max-width: 720px;
}

.headline-grid.compact {
  grid-template-columns: repeat(3, minmax(120px, 1fr));
}

.headline-card,
.metric-card {
  display: grid;
  gap: 0.25rem;
  min-width: 0;
  padding: 0.85rem;
  border: 2px solid var(--ink);
  border-radius: var(--radius);
  background: var(--paper);
  color: var(--ink);
  box-shadow: 5px 5px 0 rgba(0, 0, 0, 0.58);
}

.headline-card span,
.metric-card span {
  font-size: 0.75rem;
  font-weight: 900;
  text-transform: uppercase;
}

.headline-card strong,
.metric-card strong {
  overflow-wrap: anywhere;
  font-size: 1.75rem;
  line-height: 1;
  font-family: Impact, "Arial Black", sans-serif;
}

.headline-card em,
.metric-card em {
  color: #5a102d;
  font-size: 0.8rem;
  font-style: normal;
  font-weight: 900;
}

.tutorial-progress {
  display: flex;
  gap: 0.55rem;
  margin-top: 1.5rem;
}

.tutorial-progress span {
  width: 42px;
  height: 8px;
  border-radius: 99px;
  background: rgba(255, 248, 233, 0.35);
}

.tutorial-progress .is-active {
  background: var(--yellow);
  box-shadow: 0 0 0 2px var(--ink), 3px 3px 0 var(--magenta);
}

.experience-shell {
  min-height: 100vh;
  padding: 1rem 1rem 1.2rem;
  overflow: auto;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 3;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin: 0 auto 1rem;
  max-width: 1180px;
  padding: 0.7rem 0.8rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(5, 5, 10, 0.78);
  backdrop-filter: blur(14px);
}

.topbar strong {
  font-family: Impact, "Arial Black", sans-serif;
  font-size: 1.35rem;
  text-transform: uppercase;
}

.topbar button {
  padding: 0.45rem 0.65rem;
  min-height: 36px;
  font-size: 0.86rem;
}

.main-stage,
.dashboard-grid {
  width: min(1180px, 100%);
  margin: 0 auto;
}

.main-stage {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(280px, 0.85fr);
  gap: 1rem;
  min-height: 360px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.stage-art {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center;
  opacity: 0.72;
}

.stage-art::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, rgba(5, 5, 10, 0.86), rgba(5, 5, 10, 0.42) 52%, rgba(5, 5, 10, 0.82));
}

.stage-copy,
.guide-card {
  position: relative;
  z-index: 1;
}

.stage-copy {
  padding: 2.4rem;
}

.mode-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  margin-top: 1.3rem;
}

.mode-tabs button {
  padding: 0.55rem 0.72rem;
  font-size: 0.85rem;
}

.mode-tabs .is-active {
  background: var(--yellow);
  color: var(--ink);
  box-shadow: 4px 4px 0 var(--magenta);
}

.guide-card {
  align-self: end;
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr);
  gap: 0.85rem;
  margin: 1rem;
  padding: 0.8rem;
  border: 1px solid rgba(255, 248, 233, 0.24);
  border-radius: var(--radius);
  background: rgba(5, 5, 10, 0.74);
}

.guide-card p {
  margin: 0;
  color: var(--paper);
  font-size: 0.95rem;
  line-height: 1.45;
}

.guide-sprite {
  display: block;
  width: 92px;
  height: 112px;
  background-image: url("../assets/sprites/switch-sprite.png");
  background-repeat: no-repeat;
  background-size: 600% 100%;
  background-position: 0 50%;
  animation: sprite-run 1s steps(5) infinite;
}

body[data-motion="off"] .guide-sprite {
  animation: none;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(240px, 0.7fr);
  gap: 1rem;
  margin-top: 1rem;
  padding-bottom: 2rem;
}

.chart-panel,
.metrics-panel,
.callout-panel,
.minigame-panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-strong);
  box-shadow: var(--shadow);
}

.chart-panel {
  min-width: 0;
  padding: 1rem;
}

.panel-heading {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: baseline;
  margin-bottom: 0.8rem;
}

.panel-heading h2 {
  margin: 0;
  font-family: Impact, "Arial Black", sans-serif;
  font-size: 1.65rem;
  text-transform: uppercase;
}

.panel-heading span {
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 800;
}

.metrics-panel {
  display: grid;
  gap: 0.75rem;
  align-content: start;
  padding: 1rem;
}

.callout-panel {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1px;
  overflow: hidden;
}

.callout-panel section {
  padding: 1rem;
  background: rgba(255, 248, 233, 0.055);
}

.callout-panel h3 {
  margin: 0 0 0.35rem;
  color: var(--yellow);
  font-family: Impact, "Arial Black", sans-serif;
  font-size: 1.25rem;
  text-transform: uppercase;
}

.callout-panel p {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}

.minigame-panel {
  position: relative;
  grid-column: 1 / -1;
  overflow: hidden;
  padding: 1rem;
}

.minigame-panel::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  background-image: var(--game-bg);
  background-position: center;
  background-size: cover;
  opacity: 0.2;
  filter: saturate(1.2) contrast(1.08);
}

.minigame-panel::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  background:
    linear-gradient(90deg, rgba(5, 5, 10, 0.88), rgba(5, 5, 10, 0.5)),
    repeating-linear-gradient(0deg, rgba(255, 248, 233, 0.04) 0 1px, transparent 1px 7px);
}

.minigame-panel > * {
  position: relative;
  z-index: 1;
}

.minigame-heading strong {
  color: var(--yellow);
  font-family: Impact, "Arial Black", sans-serif;
  font-size: 1.2rem;
  text-transform: uppercase;
}

.minigame-panel p {
  max-width: 70ch;
  margin: 0 0 0.85rem;
  color: var(--paper);
  font-weight: 750;
  line-height: 1.45;
}

.minigame-screen-card {
  display: grid;
  gap: 0.25rem;
  margin-bottom: 0.75rem;
  padding: 0.65rem 0.8rem;
  border: 1px solid rgba(255, 248, 233, 0.22);
  border-left: 6px solid var(--yellow);
  border-radius: var(--radius);
  background: rgba(5, 5, 10, 0.78);
}

.minigame-screen-card strong {
  color: var(--yellow);
  font-family: Impact, "Arial Black", sans-serif;
  font-size: 1.1rem;
  text-transform: uppercase;
}

.minigame-screen-card span {
  color: var(--paper);
  font-size: 0.9rem;
  font-weight: 750;
  line-height: 1.35;
}

.minigame-screen-card[data-minigame-screen="game-over"] {
  border-left-color: var(--magenta);
}

.minigame-screen-card[data-minigame-screen="game-over"] strong {
  color: var(--magenta);
}

.minigame-screen-card[data-minigame-screen="won"] {
  border-left-color: var(--cyan);
}

.minigame-screen-card[data-minigame-screen="won"] strong {
  color: var(--cyan);
}

.minigame-stage-row,
.minigame-hud,
.minigame-controls {
  display: grid;
  gap: 0.55rem;
}

.minigame-stage-row {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-bottom: 0.75rem;
}

.minigame-stage-row span,
.minigame-hud span {
  min-width: 0;
  border: 1px solid rgba(255, 248, 233, 0.18);
  border-radius: var(--radius);
  background: rgba(5, 5, 10, 0.76);
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 900;
  line-height: 1.15;
  text-align: center;
  text-transform: uppercase;
}

.minigame-stage-row span {
  padding: 0.5rem 0.45rem;
}

.minigame-stage-row .is-active {
  border-color: var(--yellow);
  background: var(--yellow);
  color: var(--ink);
  box-shadow: 4px 4px 0 var(--magenta);
}

.minigame-canvas {
  display: block;
  width: 100%;
  aspect-ratio: 2 / 1;
  max-height: 420px;
  border: 1px solid rgba(255, 248, 233, 0.2);
  border-radius: var(--radius);
  background: rgba(5, 5, 10, 0.84);
}

.minigame-hud {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-top: 0.65rem;
}

.minigame-hud span {
  padding: 0.55rem 0.45rem;
  color: var(--paper);
}

.minigame-controls {
  grid-template-columns: repeat(6, minmax(0, 1fr));
  margin-top: 0.7rem;
}

.minigame-controls button {
  min-width: 0;
  padding: 0.58rem 0.45rem;
  background: rgba(255, 248, 233, 0.1);
  text-transform: uppercase;
}

.minigame-controls [data-game-action="start"] {
  background: var(--paper);
  color: var(--ink);
  box-shadow: 4px 4px 0 var(--cyan);
}

.tsi-chart {
  display: block;
  width: 100%;
  min-height: 260px;
}

.chart-grid,
.chart-axis {
  stroke: rgba(255, 248, 233, 0.16);
  stroke-width: 1;
}

.chart-line {
  fill: none;
  stroke-width: 4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

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

.chart-line-2 {
  stroke: var(--yellow);
}

.chart-line-3 {
  stroke: var(--magenta);
}

.chart-label {
  font-size: 15px;
  font-weight: 900;
  paint-order: stroke;
  stroke: var(--ink);
  stroke-width: 4px;
}

.chart-label-1 {
  fill: var(--cyan);
}

.chart-label-2 {
  fill: var(--yellow);
}

.chart-label-3 {
  fill: var(--magenta);
}

.settings-list,
.credits-list {
  width: min(620px, 100%);
  margin: 1.4rem 0 0;
  padding: 0;
}

.settings-list {
  display: grid;
  gap: 0.75rem;
}

.setting-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 0.85rem;
  border: 1px solid rgba(255, 248, 233, 0.24);
  border-radius: var(--radius);
  background: rgba(5, 5, 10, 0.78);
}

.setting-row span {
  font-weight: 900;
}

.toggle,
.segmented button {
  padding: 0.45rem 0.7rem;
  min-width: 70px;
}

.toggle.is-on,
.segmented .is-active {
  background: var(--yellow);
  color: var(--ink);
  box-shadow: 4px 4px 0 var(--magenta);
}

.segmented {
  display: flex;
  gap: 0.45rem;
}

.credits-list {
  display: grid;
  gap: 0.6rem;
  list-style: none;
}

.credits-list li {
  padding: 0.85rem;
  border-left: 6px solid var(--yellow);
  background: rgba(5, 5, 10, 0.76);
  color: var(--paper);
  font-weight: 700;
  line-height: 1.45;
}

@keyframes sprite-run {
  to {
    background-position: 100% 50%;
  }
}

@media (max-width: 900px) {
  body {
    overflow: auto;
  }

  .screen-shell {
    min-height: 100svh;
    padding: 5rem 1rem 2.2rem;
    align-items: end;
  }

  .screen-vignette {
    background: linear-gradient(0deg, rgba(5, 5, 10, 0.94), rgba(5, 5, 10, 0.34) 70%);
  }

  .screen-panel h1,
  .stage-copy h1 {
    max-width: 12ch;
    font-size: 3rem;
  }

  .headline-grid,
  .headline-grid.compact,
  .dashboard-grid,
  .callout-panel,
  .minigame-stage-row,
  .minigame-hud,
  .main-stage {
    grid-template-columns: 1fr;
  }

  .minigame-controls {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .stage-copy {
    padding: 1.3rem;
  }

  .guide-card {
    margin: 0 1rem 1rem;
  }

  .topbar {
    position: static;
    align-items: flex-start;
    flex-direction: column;
  }

  .dashboard-grid {
    padding-bottom: 4rem;
  }
}

@media (max-width: 540px) {
  .screen-shell {
    padding: 4.5rem 0.8rem 2rem;
  }

  .screen-panel h1,
  .stage-copy h1 {
    font-size: 2.45rem;
  }

  .screen-panel p,
  .stage-copy p {
    font-size: 1rem;
  }

  .button,
  .button-row button {
    width: 100%;
  }

  .guide-card,
  .setting-row,
  .panel-heading {
    grid-template-columns: 1fr;
    flex-direction: column;
    align-items: stretch;
  }

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

  .guide-sprite {
    width: 82px;
    height: 100px;
  }

  .hud {
    display: none;
  }
}
