[hidden] { display: none !important; }
*, *::before, *::after { box-sizing: border-box; }
:root {
    --bg: #14110d; --panel: rgba(28, 22, 16, 0.9); --line: rgba(232, 200, 150, 0.28);
    --gold: #e3b866; --ember: #d9773a; --sage: #8fbf8a; --sky: #8ec5e8; --text: #f1e7d6; --red: #e0665a;
}
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--bg); color: var(--text); }
body { font-family: 'Lora', Georgia, serif; font-size: 16px; user-select: none; -webkit-user-select: none; touch-action: none; }
canvas#game { position: fixed; inset: 0; width: 100%; height: 100%; display: block; cursor: crosshair; }
button { font: inherit; cursor: pointer; }
kbd { display: inline-block; min-width: 1.5em; padding: 0 4px; border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 4px; background: rgba(255,255,255,0.06); font-family: inherit; font-size: 0.85em; text-align: center; }

/* Screens */
.screen { position: fixed; inset: 0; z-index: 30; display: flex; align-items: center; justify-content: center; padding: 16px; }
.screen.dim { background: rgba(8, 6, 4, 0.55); }
.card { width: min(560px, 100%); max-height: 100%; overflow-y: auto; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 22px 24px; box-shadow: 0 20px 60px rgba(0,0,0,0.6); backdrop-filter: blur(5px); }
.card.wide { width: min(980px, 100%); }
h1, h2, h3 { font-family: 'Cinzel', serif; margin: 0; color: var(--gold); letter-spacing: 0.04em; }
h1 { font-size: clamp(2.2em, 8vw, 3.6em); text-align: center; text-shadow: 0 0 24px rgba(227,184,102,0.45); }
h2 { font-size: 1.6em; margin-bottom: 8px; }
h3 { font-size: 1em; margin: 10px 0 4px; color: var(--ember); }
.lede { text-align: center; line-height: 1.55; margin: 12px 0 20px; opacity: 0.9; }
.eyebrow { font-family: 'Cinzel', serif; font-size: 0.75em; letter-spacing: 0.22em; color: var(--ember); }
.small { font-size: 0.85em; opacity: 0.75; }
.hint { opacity: 0.8; margin: 0 0 10px; }
.menu { display: flex; flex-direction: column; gap: 10px; max-width: 340px; margin: 0 auto; }
.row { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 10px; margin-top: 16px; }
.btn { display: block; text-align: center; text-decoration: none; color: var(--text); padding: 10px 18px; border-radius: 8px; border: 1px solid var(--line); background: rgba(255,255,255,0.05); font-family: 'Cinzel', serif; font-size: 0.9em; letter-spacing: 0.05em; }
.btn:hover { background: rgba(227,184,102,0.15); border-color: var(--gold); }
.btn.primary { background: linear-gradient(180deg, #b0782c, #7d5216); border-color: var(--gold); }
.btn.primary:hover { background: linear-gradient(180deg, #c58a38, #8f601c); }
.btn.ghost { background: transparent; }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.story { line-height: 1.6; font-size: 1.05em; border-left: 3px solid var(--ember); padding: 4px 0 4px 14px; font-style: italic; }
.choices { display: flex; flex-direction: column; gap: 8px; margin-top: 14px; }
.choices .btn { text-align: left; font-family: 'Lora', serif; font-size: 1em; }

/* Hub */
.hub-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; }
.spirit { min-width: 220px; font-family: 'Cinzel', serif; font-size: 0.85em; }
.spirit-bar { height: 12px; border-radius: 6px; background: rgba(0,0,0,0.5); border: 1px solid var(--line); overflow: hidden; margin: 3px 0; }
.spirit-bar i { display: block; height: 100%; background: linear-gradient(90deg, #6fb7d8, #b8e3f2); box-shadow: 0 0 10px #8ec5e8; }
.lives { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 10px; }
.life { position: relative; border: 1px solid var(--line); border-radius: 12px; padding: 12px; background: rgba(255,255,255,0.03); display: flex; flex-direction: column; }
.life.done { opacity: 0.75; border-color: var(--sage); }
.life .head { display: flex; align-items: center; gap: 8px; }
.life .icon { font-size: 1.8em; }
.life .lname { font-family: 'Cinzel', serif; font-size: 1.1em; color: var(--gold); }
.life .status { font-size: 0.8em; opacity: 0.8; }
.life .stats { list-style: none; padding: 0; margin: 8px 0; font-size: 0.85em; }
.life .stats li { display: flex; align-items: center; gap: 6px; margin: 3px 0; }
.life .stats li span { width: 78px; opacity: 0.8; }
.life .stats li .b { flex: 1; height: 6px; border-radius: 3px; background: rgba(255,255,255,0.1); overflow: hidden; }
.life .stats li .b i { display: block; height: 100%; background: var(--gold); }
.life .stats li em { font-style: normal; font-size: 0.9em; }
.life .last { font-size: 0.82em; font-style: italic; opacity: 0.75; flex: 1; margin: 4px 0 8px; }
.life .btn { width: 100%; }
.effects-row { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.chip { font-size: 0.8em; padding: 3px 9px; border-radius: 10px; border: 1px solid var(--line); }
.chip.good { border-color: var(--sage); color: #cfeccb; background: rgba(143,191,138,0.12); }
.chip.bad { border-color: var(--red); color: #f4c4bd; background: rgba(224,102,90,0.12); }
.results { list-style: none; padding: 0; margin: 10px 0 0; }
.results li { padding: 6px 0; border-bottom: 1px solid rgba(255,255,255,0.06); }
.results li.ok::before { content: '✓ '; color: var(--sage); }
.results li.no::before { content: '✗ '; color: var(--red); }
.results li.info::before { content: '• '; color: var(--gold); }
.summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 12px; }
.summary .block { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; background: rgba(255,255,255,0.03); }
.summary .block.full { grid-column: 1 / -1; }
.summary p { margin: 6px 0; line-height: 1.5; }
.journal-tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.journal-tabs button { background: transparent; color: var(--text); border: 1px solid var(--line); border-radius: 14px; padding: 3px 12px; }
.journal-tabs button.on { background: var(--gold); color: #1d150c; border-color: var(--gold); }
.journal { list-style: none; padding: 0; margin: 0; max-height: 55vh; overflow-y: auto; }
.journal li { padding: 6px 0; border-bottom: 1px solid rgba(255,255,255,0.06); line-height: 1.45; }
.journal li b { color: var(--ember); font-family: 'Cinzel', serif; font-size: 0.8em; margin-right: 6px; }
.help { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 4px 20px; }
.help p { margin: 0 0 8px; line-height: 1.5; }

/* HUD */
#hud { position: fixed; inset: 0; z-index: 10; pointer-events: none; }
.hud-top { display: flex; align-items: center; gap: 12px; padding: 10px 12px; }
.form-badge { display: flex; align-items: center; gap: 8px; background: rgba(0,0,0,0.55); border: 1px solid var(--line); border-radius: 10px; padding: 5px 12px 5px 8px; }
.form-badge span { font-size: 1.6em; }
.form-badge b { display: block; font-family: 'Cinzel', serif; color: var(--gold); }
.form-badge small { opacity: 0.8; font-size: 0.78em; }
.sun { flex: 1; max-width: 360px; margin: 0 auto; text-align: center; text-shadow: 0 1px 3px #000; }
.sun-track { height: 8px; border-radius: 4px; background: linear-gradient(90deg, #f4c770, #f39b4a 70%, #6d3a6b); position: relative; border: 1px solid rgba(0,0,0,0.4); }
.sun-track i { position: absolute; top: -5px; width: 16px; height: 16px; margin-left: -8px; border-radius: 50%; background: #fff3c4; box-shadow: 0 0 12px #ffd76a; left: 0; }
.sun small { font-size: 0.78em; }
.hud-right { pointer-events: auto; }
.icon-btn { width: 38px; height: 38px; border-radius: 8px; border: 1px solid var(--line); background: rgba(0,0,0,0.55); color: var(--text); }
.hud-left { position: absolute; left: 12px; top: 70px; width: 250px; display: flex; flex-direction: column; gap: 6px; }
.meter { display: flex; align-items: center; gap: 6px; font-size: 0.78em; text-shadow: 0 1px 3px #000; }
.meter span { width: 62px; }
.meter div { flex: 1; height: 9px; border-radius: 5px; background: rgba(0,0,0,0.6); border: 1px solid rgba(255,255,255,0.15); overflow: hidden; }
.meter i { display: block; height: 100%; }
.meter.hp i { background: linear-gradient(90deg, #c94f3d, #e38c4d); }
.meter.st i { background: linear-gradient(90deg, #6fb7d8, #b8e3f2); }
.extra { font-size: 0.85em; text-shadow: 0 1px 3px #000; min-height: 1em; }
.tasks { list-style: none; padding: 8px 10px; margin: 2px 0 0; background: rgba(0,0,0,0.5); border: 1px solid var(--line); border-radius: 10px; font-size: 0.85em; }
.tasks li { margin: 3px 0; }
.tasks li.ok { color: var(--sage); }
.tasks li.ok::before { content: '✓ '; }
.tasks li.todo::before { content: '○ '; color: var(--gold); }
.tasks li.threat { color: #f4a49b; }
.tasks li.threat::before { content: '⚠ '; }
.tasks small { display: block; opacity: 0.65; font-size: 0.85em; margin-left: 1.2em; }
.effects { display: flex; flex-wrap: wrap; gap: 4px; }
.effects .chip { font-size: 0.72em; background: rgba(0,0,0,0.5); }
.prompt { position: absolute; left: 50%; bottom: calc(18% + 10px); transform: translateX(-50%); background: rgba(0,0,0,0.7); border: 1px solid var(--gold); border-radius: 8px; padding: 6px 14px; font-size: 0.95em; white-space: nowrap; }
.controls { position: absolute; left: 50%; bottom: 8px; transform: translateX(-50%); display: flex; flex-wrap: wrap; justify-content: center; gap: 4px 12px; max-width: 94vw; background: rgba(0,0,0,0.5); border: 1px solid var(--line); border-radius: 10px; padding: 5px 12px; font-size: 0.78em; text-shadow: 0 1px 2px #000; }
.controls { flex-direction: column; align-items: center; gap: 3px; }
.controls > div { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px 12px; }
.controls .extra-row { border-top: 1px solid var(--line); padding-top: 3px; color: var(--gold); }
.controls span { white-space: nowrap; opacity: 0.9; }
.controls kbd { margin-right: 4px; }
.weapons { position: absolute; right: 12px; bottom: 60px; display: flex; gap: 6px; pointer-events: auto; }
.weapons button { position: relative; width: 70px; height: 62px; border-radius: 10px; border: 1px solid var(--line); background: rgba(0,0,0,0.55); color: var(--text); font-size: 1.4em; padding: 4px 0 0; }
.weapons button b { position: absolute; top: 2px; left: 6px; font-size: 0.5em; color: var(--gold); }
.weapons button small { display: block; font-size: 0.45em; margin-top: 2px; }
.weapons button small i { font-style: normal; color: var(--gold); }
.weapons button.on { border-color: var(--gold); background: rgba(227,184,102,0.25); box-shadow: 0 0 10px rgba(227,184,102,0.5); }
.end-day { position: absolute; left: 50%; bottom: calc(18% + 44px); transform: translateX(-50%); pointer-events: auto; background: rgba(40, 32, 60, 0.85); color: var(--text); border: 1px solid #8ec5e8; border-radius: 18px; padding: 6px 16px; font-family: 'Cinzel', serif; font-size: 0.9em; }
.end-day:hover { background: rgba(70, 60, 110, 0.95); }
.toast { position: absolute; left: 50%; top: 70px; transform: translateX(-50%); max-width: min(560px, 90vw); background: rgba(0,0,0,0.75); border: 1px solid var(--ember); border-radius: 8px; padding: 7px 14px; text-align: center; animation: fadeIn 0.3s; }
@keyframes fadeIn { from { opacity: 0; transform: translate(-50%, -6px); } }
.hold { position: absolute; left: 50%; bottom: calc(18% + 40px); transform: translateX(-50%); width: 140px; height: 8px; border-radius: 4px; background: rgba(0,0,0,0.6); overflow: hidden; border: 1px solid var(--line); }
.hold i { display: block; height: 100%; width: 0; background: var(--sage); }

/* Touch */
#touch { position: fixed; inset: 0; z-index: 12; pointer-events: none; }
#stick-zone { position: absolute; left: 0; bottom: 0; width: 50%; height: 60%; pointer-events: auto; }
#stick-base { position: absolute; width: 120px; height: 120px; left: 30px; bottom: 60px; border-radius: 50%; border: 2px solid rgba(255,255,255,0.25); background: rgba(0,0,0,0.25); }
#stick-knob { position: absolute; width: 52px; height: 52px; left: 34px; top: 34px; border-radius: 50%; background: rgba(227,184,102,0.6); border: 2px solid var(--gold); }
.tbuttons { position: absolute; right: 12px; bottom: 50px; display: grid; grid-template-columns: repeat(2, 72px); gap: 10px; pointer-events: auto; }
.tbtn { height: 64px; border-radius: 50%; border: 2px solid var(--line); background: rgba(0,0,0,0.45); color: var(--text); font-family: 'Cinzel', serif; font-size: 0.72em; touch-action: none; }
.tbtn.a { border-color: var(--ember); background: rgba(217,119,58,0.3); }
.tbtn.down { background: rgba(255,255,255,0.25); }
@media (pointer: coarse) {
    .hud-top { flex-wrap: wrap; gap: 6px 10px; padding: 8px; }
    .form-badge { padding: 3px 10px 3px 6px; }
    .form-badge span { font-size: 1.2em; }
    .sun { order: 3; flex-basis: 100%; max-width: none; }
    .hud-left { width: 190px; top: 92px; font-size: 0.82em; gap: 4px; }
    .tasks small { display: none; }
    .toast { top: auto; bottom: 330px; font-size: 0.9em; }
    .prompt { bottom: 250px; font-size: 0.9em; white-space: normal; max-width: 90vw; text-align: center; }
    .hold { bottom: 290px; }
    .end-day { bottom: 296px; }
    .weapons { right: 10px; bottom: 210px; gap: 5px; }
    .weapons button { width: 56px; height: 50px; font-size: 1.15em; }
}
@media (max-width: 600px) {
    .hud-top { flex-wrap: wrap; }
    .sun { order: 3; flex-basis: 100%; }
}
