:root {
  color-scheme: dark;
  --bg: #050706;
  --surface: #0b0f0c;
  --surface-raised: #121713;
  --surface-active: #171d17;
  --text: #f1f3ec;
  --text-muted: #858d86;
  --line: rgba(234, 242, 232, 0.18);
  --line-strong: rgba(234, 242, 232, 0.28);
  --acid: #b9ff32;
  --acid-soft: rgba(185, 255, 50, 0.12);
  --danger: #ff594d;
  --radius: 3px;
  --space: clamp(20px, 3vw, 48px);
  --font-display: "Segoe UI Variable Display", "Segoe UI", Arial, sans-serif;
  --font-body: "Segoe UI Variable Text", "Segoe UI", Arial, sans-serif;
  --font-numeric: "Bahnschrift", "Segoe UI Variable Display", "Segoe UI", sans-serif;
  --ease: cubic-bezier(.2, .75, .22, 1);
}

* { box-sizing: border-box; }

html {
  min-width: 320px;
  background: var(--bg);
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  overflow-x: hidden;
  color: var(--text);
  background:
    radial-gradient(circle at 76% 18%, rgba(185, 255, 50, .035), transparent 30%),
    linear-gradient(180deg, #070a08 0%, var(--bg) 62%);
  font: 430 15px/1.48 var(--font-body);
  letter-spacing: -.005em;
}

button, input, textarea { font: inherit; }
button { color: inherit; }
button:focus-visible, a:focus-visible, [tabindex]:focus-visible {
  outline: 2px solid var(--acid);
  outline-offset: 4px;
}

[hidden] { display: none !important; }

.skip-link {
  position: fixed;
  z-index: 100;
  top: 8px;
  left: 8px;
  padding: 10px 14px;
  color: #050706;
  background: var(--acid);
  transform: translateY(-140%);
}
.skip-link:focus { transform: translateY(0); }

.grain {
  position: fixed;
  z-index: 20;
  inset: 0;
  pointer-events: none;
  opacity: .22;
  mix-blend-mode: soft-light;
  background-image:
    repeating-radial-gradient(circle at 0 0, transparent 0, rgba(255,255,255,.1) .6px, transparent 1.2px, transparent 4px);
  background-size: 7px 7px;
}

.topbar {
  position: fixed;
  z-index: 30;
  top: 0;
  right: 0;
  left: 0;
  height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 clamp(20px, 3.5vw, 64px);
  border-bottom: 1px solid var(--line);
  background: rgba(5, 7, 6, .78);
  backdrop-filter: blur(14px);
}

.wordmark,
.profile-control,
.rail button,
.close-control,
.back-control,
.text-action {
  border: 0;
  padding: 0;
  background: none;
  cursor: pointer;
}

.wordmark {
  font-family: var(--font-numeric);
  font-size: 23px;
  font-weight: 900;
  letter-spacing: -.06em;
}
.wordmark__signal { margin-left: 7px; color: var(--acid); font-size: 9px; vertical-align: top; }

.topbar__status { display: flex; align-items: center; gap: 24px; }
.session-state { color: var(--text-muted); font-size: 11px; letter-spacing: .08em; text-transform: uppercase; }
.session-state i, .profile-identity__state i {
  display: inline-block;
  width: 6px;
  height: 6px;
  margin-right: 8px;
  border-radius: 50%;
  background: var(--acid);
  box-shadow: 0 0 12px rgba(185,255,50,.65);
}
.profile-control { font-size: 13px; border-bottom: 1px solid var(--text); padding-bottom: 2px; }

.rail {
  position: fixed;
  z-index: 15;
  top: 72px;
  bottom: 0;
  left: 0;
  width: 72px;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 28px 0;
  border-right: 1px solid var(--line);
}
.rail__label { writing-mode: vertical-rl; color: var(--text-muted); font: 10px/1 monospace; letter-spacing: .18em; }
.rail__line { width: 1px; flex: 1; min-height: 40px; margin: 22px 0; background: var(--line); }
.rail button { margin: 15px 0; color: var(--text-muted); font-size: 9px; letter-spacing: .12em; text-transform: uppercase; writing-mode: vertical-rl; }
.rail button:hover { color: var(--acid); }

main { padding-top: 72px; padding-left: 72px; }
.screen {
  position: relative;
  min-height: calc(100svh - 72px);
  padding: clamp(32px, 5vw, 76px) clamp(24px, 5vw, 84px);
  background-image: linear-gradient(rgba(255,255,255,.018) 1px, transparent 1px);
  background-size: 100% 72px;
  animation: screen-in 420ms var(--ease) both;
}

.eyebrow,
.panel__label,
.terminal-code,
.entry__signal,
.art-note,
.demo-label,
.paywall-note {
  margin: 0;
  color: var(--text-muted);
  font: 680 10px/1.2 var(--font-body);
  letter-spacing: .145em;
  text-transform: uppercase;
}

.button {
  min-width: 170px;
  min-height: 52px;
  padding: 14px 24px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: transparent;
  color: var(--text);
  font-size: 11px;
  font-weight: 750;
  letter-spacing: .075em;
  text-transform: uppercase;
  cursor: pointer;
  transition: transform 180ms var(--ease), background 180ms, border-color 180ms, color 180ms;
}
.button:hover:not(:disabled) { transform: translateY(-2px); }
.button--acid { border-color: var(--acid); background: var(--acid); color: #090c08; box-shadow: 0 0 28px rgba(185,255,50,.10); }
.button--acid:hover:not(:disabled) { box-shadow: 0 0 34px rgba(185,255,50,.20); }
.button--quiet:hover:not(:disabled) { border-color: rgba(185,255,50,.45); }
.button:disabled { cursor: not-allowed; opacity: .58; }
.text-action { width: fit-content; color: var(--text-muted); font-size: 12px; text-decoration: underline; text-underline-offset: 4px; }
.text-action:hover { color: var(--acid); }

/* Entry */
.screen--entry { display: grid; align-items: center; overflow: hidden; padding-block: clamp(30px, 4vw, 58px); }
html:not([data-initial-view="entry"]) .screen--entry:not([aria-hidden="false"]) { display: none; }
.screen--entry::before {
  content: "";
  position: absolute;
  inset: 0 0 0 50%;
  pointer-events: none;
  background: linear-gradient(135deg, rgba(185,255,50,.025), transparent 58%);
}
.screen--entry::after {
  content: "";
  position: absolute;
  right: 4%;
  bottom: 8%;
  width: min(30vw, 430px);
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(185,255,50,.42));
}
.entry__layout { position: relative; z-index: 1; width: min(1260px, 100%); margin: auto; display: grid; grid-template-columns: minmax(430px, .88fr) minmax(520px, 1.12fr); align-items: center; gap: clamp(54px, 7vw, 110px); }
.entry__core { min-width: 0; }
.entry__core h1 {
  margin: 10px 0 0;
  font: 840 clamp(94px, 10.5vw, 154px)/.82 var(--font-display);
  letter-spacing: -.072em;
}
.entry__line { margin: clamp(30px, 3vw, 44px) 0 18px; font: 610 clamp(31px, 3.3vw, 50px)/1.03 var(--font-display); letter-spacing: -.04em; }
.entry__line span { color: var(--acid); }
.entry__promise { max-width: 440px; margin: 0 0 30px; color: var(--text-muted); font-size: 14px; line-height: 1.55; }
.entry__actions { display: flex; gap: 12px; }
.entry__meta { display: flex; gap: 22px; margin-top: 29px; color: var(--text-muted); font: 650 9px/1 var(--font-body); letter-spacing: .11em; text-transform: uppercase; }
.entry__meta span { padding-left: 11px; border-left: 1px solid var(--line-strong); }
.entry-world { position: relative; width: 100%; min-height: min(620px, calc(100svh - 160px)); display: grid; grid-template-rows: auto 1fr auto; border: 1px solid var(--line-strong); background: linear-gradient(145deg, rgba(18,24,19,.96), rgba(7,10,8,.98)); box-shadow: 0 34px 100px rgba(0,0,0,.35); }
.entry-world::before { content: ""; position: absolute; inset: 11% 8% 18%; pointer-events: none; border: 1px solid rgba(185,255,50,.08); background: radial-gradient(circle at 50% 28%, rgba(185,255,50,.06), transparent 42%); }
.entry-world__head { position: relative; z-index: 1; display: flex; justify-content: space-between; padding: 18px 20px; border-bottom: 1px solid var(--line); color: var(--text-muted); font-size: 9px; letter-spacing: .12em; text-transform: uppercase; }
.entry-world__head b { color: var(--text); font: 600 11px/1 var(--font-numeric); }
.entry-world__scene { position: relative; z-index: 1; align-self: center; width: min(82%, 470px); margin: auto; }
.entry-world__identity { display: flex; align-items: center; gap: 13px; margin-bottom: 34px; }
.entry-world__identity i, .entry-world__cast i { display: grid; place-items: center; border: 1px solid rgba(185,255,50,.35); color: var(--acid); font: 700 17px/1 var(--font-numeric); font-style: normal; }
.entry-world__identity i { width: 46px; height: 46px; background: var(--acid-soft); }
.entry-world__identity strong, .entry-world__identity span { display: block; }
.entry-world__identity strong { font-size: 17px; }
.entry-world__identity span { margin-top: 2px; color: var(--text-muted); font-size: 10px; }
.entry-world__messages { display: flex; flex-direction: column; gap: 9px; }
.entry-world__bubble { width: fit-content; max-width: 78%; margin: 0; padding: 13px 15px; border: 1px solid var(--line); background: var(--surface-active); font-size: 14px; }
.entry-world__bubble--player { align-self: flex-end; border-color: rgba(185,255,50,.24); background: var(--acid-soft); }
.entry-world__signal { display: flex; gap: 5px; margin-top: 25px; }
.entry-world__signal span { width: 5px; height: 5px; border-radius: 50%; background: var(--text-muted); animation: typing 1.2s infinite; }
.entry-world__signal span:nth-child(2) { animation-delay: 120ms; }.entry-world__signal span:nth-child(3) { animation-delay: 240ms; }
.entry-world__cast { position: relative; z-index: 1; display: grid; grid-template-columns: repeat(3, 1fr); border-top: 1px solid var(--line); }
.entry-world__cast span { display: flex; align-items: center; gap: 10px; padding: 16px 18px; border-right: 1px solid var(--line); color: var(--text-muted); font-size: 11px; }
.entry-world__cast span:last-child { border-right: 0; }
.entry-world__cast i { width: 27px; height: 27px; border-color: var(--line); color: var(--text-muted); font-size: 11px; }
.entry-world__cast .is-live { color: var(--text); background: rgba(185,255,50,.03); }
.entry-world__cast .is-live i { border-color: rgba(185,255,50,.35); color: var(--acid); }

/* Shared headings */
.section-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 30px; margin-bottom: clamp(24px, 3vw, 42px); }
.section-head h2 { margin: 9px 0 0; font: 820 clamp(46px, 6vw, 92px)/.92 var(--font-display); letter-spacing: -.045em; }
.close-control { width: 44px; height: 44px; color: var(--text-muted); font-size: 32px; line-height: 1; }
.close-control:hover { color: var(--acid); }

