:root {
  --bg: #0a0e16;
  --ink: #eaf2ff;
  --accent: #7fe3ff;
  --accent-2: #ffd36b;
  --good: #6bff9e;
  --danger: #ff6b7f;
  --panel: rgba(12, 18, 28, 0.72);
  --panel-solid: #0d1420;
  --font: "Segoe UI", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  width: 100%; height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}

#app { position: fixed; inset: 0; }
#app canvas { display: block; width: 100%; height: 100%; }

.hidden { display: none !important; }

/* ---------- Overlays ---------- */
.overlay {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  z-index: 50;
  background:
    radial-gradient(1100px 760px at 50% 10%, rgba(40, 92, 132, 0.30), transparent 62%),
    radial-gradient(900px 700px at 84% 112%, rgba(28, 150, 118, 0.20), transparent 55%),
    linear-gradient(180deg, #05080e 0%, #080f18 100%);
  transition: opacity 0.6s ease;
  overflow: hidden;
  font-family: var(--font);
}

/* Reveal the live world as a backdrop, framed like a camera viewfinder. A soft
   central scrim keeps the title text legible over the bright world. */
.overlay.revealed {
  background:
    radial-gradient(58% 46% at 50% 50%, rgba(3, 8, 14, 0.66), rgba(3, 8, 14, 0.18) 58%, transparent 82%),
    radial-gradient(150% 120% at 50% 42%, transparent 26%, rgba(3, 7, 13, 0.52) 78%, rgba(2, 5, 9, 0.86) 100%);
}
.overlay.revealed .loading-block { display: none; }

/* Subtle film scanlines */
.vf-grain {
  position: absolute; inset: 0; pointer-events: none; z-index: 2; opacity: 0.55;
  background-image: repeating-linear-gradient(0deg, rgba(255,255,255,0.03) 0 1px, transparent 1px 3px);
  mix-blend-mode: overlay;
}

/* Viewfinder corner brackets */
.vf-corner {
  position: absolute; width: 46px; height: 46px; z-index: 3; pointer-events: none;
  border: 2px solid rgba(165, 228, 255, 0.7);
  filter: drop-shadow(0 0 5px rgba(0,0,0,0.6));
}
.vf-tl { top: 26px; left: 28px; border-right: none; border-bottom: none; }
.vf-tr { top: 26px; right: 28px; border-left: none; border-bottom: none; }
.vf-bl { bottom: 26px; left: 28px; border-right: none; border-top: none; }
.vf-br { bottom: 26px; right: 28px; border-left: none; border-top: none; }

/* Viewfinder readouts */
.vf-hud {
  position: absolute; left: 42px; right: 42px; z-index: 3; pointer-events: none;
  display: flex; justify-content: space-between; align-items: center;
  font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
  font-size: 12.5px; letter-spacing: 1.5px; color: rgba(200, 235, 255, 0.85);
  text-shadow: 0 1px 4px rgba(0,0,0,0.85);
}
.vf-hud-top { top: 32px; }
.vf-hud-bottom { bottom: 32px; }
.vf-rec { display: flex; align-items: center; gap: 8px; color: #ff8088; font-weight: 700; }
.rec-dot { width: 10px; height: 10px; border-radius: 50%; background: #ff5a68; box-shadow: 0 0 10px #ff5a68; animation: rec-blink 1.4s infinite; }
@keyframes rec-blink { 0%, 45% { opacity: 1; } 55%, 100% { opacity: 0.12; } }
.batt-cells { color: var(--good); letter-spacing: 1px; }

/* Hero */
.hero { position: relative; z-index: 4; text-align: center; width: min(860px, 94vw); }
.hero-frame { position: relative; padding: 24px 30px 8px; }
.hero-tick { position: absolute; background: var(--good); box-shadow: 0 0 8px var(--good); }
.hero-tick.t-t, .hero-tick.t-b { left: 50%; transform: translateX(-50%); width: 2px; height: 13px; }
.hero-tick.t-l, .hero-tick.t-r { top: 46%; transform: translateY(-50%); width: 13px; height: 2px; }
.hero-tick.t-t { top: 0; } .hero-tick.t-b { bottom: 0; }
.hero-tick.t-l { left: 0; } .hero-tick.t-r { right: 0; }

.brand-logo { width: 62px; height: 62px; margin: 0 auto 8px; filter: drop-shadow(0 0 18px rgba(127,227,255,0.55)); }
.brand-logo svg { width: 100%; height: 100%; display: block; }
.brand-title {
  font-size: clamp(46px, 9.5vw, 92px); font-weight: 800; letter-spacing: 7px; margin: 0;
  padding-left: 7px; /* offset trailing letter-spacing so it stays centred */
  background: linear-gradient(180deg, #ffffff 0%, #a9e4ff 55%, #4aa6e6 100%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  text-shadow: 0 6px 36px rgba(8, 30, 50, 0.85); line-height: 1; white-space: nowrap;
}
.brand-sub {
  text-transform: uppercase; letter-spacing: 9px; font-size: 13px;
  color: var(--accent-2); margin-top: 10px; text-shadow: 0 2px 10px rgba(0,0,0,0.85);
}

/* Loading */
.loading-block { margin-top: 28px; }
.loader-bar { width: min(340px, 66vw); height: 5px; border-radius: 6px; margin: 0 auto 10px;
  background: rgba(255,255,255,0.1); overflow: hidden; }
#loader-fill { height: 100%; width: 0%;
  background: linear-gradient(90deg, var(--accent), var(--good)); box-shadow: 0 0 14px var(--accent);
  transition: width 0.3s ease; }
#loader-status { font-family: ui-monospace, Consolas, monospace; font-size: 11.5px;
  letter-spacing: 2px; text-transform: uppercase; opacity: 0.6; }

/* Start panel */
.start-panel { margin-top: 26px; }
.howto { font-size: 15px; line-height: 1.55; color: rgba(232,243,255,0.92);
  max-width: 440px; margin: 0 auto 22px; text-shadow: 0 2px 10px rgba(0,0,0,0.9); }

.shutter-row { display: flex; align-items: center; justify-content: center; gap: 16px; flex-wrap: wrap; }
.shutter-btn {
  position: relative; display: inline-flex; align-items: center; gap: 14px;
  font-family: var(--font); cursor: pointer; border: none;
  padding: 13px 30px 13px 15px; border-radius: 44px; color: #052015; font-weight: 800;
  letter-spacing: 2px; font-size: 16px;
  background: linear-gradient(180deg, #bcffd4, #4fe39a);
  box-shadow: 0 10px 34px rgba(79, 227, 154, 0.42), inset 0 1px 0 rgba(255,255,255,0.5);
  transition: transform 0.15s ease, box-shadow 0.2s ease, filter 0.2s ease;
}
.shutter-btn:hover { transform: translateY(-2px); filter: brightness(1.05); box-shadow: 0 14px 42px rgba(79,227,154,0.58); }
.shutter-btn:active { transform: translateY(0); }
.shutter-ring {
  width: 28px; height: 28px; border-radius: 50%; flex: none; background: #052015;
  box-shadow: inset 0 0 0 3px #bcffd4; animation: shutter-pulse 2.2s ease-in-out infinite;
}
@keyframes shutter-pulse { 0%, 100% { box-shadow: inset 0 0 0 3px #bcffd4; } 50% { box-shadow: inset 0 0 0 6px #bcffd4; } }

.vr-btn {
  font-family: var(--font); cursor: pointer; border: 1px solid rgba(255,211,107,0.5);
  padding: 12px 22px; border-radius: 44px; font-weight: 700; letter-spacing: 1px; font-size: 15px;
  color: var(--accent-2); background: rgba(255, 211, 107, 0.08); backdrop-filter: blur(4px);
  transition: transform 0.15s ease, filter 0.2s ease;
}
.vr-btn:hover { transform: translateY(-2px); }
.vr-btn:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }

.controls-strip {
  display: flex; align-items: center; justify-content: center; gap: 10px; flex-wrap: wrap;
  margin-top: 24px; font-family: ui-monospace, Consolas, monospace;
  font-size: 12px; letter-spacing: 1px; color: rgba(210,232,255,0.72);
  text-shadow: 0 2px 8px rgba(0,0,0,0.85);
}
.controls-strip b { color: var(--accent); }
.controls-strip i { color: rgba(127,227,255,0.4); font-style: normal; }

.title-credit {
  position: absolute; bottom: 13px; left: 50%; transform: translateX(-50%);
  z-index: 3; pointer-events: none;
  font-family: var(--font); font-size: 12px; letter-spacing: 2px;
  color: rgba(224, 236, 255, 0.62);
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.85);
}
.title-credit::after {
  content: ''; display: block; width: 42px; height: 2px; margin: 7px auto 0;
  background: linear-gradient(90deg, transparent, var(--accent-2), transparent); opacity: 0.7;
}

/* Buttons reused by the end-of-run gallery */
.btn {
  font-family: var(--font); font-size: 16px; font-weight: 700;
  letter-spacing: 1px; cursor: pointer; border: none; border-radius: 12px;
  padding: 14px 26px; color: #04121f;
  transition: transform 0.15s ease, box-shadow 0.2s ease, filter 0.2s ease;
}
.btn:hover { transform: translateY(-2px); filter: brightness(1.08); }
.btn:active { transform: translateY(0); }
.btn-primary { background: linear-gradient(180deg, #aef0ff, #5cc6ff); box-shadow: 0 8px 28px rgba(92,198,255,0.4); }
.btn-vr { background: linear-gradient(180deg, #ffe79a, #ffc24a); box-shadow: 0 8px 28px rgba(255,194,74,0.35); }
.btn-vr:disabled { filter: grayscale(0.7) brightness(0.7); cursor: not-allowed; box-shadow: none; }

/* ---------- HUD ---------- */
#hud-root { position: fixed; inset: 0; z-index: 30; pointer-events: none; }

.hud-top {
  position: absolute; top: 0; left: 0; right: 0;
  display: flex; justify-content: space-between; align-items: flex-start;
  padding: 18px 22px;
  background: linear-gradient(180deg, rgba(0,0,0,0.45), transparent);
}
.hud-chip {
  background: var(--panel); border: 1px solid rgba(255,255,255,0.08);
  border-radius: 12px; padding: 8px 14px; backdrop-filter: blur(6px);
  display: flex; align-items: center; gap: 10px; font-weight: 700;
}
.hud-timer { font-size: 28px; font-variant-numeric: tabular-nums; letter-spacing: 1px; }
.hud-timer.warn { color: var(--danger); animation: pulse 0.8s infinite; }
.hud-label { font-size: 11px; text-transform: uppercase; letter-spacing: 2px; opacity: 0.6; font-weight: 600; }
.hud-shots { font-size: 22px; color: var(--accent-2); font-variant-numeric: tabular-nums; }

@keyframes pulse { 50% { opacity: 0.45; } }

/* Center reticle (desktop) */
.reticle {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%,-50%);
  width: 220px; height: 220px; pointer-events: none;
  opacity: 0.9; transition: width 0.25s ease, height 0.25s ease, opacity 0.25s ease;
}
.reticle .frame {
  position: absolute; inset: 0;
}
.reticle .corner {
  position: absolute; width: 26px; height: 26px;
  border: 3px solid rgba(255,255,255,0.85); filter: drop-shadow(0 0 6px rgba(0,0,0,0.6));
}
.reticle .tl { top: 0; left: 0; border-right: none; border-bottom: none; border-radius: 6px 0 0 0; }
.reticle .tr { top: 0; right: 0; border-left: none; border-bottom: none; border-radius: 0 6px 0 0; }
.reticle .bl { bottom: 0; left: 0; border-right: none; border-top: none; border-radius: 0 0 0 6px; }
.reticle .br { bottom: 0; right: 0; border-left: none; border-top: none; border-radius: 0 0 6px 0; }
.reticle .dot {
  position: absolute; top: 50%; left: 50%; width: 6px; height: 6px;
  transform: translate(-50%,-50%); border-radius: 50%;
  background: var(--accent); box-shadow: 0 0 10px var(--accent);
}
.reticle.locked .corner { border-color: var(--good); }
.reticle.locked .dot { background: var(--good); box-shadow: 0 0 12px var(--good); }

.subject-tag {
  position: absolute; top: -34px; left: 50%; transform: translateX(-50%);
  white-space: nowrap; font-size: 13px; font-weight: 700; color: var(--good);
  background: rgba(0,0,0,0.55); padding: 3px 10px; border-radius: 20px;
  border: 1px solid rgba(107,255,158,0.4); opacity: 0; transition: opacity 0.2s;
}
.reticle.locked .subject-tag { opacity: 1; }

.zoom-badge {
  position: absolute; bottom: -30px; left: 50%; transform: translateX(-50%);
  font-size: 12px; letter-spacing: 1px; opacity: 0.8; font-weight: 700;
  background: rgba(0,0,0,0.4); padding: 2px 10px; border-radius: 12px;
}

/* Toast / hints */
.hud-toast {
  position: absolute; bottom: 36px; left: 50%; transform: translateX(-50%);
  background: var(--panel); border: 1px solid rgba(255,255,255,0.1);
  padding: 10px 20px; border-radius: 30px; font-size: 14px; font-weight: 600;
  backdrop-filter: blur(8px); opacity: 0; max-width: 80vw; text-align: center;
}

/* Countdown */
.countdown {
  position: fixed; top: 44%; left: 50%; transform: translate(-50%, -50%);
  z-index: 38; pointer-events: none; display: none;
  font-size: clamp(90px, 18vw, 200px); font-weight: 900; letter-spacing: 4px;
  color: #fff;
  text-shadow: 0 0 40px rgba(127, 227, 255, 0.9), 0 6px 24px rgba(0,0,0,0.6);
}
.countdown.go {
  background: linear-gradient(180deg, #aef0ff, #6bff9e);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  text-shadow: 0 0 50px rgba(107, 255, 158, 0.8);
}

/* Photo flash + capture frame */
.flash {
  position: fixed; inset: 0; background: #fff; opacity: 0;
  pointer-events: none; z-index: 40;
}
.shot-thumb {
  position: fixed; z-index: 41; border-radius: 8px; overflow: hidden;
  border: 3px solid #fff; box-shadow: 0 12px 40px rgba(0,0,0,0.6);
  pointer-events: none;
}
.shot-thumb img { display: block; width: 100%; height: 100%; object-fit: cover; }
.shot-score {
  position: absolute; bottom: 0; left: 0; right: 0;
  background: linear-gradient(transparent, rgba(0,0,0,0.85));
  color: #fff; font-weight: 800; font-size: 13px; padding: 14px 8px 5px; text-align: center;
}

/* ---------- Gallery ---------- */
#gallery-root { position: fixed; inset: 0; z-index: 60; pointer-events: none; }
.gallery {
  position: absolute; inset: 0; pointer-events: auto; overflow-y: auto;
  background:
    radial-gradient(1000px 600px at 50% -5%, rgba(60,110,160,0.3), transparent 60%),
    linear-gradient(180deg, #070b12, #0a121c);
  padding: 40px 24px 80px;
}
.gallery-head { text-align: center; margin-bottom: 8px; }
.gallery-head h2 {
  font-size: clamp(30px, 6vw, 52px); letter-spacing: 6px; font-weight: 800;
  background: linear-gradient(180deg, #fff, #8fd6ff); -webkit-background-clip: text; background-clip: text; color: transparent;
}
.gallery-sub { opacity: 0.7; letter-spacing: 2px; text-transform: uppercase; font-size: 13px; }
.gallery-total {
  text-align: center; margin: 18px 0 30px; font-size: 18px;
}
.gallery-total b { color: var(--accent-2); font-size: 34px; }

.gallery-grid {
  display: grid; gap: 18px; max-width: 1100px; margin: 0 auto;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
}
.photo-card {
  background: var(--panel-solid); border: 1px solid rgba(255,255,255,0.08);
  border-radius: 14px; overflow: hidden; transform-origin: center;
  box-shadow: 0 10px 30px rgba(0,0,0,0.4);
}
.photo-card img { display: block; width: 100%; aspect-ratio: 4/3; object-fit: cover; background: #04121f; }
.photo-meta { padding: 12px 14px; display: flex; justify-content: space-between; align-items: center; }
.photo-subject { font-weight: 700; }
.photo-rank {
  font-weight: 800; font-size: 14px; padding: 3px 10px; border-radius: 20px;
  background: rgba(255,211,107,0.15); color: var(--accent-2);
}
.photo-stars { letter-spacing: 2px; color: var(--accent-2); font-size: 14px; }
.photo-score-bar { height: 5px; background: rgba(255,255,255,0.07); }
.photo-score-fill { height: 100%; background: linear-gradient(90deg, var(--accent), var(--good)); }

.gallery-actions { text-align: center; margin-top: 40px; display: flex; gap: 14px; justify-content: center; flex-wrap: wrap; }
.gallery-empty { text-align: center; opacity: 0.6; margin: 60px 0; font-size: 18px; }

/* ---------- Mobile touch controls ---------- */
#app, #app canvas { touch-action: none; } /* drag-to-aim without page gestures */

.touch-controls {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 42;
  display: flex; align-items: flex-end; justify-content: space-between;
  padding: 0 24px calc(22px + env(safe-area-inset-bottom));
  pointer-events: none; /* only the controls themselves capture touches */
}
.touch-controls > * { pointer-events: auto; }

/* Virtual joystick (camera aim) */
.touch-joy {
  position: relative; width: 132px; height: 132px; border-radius: 50%;
  background: rgba(8, 22, 31, 0.4); border: 1px solid rgba(127, 227, 255, 0.35);
  backdrop-filter: blur(4px); display: grid; place-items: center;
  touch-action: none; -webkit-tap-highlight-color: transparent;
}
.touch-joy-ring {
  position: absolute; inset: 12px; border-radius: 50%;
  border: 1px dashed rgba(127, 227, 255, 0.28);
}
.touch-joy-knob {
  width: 60px; height: 60px; border-radius: 50%; pointer-events: none;
  background: radial-gradient(circle at 38% 34%, #c7f2ff, #49a6cf);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.45), 0 0 0 3px rgba(255, 255, 255, 0.12) inset;
  will-change: transform;
}

.touch-right { display: flex; align-items: center; gap: 18px; }
.touch-zooms { display: flex; flex-direction: column; gap: 12px; }

.touch-shutter {
  width: 80px; height: 80px; border-radius: 50%; border: none; padding: 0;
  background: rgba(255, 255, 255, 0.14); backdrop-filter: blur(6px);
  display: grid; place-items: center; cursor: pointer;
  touch-action: manipulation; -webkit-tap-highlight-color: transparent;
  transition: transform 0.1s ease;
}
.touch-shutter:active { transform: scale(0.9); }
.touch-shutter-ring {
  width: 62px; height: 62px; border-radius: 50%; background: #fff;
  box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.35) inset, 0 4px 16px rgba(0, 0, 0, 0.45);
}

.touch-zoom {
  width: 54px; height: 54px; border-radius: 50%;
  border: 1px solid rgba(127, 227, 255, 0.5); background: rgba(8, 22, 31, 0.55);
  backdrop-filter: blur(6px); color: #cdeffb;
  font-size: 30px; font-weight: 600; line-height: 1; cursor: pointer;
  display: grid; place-items: center;
  touch-action: manipulation; -webkit-tap-highlight-color: transparent;
  transition: transform 0.1s ease, background 0.15s ease;
}
.touch-zoom:active { transform: scale(0.9); background: rgba(127, 227, 255, 0.25); }

/* AR mode: the device pose is the camera, so the joystick is hidden — only the
   shutter (and zoom) remain. */
body.ar-mode .touch-joy { display: none; }
body.ar-mode .touch-controls { justify-content: flex-end; }

/* ---------- Pause ---------- */
.pause-overlay {
  position: fixed; inset: 0; z-index: 45; display: flex;
  align-items: center; justify-content: center;
  background: radial-gradient(60% 50% at 50% 50%, rgba(3,8,14,0.55), rgba(3,8,14,0.78));
  backdrop-filter: blur(3px); pointer-events: auto;
}
.pause-panel {
  text-align: center; padding: 34px 44px; border-radius: 20px;
  background: rgba(8, 15, 24, 0.72); border: 1px solid rgba(127, 227, 255, 0.16);
  box-shadow: 0 24px 70px rgba(0,0,0,0.55);
  font-family: var(--font);
}
.pause-rec {
  display: inline-flex; align-items: center; gap: 9px;
  font-family: ui-monospace, Consolas, monospace; letter-spacing: 3px; font-weight: 700;
  color: #ff8088; font-size: 14px;
}
.pause-title {
  font-size: 13px; letter-spacing: 6px; text-transform: uppercase;
  color: var(--accent-2); opacity: 0.8; margin: 8px 0 26px;
}
.pause-buttons { display: flex; flex-direction: column; align-items: center; gap: 12px; }
.pause-buttons .vr-btn { color: var(--accent); border-color: rgba(127,227,255,0.4);
  background: rgba(127,227,255,0.08); min-width: 200px; }
.pause-hint { margin-top: 22px; font-family: ui-monospace, Consolas, monospace;
  font-size: 11px; letter-spacing: 2px; opacity: 0.45; }
