@font-face {
  font-family: 'Cinzel';
  font-style: normal;
  font-weight: 400 900;
  font-display: swap;
  src: url(fonts/cinzel-latin-ext.woff2) format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'Cinzel';
  font-style: normal;
  font-weight: 400 900;
  font-display: swap;
  src: url(fonts/cinzel-latin.woff2) format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  --bg: #121018;
  --bg2: #19161f;
  --bg3: #211d29;
  --slate: #2a2633;
  --slate2: #322d3d;
  --ink: #ece3cf;
  --ink2: #cfc4ad;
  --muted: #968c7a;
  --gold: #e2b65a;
  --gold2: #f3d58a;
  --line: rgba(236, 227, 207, 0.11);
  --ok: #79c784;
  --no: #e86b5a;
  --alien: 'Cinzel', 'Trajan Pro', 'Times New Roman', serif;
  --ui: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: radial-gradient(1200px 700px at 30% -10%, #241f2e 0%, var(--bg) 60%) fixed, var(--bg);
  color: var(--ink);
  font-family: var(--ui);
  font-size: 15px;
  line-height: 1.5;
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
}
button { font: inherit; color: inherit; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.alien { font-family: var(--alien); letter-spacing: 0.03em; }
.eyebrow { font-family: var(--alien); font-size: 12px; letter-spacing: 0.18em; text-transform: uppercase; color: var(--gold); }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 16px; border-radius: 10px; cursor: pointer;
  background: var(--slate2); border: 1px solid rgba(236, 227, 207, 0.16);
  color: var(--ink); font-weight: 600; letter-spacing: 0.01em;
  transition: background 0.15s, transform 0.08s, border-color 0.15s;
  touch-action: manipulation;
}
.btn:hover { background: #3b3547; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.4; cursor: default; }
.btn.primary { background: linear-gradient(180deg, #ebc56d, #c99a3c); color: #1b1408; border-color: #f2d58d; }
.btn.primary:hover { background: linear-gradient(180deg, #f3d17f, #d4a646); }
.btn.ghost { background: transparent; }
.btn.ghost:hover { background: rgba(236, 227, 207, 0.06); }
.btn.sm { padding: 5px 10px; font-size: 13px; border-radius: 8px; }
.btn.wide { width: 100%; margin-top: 14px; }
.btn.grow { flex: 1; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 12px; }
.btn-row.center { justify-content: center; }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; border-radius: 50%; cursor: pointer;
  background: transparent; border: 1px solid var(--line); color: var(--ink2); font-weight: 700;
}
.icon-btn:hover { background: rgba(236, 227, 207, 0.07); }
.link { background: none; border: none; color: var(--gold2); cursor: pointer; text-decoration: underline; text-underline-offset: 3px; padding: 8px; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

/* ---------- title ---------- */
#title { min-height: 100dvh; display: flex; align-items: center; justify-content: center; padding: 24px 16px; position: relative; overflow: hidden; }
.title-wrap { max-width: 760px; width: 100%; text-align: center; position: relative; z-index: 1; }
.title-glyphs { position: fixed; inset: 0; pointer-events: none; z-index: -1; }
.title-glyphs span {
  position: absolute; font-family: var(--alien); color: rgba(226, 182, 90, 0.05);
  animation: drift 16s ease-in-out infinite;
}
@keyframes drift { 0%, 100% { transform: translateY(0); opacity: 0.5; } 50% { transform: translateY(-18px); opacity: 1; } }
.logo-big {
  font-family: var(--alien); font-weight: 700; font-size: clamp(54px, 13vw, 104px); letter-spacing: 0.12em; margin: 0;
  background: linear-gradient(180deg, #fbe7b0 10%, #d9a94a 60%, #9c7126); -webkit-background-clip: text; background-clip: text; color: transparent;
  text-shadow: 0 6px 40px rgba(226, 182, 90, 0.15);
}
.tag { font-size: 18px; color: var(--ink2); margin: 4px 0 28px; }
.cards { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; text-align: left; }
.card {
  background: linear-gradient(160deg, rgba(50, 45, 61, 0.97), rgba(33, 29, 41, 0.97));
  border: 1px solid var(--line); border-radius: 16px; padding: 18px 18px 20px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
}
.card-title { font-family: var(--alien); font-size: 20px; font-weight: 600; margin: 4px 0 2px; }
.card .btn { margin-top: 6px; }
.done-line { display: flex; gap: 10px; align-items: center; margin: 4px 0 6px; color: var(--ink2); }
.done-line { font-size: 15px; }
.seg { display: flex; background: rgba(0, 0, 0, 0.25); border-radius: 10px; padding: 3px; margin: 8px 0 4px; border: 1px solid var(--line); }
.seg button { flex: 1; background: none; border: none; padding: 8px 4px; border-radius: 8px; cursor: pointer; color: var(--ink2); font-weight: 600; font-size: 14px; }
.seg button.on { background: var(--slate2); color: var(--gold2); box-shadow: 0 1px 0 rgba(255, 255, 255, 0.06) inset; }
.foot { color: var(--muted); font-size: 13px; margin-top: 18px; }
.stats-line { color: var(--ink2); font-size: 14px; margin: 4px 0 0; font-variant-numeric: tabular-nums; }
@media (max-width: 640px) {
  .cards { grid-template-columns: 1fr; }
}

/* ---------- game layout ---------- */
#game { display: grid; grid-template-rows: auto 1fr; height: 100dvh; }
#hud {
  display: flex; align-items: center; gap: 14px; padding: 8px 16px;
  border-bottom: 1px solid var(--line); background: rgba(18, 16, 24, 0.9); backdrop-filter: blur(8px);
  position: relative; z-index: 15;
}
.logo-short { display: none; }
.logo { font-family: var(--alien); font-weight: 700; letter-spacing: 0.14em; font-size: 18px; color: var(--gold); background: none; border: none; cursor: pointer; padding: 4px 2px; }
.hud-lang { display: flex; flex-direction: column; line-height: 1.1; }
.hud-lang .alien { font-size: 15px; color: var(--ink); }
.seals { display: flex; gap: 6px; margin-left: auto; }
.seal { width: 14px; height: 14px; border-radius: 50%; display: inline-block; background: rgba(255, 255, 255, 0.06); border: 1px solid rgba(255, 255, 255, 0.16); }
.seal.cur { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(226, 182, 90, 0.18); animation: pulse 2.2s ease-in-out infinite; }
.seal.gold { background: radial-gradient(circle at 35% 30%, #fff4c8, #e2b65a 45%, #8d661c); border-color: #f5d88f; }
.seal.silver { background: radial-gradient(circle at 35% 30%, #ffffff, #c3c7cf 45%, #6c727c); border-color: #e3e6ea; }
.seal.bronze { background: radial-gradient(circle at 35% 30%, #ffd9b5, #bb7643 45%, #66391a); border-color: #dca275; }
@keyframes pulse { 50% { box-shadow: 0 0 0 6px rgba(226, 182, 90, 0.05); } }
.hud-stats { display: flex; gap: 12px; color: var(--ink2); font-variant-numeric: tabular-nums; }
.stat { display: inline-flex; align-items: center; gap: 4px; }

#panes { display: grid; grid-template-columns: minmax(0, 1fr) minmax(360px, 440px); min-height: 0; }
#codex { overflow-y: auto; padding: 14px 20px 60px; min-height: 0; }
#panel { overflow-y: auto; border-left: 1px solid var(--line); background: var(--bg2); min-height: 0; }

.codex-head { display: flex; align-items: baseline; gap: 12px; margin-bottom: 4px; }
.codex-head h2 { font-family: var(--alien); font-size: 20px; margin: 0; letter-spacing: 0.08em; }
.chap { margin-top: 14px; }
.chap h3 { font-family: var(--alien); font-weight: 600; font-size: 14px; letter-spacing: 0.1em; color: var(--ink2); margin: 0 0 8px; display: flex; align-items: center; gap: 8px; text-transform: uppercase; }
.chap h3 .rn { color: var(--gold); min-width: 26px; }
.chap h3 { cursor: pointer; user-select: none; }
.chap h3 .cnt { font-family: var(--ui); font-size: 11px; letter-spacing: 0; color: var(--muted); background: rgba(236, 227, 207, 0.07); border-radius: 999px; padding: 0 7px; }
.chap h3 .fold { display: inline-flex; color: var(--muted); transition: transform 0.15s; }
.chap.folded h3 .fold { transform: rotate(-90deg); }
.chap.folded .grid, .chap.folded .empty-chap { display: none; }
.empty-chap { margin: 0 0 8px; }
.chap.current h3 { color: var(--ink); }
.chap:not(.current) .tablet { background: linear-gradient(160deg, #26222e, #201c27); }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(196px, 1fr)); gap: 12px; }

/* ---------- tablets ---------- */
.tablet {
  position: relative; border-radius: 12px; padding: 8px 10px 8px;
  background: linear-gradient(160deg, #2e2938, #25212d);
  border: 1px solid rgba(255, 240, 210, 0.08);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04), 0 3px 10px rgba(0, 0, 0, 0.28);
  transition: opacity 0.2s, filter 0.2s;
}
.tablet.dim { opacity: 0.2; filter: saturate(0.4); }
.tablet.fresh { animation: carve 1.1s ease-out both; }
@keyframes carve {
  0% { opacity: 0; transform: translateY(8px) scale(0.97); filter: blur(4px); }
  45% { opacity: 1; filter: none; box-shadow: 0 0 0 2px rgba(226, 182, 90, 0.7), 0 0 26px rgba(226, 182, 90, 0.35); }
  100% { transform: none; box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04), 0 3px 10px rgba(0, 0, 0, 0.28); }
}
.tablet .tag {
  position: absolute; top: 6px; right: 8px; font-size: 10px; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--muted); background: rgba(0, 0, 0, 0.3); padding: 1px 6px; border-radius: 6px;
}
.tablet.src-rev .tag { color: #f0a090; }
.tablet[class*='src-ans'] .tag { color: #a6d9a9; }
.tablet.src-dig .tag { color: var(--gold2); }
.pic { width: 100%; height: auto; display: block; }
.pic .divider { stroke: rgba(236, 227, 207, 0.32); stroke-width: 1.3; stroke-dasharray: 4 3; stroke-linecap: round; }

/* ---------- sentences ---------- */
.sent, .sentence, .answer { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 2px 11px; font-family: var(--alien); }
.sent { margin-top: 4px; }
.w { display: inline-flex; align-items: flex-start; }
.m {
  display: inline-flex; flex-direction: column; align-items: center; cursor: pointer;
  padding: 1px 3px 0; border-radius: 5px; transition: background 0.12s;
}
.m:hover { background: rgba(236, 227, 207, 0.08); }
.m b { font-weight: 600; font-size: 15.5px; letter-spacing: 0.03em; color: var(--ink); white-space: nowrap; }
.m.suf { padding-left: 0; }
.w > .m:has(+ .suf) { padding-right: 0; }
.m.suf b { color: var(--gold2); }
.m .gl { font-style: normal; font-family: var(--ui); height: 15px; font-size: 11px; line-height: 15px; display: flex; align-items: center; justify-content: center; color: var(--ink2); }
.m.hl { background: rgba(226, 182, 90, 0.2); box-shadow: 0 0 0 1px rgba(226, 182, 90, 0.55); }
.m.bad b { color: var(--no); text-decoration: line-through; text-decoration-thickness: 2px; }
.m[data-mark='sel'] { background: rgba(226, 182, 90, 0.25); box-shadow: 0 0 0 2px var(--gold); }
.m[data-mark='bad'] { background: rgba(232, 107, 90, 0.18); box-shadow: 0 0 0 2px var(--no); }
.m[data-mark='miss'] { box-shadow: 0 0 0 2px rgba(236, 227, 207, 0.4); }
.m[data-mark='good'] { background: rgba(121, 199, 132, 0.18); box-shadow: 0 0 0 2px var(--ok); }
.sentence.big .m b { font-size: 21px; }
.sentence.big { gap: 4px 14px; justify-content: center; padding: 6px 0; }
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.4); }
.dot.big { width: 18px; height: 18px; }
body.patterns .dot { position: relative; }
body.patterns .dot.big::after { content: attr(data-c); position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 10px; font-weight: 800; color: rgba(0, 0, 0, 0.7); }
.help-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-top: 6px; }
.gnum { font-weight: 700; color: var(--ink); font-size: 12px; }
.gsym { font-weight: 700; color: var(--gold2); font-size: 11px; letter-spacing: 0.02em; }
.gtext { font-size: 10.5px; color: #c9d7f0; max-width: 64px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.icon { display: block; }

/* ---------- panel ---------- */
.phead {
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
  padding: 10px 14px; border-bottom: 1px solid var(--line);
  position: sticky; top: 0; background: var(--bg2); z-index: 3;
}
.pstep { display: flex; align-items: center; gap: 10px; font-size: 13px; }
.phead-r { display: flex; align-items: center; gap: 6px; }
.collapse-btn { display: none; }
.kind {
  font-family: var(--alien); font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; font-size: 12px;
  padding: 3px 10px; border-radius: 999px; background: rgba(226, 182, 90, 0.14); color: var(--gold2);
}
.kind.k-read { background: rgba(77, 134, 236, 0.18); color: #a9c6ff; }
.kind.k-spot { background: rgba(226, 85, 63, 0.18); color: #ffb2a4; }
.pbody { padding: 12px 16px 22px; }
.prompt { margin: 2px 0 10px; color: var(--ink2); }
.target .pic.big {
  background: radial-gradient(120% 120% at 50% 0%, #332e3f, #26222f);
  border-radius: 12px; border: 1px solid rgba(255, 240, 210, 0.1);
  max-height: 34vh;
}
.answer {
  min-height: 58px; margin-top: 12px; padding: 8px 10px; border-radius: 10px;
  border: 1px dashed rgba(236, 227, 207, 0.25); background: rgba(0, 0, 0, 0.18); align-items: center;
}
.answer.has { border-style: solid; border-color: rgba(226, 182, 90, 0.4); }
.answer .m b { font-size: 18px; }
.placeholder { color: var(--muted); font-family: var(--ui); font-size: 14px; }
.typed { font-family: var(--alien); color: var(--gold2); font-size: 18px; opacity: 0.8; }
.caret { width: 2px; height: 20px; background: var(--gold); animation: blink 1s steps(1) infinite; align-self: center; margin-left: -6px; }
@keyframes blink { 50% { opacity: 0; } }
.crow { display: flex; gap: 8px; margin-top: 10px; }
.palette { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); }
.tile {
  font-family: var(--alien); cursor: pointer; touch-action: manipulation;
  background: linear-gradient(180deg, #37313f, #2c2734); border: 1px solid rgba(255, 240, 210, 0.13);
  border-radius: 8px; padding: 5px 10px 2px; display: inline-flex; flex-direction: column; align-items: center; min-width: 50px;
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.35); transition: transform 0.06s, background 0.12s;
}
.tile:hover { background: linear-gradient(180deg, #423b4b, #332d3c); }
.tile:active { transform: translateY(2px); box-shadow: none; }
.tile b { font-weight: 600; font-size: 16px; letter-spacing: 0.03em; }
.tile.suf b { color: var(--gold2); }
.tile .gl { font-style: normal; font-family: var(--ui); height: 15px; font-size: 11px; line-height: 15px; display: flex; align-items: center; }
.tile.hl { box-shadow: 0 0 0 2px var(--gold); }

.options { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 8px; }
.opt {
  position: relative; cursor: pointer; padding: 4px; border-radius: 12px;
  background: linear-gradient(160deg, #2e2938, #25212d); border: 2px solid rgba(255, 240, 210, 0.08);
  transition: border-color 0.12s, transform 0.08s;
}
.opt:hover { border-color: rgba(226, 182, 90, 0.4); }
.opt.sel { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(226, 182, 90, 0.2); }
.opt.right { border-color: var(--ok); box-shadow: 0 0 0 3px rgba(121, 199, 132, 0.2); }
.opt.wrong { border-color: var(--no); opacity: 0.75; }
.opt:disabled { cursor: default; }
.optn { position: absolute; top: 4px; left: 8px; font-size: 11px; color: var(--muted); font-weight: 700; }

.banner { margin-top: 14px; padding: 10px 12px; border-radius: 10px; font-weight: 700; }
.banner .muted { font-weight: 400; margin-left: 4px; }
.banner.ok { background: rgba(121, 199, 132, 0.12); color: #b7e8bc; border: 1px solid rgba(121, 199, 132, 0.3); }
.banner.no { background: rgba(232, 107, 90, 0.12); color: #ffc0b5; border: 1px solid rgba(232, 107, 90, 0.3); }
.fb-line { margin-top: 10px; display: flex; flex-direction: column; gap: 2px; }
.fb-line .lbl { font-size: 11px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); }
.fb-line .sentence .m b { font-size: 18px; }
#panel.flash-ok { animation: flashOk 0.8s ease-out; }
#panel.flash-no { animation: flashNo 0.5s ease-out; }
@keyframes flashOk { 0% { box-shadow: inset 0 0 0 2px var(--ok), inset 0 0 40px rgba(121, 199, 132, 0.25); } 100% { box-shadow: none; } }
@keyframes flashNo {
  0% { box-shadow: inset 0 0 0 2px var(--no); transform: translateX(0); }
  20% { transform: translateX(-5px); } 40% { transform: translateX(5px); } 60% { transform: translateX(-3px); } 80% { transform: translateX(2px); }
  100% { box-shadow: none; transform: none; }
}

/* ---------- gloss popover ---------- */
#gloss {
  position: fixed; z-index: 40; width: 330px; padding: 12px 14px 14px;
  background: #24202c; border: 1px solid rgba(236, 227, 207, 0.18); border-radius: 14px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6);
  animation: pop 0.14s ease-out;
}
@keyframes pop { from { opacity: 0; transform: translateY(-4px) scale(0.98); } }
#gloss.sheet { left: 0 !important; right: 0; bottom: 0; top: auto !important; width: auto; border-radius: 16px 16px 0 0; padding-bottom: calc(14px + env(safe-area-inset-bottom)); }
.gh { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.gh b { font-size: 22px; color: var(--gold2); }
.gh .icon-btn { margin-left: auto; width: 30px; height: 30px; }
.gsec { margin-top: 8px; }
.gsec label { display: block; font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); margin-bottom: 4px; }
.gopts { display: flex; flex-wrap: wrap; gap: 5px; }
.gopt {
  min-width: 36px; height: 34px; border-radius: 8px; cursor: pointer; display: inline-flex; align-items: center; justify-content: center;
  background: var(--slate); border: 1px solid rgba(236, 227, 207, 0.12); padding: 0 6px;
}
.gopt:hover { background: var(--slate2); }
.gopt.on { border-color: var(--gold); box-shadow: 0 0 0 2px rgba(226, 182, 90, 0.25); }
.gopt .gsym { font-size: 13px; }
.gopt .gnum { font-size: 15px; }
.grow-row { display: flex; gap: 8px; align-items: center; }
#gtext {
  flex: 1; min-width: 0; background: rgba(0, 0, 0, 0.3); border: 1px solid rgba(236, 227, 207, 0.18); border-radius: 8px;
  color: var(--ink); padding: 7px 10px; font: inherit; font-size: 14px;
}

/* ---------- overlay ---------- */
#overlay {
  position: fixed; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center; padding: 16px;
  background: rgba(8, 6, 12, 0.66); backdrop-filter: blur(5px);
  animation: fade 0.2s ease-out;
}
@keyframes fade { from { opacity: 0; } }
.ov-card {
  width: 100%; max-width: 440px; max-height: 92dvh; overflow-y: auto; text-align: center;
  background: linear-gradient(170deg, #2e2938, #1f1b27); border: 1px solid rgba(236, 227, 207, 0.16);
  border-radius: 18px; padding: 26px 24px 22px; box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6);
  animation: rise 0.28s cubic-bezier(0.2, 0.9, 0.3, 1.2);
}
@keyframes rise { from { opacity: 0; transform: translateY(14px) scale(0.98); } }
.ov-card h2 { font-family: var(--alien); font-size: 30px; margin: 6px 0 8px; letter-spacing: 0.06em; }
.ov-card p { margin: 8px 0; }
.ov-card.help { max-width: 620px; text-align: left; }
.ov-card.help h2 { text-align: center; }
textarea.code { width: 100%; margin-top: 12px; padding: 10px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg); color: var(--ink); font: 12px/1.4 ui-monospace, monospace; word-break: break-all; resize: vertical; }
.help-pics { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 12px 0; }
.help-pics figure { margin: 0; background: linear-gradient(160deg, #2e2938, #25212d); border-radius: 10px; padding: 4px 4px 6px; border: 1px solid rgba(255, 240, 210, 0.08); }
.help-pics figcaption { font-size: 11.5px; text-align: center; color: var(--ink2); }
@media (max-width: 560px) { .help-pics { grid-template-columns: 1fr 1fr; } }
.big-seal { width: 74px; height: 74px; border-radius: 50%; margin: 0 auto 12px; animation: stamp 0.5s cubic-bezier(0.3, 1.6, 0.5, 1); }
.big-seal.gold { background: radial-gradient(circle at 35% 30%, #fff4c8, #e2b65a 45%, #8d661c); box-shadow: 0 0 40px rgba(226, 182, 90, 0.45); }
.big-seal.silver { background: radial-gradient(circle at 35% 30%, #ffffff, #c3c7cf 45%, #6c727c); box-shadow: 0 0 34px rgba(200, 205, 215, 0.3); }
.big-seal.bronze { background: radial-gradient(circle at 35% 30%, #ffd9b5, #bb7643 45%, #66391a); box-shadow: 0 0 30px rgba(187, 118, 67, 0.3); }
@keyframes stamp { from { transform: scale(1.8); opacity: 0; } }
.next-ch { margin: 16px 0 4px; padding-top: 14px; border-top: 1px solid var(--line); }
.next-ch h3 { font-family: var(--alien); font-size: 20px; margin: 4px 0 2px; letter-spacing: 0.05em; }
.next-ch p { margin: 2px 0; font-size: 14px; }

#toast {
  position: fixed; left: 50%; top: 64px; transform: translate(-50%, -20px); z-index: 60;
  background: #2f2a3a; border: 1px solid rgba(226, 182, 90, 0.4); color: var(--ink); padding: 8px 14px; border-radius: 10px;
  opacity: 0; pointer-events: none; transition: opacity 0.2s, transform 0.2s; font-size: 14px;
}
#toast.on { opacity: 1; transform: translate(-50%, 0); }
#toast.act { display: flex; align-items: center; gap: 12px; white-space: nowrap; }
#toast.act.on { pointer-events: auto; }
#toast button { background: var(--gold); color: var(--bg); border: none; border-radius: 6px; padding: 4px 10px; font: inherit; font-weight: 600; cursor: pointer; }

/* ---------- end ---------- */
#end { padding: 32px 16px 60px; }
.end-wrap { max-width: 860px; margin: 0 auto; text-align: center; }
.end-wrap h1 { font-family: var(--alien); font-size: clamp(30px, 6vw, 46px); margin: 6px 0 10px; font-weight: 600; }
.end-wrap h1 .alien { color: var(--gold2); }
.end-wrap h2 { font-family: var(--alien); font-size: 22px; margin: 40px 0 12px; letter-spacing: 0.06em; }
.end-seals { display: flex; justify-content: center; gap: 10px; margin: 10px 0; }
.end-seals .seal { width: 22px; height: 22px; }
.score { font-size: 18px; margin: 4px 0; }
.verdict { color: var(--ink2); font-style: italic; margin: 0 0 8px; }
.rules { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 12px; text-align: left; }
.rule { background: linear-gradient(160deg, #2b2734, #221e2a); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; }
.rule h4 { margin: 0 0 4px; font-family: var(--alien); color: var(--gold2); letter-spacing: 0.05em; font-size: 15px; }
.rule p { margin: 0 0 8px; color: var(--ink2); font-size: 14px; }
.inter { display: flex; flex-wrap: wrap; gap: 2px 10px; margin-top: 6px; padding-top: 6px; border-top: 1px dashed var(--line); }
.iw { display: inline-flex; flex-direction: column; align-items: center; }
.iw.suf { margin-left: -8px; }
.iw b { font-family: var(--alien); font-weight: 600; font-size: 15px; }
.iw.suf b { color: var(--gold2); }
.iw i { font-style: normal; font-size: 10.5px; color: var(--muted); letter-spacing: 0.04em; }
.lex { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; text-align: left; }
.lex-group h4 { margin: 0 0 6px; font-size: 12px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); }
.lex-row { display: grid; grid-template-columns: 1fr 1fr 54px; align-items: center; gap: 6px; padding: 4px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.lex-row b { font-weight: 600; }
.lex-row .mine { display: inline-flex; gap: 6px; align-items: center; justify-content: flex-end; }
.lex-row .ok { color: var(--ok); font-weight: 700; }
.lex-row .no { color: var(--no); font-weight: 700; }

/* ---------- mobile ---------- */
@media (max-width: 899px) {
  #game { display: block; height: auto; min-height: 100dvh; }
  #hud { position: sticky; top: 0; gap: 10px; padding: 8px 12px; flex-wrap: nowrap; }
  .hud-lang .muted { display: none; }
  .seals { gap: 4px; }
  .seal { width: 11px; height: 11px; }
  #panes { display: block; }
  #codex { overflow: visible; padding: 10px 12px 64vh; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
  .tablet { padding: 6px 7px 6px; }
  .m b { font-size: 14px; }
  #panel {
    position: fixed; left: 0; right: 0; bottom: 0; max-height: 60dvh; z-index: 20;
    border-left: none; border-top: 1px solid rgba(236, 227, 207, 0.2); border-radius: 16px 16px 0 0;
    box-shadow: 0 -12px 40px rgba(0, 0, 0, 0.6); padding-bottom: env(safe-area-inset-bottom);
    transition: max-height 0.25s ease;
  }
  #panel.collapsed { max-height: 52px; overflow: hidden; }
  body.glossing #panel { display: none; }
  #panel.collapsed .collapse-btn svg { transform: rotate(180deg); }
  .phead { border-radius: 16px 16px 0 0; cursor: pointer; }
  .collapse-btn { display: inline-flex; width: 30px; height: 30px; }
  .target .pic.big { max-height: 22dvh; }
  .pbody { padding: 10px 12px 16px; }
  .sentence.big .m b { font-size: 18px; }
  .options { gap: 6px; }
  .tile { padding: 4px 8px 1px; min-width: 44px; }
  .tile b { font-size: 15px; }
}
@media (max-width: 520px) {
  #hud { gap: 8px; padding: 6px 10px; }
  .logo-full { display: none; }
  .logo-short { display: inline; }
  .logo { font-size: 18px; width: 30px; height: 30px; border: 1px solid rgba(226, 182, 90, 0.4); border-radius: 8px; padding: 0; letter-spacing: 0; }
  .hud-stats { gap: 7px; font-size: 13px; }
  .hud-lang .alien { font-size: 13px; }
  .seals { gap: 3px; }
  .seal { width: 9px; height: 9px; }
  #hud .icon-btn { width: 28px; height: 28px; }
  .target .pic.big { max-height: 17dvh; }
  .answer { min-height: 48px; margin-top: 8px; }
  .crow { margin-top: 8px; }
  .crow .btn { padding: 8px 12px; }
  .palette { margin-top: 10px; padding-top: 10px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