/* Profile */
.screen--profile { display: flex; flex-direction: column; padding-block: clamp(24px, 3.2vw, 44px); overflow: hidden; }
.screen--profile .section-head { width: min(1260px, 100%); margin: 0 auto 22px; }
.screen--profile .section-head h2 { font-size: clamp(48px, 5.2vw, 74px); }
.profile-grid { flex: 1; width: min(1260px, 100%); min-height: 0; margin: 0 auto; display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); grid-template-rows: minmax(220px, 1.05fr) minmax(190px, .9fr); gap: 1px; background: var(--line); border: 1px solid var(--line); }
.panel { min-height: 0; padding: clamp(22px, 2.1vw, 34px); background: linear-gradient(145deg, var(--surface-raised), var(--surface) 74%); }
.profile-identity { grid-column: span 4; grid-row: span 2; display: flex; flex-direction: column; }
.profile-stats { grid-column: span 5; }
.profile-progress { grid-column: span 3; }
.profile-recent { grid-column: 5 / span 5; overflow: hidden; }
.profile-identity strong { display: block; margin: clamp(26px, 4vh, 44px) 0 auto; font: 720 clamp(32px, 3.1vw, 48px)/1.04 var(--font-numeric); letter-spacing: .025em; overflow-wrap: anywhere; }
.profile-identity__state { margin-bottom: 18px; color: var(--text-muted); font-size: 12px; }
.link-status { min-height: 20px; color: var(--acid); font-size: 11px; }
.stat-primary { display: flex; align-items: baseline; gap: 15px; margin: 16px 0 clamp(24px, 4vh, 36px); }
.stat-primary strong { font: 780 clamp(68px, 7vw, 104px)/.8 var(--font-numeric); letter-spacing: -.055em; }
.stat-primary span { color: var(--text-muted); }
.stat-row { display: flex; gap: clamp(18px, 4vw, 58px); color: var(--text-muted); font-size: 11px; }
.stat-row b { display: block; margin-bottom: 6px; color: var(--text); font: 650 23px/1 var(--font-numeric); }
.profile-progress__row, .recent-run { display: flex; justify-content: space-between; gap: 16px; padding: clamp(12px, 1.8vh, 17px) 0; border-bottom: 1px solid var(--line); }
.profile-progress__row:last-child, .recent-run:last-child { border-bottom: 0; }
.profile-progress__row span:last-child, .recent-run > span:last-child { color: var(--text-muted); font-size: 11px; text-align: right; }
.recent-run strong, .recent-run small { display: block; }
.recent-run small { max-width: 390px; margin-top: 5px; color: var(--text-muted); }
.empty-state { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-top: 24px; color: var(--text-muted); }
.empty-state button { border: 0; background: none; color: var(--acid); cursor: pointer; }
.screen-actions { grid-column: span 3; display: flex; flex-direction: column; align-items: flex-start; justify-content: space-between; background: linear-gradient(145deg, var(--surface-active), var(--surface)); text-align: left; }
.screen-actions > strong { font: 700 clamp(30px, 2.8vw, 42px)/.98 var(--font-display); letter-spacing: -.04em; }
.screen-actions .button { width: 100%; }

