:root {
  --bg: #0c0b10;
  --bg-2: #14121b;
  --panel: rgba(24, 20, 32, 0.86);
  --ink: #f3ead7;
  --muted: #b9ad96;
  --gold: #e4c27a;
  --gold-2: #c9a24a;
  --blood: #c44b4b;
  --ok: #7dba7a;
  --warn: #d9844a;
  --line: rgba(228, 194, 122, 0.22);
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
  --radius: 18px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bot: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: "Source Serif 4", "Palatino Linotype", Palatino, Georgia, serif;
  background:
    radial-gradient(1200px 700px at 80% -10%, rgba(196, 75, 75, 0.16), transparent 50%),
    radial-gradient(900px 600px at -10% 110%, rgba(228, 194, 122, 0.08), transparent 45%),
    var(--bg);
  color: var(--ink);
  overflow-x: hidden;
}

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }

.app {
  width: min(720px, 100%);
  margin: 0 auto;
  min-height: 100dvh;
  padding: calc(16px + var(--safe-top)) 16px calc(24px + var(--safe-bot));
  position: relative;
}

.skyline {
  position: fixed;
  inset: auto 0 0 0;
  height: 28vh;
  pointer-events: none;
  background: linear-gradient(to top, rgba(0,0,0,0.55), transparent);
}

h1, h2, h3 { font-family: "Cinzel", "Times New Roman", serif; letter-spacing: 0.04em; margin: 0; }
.muted { color: var(--muted); }
.gold { color: var(--gold); }

.screen { display: none; animation: rise 0.45s ease; }
.screen.active { display: block; }

@keyframes rise {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}

.mast {
  text-align: center;
  padding: 28px 8px 10px;
}
.mast .mark {
  font-size: 48px;
  line-height: 1;
  filter: drop-shadow(0 8px 16px rgba(0,0,0,0.5));
}
.mast h1 {
  font-size: clamp(32px, 8vw, 54px);
  margin-top: 8px;
}
.subtitle {
  color: var(--muted);
  margin: 10px auto 0;
  max-width: 28em;
  line-height: 1.45;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
  backdrop-filter: blur(10px);
}

.stack { display: grid; gap: 12px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; }

.btn {
  appearance: none;
  border: 1px solid var(--line);
  background: linear-gradient(180deg, #2a2433, #1a1620);
  color: var(--ink);
  border-radius: 999px;
  padding: 14px 18px;
  min-height: 48px;
  letter-spacing: 0.03em;
}
.btn:active { transform: translateY(1px); }
.btn.primary {
  background: linear-gradient(180deg, #8a3030, #5c1d1d);
  border-color: rgba(255, 210, 210, 0.18);
}
.btn.gold {
  background: linear-gradient(180deg, #e4c27a, #9a7428);
  color: #1a1408;
  font-weight: 650;
  border-color: transparent;
}
.btn.ghost { background: transparent; }
.btn.block { width: 100%; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

.hud {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: end;
  margin-bottom: 12px;
}
.stat { font-size: 13px; color: var(--muted); }
.stat b { color: var(--gold); font-size: 18px; display: block; font-family: Cinzel, serif; }

.reaper-wrap { position: relative; height: 86px; margin: 8px 0 16px; }
.lane {
  position: absolute;
  left: 0; right: 0; top: 38px;
  height: 10px;
  border-radius: 99px;
  background: #2a2430;
  overflow: hidden;
  border: 1px solid var(--line);
}
.lane > i {
  display: block;
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #7dba7a, #d9844a, #c44b4b);
  transition: width 0.35s ease;
}
.ward, .reaper {
  position: absolute;
  top: 0;
  font-size: 34px;
  transition: left 0.35s ease;
  filter: drop-shadow(0 6px 10px rgba(0,0,0,0.45));
}
.ward { left: 0; }
.reaper { left: 8%; }
.reaper.swing { animation: swing 0.55s ease; }
.reaper.urgent { animation: timerPulse 0.9s infinite ease-in-out; }
@keyframes swing {
  0% { transform: rotate(0deg); }
  40% { transform: rotate(-28deg); }
  100% { transform: rotate(0deg); }
}

@keyframes correctGlow {
  0% { transform: scale(1); filter: drop-shadow(0 0 0 rgba(125, 186, 122, 0)); }
  50% { transform: scale(1.18); filter: drop-shadow(0 0 10px rgba(125, 186, 122, 0.85)); color: var(--ok); }
  100% { transform: scale(1); filter: drop-shadow(0 0 0 rgba(125, 186, 122, 0)); }
}

@keyframes timerPulse {
  0% { transform: scale(1); opacity: 0.9; }
  50% { transform: scale(1.12); opacity: 1; filter: drop-shadow(0 0 12px rgba(196, 75, 75, 0.8)); }
  100% { transform: scale(1); opacity: 0.9; }
}

@keyframes choiceGlow {
  0% { box-shadow: 0 0 0 rgba(125, 186, 122, 0); }
  50% { box-shadow: 0 0 16px rgba(125, 186, 122, 0.5); }
  100% { box-shadow: 0 0 0 rgba(125, 186, 122, 0); }
}

.stat b.glow {
  animation: correctGlow 0.65s ease-out;
}

.lane.critical {
  box-shadow: 0 0 10px rgba(196, 75, 75, 0.6);
}

.case-head {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 10px;
}
.case-head .icon {
  width: 52px; height: 52px;
  border-radius: 16px;
  display: grid; place-items: center;
  background: #211c28;
  border: 1px solid var(--line);
  font-size: 28px;
}
.type-pill {
  display: inline-block;
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--gold);
}
.setup { line-height: 1.45; font-size: 18px; }

.choices { display: grid; gap: 10px; margin-top: 14px; }
.choice {
  text-align: left;
  border-radius: 14px;
  padding: 14px 14px;
  min-height: 56px;
  line-height: 1.35;
  background: #1c1823;
  border: 1px solid var(--line);
}
.choice:hover { border-color: rgba(228,194,122,0.45); }
.choice.best { border-color: var(--ok); background: rgba(125,186,122,0.12); }
.choice.good { border-color: #8aa36a; }
.choice.bad, .choice.worst { border-color: var(--blood); background: rgba(196,75,75,0.12); }

.lesson {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  color: var(--ink);
  line-height: 1.45;
}
.ai-note {
  margin-top: 10px;
  color: var(--muted);
  font-style: italic;
  font-size: 15px;
}

input, select, textarea {
  width: 100%;
  background: #121018;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 12px;
  min-height: 46px;
}
label { display: grid; gap: 6px; color: var(--muted); font-size: 14px; }

.ledger { display: grid; gap: 8px; max-height: 50vh; overflow: auto; }
.ledger article {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  background: #16131c;
}
.tiny { font-size: 13px; color: var(--muted); }

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(18px + var(--safe-bot));
  transform: translateX(-50%);
  background: #221c16;
  border: 1px solid var(--gold-2);
  color: var(--gold);
  padding: 10px 14px;
  border-radius: 999px;
  display: none;
  z-index: 20;
}
.toast.show { display: block; animation: rise 0.3s ease; }

footer.fine {
  margin-top: 18px;
  font-size: 12px;
  color: #8d8474;
  text-align: center;
  line-height: 1.4;
}

@media (min-width: 720px) {
  .setup { font-size: 20px; }
}
