:root {
  color-scheme: light;
  --spd-red: #e3000f;
  --spd-dark: #290507;
  --ink: #202020;
  --paper: #f7f7f2;
  --paper-strong: #ffffff;
  --panel: rgba(255, 255, 252, 0.96);
  --line: rgba(32, 32, 32, 0.14);
  --line-strong: rgba(32, 32, 32, 0.22);
  --muted: rgba(32, 32, 32, 0.62);
  --gold: #d8ad44;
  --green: #5f9d72;
  --blue: #496d86;
  --shadow: 0 12px 30px rgba(39, 38, 34, 0.12);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  min-height: 100%;
  margin: 0;
}

body {
  overflow: hidden;
  background: #ecefe9;
  color: var(--ink);
}

body.legal-page {
  overflow: auto;
}

button,
a {
  font: inherit;
}

.game-shell {
  position: relative;
  width: 100vw;
  height: 100vh;
  min-height: 560px;
  overflow: hidden;
  background: #ecefe9;
}

#gameCanvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

.screen {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: grid;
  place-content: center;
  justify-items: start;
  gap: 16px;
  padding: clamp(24px, 5vw, 64px);
  background:
    linear-gradient(90deg, rgba(32, 32, 32, 0.91), rgba(32, 32, 32, 0.62) 52%, rgba(32, 32, 32, 0.2)),
    linear-gradient(135deg, rgba(227, 0, 15, 0.24), rgba(73, 109, 134, 0.22));
  color: #fff;
}

.screen[hidden],
.hud[hidden],
.dialog-panel[hidden],
.action-panel[hidden] {
  display: none;
}

.screen--active {
  display: grid;
}

.brand-mark {
  display: inline-grid;
  place-items: center;
  min-width: 84px;
  height: 50px;
  padding: 0 16px;
  background: var(--spd-red);
  color: #fff;
  font-weight: 900;
  font-size: 1.45rem;
  letter-spacing: 0;
}

.eyebrow {
  margin: 0;
  color: #f6d4d6;
  font-weight: 800;
  text-transform: uppercase;
  font-size: 0.8rem;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  max-width: 820px;
  font-size: clamp(3.2rem, 12vw, 8.8rem);
  line-height: 0.88;
  letter-spacing: 0;
}

.claim {
  max-width: 720px;
  color: #f0ebe0;
  font-size: clamp(1.45rem, 3vw, 2.3rem);
  font-weight: 850;
}

.intro {
  max-width: 680px;
  font-size: clamp(1rem, 2vw, 1.25rem);
  line-height: 1.5;
}

.start-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 10px;
}

.button,
.cta-card,
.icon-button {
  border: 0;
  cursor: pointer;
  transition:
    transform 160ms ease,
    box-shadow 160ms ease,
    background 160ms ease;
}

.button {
  min-height: 48px;
  padding: 0 20px;
  border-radius: 8px;
  font-weight: 850;
}

.button:hover,
.cta-card:hover,
.icon-button:hover {
  transform: translateY(-1px);
}

.button--primary {
  background: var(--spd-red);
  color: #fff;
  box-shadow: 0 10px 22px rgba(227, 0, 15, 0.22);
}

.button--secondary {
  background: rgba(255, 255, 255, 0.94);
  color: var(--ink);
}

.how-panel {
  display: grid;
  gap: 8px;
  max-width: 620px;
  padding: 14px 16px;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.12);
  line-height: 1.42;
}

.how-panel[hidden] {
  display: none;
}

.legal-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 8px;
  font-size: 0.86rem;
  font-weight: 800;
}

.legal-nav a,
.back-link,
.legal-content a {
  color: inherit;
  text-underline-offset: 0.18em;
}

.legal-nav a {
  color: rgba(255, 255, 255, 0.84);
}

.legal-nav a:hover,
.back-link:hover,
.legal-content a:hover {
  color: var(--spd-red);
}

.hud {
  position: absolute;
  top: 10px;
  left: 50%;
  z-index: 3;
  display: grid;
  grid-template-columns: minmax(360px, 1fr) auto;
  align-items: center;
  gap: 8px;
  width: min(1200px, calc(100vw - 20px));
  min-height: 54px;
  padding: 7px 8px;
  transform: translateX(-50%);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  pointer-events: none;
  backdrop-filter: blur(10px);
}

