:root {
  --bg: #0b1030;
  --bg2: #141a45;
  --card: #1a2157;
  --card2: #222a68;
  --ink: #f6eedd;
  --muted: #b9b4d6;
  --saffron: #ff8a1f;
  --gold: #f6c453;
  --lotus: #ff6f91;
  --sea: #2bb3c0;
  --danger: #ff5a5a;
  --ok: #5fd68a;
  --line: rgba(246, 196, 83, 0.25);
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  --radius: 18px;
  --display: "Rozha One", Georgia, serif;
  --body: "Mukta", system-ui, -apple-system, "Segoe UI", sans-serif;
  color-scheme: dark;
}
[data-theme="light"] {
  --bg: #fbf3e2;
  --bg2: #f4e5c6;
  --card: #fffaf0;
  --card2: #f7ecd5;
  --ink: #2a1a0e;
  --muted: #6c5640;
  --saffron: #c9530a;
  --gold: #8a5a00;
  --lotus: #c2275a;
  --sea: #0d7c88;
  --danger: #b71c1c;
  --ok: #1b7a40;
  --line: rgba(166, 108, 0, 0.3);
  --shadow: 0 10px 30px rgba(110, 70, 10, 0.15);
  color-scheme: light;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--body);
  font-size: 17px;
  line-height: 1.55;
  color: var(--ink);
  background: radial-gradient(1200px 600px at 50% -200px, var(--bg2), var(--bg)) fixed;
  min-height: 100vh;
  overflow-x: hidden;
}
a { color: var(--gold); }
a:hover { color: var(--saffron); }
img, svg, canvas { max-width: 100%; }
h1, h2, h3 { font-family: var(--display); font-weight: 400; line-height: 1.15; margin: 0 0 .5em; letter-spacing: .01em; }
h1 { font-size: clamp(2.1rem, 7vw, 3.8rem); }
h2 { font-size: clamp(1.6rem, 4.5vw, 2.3rem); }
h3 { font-size: 1.3rem; }
p { margin: 0 0 1em; }
.skip { position: absolute; left: -999px; top: 0; background: var(--gold); color: #000; padding: 8px 12px; z-index: 100; }
.skip:focus { left: 8px; top: 8px; }
:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; border-radius: 6px; }

