/* Ashgrove — a dark, quiet interface that stays out of the way of the scene. */
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #000; color: #d8d2c6; font-family: Georgia, 'Times New Roman', serif; -webkit-user-select: none; user-select: none; }
button { font: inherit; color: inherit; cursor: pointer; }
.hidden { display: none !important; }
.muted { color: #8a8478; font-size: 0.9em; }
.red { color: #c33a2a; }

#scene { position: fixed; inset: 0; }
#scene canvas { display: block; }

/* ── Lens ─────────────────────────────────────────────────────────────────── */
#grain, #vignette, #dread, #slats, #whiteout, #fade { position: fixed; inset: 0; pointer-events: none; }
#grain { opacity: 0.09; mix-blend-mode: overlay; background-size: 160px 160px; image-rendering: pixelated; }
#vignette { background: radial-gradient(ellipse at center, rgba(0,0,0,0) 45%, rgba(0,0,0,0.55) 80%, rgba(0,0,0,0.92) 100%); }
#dread { opacity: 0; background: radial-gradient(ellipse at center, rgba(90,0,0,0) 40%, rgba(110,0,0,0.65) 100%); transition: opacity 0.2s; }
#slats { background: repeating-linear-gradient(to bottom, rgba(6,4,3,0.98) 0 26px, rgba(6,4,3,0.55) 26px 34px, rgba(6,4,3,0.98) 34px 40px); }
#slats::after { content: ''; position: absolute; inset: 0; background: linear-gradient(to right, #060403 0 22%, transparent 32% 68%, #060403 78%); }
#whiteout { background: #fff; opacity: 0; }
#fade { background: #000; opacity: 0; transition: opacity 1.4s; }
#fade.on { opacity: 1; }

/* ── HUD ──────────────────────────────────────────────────────────────────── */
#hud { position: fixed; inset: 0; pointer-events: none; text-shadow: 0 1px 3px #000; }
#objective { position: absolute; top: max(16px, env(safe-area-inset-top)); left: 20px; font-style: italic; font-size: 15px; color: #b9b2a4; max-width: 50vw; }
#status { position: absolute; bottom: max(18px, env(safe-area-inset-bottom)); left: 20px; display: flex; flex-direction: column; gap: 6px; }
.meter { display: flex; align-items: center; gap: 8px; }
.meter .label { width: 22px; text-align: center; font-size: 14px; }
.bar { width: 120px; height: 5px; background: rgba(255,255,255,0.12); border-radius: 3px; overflow: hidden; }
#battery-fill { height: 100%; background: #e6d9b8; width: 100%; transition: background 0.3s; }
#battery-fill.low { background: #c84a2a; }
#stamina-fill { height: 100%; background: #9fb3c8; width: 100%; }
#stamina-meter { transition: opacity 0.4s; }
#stamina-meter.full { opacity: 0; }
#fuses { font-size: 14px; color: #c9a85a; }
#dot { position: absolute; left: 50%; top: 50%; width: 3px; height: 3px; margin: -1.5px; border-radius: 50%; background: rgba(255,255,255,0.35); }
#prompt { position: absolute; left: 50%; top: calc(50% + 34px); transform: translateX(-50%); font-size: 16px; color: #efe7d4; letter-spacing: 0.04em; white-space: nowrap; }
#prompt b { display: inline-block; padding: 1px 7px; margin-right: 8px; border: 1px solid rgba(255,255,255,0.4); border-radius: 4px; font-family: system-ui, sans-serif; font-size: 13px; }
#subtitle { position: absolute; left: 50%; bottom: 14%; transform: translateX(-50%); max-width: min(720px, 90vw); text-align: center; font-size: 18px; color: #eee6d2; opacity: 0; transition: opacity 0.6s; }
#subtitle.show { opacity: 1; }

/* ── Screens ──────────────────────────────────────────────────────────────── */
.screen { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; padding: 20px; background: radial-gradient(ellipse at center, rgba(0,0,0,0.55), rgba(0,0,0,0.9)); overflow-y: auto; }
.panel { width: min(560px, 100%); text-align: center; display: flex; flex-direction: column; gap: 10px; }
.panel.narrow { width: min(460px, 100%); }
.logo { margin: 0; font-size: clamp(44px, 11vw, 84px); letter-spacing: 0.32em; font-weight: normal; color: #cfc6b4; text-shadow: 0 0 30px rgba(200,40,20,0.25), 0 2px 0 #000; animation: breathe 6s ease-in-out infinite; padding-left: 0.32em; }
@keyframes breathe { 0%, 100% { opacity: 0.85; } 48% { opacity: 1; } 50% { opacity: 0.4; } 52% { opacity: 1; } }
.tag { margin: 0 0 12px; font-style: italic; color: #9a9384; }
h2 { margin: 0 0 6px; font-weight: normal; font-size: 30px; letter-spacing: 0.06em; }
.panel p { line-height: 1.55; }
.panel button { background: rgba(30,26,22,0.85); border: 1px solid #3e362c; border-radius: 6px; padding: 11px 16px; transition: background 0.15s, border-color 0.15s; }
.panel button:hover:not(:disabled) { background: rgba(60,48,36,0.9); border-color: #7a6448; }
.panel button:disabled { opacity: 0.4; cursor: default; }
.panel button.primary { background: #4a1a12; border-color: #8a3020; }
.panel button.primary:hover { background: #6a2418; }
.panel button.big { font-size: 19px; padding: 14px; }
#nights { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
#nights button { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 12px 4px; }
#nights button b { font-size: 22px; font-weight: normal; }
#nights button small { color: #8a8478; font-size: 12px; }
.settings { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-top: 6px; }
.chip { font-size: 13px; padding: 6px 12px !important; border-radius: 16px !important; display: inline-flex; align-items: center; gap: 8px; background: rgba(30,26,22,0.85); border: 1px solid #3e362c; }
.chip input { width: 90px; accent-color: #8a3020; }
.help { text-align: left; background: rgba(20,17,14,0.8); border: 1px solid #2e2820; border-radius: 6px; padding: 10px 14px; }
.help summary { cursor: pointer; color: #b9b2a4; }
.help-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 16px; font-size: 14px; }
.help-grid b { display: inline-block; min-width: 64px; color: #e6dcc4; font-family: system-ui, sans-serif; font-size: 12px; }
.touch-help { display: none; }
body.touch .touch-help { display: block; }
body.touch .help-grid { display: none; }
#loading { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; background: #000; font-style: italic; color: #8a8478; }

/* ── Phone controls ───────────────────────────────────────────────────────── */
#touch { position: fixed; inset: 0; }
#touch-pad { position: absolute; inset: 0; touch-action: none; }
#stick { position: absolute; width: 120px; height: 120px; margin: -60px; border-radius: 50%; border: 2px solid rgba(255,255,255,0.18); background: rgba(255,255,255,0.04); pointer-events: none; }
#stick > div { position: absolute; left: 50%; top: 50%; width: 52px; height: 52px; margin: -26px; border-radius: 50%; background: rgba(255,255,255,0.22); }
#touch-buttons { position: absolute; right: max(16px, env(safe-area-inset-right)); bottom: max(20px, env(safe-area-inset-bottom)); display: grid; grid-template-columns: auto auto; gap: 12px; align-items: end; }
.tb { width: 64px; height: 64px; border-radius: 50%; border: 1px solid rgba(255,255,255,0.25); background: rgba(20,16,12,0.45); color: #e6dcc4; font-size: 14px; touch-action: none; -webkit-tap-highlight-color: transparent; }
.tb.big { width: 84px; height: 84px; grid-row: span 2; font-size: 17px; }
.tb.on { background: rgba(140,60,30,0.6); }
.tb.small { position: absolute; top: max(12px, env(safe-area-inset-top)); right: max(12px, env(safe-area-inset-right)); width: 44px; height: 44px; font-size: 13px; }
#touch-hint { position: absolute; left: 0; right: 0; bottom: 34%; text-align: center; color: rgba(230,220,200,0.6); font-style: italic; font-size: 14px; pointer-events: none; transition: opacity 1s; }
#touch-hint.gone { opacity: 0; }
body.touch #dot { display: none; }
body.touch #status { bottom: auto; top: calc(max(16px, env(safe-area-inset-top)) + 34px); }

@media (max-width: 720px) {
  #nights { grid-template-columns: repeat(3, 1fr); }
  #subtitle { font-size: 16px; bottom: 30%; }
  #objective { max-width: 70vw; font-size: 13px; }
  .help-grid { grid-template-columns: 1fr; }
}