.hud__top,
.hud__bottom {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
}

.hud__top {
  grid-column: 2;
  grid-row: 1;
  justify-content: end;
  min-width: 0;
  overflow: hidden;
}

.hud__bottom {
  grid-column: 1;
  grid-row: 1;
  min-width: 0;
}

.stat,
.mission,
.counter {
  border-radius: 6px;
}

.stat {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-width: 0;
  min-height: 32px;
  padding: 0 7px;
  border: 1px solid rgba(32, 32, 32, 0.08);
  background: rgba(32, 32, 32, 0.035);
}

.stat--time {
  min-width: 78px;
}

.stat meter {
  display: none;
}

.stat span,
.mission span,
.counter {
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 750;
}

.stat strong {
  font-variant-numeric: tabular-nums;
  font-size: 0.86rem;
}

meter {
  width: 100%;
  height: 12px;
}

meter::-webkit-meter-bar {
  border: 0;
  border-radius: 999px;
  background: rgba(32, 32, 32, 0.12);
}

meter::-webkit-meter-optimum-value {
  border-radius: 999px;
  background: linear-gradient(90deg, var(--spd-red), #7c3438);
}

.icon-button {
  width: 36px;
  height: 36px;
  flex: 0 0 auto;
  border-radius: 8px;
  background: #2d2d2a;
  color: #fff;
  font-size: 1.05rem;
  pointer-events: auto;
}

.mission {
  display: grid;
  gap: 1px;
  min-height: 36px;
  min-width: 0;
  flex: 1 1 auto;
  padding: 0 4px;
}

.mission strong {
  font-size: 0.92rem;
}

.mission strong,
.mission span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.counter,
.seed-pill {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  min-height: 32px;
  padding: 0 8px;
  white-space: nowrap;
}

.seed-pill {
  border-radius: 6px;
  background: rgba(32, 32, 32, 0.045);
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 850;
}

.seed-pill span {
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

.action-panel {
  position: absolute;
  left: 50%;
  right: auto;
  top: auto;
  bottom: 10px;
  z-index: 3;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-items: center;
  gap: 9px;
  width: min(980px, calc(100vw - 20px));
  height: 114px;
  max-height: 114px;
  padding: 9px;
  transform: translateX(-50%);
  pointer-events: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
}

.action-panel__head,
.action-chip {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.9);
}

.action-panel__head {
  display: none;
}

.action-panel__head span {
  color: rgba(25, 17, 17, 0.68);
  font-size: 0.82rem;
  font-weight: 800;
}

.action-list {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  overflow-y: hidden;
  padding-bottom: 1px;
  scroll-snap-type: x proximity;
}

.action-chip {
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 5px;
  flex: 0 0 190px;
  height: 94px;
  padding: 10px 11px;
  border-color: var(--line-strong);
  background: rgba(255, 255, 255, 0.96);
  color: var(--ink);
  text-align: left;
  scroll-snap-align: start;
}

.action-chip:hover,
.action-chip:focus-visible {
  outline: 2px solid rgba(227, 0, 15, 0.28);
  background: #fff;
}

.action-chip:disabled {
  cursor: not-allowed;
  opacity: 0.56;
  transform: none;
}

.action-chip__type {
  color: #9d000a;
  font-size: 0.68rem;
  font-weight: 900;
  line-height: 1.1;
  text-transform: uppercase;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.action-chip__title {
  min-width: 0;
  overflow: hidden;
  color: #191111;
  font-size: 0.9rem;
  font-weight: 900;
  line-height: 1.18;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.action-chip__footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  min-width: 0;
}

.action-chip__cost {
  color: rgba(32, 32, 32, 0.76);
  font-size: 0.72rem;
  font-weight: 850;
  line-height: 1.1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.option-button__idea {
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 800;
  line-height: 1.28;
  overflow-wrap: anywhere;
}

.risk-signal {
  display: inline-flex;
  align-items: center;
  color: rgba(32, 32, 32, 0.82);
  font-size: 0;
  font-weight: 900;
  white-space: nowrap;
}

.risk-signal::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--green);
}

.risk-signal--medium::before {
  background: var(--gold);
}

.risk-signal--high::before {
  background: var(--spd-red);
}

.dialog-panel {
  position: absolute;
  left: 50%;
  bottom: 12px;
  z-index: 4;
  display: grid;
  grid-template-columns: 76px minmax(0, 1fr);
  gap: 16px;
  width: min(940px, calc(100vw - 24px));
  max-height: min(58vh, 440px);
  padding: 16px;
  transform: translateX(-50%);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  overflow: auto;
  backdrop-filter: blur(10px);
}

.portrait {
  position: relative;
  display: grid;
  place-items: center;
  width: 76px;
  height: 76px;
  overflow: hidden;
  border-radius: 8px;
  background: #2d2d2a;
  color: #fff;
  font-size: 2rem;
  font-weight: 900;
}

.portrait__image {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity 120ms ease;
}

.portrait__image[hidden] {
  display: none;
}

.portrait span {
  position: relative;
  z-index: 1;
}

.portrait--image-loaded .portrait__image {
  opacity: 1;
}

.portrait--image-loaded span {
  visibility: hidden;
}

.dialog-content {
  min-width: 0;
  overflow: auto;
}

.citizen-meta {
  color: var(--spd-red);
  font-weight: 850;
  font-size: 0.8rem;
  text-transform: uppercase;
}

.dialog-content h2 {
  font-size: clamp(1.3rem, 2vw, 1.8rem);
}

.citizen-line {
  margin-top: 8px;
  line-height: 1.45;
  color: rgba(32, 32, 32, 0.84);
}

.option-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-top: 16px;
}