/* header */
.site-header {
  position: sticky; top: 0; z-index: 20;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.nav-wrap { max-width: 1100px; margin: 0 auto; display: flex; align-items: center; gap: 10px; padding: 8px 14px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 8px; text-decoration: none; color: var(--ink); font-family: var(--display); font-size: 1.25rem; }
.brand img { width: 30px; height: 30px; }
.nav { display: flex; gap: 2px; flex-wrap: wrap; margin-left: auto; }
.nav a { text-decoration: none; color: var(--muted); padding: 6px 10px; border-radius: 999px; font-weight: 600; font-size: .95rem; }
.nav a:hover { color: var(--ink); background: var(--card); }
.nav a[aria-current="page"] { color: var(--bg); background: var(--gold); }
.tools { display: flex; gap: 6px; }
.icon-btn { background: var(--card); color: var(--ink); border: 1px solid var(--line); border-radius: 999px; width: 38px; height: 38px; cursor: pointer; font-size: 1.05rem; display: inline-grid; place-items: center; }
.icon-btn:hover { border-color: var(--gold); }
@media (max-width: 640px) {
  .nav { order: 3; width: 100%; justify-content: space-between; margin-left: 0; }
  .nav a { padding: 5px 6px; font-size: .84rem; }
  .tools { margin-left: auto; }
}

main { max-width: 1100px; margin: 0 auto; padding: 18px 14px 40px; }
.hero { text-align: center; padding: 18px 0 8px; }
.kicker { text-transform: uppercase; letter-spacing: .18em; font-size: .78rem; color: var(--saffron); font-weight: 700; margin-bottom: .4em; }
.lede { color: var(--muted); max-width: 680px; margin: 0 auto 1em; font-size: 1.08rem; }
.gold { color: var(--gold); }
.saffron { color: var(--saffron); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font: 700 1rem var(--body); cursor: pointer; text-decoration: none;
  padding: 11px 20px; border-radius: 999px; border: 2px solid transparent;
  background: linear-gradient(135deg, var(--saffron), var(--gold)); color: #1b0d00;
  box-shadow: 0 4px 0 rgba(0,0,0,.25); transition: transform .12s, box-shadow .12s;
  min-height: 44px;
}
.btn:hover { transform: translateY(-1px); color: #1b0d00; }
.btn:active { transform: translateY(2px); box-shadow: 0 1px 0 rgba(0,0,0,.25); }
.btn.ghost { background: transparent; color: var(--ink); border-color: var(--line); box-shadow: none; }
.btn.ghost:hover { border-color: var(--gold); color: var(--ink); }
.btn.small { padding: 7px 14px; font-size: .9rem; min-height: 36px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.row { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; align-items: center; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.grid { display: grid; gap: 14px; }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.grid.three { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.section { margin: 34px 0; }

.seg { display: inline-flex; background: var(--card); border: 1px solid var(--line); border-radius: 999px; padding: 3px; flex-wrap: wrap; justify-content: center; }
.seg button { background: none; border: 0; color: var(--muted); font: 700 .92rem var(--body); padding: 7px 13px; border-radius: 999px; cursor: pointer; min-height: 36px; }
.seg button[aria-pressed="true"] { background: var(--gold); color: var(--bg); }

/* game stage */
.stage-wrap { position: relative; max-width: 960px; margin: 0 auto; }
.stage {
  position: relative; width: 100%; aspect-ratio: 16 / 10; border-radius: var(--radius); overflow: hidden;
  border: 2px solid var(--line); box-shadow: var(--shadow); background: #08102e; touch-action: none; user-select: none; -webkit-user-select: none;
}
@media (max-width: 640px) { .stage { aspect-ratio: 4 / 5; } }
.stage.tall { aspect-ratio: 3 / 4; max-width: 520px; margin: 0 auto; }
.stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.overlay {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; padding: 18px; background: rgba(6, 9, 30, .72); color: #f6eedd; overflow-y: auto;
}
.overlay { justify-content: flex-start; }
.overlay > :first-child { margin-top: auto; }
.overlay > :last-child { margin-bottom: auto; }
.overlay[hidden] { display: none; }
@media (max-width: 640px) {
  .overlay { padding: 12px; font-size: .94rem; }
  .overlay h2 { font-size: 1.5rem; }
  .overlay p { margin-bottom: .6em; }
  .result-card .big { font-size: 2.1rem; }
  .result-card .rank { font-size: 1.5rem; }
}
.overlay h2 { color: #f6c453; }
.overlay p { color: #e6def5; max-width: 520px; }
.overlay .seg { background: rgba(255,255,255,.08); border-color: rgba(246,196,83,.35); }
.overlay .seg button { color: #d9d2f0; }
.overlay .seg button[aria-pressed="true"] { color: #1b0d00; background: #f6c453; }
.overlay a { color: #f6c453; }
.overlay .btn.ghost { color: #f6eedd; border-color: rgba(246,196,83,.45); }
.opt-label { font-size: .78rem; text-transform: uppercase; letter-spacing: .14em; color: #f6c453; margin: 8px 0 4px; }
.controls-bar { display: flex; gap: 10px; justify-content: space-between; align-items: center; margin-top: 10px; flex-wrap: wrap; }
.size-btns { display: flex; gap: 8px; }
.size-btns button { min-width: 64px; }
.size-btns button[aria-pressed="true"] { background: var(--gold); color: var(--bg); border-color: var(--gold); }
@media (max-width: 400px) { .size-btns button { padding: 7px 10px; } }
.hint { color: var(--muted); font-size: .92rem; }
kbd { background: var(--card2); border: 1px solid var(--line); border-bottom-width: 3px; border-radius: 6px; padding: 0 6px; font-size: .85em; font-family: var(--body); }

.result-card {
  background: linear-gradient(160deg, #1d2466, #0b1030 70%); color: #f6eedd; border: 2px solid #f6c453; border-radius: 22px;
  padding: 18px; max-width: 440px; width: 100%; margin: 6px auto; text-align: center; position: relative; overflow: hidden;
}
.result-card .rank { font-family: var(--display); font-size: 1.9rem; color: #f6c453; margin: 0; }
.result-card .big { font-size: 2.6rem; font-family: var(--display); line-height: 1; color: #fff; }
.virtues { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; margin: 10px 0; padding: 0; list-style: none; }
.virtues li { font-size: .82rem; padding: 3px 10px; border-radius: 999px; border: 1px solid rgba(246,196,83,.4); color: #9e98c2; }
.virtues li.on { background: #f6c453; color: #1b0d00; border-color: #f6c453; font-weight: 700; }
.stat-row { display: flex; justify-content: center; gap: 18px; flex-wrap: wrap; font-size: .9rem; color: #cfc8ea; }
.stat-row b { display: block; color: #fff; font-size: 1.2rem; }

.toast { position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%) translateY(120px); background: var(--gold); color: #1b0d00; padding: 10px 18px; border-radius: 999px; font-weight: 700; z-index: 200; transition: transform .25s; box-shadow: var(--shadow); }
.toast.show { transform: translateX(-50%) translateY(0); }

.feature-cards a.card { text-decoration: none; color: var(--ink); display: block; transition: transform .15s, border-color .15s; }
.feature-cards a.card:hover { transform: translateY(-3px); border-color: var(--gold); }
.feature-cards .emoji { font-size: 2rem; }

.encounter-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.encounter-list li { display: grid; grid-template-columns: 64px 1fr; gap: 12px; align-items: start; }
.yj { font-family: var(--display); color: var(--gold); font-size: 1.3rem; text-align: right; }

.best { font-size: .9rem; color: var(--muted); }

/* quiz */
.quiz-box { max-width: 720px; margin: 0 auto; }
.q-meta { display: flex; justify-content: space-between; color: var(--muted); font-size: .9rem; margin-bottom: 8px; }
.progress { height: 8px; border-radius: 99px; background: var(--card2); overflow: hidden; margin-bottom: 14px; }
.progress span { display: block; height: 100%; background: linear-gradient(90deg, var(--saffron), var(--gold)); width: 0; transition: width .3s; }
.q-text { font-size: 1.3rem; font-weight: 700; margin-bottom: 14px; }
.answers { display: grid; gap: 10px; }
.answers button {
  text-align: left; font: 600 1rem var(--body); color: var(--ink); background: var(--card2); border: 2px solid var(--line);
  padding: 12px 14px; border-radius: 14px; cursor: pointer; min-height: 48px;
}
.answers button:hover:not([disabled]) { border-color: var(--gold); }
.answers button.right { border-color: var(--ok); background: color-mix(in srgb, var(--ok) 22%, var(--card2)); }
.answers button.wrong { border-color: var(--danger); background: color-mix(in srgb, var(--danger) 18%, var(--card2)); }
.explain { margin-top: 12px; padding: 12px 14px; border-left: 4px solid var(--gold); background: var(--card2); border-radius: 0 12px 12px 0; }
.tag { display: inline-block; font-size: .72rem; text-transform: uppercase; letter-spacing: .1em; padding: 2px 8px; border-radius: 99px; border: 1px solid var(--line); color: var(--muted); }
.tag.p1 { color: var(--sea); border-color: var(--sea); }
.tag.p2 { color: var(--lotus); border-color: var(--lotus); }
.tag.later { color: var(--gold); border-color: var(--gold); }

/* story */
.kanda-track { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; margin: 16px 0; }
.kanda-track button {
  background: var(--card); border: 2px solid var(--line); border-radius: 14px; padding: 10px 4px; color: var(--ink);
  font: 700 .82rem var(--body); cursor: pointer; min-height: 70px; position: relative;
}
.kanda-track button .n { display: block; font-family: var(--display); font-size: 1.4rem; color: var(--gold); }
.kanda-track button.film { border-color: var(--sea); }
.kanda-track button[aria-pressed="true"] { background: var(--gold); color: var(--bg); }
.kanda-track button[aria-pressed="true"] .n { color: var(--bg); }
@media (max-width: 560px) {
  .kanda-track { grid-template-columns: repeat(4, 1fr); }
}
.film-line { font-size: .85rem; color: var(--sea); text-align: center; }
.kanda-detail ol { padding-left: 1.2em; }
.kanda-detail li { margin-bottom: .45em; }
.filters { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin: 12px 0 16px; }
.filters input { font: 1rem var(--body); padding: 9px 14px; border-radius: 999px; border: 1px solid var(--line); background: var(--card); color: var(--ink); min-width: 200px; }
.char-card h3 { margin-bottom: .2em; }
.char-card .role { color: var(--saffron); font-weight: 700; font-size: .92rem; margin-bottom: .4em; }
.char-card .cast { font-size: .88rem; color: var(--muted); margin-top: .5em; }
.char-card .glyph { float: right; font-size: 2rem; margin-left: 8px; }

/* setu */
.setu-hud { display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; font-weight: 700; margin-top: 8px; }
.daybar { display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px; margin-top: 8px; }
.daybar span { height: 10px; border-radius: 99px; background: var(--card2); }
.daybar span.done { background: var(--gold); }
.daybar span.now { background: var(--saffron); }

footer.site-footer { border-top: 1px solid var(--line); padding: 22px 14px 40px; text-align: center; color: var(--muted); font-size: .9rem; }
footer.site-footer a { color: var(--muted); }

.prose { max-width: 760px; margin: 0 auto; }
.prose h2 { margin-top: 1.4em; }
.prose ul { padding-left: 1.2em; }
.prose li { margin-bottom: .4em; }
.note { font-size: .9rem; color: var(--muted); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; scroll-behavior: auto !important; }
}
.float-in { animation: floatIn .5s ease both; }
@keyframes floatIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
