:root {
  --night: #0a111d; --deep: #111c2e; --panel: #16243a; --line: #2b3f5e;
  --ice: #cfeaf7; --frost: #8fb8d1; --ember: #f2ae5a; --ember-deep: #c9722b; --blood: #c9566a;
  --text: #eaf2f8; --muted: #a9bccd;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  background: radial-gradient(120% 80% at 50% 0%, #1a2b47 0%, var(--night) 60%) fixed, var(--night);
  color: var(--text); font-family: 'Lora', Georgia, serif; font-size: 17px; line-height: 1.6;
}
#app { max-width: 720px; margin: 0 auto; padding: 16px 16px 64px; }
h1, h2, h3, .eyebrow, button { font-family: 'Cinzel', 'Times New Roman', serif; }
h1 { font-size: clamp(30px, 8vw, 46px); line-height: 1.15; margin: 24px 0 8px; color: var(--ice); letter-spacing: .04em; text-align: center; }
h2 { font-size: 24px; margin: 0 0 8px; color: var(--ice); }
h3 { font-size: 18px; margin: 0 0 8px; color: var(--ember); }
p { margin: 0 0 14px; }
.eyebrow { font-size: 14px; letter-spacing: .18em; text-transform: uppercase; color: var(--ember); margin: 0 0 4px; }
.center { text-align: center; }
.muted { color: var(--muted); }
.beat { font-style: italic; color: var(--frost); border-left: 3px solid var(--line); padding-left: 12px; }
.card { background: linear-gradient(180deg, var(--panel), var(--deep)); border: 1px solid var(--line); border-radius: 14px; padding: 18px; margin: 14px 0; box-shadow: 0 10px 30px rgba(0,0,0,.35); }
.card.his { border-color: var(--ember-deep); background: linear-gradient(180deg, #2a1d19, #17131a); }
.msg { border-left: 3px solid var(--ember); background: rgba(242,174,90,.07); padding: 14px 16px 2px; border-radius: 0 10px 10px 0; margin: 14px 0; }
.prose { margin: 16px 0; }
.prose p:first-child::first-letter { font-family: 'Cinzel', serif; font-size: 2.6em; float: left; line-height: .9; padding: 4px 8px 0 0; color: var(--ember); }
em { color: var(--ice); }

.hud { position: sticky; top: 0; z-index: 5; background: rgba(10,17,29,.94); backdrop-filter: blur(6px); margin: 0 -16px; padding: 10px 16px; border-bottom: 1px solid var(--line); }
.hud-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-family: 'Cinzel', serif; font-size: 14px; color: var(--frost); }
.bars { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 8px; }
.bar label { display: flex; justify-content: space-between; font-size: 14px; color: var(--muted); }
.track { height: 8px; background: #0c1626; border-radius: 6px; overflow: hidden; border: 1px solid var(--line); }
.fill { height: 100%; border-radius: 6px; transition: width .6s ease; }
.fill.dragon { background: linear-gradient(90deg, #7fc6e8, #e9f8ff); }
.fill.trust { background: linear-gradient(90deg, #a04a63, #e58aa0); }
.fill.hearth { background: linear-gradient(90deg, var(--ember-deep), #ffd08a); }

.options { display: grid; gap: 10px; margin-top: 14px; }
button { cursor: pointer; font-size: 16px; color: var(--text); background: #1c2e4a; border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; text-align: left; min-height: 48px; transition: transform .12s, border-color .12s, background .12s; }
button:hover, button:focus-visible { border-color: var(--ember); background: #223758; outline: none; }
button:active { transform: scale(.985); }
button .hint { display: block; font-family: 'Lora', serif; font-size: 15px; color: var(--muted); margin-top: 4px; }
button.primary { background: linear-gradient(180deg, #e2994a, var(--ember-deep)); color: #1b0f05; border-color: #f6c98c; text-align: center; font-weight: 700; }
button.ghost { background: transparent; text-align: center; font-size: 14px; padding: 10px 12px; min-height: 44px; }
.row { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { min-height: 44px; padding: 8px 14px; border-radius: 999px; font-size: 14px; text-align: center; }
.chip[aria-pressed="true"] { background: var(--ember); color: #1b0f05; border-color: #ffe0b0; }
.spice button[aria-pressed="true"] { border-color: var(--ember); background: #2a3f63; }

textarea { width: 100%; min-height: 110px; font: inherit; font-size: 16px; color: var(--text); background: #0c1626; border: 1px solid var(--line); border-radius: 10px; padding: 12px; resize: vertical; }
textarea:focus { outline: 2px solid var(--ember); }
.prompt { font-style: italic; color: var(--ice); margin-bottom: 6px; }
fieldset { border: 1px solid var(--line); border-radius: 12px; padding: 12px; margin: 12px 0; }
legend { font-family: 'Cinzel', serif; color: var(--ember); padding: 0 6px; font-size: 16px; }
.radio { display: flex; gap: 10px; align-items: flex-start; padding: 8px 4px; font-size: 16px; }
.radio input { margin-top: 6px; width: 18px; height: 18px; accent-color: var(--ember); }

.glyphs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 14px 0; }
.glyph { font-size: 34px; text-align: center; min-height: 72px; font-family: serif; }
.glyph.lit { background: var(--ember); color: #1b0f05; border-color: #fff0d0; box-shadow: 0 0 24px rgba(242,174,90,.7); }
.entry { border-top: 1px solid var(--line); padding-top: 12px; margin-top: 12px; }
.tab { display: inline-block; font-size: 14px; padding: 2px 10px; border-radius: 999px; background: #24385a; margin-right: 6px; }
.right { color: #9be0b0; } .wrong { color: var(--blood); }
@media (min-width: 700px) { body { font-size: 18px; } #app { padding-top: 28px; } }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

.art { display: block; width: 100%; height: auto; border-radius: 14px; margin: 12px 0; border: 1px solid var(--line); box-shadow: 0 10px 30px rgba(0,0,0,.45); }
.art.cover { max-width: 420px; margin: 16px auto; }

.avatar { float: right; width: 84px; height: 84px; border-radius: 50%; object-fit: cover; margin: 0 0 8px 12px; border: 2px solid var(--ember); box-shadow: 0 4px 14px rgba(0,0,0,.5); }
em.voiced { cursor: pointer; border-bottom: 1px dotted var(--frost); }
.hud [data-sound][aria-pressed="false"] { opacity: .6; }

/* ---------- Minigames ---------- */
#mini { margin-top: 12px; touch-action: none; user-select: none; -webkit-user-select: none; }
.mg-hint { text-align: center; margin: 12px 0 8px; min-height: 1.6em; }
.mg-meter { height: 8px; background: #0c1626; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.mg-meter i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--ember-deep), #ffd08a); transition: width .15s; }
.mg-skip { display: block; margin: 12px auto 0; }
.mg-skip[hidden] { display: none; }
.mg-map svg { width: 100%; max-width: 460px; display: block; margin: 0 auto; }
.spot { fill: transparent; cursor: pointer; outline: none; }
.spot:focus-visible { stroke: var(--ember); stroke-width: 2; }
.spot.wound { fill: rgba(70,150,210,.55); stroke: #dff4ff; stroke-width: 1.5; animation: pulse 1.6s ease-in-out infinite; }
.spot.found { fill: rgba(242,174,90,.8); animation: none; }
@keyframes pulse { 50% { fill: rgba(70,150,210,.95); } }
.mg-scrub { position: relative; padding-top: 60%; border-radius: 12px; overflow: hidden; border: 1px solid var(--line); }
.mg-under, .mg-scrub canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.mg-under svg { width: 100%; height: 100%; display: block; }
.mg-scrub canvas { cursor: grab; transition: opacity .8s; touch-action: none; }
.mg-trace { max-width: 320px; margin: 0 auto; background: radial-gradient(circle, #2b3a52, #121b2b); border: 1px solid var(--line); border-radius: 16px; }
.mg-trace svg { display: block; width: 100%; touch-action: none; cursor: crosshair; }
.ghost-line { fill: none; stroke: rgba(207,234,247,.28); stroke-width: 7; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 1 10; }
.ink-line { fill: none; stroke: var(--ember); stroke-width: 5; stroke-linecap: round; stroke-linejoin: round; filter: drop-shadow(0 0 4px rgba(242,174,90,.9)); }
.mg-heat { position: relative; height: 26px; background: #0c1626; border: 1px solid var(--line); border-radius: 13px; overflow: hidden; }
.mg-heat .band { position: absolute; left: 55%; width: 25%; top: 0; bottom: 0; background: rgba(242,174,90,.28); border-left: 2px solid var(--ember); border-right: 2px solid var(--ember); }
.mg-heat i { display: block; height: 100%; width: 35%; background: linear-gradient(90deg, #7a2f1a, #e2713a); }
.mg-heat i.good { background: linear-gradient(90deg, var(--ember-deep), #ffe2a6); }
.mg-hold { width: 100%; touch-action: none; }
.mg-stones { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.stone { min-height: 96px; text-align: center; font-size: 26px; border-radius: 50% / 40%; background: #2a3444; transition: transform .35s, background .35s; }
.stone.up { background: #e8eef4; color: #1b2433; transform: rotateY(360deg); font-size: 18px; font-weight: 700; }
.mg-score { text-align: center; font-family: 'Cinzel', serif; color: var(--frost); }
.tell { text-align: center; font-style: italic; color: var(--ice); font-size: 19px; margin: 14px 0; }
.mg-moves button { flex: 1 1 30%; text-align: center; }
.mg-sky { position: relative; padding-top: 80%; border-radius: 12px; overflow: hidden; touch-action: none; cursor: ew-resize; background: linear-gradient(180deg, #f7d9a8 0%, #9fd0ee 35%, #dff3ff 100%); border: 1px solid var(--line); }
.wing { position: absolute; top: 82%; left: 50%; transform: translate(-50%, -50%); font-size: 38px; color: #fff; text-shadow: 0 2px 6px rgba(20,40,70,.6); transition: left .08s linear; }
.ring { position: absolute; top: -5%; width: 44px; height: 44px; margin-left: -22px; border: 4px solid #f2ae5a; border-radius: 50%; box-shadow: 0 0 12px rgba(242,174,90,.8); }
.ring.caught { border-color: #fff; transform: scale(1.6); opacity: 0; transition: all .3s; }

/* ---------- Keepsakes: kept lines, cards, book ---------- */
.prose p, .msg p, .story p { cursor: pointer; border-radius: 6px; transition: background .2s; }
.prose p.kept, .msg p.kept, .story p.kept { background: rgba(242,174,90,.14); box-shadow: -4px 0 0 var(--ember); padding-left: 8px; }
.tip { font-size: 15px; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: #1c2e4a; color: var(--text); border: 1px solid var(--ember); border-radius: 999px; padding: 10px 18px; font-size: 15px; z-index: 50; box-shadow: 0 8px 24px rgba(0,0,0,.5); max-width: 90vw; text-align: center; }
#card-out { margin-top: 14px; display: grid; gap: 10px; }
.card-preview { width: 100%; max-width: 360px; height: auto; margin: 0 auto; display: block; border-radius: 12px; border: 1px solid var(--line); }
.book { background: #f7f1e6; color: #22201c; border-radius: 10px; padding: 24px 20px; margin-top: 14px; }
.book h1, .book h2 { color: #3a2412; text-align: center; }
.book .eyebrow { color: #9a5a22; text-align: center; }
.book .muted { color: #6b6257; }
.book em { color: #3d5a73; }
.book .art { box-shadow: none; }
.bk-title { text-align: center; padding-bottom: 20px; }
.bk-night { border-top: 1px solid #d8cbb4; padding-top: 22px; margin-top: 22px; }
.bk-his { background: #efe4d2; border-left: 3px solid #9a5a22; padding: 12px 14px 2px; margin: 14px 0; }
.bk-choice { font-family: 'Cinzel', serif; text-align: center; color: #9a5a22; margin: 16px 0; }
.bk-choice::before { content: '\2766  '; }
.bk-note { background: #fffaf0; border: 1px dashed #b89a6a; border-radius: 8px; padding: 12px 14px 2px; margin: 14px 0; font-style: italic; }
.bk-note .eyebrow, .bk-kept .eyebrow { text-align: left; font-style: normal; }
.bk-kept { border-left: 3px solid #c9722b; padding-left: 12px; margin: 14px 0; }
.book .tab { background: #e6d6ba; color: #3a2412; font-style: normal; }
@media print {
  body { background: #fff !important; color: #000; font-size: 12pt; }
  .book-tools, .hud, .toast { display: none !important; }
  #app { max-width: none; padding: 0; }
  .book { background: #fff; padding: 0; margin: 0; border-radius: 0; }
  .bk-night { break-before: page; border-top: 0; margin-top: 0; }
  .bk-note, .bk-his, .bk-kept, .art { break-inside: avoid; }
  .art { max-height: 9cm; width: auto; max-width: 100%; margin: 0 auto 12pt; }
}
