:root {
  --bg: #07080b; --ink: #e9e2d4; --muted: #9a9283; --amber: #e8b45a; --teal: #2fb7c9; --ember: #ff7a59;
  --panel: #12151bf2; --line: #ffffff1c;
  --serif: Georgia, "Times New Roman", serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink); font-family: var(--sans); overscroll-behavior: none; }
#app { height: 100dvh; max-width: 520px; margin: 0 auto; position: relative; }
[hidden] { display: none !important; }
.screen { height: 100%; }
button { font: inherit; color: inherit; cursor: pointer; touch-action: manipulation; }
:focus-visible { outline: 2px solid var(--amber); outline-offset: 2px; }

.eyebrow { font-size: .72rem; letter-spacing: .22em; text-transform: uppercase; color: var(--amber); margin: 0 0 .5rem; }

/* Title */
#title-screen { display: grid; place-items: center; padding: 1.5rem;
  background: radial-gradient(ellipse at 50% 20%, #1b2a33 0%, #07080b 70%); }
.title-wrap { width: 100%; }
.card { border: 1px solid var(--line); border-radius: 14px; padding: 1.6rem 1.4rem; background: #0d1015cc; }
.card h2 { font-family: var(--serif); font-weight: 400; font-size: 2.2rem; margin: 0 0 .6rem; letter-spacing: .02em; }
.card p { color: var(--muted); line-height: 1.55; margin: 0 0 1.3rem; }

.actions { display: flex; flex-wrap: wrap; gap: .6rem; }
.btn { min-height: 48px; padding: .7rem 1.2rem; border-radius: 999px; border: 1px solid var(--line); background: #ffffff0d; }
.btn.primary { background: var(--amber); color: #1a1208; border-color: var(--amber); font-weight: 600; }
.btn:active { transform: scale(.97); }

/* Game */
#game-screen { display: flex; flex-direction: column; position: relative; background: #07080b;
  padding-top: env(safe-area-inset-top); }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: .5rem; padding: .5rem .75rem; }
.topbar h1 { flex: 1; text-align: center; margin: 0; font-family: var(--serif); font-weight: 400; font-size: .95rem; letter-spacing: .08em; color: var(--muted); }
.chip { min-height: 44px; padding: 0 .85rem; border-radius: 999px; background: #ffffff0d; border: 1px solid var(--line); font-size: .8rem; color: var(--ink); }

#stage { flex: 1; min-height: 0; display: flex; }
#stage svg { width: 100%; height: 100%; display: block; }

.hotspot { cursor: pointer; outline: none; }
.hotspot > * { fill: transparent; stroke: transparent; stroke-width: 2; transition: fill .2s, stroke .2s; }
.hotspot:hover > *, .hotspot:focus-visible > * { fill: #e8b45a22; stroke: #e8b45a99; }
.hotspot.gone { display: none; }
.pulsing .hotspot:not(.gone) > * { animation: hint 1.1s ease-in-out 2; }
@keyframes hint { 50% { fill: #e8b45a33; stroke: #e8b45acc; } }

.flicker { animation: flicker 5s infinite; }
@keyframes flicker { 0%,100% { opacity: 1 } 46% { opacity: .92 } 48% { opacity: .75 } 50% { opacity: .95 } }
.neon { animation: neon 7s infinite; }
@keyframes neon { 0%,100% { opacity: 1 } 62% { opacity: 1 } 63% { opacity: .35 } 66% { opacity: 1 } 68% { opacity: .5 } 70% { opacity: 1 } }
.glint { animation: glint 3s ease-in-out infinite; }
@keyframes glint { 50% { filter: drop-shadow(0 0 4px #ffd27a); } }
.rain path { animation: rain 1.4s linear infinite; }
@keyframes rain { from { transform: translateY(-6px); opacity: .2 } to { transform: translateY(10px); opacity: .6 } }
.motes circle { animation: drift 9s ease-in-out infinite alternate; opacity: .5; }
@keyframes drift { to { transform: translate(8px, -14px); opacity: .1; } }

/* Inventory */
#inventory { display: flex; align-items: center; gap: .5rem; padding: .6rem .75rem calc(.6rem + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line); background: #0b0d12; transition: background .3s; }
#inventory.got { background: #2a2110; }
.inv-label { font-size: .65rem; letter-spacing: .18em; text-transform: uppercase; color: var(--muted); writing-mode: vertical-rl; transform: rotate(180deg); }
.slot { width: 56px; height: 56px; border-radius: 10px; border: 1px solid var(--line); background: #ffffff08; padding: 8px; flex: none; }
.slot svg { width: 100%; height: 100%; }
.slot.empty { border-style: dashed; opacity: .4; }
button.slot:active { transform: scale(.94); }

/* Bottom sheet */
.sheet { position: absolute; inset: 0; display: flex; align-items: flex-end; background: #000000a0; animation: fade .2s; z-index: 10; }
.panel { width: 100%; padding: 1.4rem 1.3rem calc(1.4rem + env(safe-area-inset-bottom)); background: var(--panel);
  border-top: 1px solid var(--line); border-radius: 18px 18px 0 0; animation: rise .25s ease-out; backdrop-filter: blur(8px); }
.panel h2 { font-family: var(--serif); font-weight: 400; font-size: 1.5rem; margin: 0 0 .6rem; }
.panel p { line-height: 1.6; color: #cfc8b8; margin: 0 0 1.2rem; }
.panel .eyebrow { margin-bottom: .4rem; }
.item-art { width: 72px; height: 72px; margin-bottom: .6rem; }
.item-art svg { width: 100%; height: 100%; }
@keyframes fade { from { opacity: 0 } }
@keyframes rise { from { transform: translateY(30px); opacity: 0 } }

@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* Stage B: touch-friendly escape-room puzzle controls */
.puzzle-dials { display:flex; flex-wrap:wrap; gap:.6rem; margin:1rem 0; }
.puzzle-dials .btn { flex:1; min-width:60px; font-size:1.2rem; border-color:#e8b45a88; }
.puzzle-input { width:100%; min-height:48px; margin:.65rem 0 1rem; padding:.75rem; border:1px solid #e8b45a88; border-radius:10px; background:#10151d; color:#fff; font:inherit; text-transform:uppercase; }
.puzzle-hint { padding:.7rem; border-left:3px solid var(--amber); background:#e8b45a12; }
.panel { max-height:85dvh; overflow-y:auto; }
