:root {
  color-scheme: dark;
  --ink: #f4efe7;
  --muted: #a7a19a;
  --subtle: #6f6b66;
  --paper: #151515;
  --panel: #1e1d1b;
  --line: rgba(244, 239, 231, .14);
  --line-strong: rgba(244, 239, 231, .25);
  --accent: #e09a6e;
  --accent-bright: #f5bd91;
  --accent-ink: #261712;
  --green: #a8cda4;
  --red: #e29a8e;
  --serif: Georgia, 'Times New Roman', 'Noto Serif SC', serif;
  --sans: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Noto Sans SC', sans-serif;
}

* { box-sizing: border-box; }
html { background: var(--paper); }
body {
  margin: 0;
  min-width: 320px;
  color: var(--ink);
  background: radial-gradient(circle at 8% -12%, rgba(224, 154, 110, .17), transparent 34rem), radial-gradient(circle at 105% 30%, rgba(114, 101, 78, .13), transparent 30rem), var(--paper);
  font-family: var(--sans);
  line-height: 1.55;
}

button, input, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: wait; opacity: .62; }
.app-shell { min-height: 100vh; display: flex; flex-direction: column; }
.topbar { width: min(1180px, calc(100% - 48px)); min-height: 82px; margin: 0 auto; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); }
.brand { display: inline-flex; align-items: center; gap: 12px; color: var(--ink); text-decoration: none; }
.brand-mark { width: 30px; color: var(--accent-bright); font-size: 22px; text-align: center; }
.brand strong { display: block; font: 17px var(--serif); letter-spacing: .03em; }
.brand small { display: block; margin-top: 1px; color: var(--subtle); font-size: 9px; letter-spacing: .18em; }
.topbar-note { color: var(--subtle); font-size: 11px; letter-spacing: .08em; text-transform: uppercase; }
.main-content { width: min(1060px, calc(100% - 48px)); flex: 1; margin: 0 auto; padding: 62px 0 76px; }
.view { animation: rise .35s ease both; }
@keyframes rise { from { opacity: 0; transform: translateY(7px); } to { opacity: 1; transform: none; } }
.status-line { min-height: 25px; margin-bottom: 15px; color: var(--muted); font-size: 12px; }
.status-line[data-tone="success"] { color: var(--green); }
.status-line[data-tone="busy"] { color: var(--accent-bright); }
.notice { margin-bottom: 18px; padding: 14px 16px; border: 1px solid rgba(226, 154, 142, .4); border-radius: 8px; color: var(--red); background: rgba(226, 154, 142, .09); font-size: 13px; }
.hero-copy { max-width: 760px; margin-bottom: 42px; }
.eyebrow, .section-kicker { margin: 0 0 12px; color: var(--accent-bright); font-size: 10px; font-weight: 700; letter-spacing: .2em; }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 18px; font: 400 clamp(38px, 6vw, 68px)/1.06 var(--serif); letter-spacing: -.045em; }
h2 { margin-bottom: 0; font: 400 28px/1.1 var(--serif); }
.lede { max-width: 680px; color: var(--muted); font-size: 16px; line-height: 1.8; }
.setup-grid { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(260px, .85fr); gap: 18px; align-items: stretch; }
.panel { border: 1px solid var(--line); border-radius: 10px; background: linear-gradient(145deg, rgba(255,255,255,.038), rgba(255,255,255,.012)); box-shadow: 0 16px 48px rgba(0,0,0,.15); }
.form-panel, .manifesto-panel, .world-form { padding: 28px; }
.panel-heading, .view-heading, .world-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; }
.panel-heading { margin-bottom: 24px; }
.view-heading { align-items: end; margin-bottom: 34px; }
.badge { padding: 5px 9px; border-radius: 999px; font-size: 10px; letter-spacing: .05em; white-space: nowrap; }
.badge-muted { border: 1px solid var(--line); color: var(--muted); }
.badge-success { border: 1px solid rgba(168,205,164,.38); color: var(--green); background: rgba(168,205,164,.08); }
label { display: block; color: var(--muted); font-size: 12px; }
label > span { display: flex; gap: 6px; margin-bottom: 7px; color: var(--ink); font-size: 12px; font-weight: 600; }
label em { color: var(--subtle); font-style: normal; font-weight: 400; }
label small, .privacy-note { color: var(--subtle); font-size: 10px; line-height: 1.5; }
.form-panel label { margin-bottom: 16px; }
input, textarea { width: 100%; color: var(--ink); border: 1px solid var(--line); border-radius: 6px; outline: none; background: rgba(0,0,0,.2); transition: border-color .2s, background .2s, box-shadow .2s; }
input { height: 42px; padding: 0 12px; }
textarea { min-height: 88px; padding: 11px 12px; resize: vertical; line-height: 1.6; }
input::placeholder, textarea::placeholder { color: #69645f; }
input:focus, textarea:focus { border-color: var(--accent); background: rgba(0,0,0,.3); box-shadow: 0 0 0 3px rgba(224,154,110,.12); }
.secret-field { position: relative; }
.secret-field input { padding-right: 64px; }
.field-action { position: absolute; top: 0; right: 0; height: 42px; padding: 0 12px; border: 0; color: var(--muted); background: transparent; font-size: 11px; }
.field-action:hover { color: var(--ink); }
.form-actions { display: flex; gap: 10px; align-items: center; margin-top: 24px; }
.form-actions-spread { justify-content: space-between; }
.button { min-height: 42px; padding: 0 16px; border: 1px solid transparent; border-radius: 6px; font-size: 12px; font-weight: 700; letter-spacing: .02em; transition: transform .2s, background .2s, border-color .2s; }
.button:hover:not(:disabled) { transform: translateY(-1px); }
.button-primary { color: var(--accent-ink); background: var(--accent-bright); }
.button-primary:hover:not(:disabled) { background: #ffd0aa; }
.button-secondary, .button-ghost { border-color: var(--line-strong); color: var(--ink); background: transparent; }
.button-secondary:hover:not(:disabled), .button-ghost:hover:not(:disabled) { border-color: var(--accent); background: rgba(224,154,110,.08); }
.privacy-note { margin: 18px 0 0; }
.flow-list { display: grid; gap: 20px; margin-top: 28px; }
.flow-list > div { display: grid; grid-template-columns: 30px 1fr; gap: 10px; align-items: start; }
.flow-list > div > span { color: var(--accent); font: 13px var(--serif); }
.flow-list p { margin: 0; color: var(--ink); font-size: 13px; line-height: 1.45; }
.flow-list small { color: var(--muted); font-size: 11px; }
.text-button { padding: 7px 0; border: 0; color: var(--muted); background: transparent; font-size: 12px; }
.text-button:hover { color: var(--accent-bright); }
.view-heading .lede { margin-bottom: 0; }
.world-form { display: grid; gap: 22px; }
.two-column { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.field-small { max-width: 430px; }
.world-header { align-items: center; padding: 24px 28px; margin-bottom: 20px; }
.world-header h1 { margin-bottom: 8px; font-size: clamp(32px, 5vw, 52px); }
.world-subtitle { margin: 0; color: var(--muted); font-size: 13px; }
.live-mark { display: inline-flex; align-items: center; gap: 7px; color: var(--green); font-size: 10px; letter-spacing: .16em; }
.live-mark i { width: 7px; height: 7px; display: block; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 4px rgba(168,205,164,.1); }
.narrative-history { display: grid; gap: 0; max-width: 820px; margin: 0 auto 30px; padding: 6px 26px; }
.story-entry { padding: 22px 0; border-bottom: 1px solid var(--line); }
.story-entry:last-child { border-bottom: 0; }
.entry-label { display: block; margin-bottom: 8px; color: var(--subtle); font-size: 9px; font-weight: 700; letter-spacing: .18em; }
.story-entry p { margin: 0; white-space: pre-wrap; }
.entry-player { padding: 16px 18px; border: 1px solid var(--line); border-radius: 8px; background: rgba(255,255,255,.025); }
.entry-player p { color: var(--muted); font-size: 13px; }
.entry-narrative p { color: var(--ink); font: 17px/1.9 var(--serif); }
.entry-error { padding: 15px 17px; border: 1px solid rgba(226,154,142,.35); border-radius: 8px; color: var(--red); background: rgba(226,154,142,.07); }
.entry-error p { font-size: 13px; }
.play-controls { padding: 16px; }
.action-form { display: grid; gap: 10px; }
.action-form textarea { min-height: 92px; border-color: var(--line-strong); }
.action-footer { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.action-hint { color: var(--subtle); font-size: 10px; }
.play-footer-actions { display: flex; justify-content: center; gap: 24px; padding-top: 12px; }
.app-footer { width: min(1180px, calc(100% - 48px)); margin: auto auto 0; padding: 20px 0 28px; border-top: 1px solid var(--line); color: var(--subtle); font-size: 10px; letter-spacing: .06em; text-align: center; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

@media (max-width: 720px) {
  .topbar, .main-content, .app-footer { width: min(100% - 30px, 600px); }
  .topbar { min-height: 68px; }
  .topbar-note { display: none; }
  .main-content { padding: 40px 0 52px; }
  .hero-copy { margin-bottom: 30px; }
  h1 { font-size: clamp(38px, 13vw, 56px); }
  .setup-grid, .two-column { grid-template-columns: 1fr; }
  .manifesto-panel { display: none; }
  .form-panel, .world-form { padding: 21px; }
  .view-heading { align-items: start; flex-direction: column; margin-bottom: 24px; }
  .world-header { padding: 20px; }
  .live-mark { margin-top: 3px; }
  .narrative-history { padding: 0 4px; }
  .entry-narrative p { font-size: 16px; line-height: 1.8; }
  .action-footer { align-items: stretch; flex-direction: column; }
  .play-footer-actions { gap: 14px; flex-wrap: wrap; }
}

/* Intake: let the GM ask before the player writes a spec sheet */
.intake-panel {
  margin-bottom: 16px;
}
.intake-panel h2 {
  margin: 4px 0 6px;
  font-size: 1.05rem;
}
.intake-hint {
  margin: 0 0 10px;
  font-size: 0.86rem;
  opacity: 0.72;
  line-height: 1.5;
}
.intake-log {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 320px;
  overflow-y: auto;
  margin-bottom: 10px;
}
.intake-log:empty {
  display: none;
}
.intake-item {
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 0.9rem;
  line-height: 1.6;
  white-space: pre-wrap;
}
.intake-user {
  align-self: flex-end;
  max-width: 82%;
  background: rgba(120, 160, 220, 0.16);
}
.intake-gm {
  align-self: flex-start;
  max-width: 94%;
  background: rgba(255, 255, 255, 0.05);
  border-left: 2px solid rgba(120, 160, 220, 0.5);
}
.intake-form {
  display: flex;
  gap: 8px;
  align-items: flex-end;
}
.intake-form textarea {
  flex: 1;
  resize: vertical;
}

/* Status bar: the panel lives here now, not in the prose */
.state-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 10px;
  align-items: center;
  padding: 8px 12px;
  margin: 0 0 12px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.07);
  font-size: 0.82rem;
  line-height: 1.4;
}
.state-chip {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 32ch;
  opacity: 0.82;
}
.state-chip-time {
  font-variant-numeric: tabular-nums;
  opacity: 1;
  font-weight: 600;
}
.state-chip-grow {
  max-width: 46ch;
}
.state-chip-dev {
  margin-left: auto;
  padding: 1px 8px;
  border-radius: 999px;
  background: rgba(120, 160, 220, 0.16);
  opacity: 1;
  font-variant-numeric: tabular-nums;
}
@media (max-width: 640px) {
  .state-bar { font-size: 0.78rem; }
  .state-chip, .state-chip-grow { max-width: 100%; }
  .state-chip-dev { margin-left: 0; }
}