/* Characters */
.screen--characters { padding: clamp(26px, 3vw, 42px) clamp(18px, 4vw, 66px); overflow: hidden; }
.screen--characters .section-head h2 { font-size: clamp(48px, 5.4vw, 78px); }
.section-head--wide { margin-bottom: clamp(22px, 2.5vw, 34px); }
.selection-counter { align-self: flex-end; color: var(--text-muted); font: 12px/1 monospace; }
.selection-counter b { color: var(--acid); font-size: 20px; }
.character-track { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: clamp(12px, 1.5vw, 24px); }
.character-card { position: relative; min-width: 0; border: 1px solid var(--line-strong); background: var(--surface); cursor: pointer; transition: transform 260ms var(--ease), opacity 260ms, border-color 180ms, background 180ms; }
.character-track:has(.character-card.is-selected) .character-card:not(.is-selected) { opacity: .48; transform: scale(.975); }
.character-card.is-selected { z-index: 2; border-color: var(--acid); transform: translateY(-7px); background: var(--surface-raised); box-shadow: 0 18px 60px rgba(0,0,0,.32); }
.character-card__art { position: relative; height: clamp(300px, 41vh, 372px); overflow: hidden; border-bottom: 1px solid var(--line); }
.character-art { background: #111511; isolation: isolate; }
.character-art::before {
  content: "";
  position: absolute;
  inset: 7% 13% -12%;
  z-index: -1;
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 47% 47% 8% 8%;
  background: radial-gradient(circle at 50% 22%, rgba(255,255,255,.13), transparent 12%), linear-gradient(150deg, rgba(255,255,255,.08), rgba(0,0,0,.3) 55%);
  filter: saturate(.35);
}
.character-art::after { content: attr(data-mark); position: absolute; right: -2%; bottom: -15%; color: rgba(241,243,236,.055); font: 900 clamp(170px, 24vw, 380px)/1 var(--font-display); letter-spacing: -.12em; }
.character-art--1 { background: linear-gradient(145deg, #182019, #080b09 62%); }
.character-art--2 { background: linear-gradient(145deg, #171b18, #090a09 60%); }
.character-art--3 { background: linear-gradient(145deg, #111713, #050706 62%); }
.character-art--1::before { transform: rotate(1.5deg); }
.character-art--2::before { inset-inline: 17%; transform: translateY(2%); }
.character-art--3::before { inset-inline: 11%; transform: rotate(-1.5deg); }
.character-card.is-selected .character-art { box-shadow: inset 0 -70px 90px rgba(185,255,50,.055); }
.character-card.is-selected .character-art::before { border-color: rgba(185,255,50,.28); }
.character-art__index, .character-art__signal { position: absolute; z-index: 2; top: 18px; color: var(--text-muted); font: 9px/1 monospace; letter-spacing: .14em; }
.character-art__index { left: 18px; color: var(--acid); }
.character-art__signal { right: 18px; }
.character-card__body { padding: clamp(16px, 1.7vw, 24px); }
.character-card__identity { display: flex; align-items: baseline; justify-content: space-between; }
.character-card h3 { margin: 0; font: 850 clamp(38px, 4.1vw, 64px)/.92 var(--font-display); letter-spacing: -.04em; }
.character-card__identity span { color: var(--acid); font: 13px/1 monospace; }
.character-card p { min-height: 36px; margin: 13px 0 17px; color: var(--text-muted); }
.character-card__choose { width: 100%; min-height: 44px; border: 1px solid var(--line); background: transparent; color: var(--text-muted); cursor: pointer; text-transform: uppercase; font-size: 10px; letter-spacing: .12em; }
.character-card.is-selected .character-card__choose { border-color: var(--acid); color: var(--acid); }
.character-dots { display: none; }
.art-note { margin-top: 18px; text-align: right; }
.art-note:empty { display: none; }

/* Situation */
.screen--situation { display: grid; place-items: center; padding-block: clamp(20px, 3vw, 42px); }
.situation-stage { width: min(1180px, 100%); height: min(650px, calc(100vh - 118px)); min-height: 500px; display: grid; grid-template-columns: minmax(360px, .95fr) minmax(440px, 1.25fr); border: 1px solid var(--line-strong); background: linear-gradient(135deg, var(--surface-raised), var(--surface) 72%); box-shadow: 0 28px 90px rgba(0,0,0,.3); }
.situation-stage__portrait { min-height: 0; display: grid; place-items: center; overflow: hidden; border-right: 1px solid var(--line-strong); color: rgba(241,243,236,.07); background: radial-gradient(circle at 50% 35%, rgba(185,255,50,.11), transparent 25%), linear-gradient(145deg, #171d18, #070907); font: 900 clamp(210px, 27vw, 440px)/1 var(--font-display); }
.situation-stage__content { display: flex; flex-direction: column; align-items: flex-start; justify-content: center; padding: clamp(30px, 4.3vw, 66px); }
.situation-stage h2 { margin: 12px 0 22px; max-width: 620px; font: 850 clamp(44px, 5.2vw, 76px)/.92 var(--font-display); letter-spacing: -.045em; }
.situation-copy { max-width: 600px; margin: 0 0 28px; color: #c8cec6; font-size: clamp(15px, 1.25vw, 19px); line-height: 1.5; }
.turn-contract { display: flex; align-items: center; gap: 16px; margin-bottom: 28px; }
.turn-contract strong { color: var(--acid); font: 850 54px/.8 var(--font-display); }
.turn-contract span { color: var(--text-muted); font-size: 11px; text-transform: uppercase; letter-spacing: .09em; }
.situation-stage .text-action { margin-top: 15px; }

/* Chat */
.screen--chat { padding: 24px; display: grid; place-items: center; background: radial-gradient(circle at 50% 0, rgba(185,255,50,.04), transparent 30%); }
.chat-shell { width: min(760px, 100%); max-width: 100%; min-width: 0; height: min(850px, calc(100vh - 120px)); min-height: 600px; display: grid; grid-template-rows: auto auto minmax(0, 1fr) auto; border: 1px solid var(--line); background: #080b09; box-shadow: 0 30px 100px rgba(0,0,0,.42); }
.chat-head { display: grid; grid-template-columns: auto auto 1fr auto; align-items: center; gap: 14px; padding: 18px 22px; border-bottom: 1px solid var(--line); }
.chat-head > div:nth-child(3), .chat-context { min-width: 0; }
.back-control { width: 36px; height: 36px; border: 0; background: none; color: var(--text-muted); cursor: pointer; }
.chat-avatar { width: 42px; height: 42px; display: grid; place-items: center; border: 1px solid rgba(185,255,50,.35); background: var(--acid-soft); color: var(--acid); font: 700 20px/1 var(--font-display); }
.chat-head h2 { margin: 0; font: 750 20px/1 var(--font-display); letter-spacing: -.015em; }
.chat-head h2 + span { color: var(--acid); font-size: 10px; }
.turn-hud { color: var(--text-muted); font: 12px/1 monospace; }
.turn-hud strong { color: var(--text); font-size: 18px; }
.chat-context { padding: 10px 22px; border-bottom: 1px solid var(--line); background: rgba(185,255,50,.025); }
.chat-context span { color: var(--acid); font: 8px/1 monospace; letter-spacing: .14em; }
.chat-context p { margin: 4px 0 0; overflow: hidden; color: var(--text-muted); font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.conversation { overflow-y: auto; padding: 30px 22px; }
.day-marker { margin: 0 auto 28px; color: var(--text-muted); font-size: 9px; text-align: center; text-transform: uppercase; letter-spacing: .1em; }
.bubble-row { display: flex; margin: 8px 0; }
.bubble-row--player { justify-content: flex-end; }
.bubble { max-width: min(78%, 470px); padding: 12px 15px; font-size: 14px; line-height: 1.45; }
.bubble--player { border: 1px solid rgba(185,255,50,.28); background: var(--acid-soft); }
.bubble--character { border: 1px solid var(--line); background: #141815; }
.chat-head .typing-state { display: block; margin-top: 3px; color: var(--text-muted); font-size: 10px; letter-spacing: .035em; }
.chat-head .typing-state[hidden] { display: none; }
.bubble-row.is-pending .bubble { opacity: .72; }
.bubble-row.is-failed .bubble { opacity: .58; outline: 1px solid rgba(255,255,255,.18); }
.demo-label { margin-top: 28px; text-align: center; }
.composer { display: grid; grid-template-columns: 1fr auto; gap: 10px; padding: 14px; padding-bottom: max(14px, env(safe-area-inset-bottom)); border-top: 1px solid var(--line); }
.composer textarea { min-width: 0; height: 48px; min-height: 48px; max-height: 112px; padding: 13px 16px; resize: none; overflow-y: auto; border: 1px solid var(--line); border-radius: 0; background: #0f1310; color: var(--text); line-height: 1.35; }
.composer button { width: 48px; height: 48px; border: 1px solid var(--line); background: var(--surface-raised); color: var(--text-muted); }
.composer button:not(:disabled) { border-color: var(--acid); background: var(--acid); color: var(--bg); cursor: pointer; }
.composer textarea:not(:disabled):focus { border-color: rgba(185,255,50,.55); outline: 0; box-shadow: inset 3px 0 var(--acid); }

/* Terminal */
.screen--terminal { display: grid; grid-template-columns: 1fr minmax(320px, .75fr); align-items: end; overflow: hidden; }
.terminal-code { position: absolute; top: var(--space); left: var(--space); }
.terminal-mark { align-self: center; color: rgba(241,243,236,.04); font: 900 min(48vw, 690px)/.72 var(--font-display); letter-spacing: -.12em; }
.terminal-copy { position: relative; z-index: 1; max-width: 650px; padding-bottom: 5vh; }
.terminal-copy h2 { margin: 14px 0 28px; font: 900 clamp(64px, 9vw, 140px)/.83 var(--font-display); letter-spacing: -.07em; }
.terminal-copy > p:not(.eyebrow) { margin: 0 0 38px; color: var(--text-muted); font-size: 18px; }
.terminal-copy .button { display: block; width: min(340px, 100%); margin-top: 10px; }
.terminal--win .terminal-mark, .terminal--win h2 { color: var(--acid); }
.terminal--lose::after { content: ""; position: absolute; inset: 0; pointer-events: none; background: radial-gradient(circle at 20% 60%, rgba(255,89,77,.07), transparent 30%); }
.terminal--timeout .terminal-mark { font-size: min(35vw, 500px); }

/* Paywall */
.screen--paywall { display: grid; grid-template-columns: 1fr 1fr; align-items: center; gap: clamp(30px, 8vw, 140px); }
.paywall-signal { display: grid; place-items: center; aspect-ratio: 1; border: 1px solid rgba(185,255,50,.15); border-radius: 50%; box-shadow: inset 0 0 120px rgba(185,255,50,.03); }
.paywall-signal span { color: var(--acid); font: 900 clamp(150px, 23vw, 360px)/1 var(--font-display); letter-spacing: -.1em; text-shadow: 0 0 50px rgba(185,255,50,.16); }
.paywall-card { max-width: 570px; }
.paywall-card h2 { margin: 14px 0 36px; font: 850 clamp(60px, 7.5vw, 108px)/.88 var(--font-display); letter-spacing: -.05em; }
.paywall-price { display: flex; align-items: center; gap: 24px; padding: 25px 0; border-block: 1px solid var(--line); }
.paywall-price strong { color: var(--acid); font: 800 58px/1 var(--font-display); }
.paywall-price span { color: var(--text-muted); font-size: 11px; text-transform: uppercase; }
.payment-methods { display: flex; align-items: center; justify-content: space-between; margin: 22px 0; color: var(--text-muted); font-size: 11px; }
.payment-methods div { display: flex; gap: 7px; }
.payment-methods i { width: 32px; height: 18px; border: 1px solid var(--line); }
.paywall-card .button { width: 100%; }
.paywall-card .button + .button { margin-top: 10px; }
.paywall-note { margin-top: 14px; text-align: center; white-space: pre-line; }
.paywall-note.is-error { color: var(--danger); }
.paywall-note.is-ready { color: var(--acid); }
.legal { margin-top: 24px; color: var(--text-muted); font-size: 10px; text-align: center; }
.legal a { color: inherit; }

.state-gallery {
  position: fixed;
  z-index: 50;
  right: 14px;
  bottom: 14px;
  display: none;
  flex-wrap: wrap;
  justify-content: flex-end;
  max-width: 520px;
  padding: 7px;
  border: 1px solid var(--line);
  background: rgba(5,7,6,.92);
}
body[data-gallery="true"] .state-gallery { display: flex; }
.state-gallery button { border: 0; padding: 7px 9px; background: none; color: var(--text-muted); font: 9px/1 monospace; cursor: pointer; text-transform: uppercase; }
.state-gallery button:hover { color: var(--acid); }

@keyframes screen-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes typing { 0%, 70%, 100% { opacity: .25; transform: translateY(0); } 35% { opacity: 1; transform: translateY(-2px); } }

@media (max-width: 900px) {
  .rail { display: none; }
  main { padding-left: 0; }
  .screen { min-height: calc(100svh - 64px); }
  .topbar { height: 64px; }
  main { padding-top: 64px; }
  .screen--profile { overflow: visible; }
  .profile-grid { flex: none; grid-template-columns: repeat(2, minmax(0, 1fr)); grid-template-rows: none; }
  .profile-identity, .profile-stats, .profile-progress, .profile-recent, .screen-actions { grid-column: span 1; grid-row: auto; }
  .profile-identity { min-height: 330px; }
  .screen-actions { min-height: 220px; }
  .entry__layout { grid-template-columns: minmax(330px, .8fr) minmax(400px, 1.2fr); gap: 36px; }
  .entry-world { min-height: min(560px, calc(100svh - 140px)); }
  .character-track { gap: 14px; overflow-x: auto; scroll-snap-type: x mandatory; scrollbar-width: none; padding: 8px 8vw 24px 0; }
  .character-track::-webkit-scrollbar { display: none; }
  .character-card { width: min(76vw, 440px); min-width: min(76vw, 440px); scroll-snap-align: center; }
  .character-card__art { height: auto; aspect-ratio: 4 / 5; }
  .character-dots { display: flex; justify-content: center; gap: 9px; }
  .character-dots button { width: 24px; height: 3px; border: 0; padding: 0; background: #303631; cursor: pointer; }
  .character-dots button.is-active { background: var(--acid); }
  .situation-stage { height: min(620px, calc(100svh - 104px)); min-height: 480px; grid-template-columns: .82fr 1.18fr; }
  .screen--terminal { grid-template-columns: .65fr 1fr; }
}

@media (max-width: 600px) {
  .topbar { padding-inline: 18px; }
  .session-state { display: none; }
  .screen { padding: 34px 18px max(34px, env(safe-area-inset-bottom)); }
  .screen--entry { padding-top: 24px; }
  .screen--entry::before { inset: 46% 0 0; }
  .screen--entry::after { display: none; }
  .entry__layout { display: flex; flex-direction: column; align-items: stretch; gap: 28px; }
  .entry__core h1 { font-size: clamp(80px, 27vw, 112px); }
  .entry__line { margin-top: 25px; font-size: clamp(31px, 9.5vw, 42px); }
  .entry__promise { margin-bottom: 22px; font-size: 13px; }
  .entry__actions { align-items: stretch; flex-direction: column; }
  .entry__actions .button { width: 100%; }
  .entry__meta { justify-content: space-between; gap: 8px; margin-top: 22px; }
  .entry-world { min-height: 430px; }
  .entry-world__scene { width: 84%; padding-block: 28px; }
  .entry-world__identity { margin-bottom: 24px; }
  .entry-world__cast span { justify-content: center; padding: 13px 8px; }
  .entry-world__cast b { display: none; }
  .section-head { margin-bottom: 30px; }
  .section-head h2 { font-size: clamp(49px, 15vw, 68px); }
  .screen--profile { display: block; }
  .profile-grid { display: grid; grid-template-columns: 1fr; border-inline: 0; }
  .profile-identity, .profile-stats, .profile-progress, .profile-recent, .screen-actions { grid-column: 1; min-height: 0; }
  .profile-identity { min-height: 270px; }
  .panel { min-height: 0; padding: 24px 20px; }
  .stat-primary strong { font-size: 88px; }
  .stat-row { justify-content: space-between; }
  .screen-actions { gap: 26px; }
  .profile-progress__row, .recent-run { align-items: flex-start; }
  .screen--characters { padding-right: 0; }
  .screen--characters .section-head, .screen--characters .art-note { padding-right: 18px; }
  .character-track { display: flex; width: 100%; padding-right: 14vw; }
  .character-card { width: 82vw; min-width: 82vw; }
  .character-card h3 { font-size: 52px; }
  .character-card__art { aspect-ratio: 4 / 5; }
  .art-note { text-align: center; }
  .situation-stage { display: block; height: auto; min-height: 0; border: 0; background: transparent; box-shadow: none; }
  .screen--situation { display: block; }
  .situation-stage__portrait { min-height: 34svh; border: 1px solid var(--line); font-size: 54vw; }
  .situation-stage__content { padding: 30px 0 0; }
  .situation-stage h2 { max-width: 100%; font-size: clamp(40px, 11vw, 48px); overflow-wrap: normal; word-break: normal; }
  .situation-copy { margin-bottom: 26px; }
  .turn-contract { margin-bottom: 26px; }
  .situation-stage .button { width: 100%; }
  .situation-stage .text-action { align-self: center; }
  .screen--chat { padding: 0; }
  .chat-shell { width: 100%; height: calc(100svh - 64px); min-height: 0; border: 0; }
  .chat-head { padding: 13px 14px; }
  .chat-context { padding-inline: 16px; }
  .conversation { padding: 24px 14px; }
  .bubble { max-width: 86%; }
  .screen--terminal { display: flex; flex-direction: column; justify-content: flex-end; align-items: stretch; }
  .terminal-mark { position: absolute; top: 18%; left: -4%; font-size: 85vw; }
  .terminal-copy { padding-bottom: 8svh; }
  .terminal-copy h2 { font-size: clamp(68px, 20vw, 94px); }
  .terminal-copy .button { width: 100%; }
  .screen--paywall { display: flex; flex-direction: column; justify-content: flex-end; align-items: stretch; gap: 20px; }
  .paywall-signal { position: absolute; top: 4%; right: -18%; width: 72vw; opacity: .6; }
  .paywall-card { position: relative; z-index: 1; padding-bottom: 4svh; }
  .paywall-card h2 { font-size: 17vw; }
  .state-gallery { right: 8px; bottom: max(8px, env(safe-area-inset-bottom)); left: 8px; }
}

@media (min-width: 901px) and (max-height: 760px) {
  .entry-world { min-height: calc(100svh - 116px); }
  .entry__core h1 { font-size: clamp(82px, 9vw, 126px); }
  .entry__line { margin-top: 25px; font-size: clamp(29px, 3vw, 43px); }
  .entry__promise { margin-bottom: 22px; }
  .screen--profile { padding-block: 20px; }
  .screen--profile .section-head { margin-bottom: 15px; }
  .screen--profile .section-head h2 { font-size: 54px; }
  .profile-grid { grid-template-rows: minmax(190px, 1fr) minmax(170px, .8fr); }
  .profile-progress__row, .recent-run { padding-block: 10px; }
}

@media (min-width: 901px) {
  body[data-view="entry"] { overflow-y: hidden; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
