:root {
  color-scheme: dark;
  --ink: #f5f0df;
  --muted: #aaa996;
  --faint: #777b70;
  --night: #0b100e;
  --surface: #121a16;
  --surface-2: #17221c;
  --surface-3: #1c2a22;
  --line: #304237;
  --gold: #d8bd79;
  --gold-strong: #f1d792;
  --moss: #8eb892;
  --danger: #ef9a92;
  --success: #9dcba0;
  --focus: #f4d47c;
  --shadow: 0 18px 50px rgba(0, 0, 0, .32);
  --radius: 16px;
  --radius-sm: 10px;
  --max-copy: 70ch;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--night); }
body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 12% 8%, rgba(74, 111, 80, .16), transparent 32rem),
    radial-gradient(circle at 90% 100%, rgba(181, 143, 69, .09), transparent 28rem),
    var(--night);
  font-size: 16px;
  line-height: 1.55;
}
button, input, textarea, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { border: 0; }
a { color: var(--gold-strong); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }
[hidden] { display: none !important; }
.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;
}
.skip-link { position: fixed; top: -100px; left: 12px; z-index: 100; padding: 10px 14px; background: var(--gold); color: #10150f; }
.skip-link:focus { top: 12px; }
.eyebrow {
  margin: 0 0 8px; color: var(--gold); font-size: .75rem; font-weight: 800;
  letter-spacing: .16em; text-transform: uppercase;
}
h1, h2, h3 { font-family: Georgia, "Times New Roman", serif; line-height: 1.15; text-wrap: balance; }
h1 { margin: 0; font-size: clamp(2rem, 6vw, 4.5rem); font-weight: 500; }
h2 { margin: 0; font-size: clamp(1.45rem, 3vw, 2rem); font-weight: 500; }
h3 { margin: 0; font-size: 1.15rem; }
p { margin: 0 0 1rem; }
.muted { color: var(--muted); }
.small { font-size: .86rem; }
.divider { height: 1px; margin: 20px 0; background: var(--line); }
.stack { display: grid; gap: 16px; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.grow { flex: 1; }
.brand {
  display: inline-flex; align-items: center; gap: 10px; color: var(--ink);
  font-family: Georgia, serif; font-size: 1.12rem; text-decoration: none;
}
.brand-mark { width: 26px; height: 30px; color: var(--gold); }
.card {
  background: linear-gradient(145deg, rgba(25, 37, 30, .97), rgba(16, 24, 20, .97));
  border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
}
.panel { padding: clamp(18px, 4vw, 30px); }
.btn {
  min-height: 46px; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 16px; border-radius: var(--radius-sm); cursor: pointer; font-weight: 750;
  text-decoration: none; transition: transform .18s ease, background .18s ease, border-color .18s ease;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn:disabled { cursor: not-allowed; opacity: .58; transform: none; }
.btn-primary { background: var(--gold); color: #11170f; }
.btn-primary:hover { background: var(--gold-strong); }
.btn-secondary { background: var(--surface-3); color: var(--ink); border: 1px solid var(--line); }
.btn-secondary:hover { border-color: var(--moss); }
.btn-quiet { background: transparent; color: var(--muted); border: 1px solid transparent; }
.btn-quiet:hover { color: var(--ink); background: rgba(255,255,255,.05); }
.btn-danger { color: var(--danger); }
.icon-btn { width: 46px; padding: 0; }
.icon { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.field { display: grid; gap: 7px; }
.field label, .legend { font-size: .88rem; color: var(--muted); font-weight: 700; }
.field input, .field textarea, .field select {
  width: 100%; min-height: 48px; padding: 11px 13px; color: var(--ink);
  background: #0c1310; border: 1px solid var(--line); border-radius: 10px;
}
.field textarea { min-height: 104px; resize: vertical; line-height: 1.5; }
.field input:hover, .field textarea:hover, .field select:hover { border-color: #506858; }
.field-error { min-height: 1.2em; color: var(--danger); font-size: .83rem; }
.form-note { color: var(--muted); font-size: .82rem; }
.alert {
  padding: 13px 15px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--surface-2); color: var(--muted);
}
.alert-error { border-color: #74443f; color: #ffd1cc; background: #261716; }
.alert-success { border-color: #3d6945; color: #d3f4d5; background: #142319; }
.loading-dot { width: 7px; height: 7px; border-radius: 99px; background: currentColor; animation: pulse 1s ease-in-out infinite alternate; }
.loading-dot:nth-child(2) { animation-delay: .18s; }
.loading-dot:nth-child(3) { animation-delay: .36s; }

/* Entry */
.entry-shell { min-height: 100vh; display: grid; grid-template-rows: auto 1fr auto; }
.entry-header { width: min(1160px, calc(100% - 32px)); margin: 0 auto; padding: 24px 0; }
.entry-main {
  width: min(1160px, calc(100% - 32px)); margin: auto; padding: 28px 0 54px;
  display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(320px, .75fr); gap: clamp(30px, 7vw, 90px); align-items: center;
}
.hero-copy { max-width: 700px; }
.hero-copy h1 em { color: var(--gold); font-style: normal; }
.hero-copy > p:not(.eyebrow) { max-width: 58ch; margin: 22px 0 26px; color: var(--muted); font-size: clamp(1rem, 2vw, 1.15rem); }
.promise-list { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin: 26px 0 0; padding: 0; list-style: none; }
.promise-list li { padding: 14px; background: rgba(20,31,25,.7); border: 1px solid var(--line); border-radius: 12px; }
.promise-list strong { display: block; color: var(--gold); font-family: Georgia, serif; }
.promise-list span { color: var(--muted); font-size: .82rem; }
.auth-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; padding: 5px; background: #0d1511; border-radius: 11px; }
.auth-tabs.single { grid-template-columns: 1fr; }
.auth-tab { min-height: 44px; border-radius: 8px; background: transparent; color: var(--muted); cursor: pointer; font-weight: 750; }
.auth-tab[aria-selected="true"] { background: var(--surface-3); color: var(--ink); box-shadow: inset 0 0 0 1px var(--line); }
.entry-footer { width: min(1160px, calc(100% - 32px)); margin: 0 auto; padding: 20px 0; color: var(--faint); font-size: .8rem; }

/* Campaign hub */
.hub-shell { min-height: 100vh; }
.hub-header {
  height: 72px; display: flex; align-items: center; justify-content: space-between;
  width: min(1100px, calc(100% - 32px)); margin: 0 auto;
}
.hub-main { width: min(1100px, calc(100% - 32px)); margin: 0 auto; padding: 34px 0 80px; }
.hub-title { display: flex; justify-content: space-between; gap: 20px; align-items: end; margin-bottom: 26px; }
.campaign-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.campaign-card { position: relative; padding: 22px; box-shadow: none; }
.campaign-card h3 { margin-bottom: 7px; font-size: 1.35rem; }
.campaign-meta { display: flex; gap: 8px 16px; flex-wrap: wrap; margin: 16px 0 20px; color: var(--muted); font-size: .84rem; }
.campaign-card .btn { width: 100%; }
.empty-state { padding: 48px 24px; text-align: center; border: 1px dashed var(--line); border-radius: var(--radius); }
.empty-state p { color: var(--muted); }
.modal {
  position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 18px;
  background: rgba(3, 7, 5, .78); backdrop-filter: blur(6px);
}
.modal-card { width: min(590px, 100%); max-height: calc(100vh - 36px); overflow: auto; }
.modal-head { display: flex; justify-content: space-between; align-items: start; gap: 12px; }
.choice-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.choice { position: relative; }
.choice input { position: absolute; opacity: 0; pointer-events: none; }
.choice span {
  min-height: 58px; display: grid; place-items: center; padding: 9px; text-align: center;
  border: 1px solid var(--line); border-radius: 10px; color: var(--muted); cursor: pointer;
}
.choice input:checked + span { border-color: var(--gold); color: var(--ink); background: rgba(216,189,121,.1); }
.choice input:focus-visible + span { outline: 3px solid var(--focus); outline-offset: 3px; }

/* Game */
.game-body { height: 100vh; overflow: hidden; }
.game-shell { height: 100%; display: grid; grid-template-columns: 264px minmax(0, 1fr); }
.game-sidebar {
  display: flex; flex-direction: column; min-width: 0; padding: 18px;
  background: rgba(10,16,13,.95); border-right: 1px solid var(--line);
}
.game-sidebar .brand { margin-bottom: 30px; }
.campaign-identity { margin-bottom: 22px; }
.campaign-identity h1 { margin: 4px 0 6px; font-size: 1.3rem; }
.world-clock {
  display: grid; grid-template-columns: auto 1fr; gap: 10px 12px; align-items: center;
  padding: 13px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface);
}
.clock-glyph { grid-row: 1 / span 2; color: var(--gold); }
.world-clock strong { font-family: Georgia, serif; font-size: 1.06rem; }
.world-clock span { color: var(--muted); font-size: .78rem; }
.sidebar-nav { display: grid; gap: 4px; margin-top: 18px; }
.sidebar-nav button {
  min-height: 44px; display: flex; align-items: center; gap: 10px; padding: 9px 10px;
  color: var(--muted); background: transparent; border-radius: 9px; cursor: pointer; text-align: left;
}
.sidebar-nav button:hover { color: var(--ink); background: var(--surface); }
.sidebar-foot { margin-top: auto; display: grid; gap: 8px; }
.sync-state { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: .76rem; }
.sync-state::before { content: ""; width: 7px; height: 7px; border-radius: 99px; background: var(--success); }
.sync-state.pending::before { background: var(--gold); animation: pulse .8s ease infinite alternate; }
.game-main { min-width: 0; height: 100%; display: grid; grid-template-rows: auto 1fr auto; }
.game-topbar {
  min-height: 65px; display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 10px clamp(14px, 3vw, 34px); border-bottom: 1px solid var(--line); background: rgba(11,16,14,.88);
}
.mobile-brand { display: none; }
.scene-label { min-width: 0; }
.scene-label strong { display: block; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.scene-label span { color: var(--muted); font-size: .78rem; }
.scene-scroll { overflow-y: auto; scroll-behavior: smooth; overscroll-behavior: contain; }
.scene-feed { width: min(760px, calc(100% - 32px)); margin: 0 auto; padding: 30px 0 40px; }
.turn { padding: 22px 0; border-bottom: 1px solid rgba(48,66,55,.68); }
.turn:first-child { padding-top: 8px; }
.turn-time { margin-bottom: 10px; color: var(--faint); font-size: .72rem; text-transform: uppercase; letter-spacing: .12em; }
.narrative { max-width: var(--max-copy); font-family: Georgia, serif; font-size: clamp(1.05rem, 2vw, 1.18rem); line-height: 1.72; }
.narrative p { margin: 0 0 .85em; }
.npc-line {
  max-width: var(--max-copy); margin: 16px 0; padding: 12px 15px;
  border-left: 3px solid var(--gold); background: rgba(216,189,121,.06); border-radius: 0 9px 9px 0;
}
.npc-line strong { display: block; margin-bottom: 3px; color: var(--gold); font-size: .78rem; letter-spacing: .05em; text-transform: uppercase; }
.player-line { color: var(--muted); }
.player-line strong { color: var(--moss); }
.turn-actions { display: flex; gap: 8px; margin-top: 14px; }
.turn-actions .btn { min-height: 38px; padding: 7px 10px; font-size: .78rem; }
.thinking {
  display: flex; align-items: center; gap: 7px; padding: 24px 0; color: var(--muted); font-family: Georgia, serif;
}
.composer-wrap {
  z-index: 5; padding: 12px clamp(12px, 3vw, 34px) calc(12px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line); background: linear-gradient(180deg, rgba(11,16,14,.94), var(--night));
}
.composer { width: min(800px, 100%); margin: 0 auto; }
.suggestions { display: flex; gap: 8px; overflow-x: auto; padding: 2px 2px 10px; scrollbar-width: thin; }
.suggestion {
  flex: 0 0 auto; min-height: 40px; max-width: 250px; padding: 8px 12px;
  border: 1px solid var(--line); border-radius: 99px; color: var(--muted); background: var(--surface); cursor: pointer;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: .83rem;
}
.suggestion:hover { color: var(--ink); border-color: var(--moss); }
.composer-box {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: end; gap: 8px;
  padding: 7px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px;
}
.composer-box:focus-within { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(216,189,121,.12); }
.composer textarea {
  width: 100%; min-height: 48px; max-height: 144px; padding: 11px 9px; resize: none;
  border: 0; outline: 0; color: var(--ink); background: transparent; line-height: 1.45;
}
.composer-tools { display: flex; gap: 7px; }
.composer .icon-btn { width: 44px; height: 44px; min-height: 44px; }
.composer-note { display: flex; justify-content: space-between; gap: 12px; margin-top: 5px; color: var(--faint); font-size: .7rem; }
.quota-card { margin: 18px 0; padding: 18px; border: 1px solid #745f32; background: #231e12; border-radius: 12px; }
.confirmation-card { margin: 18px 0; padding: 18px; border: 1px solid var(--gold); background: rgba(216,189,121,.08); border-radius: 12px; }
.drawer {
  position: fixed; top: 0; right: 0; z-index: 60; width: min(390px, 100%); height: 100%;
  overflow-y: auto; padding: 24px; background: var(--surface); border-left: 1px solid var(--line); box-shadow: var(--shadow);
  transform: translateX(102%); transition: transform .22s ease;
}
.drawer.open { transform: translateX(0); }
.drawer-backdrop { position: fixed; inset: 0; z-index: 55; background: rgba(0,0,0,.48); }
.stat-list { display: grid; gap: 9px; margin: 18px 0; padding: 0; list-style: none; }
.stat-list li { display: flex; justify-content: space-between; gap: 20px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.stat-list span { color: var(--muted); }
.mobile-nav { display: none; }
.toast {
  position: fixed; z-index: 90; left: 50%; bottom: 118px; transform: translateX(-50%);
  width: min(420px, calc(100% - 28px)); padding: 12px 15px; text-align: center;
  color: var(--ink); background: #26332b; border: 1px solid #55705e; border-radius: 10px; box-shadow: var(--shadow);
}

@keyframes pulse { from { opacity: .35; } to { opacity: 1; } }
@media (max-width: 800px) {
  .entry-main { grid-template-columns: 1fr; padding-top: 10px; }
  .hero-copy { text-align: center; margin: 0 auto; }
  .promise-list { max-width: 560px; margin-inline: auto; }
  .auth-card { width: min(520px, 100%); margin: 0 auto; }
  .campaign-grid { grid-template-columns: 1fr; }
  .game-shell { grid-template-columns: 1fr; }
  .game-sidebar { display: none; }
  .mobile-brand { display: inline-flex; }
  .game-topbar { min-height: 58px; }
  .game-body { height: 100dvh; }
  .scene-feed { padding-top: 20px; }
  .mobile-nav {
    position: fixed; left: 10px; bottom: calc(105px + env(safe-area-inset-bottom)); z-index: 25;
    display: flex; gap: 5px; padding: 5px; border: 1px solid var(--line); border-radius: 12px;
    background: rgba(18,26,22,.96); box-shadow: var(--shadow);
  }
  .mobile-nav .icon-btn { width: 42px; height: 42px; min-height: 42px; }
  .composer-note span:last-child { display: none; }
}
@media (max-width: 520px) {
  .entry-header { padding: 18px 0; }
  .entry-main { width: min(100% - 24px, 1160px); }
  .hero-copy h1 { font-size: 2.25rem; }
  .promise-list { grid-template-columns: 1fr; text-align: left; gap: 7px; }
  .promise-list li { display: flex; align-items: baseline; gap: 8px; padding: 10px 12px; }
  .panel { padding: 19px; }
  .hub-title { align-items: stretch; flex-direction: column; }
  .choice-grid { grid-template-columns: 1fr; }
  .scene-label { max-width: 42vw; }
  .topbar-actions .btn span { display: none; }
  .narrative { font-size: 1.04rem; line-height: 1.67; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