.option-button {
  display: grid;
  align-content: start;
  gap: 8px;
  min-height: 148px;
  padding: 14px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.98);
  color: var(--ink);
  text-align: left;
  line-height: 1.38;
  font-weight: 780;
}

.option-button__title,
.option-button__text,
.option-button__idea,
.effect-preview {
  min-width: 0;
  overflow-wrap: anywhere;
}

.option-button__title {
  color: #a0000a;
  font-size: 0.98rem;
  font-weight: 900;
  line-height: 1.18;
}

.option-button__text {
  color: rgba(32, 32, 32, 0.88);
  font-size: 0.94rem;
  font-weight: 740;
}

.effect-preview {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 2px;
}

.effect-chip {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 2px 6px;
  border-radius: 6px;
  background: rgba(32, 32, 32, 0.07);
  color: rgba(32, 32, 32, 0.78);
  font-size: 0.7rem;
  font-weight: 900;
  line-height: 1.1;
  white-space: nowrap;
}

.effect-chip--up {
  background: rgba(68, 181, 108, 0.16);
  color: #16683a;
}

.effect-chip--down {
  background: rgba(227, 0, 15, 0.12);
  color: #9d000a;
}

.effect-chip--risk {
  background: rgba(255, 200, 87, 0.28);
  color: #6b4700;
}

.option-button:hover,
.option-button:focus-visible {
  outline: 3px solid rgba(227, 0, 15, 0.22);
  background: #fff;
}

.result-screen {
  overflow: auto;
  align-content: center;
}

.result-screen h2 {
  max-width: 820px;
  font-size: clamp(2.4rem, 8vw, 5.8rem);
  line-height: 0.95;
}

.result-grid,
.cta-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  width: min(760px, 100%);
}

.result-grid {
  grid-template-columns: repeat(6, minmax(0, 1fr));
  width: min(960px, 100%);
}

.result-grid > div,
.topic-report,
.cta-card {
  border: 1px solid rgba(255, 255, 255, 0.38);
  border-radius: 8px;
  background: rgba(41, 5, 7, 0.42);
  color: #fff;
}

.result-grid > div {
  display: grid;
  gap: 4px;
  padding: 14px;
}

.result-grid span {
  color: #ffe6e8;
  font-weight: 800;
  font-size: 0.8rem;
}

.result-grid strong {
  font-size: 2rem;
  font-variant-numeric: tabular-nums;
}

.topic-report {
  width: min(960px, 100%);
  padding: 14px;
  line-height: 1.35;
}

.cta-grid {
  margin-top: 6px;
}

