:root {
  --ink: #16130f;
  --paper: #f4ead3;
  --paper-2: #efe1c4;
  --lantern: #f0c36a;
  --moss: #3f6b4a;
  --moss-2: #2a4a34;
  --dusk: #1c3144;
  --night: #0c161f;
  --rose: #c45c48;
  --lily: #d6f08a;
  --mist: #8fb8c4;
  --line: #2a241c;
  --hud: #0f1c24;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: Outfit, "Segoe UI", sans-serif;
  color: var(--paper);
  background: var(--night);
  overflow-x: hidden;
}
body[data-sky="dawn"] { --hud: #3a2a24; }
body[data-sky="day"] { --hud: #1c3a40; }
body[data-sky="dusk"] { --hud: #241820; }
button, input { font: inherit; }
button { cursor: pointer; }
button:focus-visible, input:focus-visible {
  outline: 3px solid var(--lantern);
  outline-offset: 2px;
}

#fx {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
}
#app { position: relative; z-index: 1; min-height: 100vh; }

.stamp {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--lantern);
  color: var(--ink);
  font-family: Fraunces, Georgia, serif;
  font-weight: 700;
  font-style: italic;
  padding: 6px 12px 8px;
  border-radius: 4px 14px 4px 14px;
  font-size: 22px;
  box-shadow: 0 8px 0 #8a5a22;
}
.stamp small {
  font-family: Outfit, sans-serif;
  font-style: normal;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: none;
}

h1, h2, h3 { font-family: Fraunces, Georgia, serif; font-weight: 650; letter-spacing: -0.03em; }
h1 { font-size: clamp(34px, 5.4vw, 68px); line-height: 0.98; margin: 0 0 12px; }
h2 { font-size: 26px; margin: 0 0 10px; }
h3 { font-size: 20px; margin: 16px 0 8px; }
p { line-height: 1.6; }

.legal {
  margin: 0 0 12px;
  font-size: 15px;
  font-weight: 650;
  line-height: 1.5;
  color: #2a241c;
  max-width: 52ch;
}

.top {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  position: sticky;
  top: 0;
  z-index: 8;
  background: linear-gradient(var(--hud) 62%, transparent);
  backdrop-filter: none;
}
.hud-chip {
  display: grid;
  gap: 2px;
  padding: 6px 10px;
  background: rgba(15, 28, 36, 0.72);
  border: 2px solid #3a2f24;
  border-radius: 10px;
  min-width: 92px;
}
.hud-chip b {
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 14px;
  color: var(--lantern);
}
.hud-chip span { font-size: 10px; color: #c9b89a; }
.session { margin-right: auto; font-size: 13px; }
.session strong { display: block; font-family: Fraunces, serif; font-size: 16px; }
.top nav { display: flex; gap: 6px; flex-wrap: wrap; margin-left: auto; }
.ghost {
  background: #13222c;
  color: var(--paper);
  border: 2px solid #3d4a42;
  border-radius: 999px;
  padding: 8px 14px;
  font-weight: 650;
}
.ghost.on, .ghost:hover { background: var(--lantern); color: var(--ink); border-color: var(--lantern); }

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 16px;
  padding: 6px 18px 88px;
  max-width: 1280px;
}
.stage { min-width: 0; }
.side { display: grid; gap: 12px; align-content: start; }
.panel {
  background: var(--paper);
  color: var(--ink);
  border-radius: 8px 22px 10px 18px;
  padding: 16px;
  box-shadow: 10px 12px 0 rgba(12, 22, 31, 0.55);
  position: relative;
}
.panel h3 { margin-top: 0; font-size: 18px; }
.panel .meter {
  height: 10px;
  background: #d9cbb0;
  border-radius: 99px;
  overflow: hidden;
  margin: 8px 0;
}
.panel .meter i {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--moss), var(--lantern));
}
.quest {
  display: grid;
  gap: 8px;
}
.quest button, .due-item, .party-row {
  width: 100%;
  text-align: left;
  border: 2px solid var(--line);
  background: var(--paper-2);
  color: var(--ink);
  border-radius: 12px;
  padding: 10px;
  font-weight: 650;
}
.party-row { display: flex; justify-content: space-between; gap: 8px; }
.muted { color: #5c5346; font-size: 13px; }

.hero {
  position: relative;
  background: var(--paper);
  color: var(--ink);
  border-radius: 10px 28px 14px 22px;
  padding: 28px 26px 22px;
  overflow: hidden;
  box-shadow: 14px 16px 0 rgba(12, 22, 31, 0.5);
  animation: rise 0.7s cubic-bezier(0.2, 0.9, 0.2, 1);
}
.hero::after {
  content: "";
  position: absolute;
  right: -30px;
  top: -40px;
  width: 180px;
  height: 180px;
  background: radial-gradient(circle at 40% 40%, var(--lantern), transparent 68%);
  pointer-events: none;
}
.pace {
  display: inline-block;
  background: var(--dusk);
  color: var(--lantern);
  padding: 6px 12px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 12px;
  margin-bottom: 10px;
}
.play {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  margin-top: 16px;
  background: var(--rose);
  color: #fff;
  border: 0;
  border-radius: 16px;
  padding: 16px 22px;
  font-family: Fraunces, serif;
  font-weight: 700;
  font-size: 22px;
  box-shadow: 8px 8px 0 var(--ink);
}
.play:hover { transform: translate(-2px, -2px); }
.play:active { transform: translate(3px, 3px); box-shadow: 3px 3px 0 var(--ink); }
.play small { display: block; font-family: Outfit, sans-serif; font-size: 13px; font-weight: 650; opacity: 0.92; }

.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-top: 18px;
}
.stat {
  background: #fff8ea;
  border: 2px solid var(--ink);
  border-radius: 14px;
  padding: 12px;
}
.stat b { display: block; font-family: Fraunces, serif; font-size: 26px; }
.stat span { font-size: 12px; color: #5c574c; }

.track {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  padding: 22px 4px 8px;
  scroll-snap-type: x mandatory;
}
.node {
  flex: 0 0 176px;
  scroll-snap-align: start;
  min-height: 176px;
  border-radius: 18px 8px 16px 10px;
  border: 3px solid var(--ink);
  padding: 14px;
  text-align: left;
  color: var(--ink);
  background: var(--paper-2);
  box-shadow: 7px 7px 0 #1a1c24;
  animation: rise 0.6s both;
}
.node.now { background: var(--lantern); }
.node.done { background: var(--lily); }
.node.lock { background: #24343c; color: #9aa8b0; box-shadow: none; border-color: #3a4a52; }
.node.wait { background: #161821; color: #c5bfae; border-style: dashed; }
.node .n { font-family: "IBM Plex Mono", monospace; font-size: 18px; }
.node .t { font-size: 13px; margin-top: 6px; font-weight: 700; }
.node .s { font-size: 11px; margin-top: 8px; opacity: 0.75; }

.lesson {
  background: var(--paper);
  color: var(--ink);
  border-radius: 10px 24px 12px 20px;
  padding: 26px;
  box-shadow: 12px 14px 0 rgba(12, 22, 31, 0.45);
  animation: rise 0.45s ease;
}
.ticks { display: flex; gap: 6px; margin-bottom: 16px; }
.ticks i { height: 8px; flex: 1; background: #d9d0ba; border-radius: 99px; }
.ticks i.on { background: var(--rose); }
.block-now { min-height: 160px; }
.block-now ul { padding-left: 18px; }
.example {
  background: var(--dusk);
  color: var(--lily);
  padding: 16px;
  border-radius: 14px;
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  white-space: pre-wrap;
  font-size: 13px;
}
.box {
  background: #ffe27a;
  border: 3px solid var(--ink);
  border-radius: 12px;
  padding: 12px 14px;
}
.box.warn { background: #ffb4a8; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 22px; }
.btn {
  background: var(--ink);
  color: var(--lantern);
  border: 0;
  border-radius: 14px;
  padding: 14px 18px;
  font-weight: 800;
  box-shadow: 5px 5px 0 var(--rose);
}
.btn:hover { transform: translate(-1px, -1px); }
.btn.quiet { background: transparent; color: var(--ink); box-shadow: none; border: 2px solid var(--ink); }
.btn:disabled { opacity: 0.45; transform: none; cursor: not-allowed; }

.phase {
  display: inline-block;
  background: var(--dusk);
  color: var(--lily);
  font-size: 12px;
  font-weight: 700;
  padding: 5px 10px;
  border-radius: 999px;
  margin-bottom: 10px;
}
.wound {
  background: #3a1c1a;
  color: #f6ddd6;
  padding: 16px;
  border-radius: 14px;
  margin: 12px 0;
}
.wound strong { color: var(--lantern); }
.rule-line {
  font-family: Fraunces, serif;
  font-size: 22px;
  line-height: 1.35;
  margin: 12px 0;
}
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  border: 2px solid var(--ink);
  background: #fff;
  color: var(--ink);
  border-radius: 999px;
  padding: 10px 14px;
  font-weight: 700;
}
.chip:hover, .chip.on { background: var(--lantern); }
.scoreboard {
  display: grid;
  gap: 6px;
  margin: 12px 0;
}
.scoreboard i {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #cfc3ab;
  margin-right: 3px;
}
.scoreboard i.ok { background: var(--moss); }
.scoreboard i.fix { background: var(--lantern); }
.scoreboard i.bad { background: var(--rose); }

.opt {
  display: block;
  width: 100%;
  text-align: left;
  margin: 8px 0;
  padding: 14px 16px;
  border-radius: 14px;
  border: 3px solid var(--ink);
  background: #fff;
  color: var(--ink);
  font-weight: 700;
}
.opt:hover:not(:disabled) { background: var(--lily); }
.opt.right { background: #b6f5c8; }
.opt.wrong { background: #ffb3ab; }
.opt.yours { box-shadow: inset 0 0 0 3px var(--rose); }
.explain { margin-top: 12px; padding: 12px; background: #fff3c4; border-radius: 10px; }
.partitura {
  margin-top: 14px;
  padding: 14px;
  background: #1c3144;
  color: #f4ead3;
  border-radius: 12px;
}
.partitura b { color: var(--lantern); }

.gate {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 32px 16px;
}
.gate-card {
  width: min(460px, 100%);
  background: var(--paper);
  color: var(--ink);
  border-radius: 10px 28px 14px 22px;
  padding: 32px 28px;
  box-shadow: 16px 18px 0 rgba(12, 22, 31, 0.55);
}
.gate-card h1 { font-size: 46px; }
.gate-form, .account-form { display: grid; gap: 12px; }
label { display: grid; gap: 6px; font-size: 14px; font-weight: 700; }
input {
  border: 3px solid var(--ink);
  border-radius: 12px;
  padding: 12px;
  background: #fff;
  color: var(--ink);
}
.auth-error { color: var(--rose); font-weight: 700; margin: 0; }
.text-link {
  background: none;
  border: 0;
  padding: 0;
  color: var(--ink);
  text-decoration: underline;
  font-weight: 800;
}

table.plain { width: 100%; border-collapse: collapse; }
table.plain td, table.plain th {
  border-bottom: 2px solid var(--ink);
  text-align: left;
  padding: 8px 4px;
  font-size: 14px;
}

.bars { display: grid; gap: 8px; }
.bar-row { display: grid; grid-template-columns: 90px 1fr 40px; gap: 8px; align-items: center; font-size: 13px; }
.bar-row u {
  display: block;
  height: 10px;
  background: #d9cbb0;
  border-radius: 99px;
  text-decoration: none;
}
.bar-row u i {
  display: block;
  height: 100%;
  background: var(--moss);
  border-radius: 99px;
}
.insight-list { display: grid; gap: 10px; }
.insight-list p {
  margin: 0;
  padding: 12px;
  background: var(--paper-2);
  border-left: 0;
  border-radius: 12px;
  border: 2px solid var(--line);
}

.combo-pop {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 12;
  background: var(--lantern);
  color: var(--ink);
  font-family: "IBM Plex Mono", monospace;
  font-weight: 700;
  padding: 10px 14px;
  border-radius: 12px;
  box-shadow: 6px 6px 0 var(--rose);
}

#toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--lantern);
  color: var(--ink);
  font-weight: 800;
  padding: 12px 18px;
  border-radius: 14px;
  z-index: 20;
  box-shadow: 6px 6px 0 var(--rose);
}
#idle {
  position: fixed;
  inset: 0;
  z-index: 30;
  background: rgba(12, 22, 31, 0.88);
  display: grid;
  place-items: center;
}
#idle[hidden] { display: none; }
#idle-ok {
  background: var(--lantern);
  color: var(--ink);
  border: 0;
  font-family: Fraunces, serif;
  font-size: 26px;
  font-weight: 700;
  padding: 20px 28px;
  border-radius: 18px;
}

.focus-on .track, .focus-on .top nav, .focus-on .side, .focus-on .hero { display: none; }
.focus-on .layout { grid-template-columns: 1fr; max-width: 760px; margin: 0 auto; }

@keyframes rise {
  from { opacity: 0; transform: translateY(18px) scale(0.98); }
  to { opacity: 1; transform: none; }
}

@media (max-width: 980px) {
  .layout { grid-template-columns: 1fr; }
  .stats { grid-template-columns: 1fr 1fr; }
  h1 { font-size: 36px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
  }
  #fx { display: none; }
}
