:root {
  color-scheme: dark;
  --ink: #f5f2e8;
  --paper: #ffffff;
  --muted: #c8c0af;
  --black: #050505;
  --panel: rgba(5, 5, 5, 0.72);
  --panel-solid: #101010;
  --line: rgba(255, 255, 255, 0.24);
  --yellow: #ffde2e;
  --cyan: #18d6ff;
  --magenta: #f044aa;
  --shadow: rgba(0, 0, 0, 0.5);
  font-family: Inter, "Arial Narrow", Arial, Helvetica, sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  min-height: 100%;
  margin: 0;
  background: var(--black);
  color: var(--ink);
}

body {
  overflow: hidden;
}

button,
input,
select {
  font: inherit;
}

button,
select {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--ink);
}

button {
  padding: 0 16px;
  font-weight: 800;
  cursor: pointer;
  text-transform: uppercase;
}

button:hover,
button:focus-visible,
select:focus-visible,
input:focus-visible {
  outline: 2px solid var(--yellow);
  outline-offset: 2px;
}

button.primary,
button.selected {
  border-color: var(--yellow);
  background: var(--yellow);
  color: #050505;
}

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

#app-canvas {
  position: fixed;
  inset: 0;
  z-index: 1;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
}

#app-shell {
  position: relative;
  z-index: 2;
}

.screen {
  position: fixed;
  inset: 0;
  display: grid;
  align-items: center;
  min-height: 100vh;
  padding: clamp(18px, 4vw, 56px);
  isolation: isolate;
}

.screen[hidden] {
  display: none;
}

.screen-art {
  position: absolute;
  inset: 0;
  z-index: -2;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0.88;
}

.screen::after {
  position: absolute;
  inset: 0;
  z-index: -1;
  content: "";
  background:
    linear-gradient(90deg, rgba(0, 0, 0, 0.82), rgba(0, 0, 0, 0.35) 52%, rgba(0, 0, 0, 0.72)),
    radial-gradient(circle at 74% 35%, rgba(255, 222, 46, 0.14), transparent 28%);
}

.main-screen::after {
  background:
    linear-gradient(90deg, rgba(0, 0, 0, 0.8), rgba(0, 0, 0, 0.15) 48%, rgba(0, 0, 0, 0.78)),
    linear-gradient(0deg, rgba(0, 0, 0, 0.68), transparent 48%);
}

.screen-copy,
.data-panel,
.trend-panel,
.tv-console,
.control-panel,
.what-if-panel,
.stat-strip,
.main-topbar {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  box-shadow: 0 18px 50px var(--shadow);
  backdrop-filter: blur(10px);
}

.screen-copy {
  width: min(710px, 100%);
  padding: clamp(22px, 4vw, 44px);
}

.intro-copy {
  align-self: center;
}

.narrow {
  width: min(620px, 100%);
}

.settings-copy,
.credits-copy {
  margin-left: auto;
  width: min(610px, 100%);
}

.brand-mark {
  margin: 0 0 18px;
  color: var(--yellow);
  font-size: clamp(0.84rem, 2vw, 1rem);
  font-weight: 900;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1,
h2 {
  max-width: 12ch;
  margin-bottom: 20px;
  color: var(--paper);
  font-size: clamp(2.4rem, 8vw, 6.8rem);
  line-height: 0.94;
  letter-spacing: 0;
  text-transform: uppercase;
}

h2 {
  font-size: clamp(2rem, 7vw, 5rem);
}

h3 {
  margin-bottom: 8px;
  font-size: clamp(1rem, 2vw, 1.35rem);
  line-height: 1.1;
  text-transform: uppercase;
}

.lede {
  max-width: 56ch;
  color: var(--muted);
  font-size: clamp(1rem, 2vw, 1.22rem);
  line-height: 1.5;
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 24px;
}

.stat-strip {
  position: fixed;
  right: clamp(18px, 4vw, 56px);
  bottom: clamp(18px, 4vw, 56px);
  display: flex;
  max-width: min(620px, calc(100vw - 36px));
  flex-wrap: wrap;
  gap: 10px;
  padding: 12px;
}

.stat-strip span {
  border-left: 4px solid var(--yellow);
  padding: 6px 14px 6px 10px;
  color: var(--muted);
}

.stat-strip strong {
  color: var(--paper);
}

.tutorial-steps {
  display: grid;
  gap: 10px;
  padding-left: 22px;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.35;
}

.tutorial-steps li {
  padding-left: 8px;
}

.tutorial-steps li.active {
  color: var(--paper);
  font-weight: 900;
}

.main-screen {
  grid-template-columns: minmax(280px, 360px) 1fr minmax(280px, 390px);
  grid-template-rows: auto 1fr;
  gap: 18px;
  align-items: start;
}

.main-topbar {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px;
}

.main-topbar h2 {
  max-width: none;
  margin: 0;
  font-size: clamp(1.2rem, 3vw, 2.2rem);
  line-height: 1;
}

.left-stack {
  grid-column: 1;
  grid-row: 2;
  display: grid;
  gap: 14px;
  align-self: start;
}

.control-panel,
.what-if-panel {
  display: grid;
  gap: 14px;
  width: 100%;
  padding: 14px;
}

.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.segmented button {
  min-width: 0;
  padding-inline: 8px;
}

.slider-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-weight: 800;
  text-transform: uppercase;
}

