/* The RocSite Quest - base, HUD and controls (phone first, 390x844) */
:root {
  --ink: #fff8ee; --ink2: #f3dfc4; --muted: #cdb9a0;
  --glass: rgba(24, 18, 22, 0.58); --glass2: rgba(24, 18, 22, 0.78); --line: rgba(255, 228, 190, 0.22);
  --gold: #ffb357; --gold2: #ffd28a; --teal: #6fd8cc; --warn: #ff8a6b; --ok: #8ff0b4;
  --st: env(safe-area-inset-top, 0px); --sb: env(safe-area-inset-bottom, 0px);
  --sl: env(safe-area-inset-left, 0px); --sr: env(safe-area-inset-right, 0px);
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; height: 100%; overflow: hidden; background: #1b1420; color: var(--ink);
  font: 16px/1.4 var(--sans); overscroll-behavior: none;
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none;
}
button { font: inherit; color: inherit; cursor: pointer; }
#gl { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }

#veil {
  position: fixed; inset: 0; z-index: 50; display: flex; flex-direction: column; gap: 14px;
  align-items: center; justify-content: center; background: radial-gradient(circle at 50% 40%, #3a2630, #140e14 70%);
  color: var(--ink2); letter-spacing: 0.14em; text-transform: uppercase; font-size: 16px;
  transition: opacity 0.6s ease, visibility 0.6s;
}
#veil img { opacity: 0.9; animation: breathe 1.6s ease-in-out infinite; }
#veil.gone { opacity: 0; visibility: hidden; pointer-events: none; }
@keyframes breathe { 50% { transform: scale(1.08); opacity: 1; } }

/* ---------- HUD ---------- */
.hud { position: fixed; inset: 0; pointer-events: none; z-index: 10; }
.hud > * { pointer-events: auto; }
.hud-top {
  position: absolute; top: calc(10px + var(--st)); left: calc(12px + var(--sl)); right: calc(12px + var(--sr));
  display: flex; align-items: center; justify-content: space-between; z-index: 30; pointer-events: none;
}
.hud-top > * { pointer-events: auto; }
.logo {
  display: flex; align-items: center; gap: 8px; height: 44px; padding: 0 12px 0 8px; border-radius: 22px;
  background: var(--glass); border: 1px solid var(--line); color: var(--ink); text-decoration: none;
  font-weight: 650; letter-spacing: 0.02em; backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
}
.logo img { height: 28px; width: auto; display: block; }
.hud-right { display: flex; gap: 10px; }
.round {
  width: 48px; height: 48px; border-radius: 50%; display: grid; place-items: center;
  background: var(--glass); border: 1px solid var(--line); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
}
.round svg { width: 24px; height: 24px; }
.mute .x { display: none; } .mute.muted .x { display: inline; } .mute.muted .w { display: none; }
.atom-btn i {
  width: 22px; height: 22px; border-radius: 50%; display: block;
  background: radial-gradient(circle at 50% 50%, #fff3dc 0 18%, #ffb35c 30%, #6fd8cc 55%, rgba(111, 216, 204, 0) 72%);
  box-shadow: 0 0 14px rgba(111, 216, 204, 0.7);
}
.atom-btn.glow { animation: ping 1.6s ease-out infinite; }
@keyframes ping { 0% { box-shadow: 0 0 0 0 rgba(111, 216, 204, 0.7); } 100% { box-shadow: 0 0 0 16px rgba(111, 216, 204, 0); } }

.objective, .reticle, .action { opacity: 0; transition: opacity 0.35s ease, transform 0.35s ease; }
.hud.on .objective, .hud.on .reticle { opacity: 1; }
.objective {
  position: absolute; top: calc(66px + var(--st)); left: calc(12px + var(--sl)); max-width: min(440px, calc(100% - 150px));
  padding: 9px 14px 10px; border-radius: 14px; background: var(--glass); border: 1px solid var(--line);
  border-left: 3px solid var(--gold); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); pointer-events: none;
}
.objective b { display: block; font-size: 12px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--gold2); font-weight: 700; }
.objective span { display: block; font-size: 16px; font-weight: 600; color: var(--ink); }
.hud.on .objective.hide { opacity: 0; }
.objective.flash { animation: objIn 0.7s cubic-bezier(.2, 1.4, .4, 1); }
@keyframes objIn { 0% { transform: translateX(-24px) scale(0.96); opacity: 0; } 100% { transform: none; opacity: 1; } }