.cta-card {
  display: grid;
  place-items: center;
  min-height: 72px;
  padding: 14px;
  color: #fff;
  text-align: center;
  text-decoration: none;
  font-weight: 850;
}

.cta-card:hover {
  background: rgba(41, 5, 7, 0.56);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.legal-shell {
  width: min(920px, calc(100% - 32px));
  margin: 0 auto;
  padding: clamp(24px, 6vw, 64px) 0;
}

.back-link {
  display: inline-flex;
  margin-bottom: 28px;
  color: var(--ink);
  font-weight: 850;
}

.legal-content {
  display: grid;
  gap: 24px;
  padding: clamp(22px, 5vw, 48px);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper-strong);
  box-shadow: var(--shadow);
}

.legal-content .eyebrow {
  color: var(--spd-red);
}

.legal-content h1 {
  max-width: 100%;
  font-size: clamp(2.4rem, 8vw, 5rem);
  line-height: 0.95;
}

.legal-content h2 {
  margin: 0 0 8px;
  color: var(--spd-dark);
  font-size: clamp(1.15rem, 2vw, 1.45rem);
  line-height: 1.2;
}

.legal-content section {
  display: grid;
  gap: 6px;
}

.legal-content p {
  line-height: 1.62;
}

.legal-content a {
  color: #a0000a;
}

@media (max-width: 1180px) {
  .hud {
    top: 8px;
    left: 8px;
    transform: none;
    grid-template-columns: 1fr;
    gap: 4px;
    width: calc(100vw - 16px);
    min-height: 0;
    padding: 6px;
  }

  .hud__top {
    grid-column: 1;
    grid-row: 2;
    justify-content: start;
    width: calc(100vw - 16px);
    overflow-x: auto;
    padding-bottom: 1px;
  }

  .hud__bottom {
    grid-column: 1;
    grid-row: 1;
    width: calc(100vw - 16px);
  }

  .stat {
    flex: 0 0 auto;
  }
}

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

  .game-shell {
    min-height: 100svh;
  }

  .mission span {
    display: none;
  }

  .counter {
    display: none;
  }

  .seed-pill {
    display: none;
  }

  .action-panel {
    top: auto;
    left: 8px;
    right: 8px;
    bottom: 8px;
    grid-template-columns: minmax(0, 1fr);
    width: calc(100vw - 16px);
    height: 118px;
    max-height: 118px;
    transform: none;
  }

  .action-list {
    display: flex;
    overflow-x: auto;
    overflow-y: hidden;
    scroll-snap-type: x mandatory;
  }

  .action-chip {
    flex: 0 0 min(190px, 58vw);
    height: 98px;
    scroll-snap-align: start;
  }

  .dialog-panel {
    grid-template-columns: 52px minmax(0, 1fr);
    bottom: 8px;
    width: calc(100vw - 16px);
    max-height: min(70svh, calc(100svh - 118px));
    padding: 12px;
    gap: 10px;
  }

  .portrait {
    width: 52px;
    height: 52px;
    font-size: 1.4rem;
  }

  .option-list {
    grid-template-columns: 1fr;
  }

  .option-button {
    min-height: 112px;
  }
}

@media (max-width: 560px) {
  .screen {
    justify-items: stretch;
    padding: 20px;
  }

  h1 {
    font-size: clamp(3rem, 18vw, 4.9rem);
  }

  .start-actions,
  .button {
    width: 100%;
  }

  .hud__top {
    gap: 6px;
  }

  .hud__top .stat:nth-of-type(n + 6) {
    display: none;
  }

  .hud__top .stat span {
    max-width: 9ch;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .stat {
    min-height: 28px;
    padding: 0 6px;
  }

  .stat span,
  .mission span,
  .counter {
    font-size: 0.72rem;
  }

  .stat strong {
    font-size: 0.8rem;
  }

  .mission strong {
    font-size: 0.84rem;
  }

  .result-grid,
  .cta-grid {
    grid-template-columns: 1fr;
  }

  .action-panel {
    height: 112px;
    max-height: 112px;
  }

  .dialog-panel {
    grid-template-columns: minmax(0, 1fr);
    max-height: min(72svh, calc(100svh - 112px));
  }

  .dialog-panel .portrait {
    display: none;
  }
}