.slider-row.compact {
  grid-template-columns: auto 1fr 28px;
  font-size: 0.88rem;
}

input[type="range"] {
  accent-color: var(--yellow);
}

.what-if-panel {
  gap: 10px;
}

.panel-heading.compact h3 {
  margin-bottom: 4px;
  color: var(--yellow);
  font-size: 1rem;
}

.panel-heading.compact p {
  margin-bottom: 0;
  font-size: 0.78rem;
}

.scenario-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}

.scenario-grid button {
  min-width: 0;
  min-height: 36px;
  padding-inline: 8px;
  font-size: 0.78rem;
}

.scenario-grid button:first-child {
  grid-column: 1 / -1;
}

.data-panel {
  grid-column: 3;
  grid-row: 2;
  align-self: start;
  padding: 16px;
}

.tv-console {
  grid-column: 2;
  grid-row: 2;
  align-self: center;
  position: relative;
  width: min(100%, 680px);
  aspect-ratio: 3 / 2;
  justify-self: center;
  border-color: rgba(255, 222, 46, 0.28);
  background:
    radial-gradient(circle at 50% 42%, rgba(24, 214, 255, 0.13), transparent 34%),
    linear-gradient(180deg, rgba(4, 4, 4, 0.34), rgba(4, 4, 4, 0.82));
  box-shadow: 0 26px 70px rgba(0, 0, 0, 0.72);
}

.tv-channel-button {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: block;
  width: 100%;
  height: 100%;
  min-height: 0;
  border: 0;
  padding: 0;
  background: transparent;
  color: var(--yellow);
  text-align: left;
}

.tv-channel-button:hover,
.tv-channel-button:focus-visible {
  outline-offset: 6px;
}

.tv-channel-button span {
  position: absolute;
  left: 20%;
  top: 12%;
  border: 1px solid rgba(255, 222, 46, 0.48);
  border-radius: 3px;
  padding: 3px 7px;
  background: rgba(0, 0, 0, 0.72);
  font-size: 0.68rem;
  letter-spacing: 0;
  line-height: 1;
}

.tv-screen {
  position: absolute;
  left: 17.5%;
  top: 17.5%;
  width: 54%;
  height: 50%;
  overflow: hidden;
  border-radius: 9% / 12%;
  background:
    repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.055) 0 1px, transparent 1px 4px),
    radial-gradient(circle at 50% 46%, rgba(24, 214, 255, 0.08), rgba(5, 35, 32, 0.56) 42%, rgba(0, 0, 0, 0.82));
  box-shadow: inset 0 0 34px rgba(0, 0, 0, 0.94), inset 0 0 22px rgba(24, 214, 255, 0.18);
}

.tv-screen::after {
  position: absolute;
  inset: 0;
  z-index: 3;
  content: "";
  background: linear-gradient(115deg, transparent 0 44%, rgba(255, 255, 255, 0.1) 46%, transparent 54%);
  mix-blend-mode: screen;
  pointer-events: none;
}

#arcade-canvas {
  position: absolute;
  inset: 0;
  z-index: 0;
  width: 100%;
  height: 100%;
  display: block;
}

.tv-broadcast-image {
  position: absolute;
  inset: 0;
  z-index: 1;
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.tv-broadcast-image[hidden] {
  display: none;
}

#simulation-summary {
  position: absolute;
  left: 18px;
  right: 18px;
  bottom: 32px;
  z-index: 4;
  color: rgba(245, 242, 232, 0.72);
  font-size: 0.78rem;
  font-weight: 800;
  line-height: 1.25;
  text-transform: uppercase;
  text-shadow: 0 0 6px rgba(0, 0, 0, 0.88);
}

body:not([data-tv-channel="arcade"]) #simulation-summary {
  display: none;
}

