:root {
  --red: #b3121b;
  --deep: #5c0a0f;
  --green: #1f6b3a;
  --gold: #f5c542;
  --cream: #fff7e6;
  --ink: #241612;
  --panel: rgba(30, 12, 10, 0.88);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #0b1530; color: var(--cream); font-family: 'Trebuchet MS', 'Segoe UI', system-ui, sans-serif; }
#scene, #scene canvas { position: fixed; inset: 0; display: block; }
.hidden { display: none !important; }
button { font: inherit; cursor: pointer; border: 0; border-radius: 10px; padding: 10px 16px; margin: 4px; background: #3a1f1a; color: var(--cream); }
button:hover:not(:disabled) { filter: brightness(1.2); }
button:disabled { opacity: 0.45; cursor: not-allowed; }
button.primary { background: linear-gradient(180deg, #d42a2a, var(--red)); box-shadow: 0 3px 0 var(--deep); }
button.big { font-size: 1.15rem; padding: 12px 22px; }
.chip { background: rgba(255, 255, 255, 0.12); padding: 6px 12px; border-radius: 999px; font-size: 0.9rem; display: inline-flex; align-items: center; gap: 6px; margin: 4px; }
.muted { opacity: 0.7; }
.red { color: #ff6b6b; }

/* ── Screens ─────────────────────────────────────────────────────────────── */
.screen { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; padding: 16px; background: rgba(5, 10, 25, 0.35); z-index: 20; }
.panel { background: var(--panel); border: 3px solid var(--gold); border-radius: 18px; padding: 22px 26px; max-width: 560px; width: 100%; max-height: calc(100vh - 32px); overflow-y: auto; text-align: center; box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5); }
.panel.narrow { max-width: 420px; }
.panel.wide { max-width: 760px; text-align: left; }
.panel h2 { margin-top: 0; color: var(--gold); }
.logo { font-family: Georgia, 'Times New Roman', serif; font-size: 3.6rem; margin: 0 0 6px; color: var(--cream); text-shadow: 0 3px 0 var(--red), 0 6px 18px rgba(0, 0, 0, 0.6); letter-spacing: 1px; white-space: nowrap; }
.logo::before { content: '🎄 '; }
.logo::after { content: ' 🎁'; }
.tag { font-size: 1.05rem; line-height: 1.5; }
.settings { margin-top: 10px; }
.help { text-align: left; margin-top: 12px; }
.help summary { cursor: pointer; color: var(--gold); }
.help-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 16px; font-size: 0.92rem; margin-top: 8px; }
.touch-help { display: none; }
body.touch .touch-help { display: block; }

/* ── Store ───────────────────────────────────────────────────────────────── */
#shop-cash { font-size: 1.2rem; color: var(--gold); margin-bottom: 8px; }
.item { display: grid; grid-template-columns: 36px 1fr auto auto auto auto; align-items: center; gap: 6px; padding: 6px 4px; border-bottom: 1px solid rgba(255, 255, 255, 0.08); }
.item .ic { font-size: 1.5rem; }
.item .nm small { display: block; opacity: 0.7; }
.item .pr { color: var(--gold); font-weight: bold; }
.item button { padding: 4px 12px; margin: 0; }
.item .ct { min-width: 22px; text-align: center; }
.recipes { margin: 10px 0; }
.recipes summary { cursor: pointer; color: var(--gold); }
.recipe { font-size: 0.88rem; opacity: 0.6; padding: 2px 0; }
.recipe.ok { opacity: 1; color: #9cff9c; }
.row { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px; }
#cart-total { font-weight: bold; }

/* ── Traps ───────────────────────────────────────────────────────────────── */
#traps-list h3 { margin: 12px 0 4px; color: var(--gold); }
button.trap { display: block; width: 100%; text-align: left; background: #2b3a22; }
button.trap small { display: block; opacity: 0.8; }
button.trap.missing { background: #333; }

/* ── HUD ─────────────────────────────────────────────────────────────────── */
#hud { position: fixed; inset: 0; pointer-events: none; z-index: 10; }
#hud button { pointer-events: auto; }
#topbar { position: absolute; top: max(10px, env(safe-area-inset-top)); left: 12px; display: flex; gap: 10px; font-weight: bold; }
#topbar span { background: var(--panel); padding: 6px 12px; border-radius: 999px; border: 2px solid var(--gold); }
#police { color: #9cd0ff; }
#objective { position: absolute; top: max(54px, calc(env(safe-area-inset-top) + 44px)); left: 12px; max-width: min(460px, 70vw); background: rgba(0, 0, 0, 0.45); padding: 8px 12px; border-radius: 10px; font-size: 0.95rem; }
#grit { position: absolute; top: 12px; right: 12px; background: var(--panel); padding: 8px 12px; border-radius: 12px; min-width: 170px; }
#grit .who { font-size: 0.85rem; margin: 2px 0; }
#grit .bar { height: 8px; background: rgba(255, 255, 255, 0.15); border-radius: 4px; overflow: hidden; }
#grit .bar div { height: 100%; width: 100%; background: linear-gradient(90deg, #ff6b6b, #ffb36b); transition: width 0.3s; }
#inventory { position: absolute; left: 12px; bottom: max(14px, env(safe-area-inset-bottom)); background: rgba(0, 0, 0, 0.5); padding: 8px 12px; border-radius: 10px; max-width: 60vw; }
kbd { background: rgba(255, 255, 255, 0.2); border-radius: 4px; padding: 0 6px; font-family: inherit; }
body.touch kbd { display: none; }
#ready-btn { position: absolute; right: 12px; bottom: max(14px, env(safe-area-inset-bottom)); }
#dot { position: absolute; left: 50%; top: 50%; width: 6px; height: 6px; margin: -3px; border-radius: 50%; background: rgba(255, 255, 255, 0.85); }
#prompt { position: absolute; left: 50%; top: 58%; transform: translateX(-50%); background: rgba(0, 0, 0, 0.55); padding: 6px 12px; border-radius: 8px; font-weight: bold; white-space: nowrap; }
#prompt:empty { display: none; }
#bubble { position: absolute; left: 50%; bottom: 90px; transform: translateX(-50%); max-width: min(640px, 90vw); background: var(--cream); color: var(--ink); padding: 10px 16px; border-radius: 16px; font-size: 1.05rem; opacity: 0; transition: opacity 0.25s; text-align: center; }
#bubble.on { opacity: 1; }
#bubble b { color: var(--red); }
#stamina { position: absolute; left: 50%; bottom: 60px; transform: translateX(-50%); width: 120px; height: 5px; background: rgba(255, 255, 255, 0.15); border-radius: 3px; overflow: hidden; }
#stamina-fill { height: 100%; background: #9cff9c; }

/* ── Cutscenes ───────────────────────────────────────────────────────────── */
#cutscene { position: fixed; inset: 0; z-index: 15; pointer-events: none; }
#cutscene .bar { position: absolute; left: 0; right: 0; height: 11vh; background: #000; }
#cutscene .top { top: 0; }
#cutscene .bottom { bottom: 0; }
#cut-title { position: absolute; top: 14vh; width: 100%; text-align: center; font-family: Georgia, serif; font-size: 2rem; color: var(--cream); text-shadow: 0 2px 10px #000; opacity: 0; }
#cut-title.fadeout { animation: title 4s ease forwards; }
@keyframes title { 0% { opacity: 0; } 15% { opacity: 1; } 70% { opacity: 1; } 100% { opacity: 0; } }
#cut-line { position: absolute; left: 50%; bottom: 13vh; transform: translateX(-50%); max-width: min(760px, 92vw); text-align: center; font-size: 1.25rem; background: rgba(0, 0, 0, 0.6); padding: 8px 16px; border-radius: 10px; }
#cut-line b { color: var(--gold); }
#cut-line.narrator { font-style: italic; color: #dfe9ff; }
#skip-btn { position: absolute; right: 14px; bottom: calc(11vh + 10px); pointer-events: auto; }
#fade { position: fixed; inset: 0; background: #000; opacity: 0; pointer-events: none; z-index: 30; transition: opacity 0.4s; }
#loading { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; background: #0b1530; z-index: 50; font-size: 1.3rem; }

/* ── Phone ───────────────────────────────────────────────────────────────── */
#touch { position: fixed; inset: 0; z-index: 11; }
#touch-pad { position: absolute; inset: 0; }
#stick { position: absolute; width: 120px; height: 120px; margin: -60px 0 0 -60px; border-radius: 50%; background: rgba(255, 255, 255, 0.12); border: 2px solid rgba(255, 255, 255, 0.35); pointer-events: none; }
#stick div { position: absolute; left: 35px; top: 35px; width: 50px; height: 50px; border-radius: 50%; background: rgba(255, 255, 255, 0.5); }
#touch-buttons { position: absolute; right: 16px; bottom: calc(80px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 10px; }
.tb { width: 70px; height: 70px; border-radius: 50%; background: rgba(0, 0, 0, 0.45); border: 2px solid rgba(255, 255, 255, 0.5); color: #fff; font-weight: bold; padding: 0; touch-action: none; }
.tb.big { width: 86px; height: 86px; background: rgba(179, 18, 27, 0.7); }
.tb.small { position: absolute; top: max(10px, env(safe-area-inset-top)); right: 200px; width: 44px; height: 44px; }
body.touch #dot { display: none; }
body.touch #ready-btn { bottom: calc(190px + env(safe-area-inset-bottom)); }

@media (max-width: 720px) {
  .logo { font-size: 2rem; }
  .panel { padding: 16px; }
  .item { grid-template-columns: 30px 1fr auto auto auto auto; font-size: 0.88rem; }
  #grit { top: auto; bottom: calc(180px + env(safe-area-inset-bottom)); left: 12px; right: auto; min-width: 140px; }
  #cut-line { font-size: 1rem; }
  #topbar { font-size: 0.85rem; flex-wrap: wrap; }
}