.reticle {
  position: absolute; left: 50%; top: 50%; width: 8px; height: 8px; margin: -4px 0 0 -4px; border-radius: 50%;
  background: rgba(255, 248, 238, 0.85); box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.18); pointer-events: none;
}
.reticle.hot { transform: scale(2.4); background: transparent; box-shadow: 0 0 0 1.5px var(--gold2), 0 0 12px rgba(255, 179, 87, 0.6); }

.action {
  position: absolute; right: calc(18px + var(--sr)); bottom: calc(26px + var(--sb)); min-width: 96px; height: 96px; padding: 0 18px;
  border-radius: 48px; border: 0; transform: scale(0.6); pointer-events: none;
  background: radial-gradient(circle at 35% 30%, #ffe2a8, #ffb357 55%, #e98a2c); color: #2a1608;
  box-shadow: 0 8px 26px rgba(233, 138, 44, 0.45), inset 0 -4px 0 rgba(0, 0, 0, 0.12);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0;
}
.action.on { opacity: 1; transform: scale(1); pointer-events: auto; animation: bob 1.8s ease-in-out infinite; }
.action em { font-style: normal; font-size: 12px; font-weight: 700; letter-spacing: 0.04em; max-width: 130px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; opacity: 0.78; }
.action span { font-size: 20px; font-weight: 800; }
.action:active { transform: scale(0.94); }
@keyframes bob { 50% { transform: translateY(-3px); } }

.pops { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.pop {
  position: absolute; transform: translate(-50%, -50%); font-weight: 800; font-size: 20px; color: var(--ink);
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.55); white-space: nowrap; animation: popUp 1.5s cubic-bezier(.2, 1.3, .4, 1) forwards;
}
.pop.gold { color: var(--gold2); } .pop.warn { color: var(--warn); } .pop.ok { color: var(--ok); }
@keyframes popUp { 0% { transform: translate(-50%, -30%) scale(0.5); opacity: 0; } 18% { transform: translate(-50%, -60%) scale(1.15); opacity: 1; } 100% { transform: translate(-50%, -190%) scale(1); opacity: 0; } }

.vignette { position: absolute; inset: 0; pointer-events: none; opacity: 0; background: radial-gradient(ellipse at center, transparent 55%, var(--vc, rgba(255, 190, 110, 0.55)) 100%); }
.vignette.go { animation: vig 0.9s ease-out; }
@keyframes vig { 0% { opacity: 0; } 25% { opacity: 1; } 100% { opacity: 0; } }

.toast {
  position: absolute; left: 50%; top: calc(188px + var(--st)); transform: translate(-50%, -8px); max-width: calc(100% - 32px);
  padding: 10px 16px; border-radius: 14px; background: var(--glass2); border: 1px solid var(--line); font-size: 16px; font-weight: 550;
  text-align: center; opacity: 0; transition: opacity 0.35s, transform 0.35s; pointer-events: none;
}
.toast.on { opacity: 1; transform: translate(-50%, 0); }

/* ---------- joystick ---------- */
.joy-base, .joy-knob { position: fixed; left: 0; top: 0; z-index: 9; pointer-events: none; opacity: 0; transition: opacity 0.15s; }
.joy-base { width: 120px; height: 120px; border-radius: 50%; border: 2px solid rgba(255, 240, 220, 0.5); background: rgba(30, 20, 26, 0.25); }
.joy-knob { width: 56px; height: 56px; border-radius: 50%; background: radial-gradient(circle at 35% 30%, #fff6e6, #f3d3a6); box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35); }
.joy-base.on, .joy-knob.on { opacity: 1; }
.joy-ghost {
  position: fixed; left: calc(34px + var(--sl)); bottom: calc(40px + var(--sb)); width: 96px; height: 96px; border-radius: 50%; z-index: 8;
  border: 2px dashed rgba(255, 240, 220, 0.45); display: grid; place-items: center; pointer-events: none; transition: opacity 0.6s;
}
.joy-ghost span { font-size: 14px; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; color: rgba(255, 248, 238, 0.8); }
.joy-ghost.off, .joy-ghost.hide { opacity: 0; }
@media (pointer: fine) { .joy-ghost { display: none; } }