.tv-ticker {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 5;
  height: 25px;
  overflow: hidden;
  border-top: 1px solid rgba(255, 222, 46, 0.34);
  background: rgba(0, 0, 0, 0.78);
  color: var(--yellow);
  font-size: 0.72rem;
  font-weight: 900;
  line-height: 25px;
  text-transform: uppercase;
  white-space: nowrap;
}

.tv-ticker span {
  display: inline-block;
  min-width: 100%;
  padding-left: 100%;
  animation: ticker-scroll 11s linear infinite;
}

@keyframes ticker-scroll {
  from {
    transform: translateX(0);
  }

  to {
    transform: translateX(-100%);
  }
}

.tv-frame {
  position: absolute;
  inset: 0;
  z-index: 2;
  width: 100%;
  height: 100%;
  object-fit: contain;
  filter: drop-shadow(0 24px 30px rgba(0, 0, 0, 0.55));
  pointer-events: none;
}

.panel-heading p {
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.4;
}

.ranking-list {
  display: grid;
  gap: 8px;
  margin: 14px 0 0;
  padding: 0;
  list-style: none;
}

.ranking-list li {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.14);
  padding-top: 8px;
}

.ranking-list span:first-child {
  color: var(--yellow);
  font-weight: 900;
}

.ranking-list strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ranking-list span:last-child {
  color: var(--cyan);
  font-weight: 900;
}

.trend-panel {
  grid-column: 1;
  grid-row: 2;
  align-self: end;
  display: grid;
  gap: 8px;
  width: 100%;
  padding: 14px;
}

.trend-panel label {
  color: var(--yellow);
  font-weight: 900;
  text-transform: uppercase;
}

.trend-panel select {
  width: 100%;
  padding: 0 10px;
  background: var(--panel-solid);
}

.trend-panel svg {
  width: 100%;
  height: auto;
  min-height: 112px;
}

.chart-baseline {
  stroke: rgba(255, 255, 255, 0.25);
  stroke-width: 1;
}

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

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

#trend-caption {
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.35;
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.settings-grid label {
  display: flex;
  align-items: center;
  min-height: 48px;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 10px;
  background: rgba(255, 255, 255, 0.08);
  font-weight: 900;
  text-transform: uppercase;
}

.settings-grid input {
  width: 18px;
  height: 18px;
  accent-color: var(--yellow);
}

.credit-list {
  display: grid;
  gap: 12px;
  margin: 0;
  padding-left: 20px;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.45;
}

#status-line {
  position: fixed;
  right: 12px;
  bottom: 10px;
  z-index: 5;
  color: rgba(255, 255, 255, 0.72);
  font-size: 0.78rem;
}

.high-contrast {
  --panel: rgba(0, 0, 0, 0.9);
  --muted: #ffffff;
  --line: rgba(255, 222, 46, 0.55);
}

.labels-muted .ranking-list span:last-child,
.labels-muted #trend-caption {
  opacity: 0.55;
}

.reduced-motion .tv-ticker span {
  animation: none;
  transform: none;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
  }
}

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

  .screen {
    position: relative;
    min-height: 100svh;
  }

  .main-screen {
    grid-template-columns: 1fr;
    grid-template-rows: auto;
    padding-bottom: 120px;
  }

  .main-topbar,
  .left-stack,
  .control-panel,
  .what-if-panel,
  .data-panel,
  .tv-console,
  .trend-panel {
    grid-column: 1;
    grid-row: auto;
  }

  .tv-console {
    width: min(100%, 720px);
    margin: 2px auto;
  }

  .data-panel {
    margin-top: 0;
  }

  .stat-strip {
    position: static;
    align-self: end;
    margin-top: 16px;
  }

  h1,
  h2 {
    max-width: 11ch;
  }
}

@media (max-width: 620px) {
  .screen {
    padding: 14px;
  }

  .screen-copy,
  .data-panel,
  .trend-panel,
  .control-panel,
  .what-if-panel,
  .main-topbar {
    border-radius: 4px;
  }

  .screen-copy {
    padding: 18px;
  }

  .settings-grid,
  .segmented,
  .slider-row,
  .scenario-grid,
  .ranking-list li {
    grid-template-columns: 1fr;
  }

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

  .main-topbar h2 {
    order: -1;
    width: 100%;
  }

  .main-topbar,
  .button-row {
    flex-direction: column;
  }

  button,
  select {
    width: 100%;
  }

  .ranking-list strong {
    white-space: normal;
  }

  #status-line {
    left: 12px;
    right: auto;
  }
}
