:root {
  color-scheme: dark;
  --paper: #f4eed8;
  --ink: #12100d;
  --copy: #fff8dc;
  --green: #9cff57;
  --amber: #ffb13b;
  --pink: #ff4f8f;
  --cyan: #42f4ff;
  --panel: rgba(15, 13, 10, 0.78);
  --panel-solid: rgba(15, 13, 10, 0.93);
  --border: rgba(244, 238, 216, 0.62);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--ink);
  font-family: "Courier New", Courier, monospace;
  letter-spacing: 0;
}

button,
select,
input {
  font: inherit;
}

button {
  min-height: 44px;
  border: 2px solid var(--copy);
  background: var(--copy);
  color: var(--ink);
  box-shadow: 4px 4px 0 var(--ink);
  cursor: pointer;
  font-weight: 800;
  text-transform: uppercase;
}

button:hover,
button:focus-visible {
  background: var(--green);
  outline: 3px solid var(--amber);
  outline-offset: 2px;
}

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

#app-shell {
  position: relative;
  min-height: 100vh;
  overflow: hidden;
  color: var(--copy);
  background: var(--ink);
}

#screen-art,
#app-canvas,
.toner-overlay {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
}

#screen-art {
  object-fit: cover;
  filter: contrast(1.04) saturate(0.96);
}

#app-canvas {
  z-index: 1;
  pointer-events: none;
}

.toner-overlay {
  z-index: 2;
  pointer-events: none;
  background:
    repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.07) 0 1px, transparent 1px 4px),
    radial-gradient(circle at 20% 18%, rgba(156, 255, 87, 0.12), transparent 24%),
    radial-gradient(circle at 82% 70%, rgba(255, 177, 59, 0.12), transparent 28%);
  mix-blend-mode: screen;
}

.top-bar {
  position: relative;
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem clamp(1rem, 3vw, 2rem);
  text-transform: uppercase;
}

#status-line {
  max-width: 42rem;
  margin: 0;
  color: var(--green);
  font-size: clamp(0.72rem, 1.4vw, 0.95rem);
  text-shadow: 2px 2px 0 var(--ink);
}

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

h1 {
  margin-bottom: 0;
  color: var(--paper);
  font-size: clamp(1rem, 2.5vw, 1.7rem);
  text-align: right;
  text-shadow: 3px 3px 0 var(--ink);
}

h2 {
  color: var(--paper);
  font-size: clamp(1.55rem, 4vw, 3.5rem);
  line-height: 1;
  text-transform: uppercase;
}

#screen-root {
  position: relative;
  z-index: 3;
  min-height: calc(100vh - 5rem);
  padding: clamp(1rem, 3vw, 2rem);
  display: flex;
  align-items: center;
  justify-content: center;
}

.panel {
  border: 2px solid var(--border);
  background: var(--panel);
  box-shadow: 8px 8px 0 rgba(0, 0, 0, 0.86);
  backdrop-filter: blur(3px);
}

.hero-panel,
.compact-panel {
  width: min(760px, 100%);
  padding: clamp(1.2rem, 4vw, 2.3rem);
}

.hero-panel p,
.compact-panel p {
  max-width: 58ch;
  line-height: 1.55;
  font-size: clamp(0.95rem, 1.5vw, 1.1rem);
}

.kicker,
.step-count {
  color: var(--green);
  font-weight: 900;
  text-transform: uppercase;
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
  margin-top: 1rem;
}

.game-layout {
  width: min(1240px, 100%);
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(280px, 0.85fr);
  gap: 1rem;
  align-items: stretch;
}

.game-board,
.data-panel,
.guide-panel {
  padding: 1rem;
}

.game-board {
  min-height: 370px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

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

.lane {
  min-height: 250px;
  display: grid;
  grid-template-columns: minmax(150px, 220px) minmax(0, 1fr);
  gap: 1rem;
  align-items: center;
}

.courier-sprite {
  width: min(34vw, 220px);
  aspect-ratio: 1;
  object-fit: contain;
  filter: drop-shadow(6px 6px 0 rgba(0, 0, 0, 0.85));
}

.lane-copy p {
  line-height: 1.45;
}

.sector-list {
  display: grid;
  gap: 0.55rem;
}

.sector-list.small {
  margin-top: 0.35rem;
}

.sector-row {
  width: 100%;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.75rem;
  align-items: center;
  min-height: 48px;
  padding: 0.55rem 0.7rem;
  text-align: left;
  text-transform: none;
}

.sector-row span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sector-row.high {
  border-color: var(--pink);
}

.sector-row.medium {
  border-color: var(--amber);
}

.sector-row.low {
  border-color: var(--green);
}

dl {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.75rem;
  margin: 0 0 1rem;
}

dl div {
  border: 1px solid var(--border);
  padding: 0.75rem;
  background: rgba(255, 248, 220, 0.08);
}

dt {
  color: var(--green);
  text-transform: uppercase;
}

dd {
  margin: 0.2rem 0 0;
  font-size: 1.4rem;
  font-weight: 900;
}

.collected-list {
  display: grid;
  gap: 0.4rem;
  margin: 0;
  padding-left: 1.2rem;
}

.collected-list li {
  line-height: 1.35;
}

.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: 56px;
  border-top: 1px solid var(--border);
  color: var(--paper);
  font-weight: 800;
}

input[type="checkbox"] {
  width: 28px;
  height: 28px;
  accent-color: var(--green);
}

select {
  min-height: 42px;
  border: 2px solid var(--copy);
  background: var(--ink);
  color: var(--copy);
  padding: 0 0.5rem;
}

.cutscene-panel {
  width: min(1080px, 100%);
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(280px, 0.8fr);
  gap: 1rem;
  align-items: end;
}

.cutscene-panel img {
  width: 100%;
  display: block;
  border: 2px solid var(--border);
  box-shadow: 8px 8px 0 rgba(0, 0, 0, 0.86);
}

.cutscene-copy {
  padding: 1rem;
}

.cutscene-copy h2 {
  font-size: clamp(1.3rem, 2.5vw, 2.2rem);
}

@media (max-width: 780px) {
  .top-bar {
    display: block;
  }

  h1 {
    margin-top: 0.35rem;
    text-align: left;
  }

  #screen-root {
    align-items: flex-start;
  }

  .game-layout,
  .cutscene-panel,
  .lane {
    grid-template-columns: 1fr;
  }

  .game-board {
    min-height: auto;
  }

  .courier-sprite {
    width: min(58vw, 220px);
    justify-self: center;
  }

  dl {
    grid-template-columns: 1fr;
  }

  .sector-row span {
    white-space: normal;
  }
}

@media (prefers-reduced-motion: reduce) {
  .toner-overlay {
    background: repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.05) 0 1px, transparent 1px 5px);
  }
}
