:root {
  --bg: #05080c;
  --ink: #e8f3f7;
  --aqua: #8fe9ff;
  --aqua-deep: #3fb9ff;
  --on: #46e08a;
  --off: #ff5d6c;
  --panel: rgba(10, 16, 22, 0.72);
  --hairline: rgba(143, 233, 255, 0.18);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background:
    radial-gradient(1200px 700px at 50% -10%, #0c1622 0%, var(--bg) 60%) fixed,
    var(--bg);
  color: var(--ink);
  font: 400 14px/1.4 "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

#app {
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 18px;
}

/* ---------- stage ---------- */
.stage {
  position: relative;
  width: min(100%, calc((100vh - 120px) * 16 / 9));
  aspect-ratio: 16 / 9;
  border-radius: 16px;
  overflow: hidden;
  background: #000;
  box-shadow:
    0 30px 90px -30px rgba(0, 0, 0, 0.9),
    0 0 0 1px rgba(143, 233, 255, 0.08),
    0 0 90px -40px rgba(63, 185, 255, 0.5);
}
.stage::after { /* subtle vignette so glows read */
  content: "";
  position: absolute; inset: 0;
  pointer-events: none;
  box-shadow: inset 0 0 160px -40px rgba(0,0,0,0.8);
  border-radius: inherit;
}
#vid {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
}
#overlay {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
}

/* ---------- TAG (config) mode ---------- */
.mode-config #overlay .tag { cursor: pointer; }
.mode-config #overlay .tag .shape {
  fill-opacity: 0.22;
  stroke-width: 2.5;
  transition: fill-opacity 0.16s ease;
}
.mode-config #overlay .tag.on  .shape { fill: var(--on);  stroke: var(--on); }
.mode-config #overlay .tag.off .shape { fill: var(--off); stroke: var(--off); fill-opacity: 0.10; stroke-dasharray: 7 7; }
.mode-config #overlay .tag:hover .shape { fill-opacity: 0.42; }
.mode-config #glowLayer, .mode-config #bloomLayer { display: none; }

.config-hint {
  position: absolute; left: 14px; bottom: 14px;
  background: var(--panel);
  border: 1px solid var(--hairline);
  border-radius: 10px;
  padding: 8px 12px;
  font-size: 12px;
  letter-spacing: 0.02em;
  backdrop-filter: blur(8px);
  display: none;
}
.mode-config .config-hint { display: block; }
.chip { padding: 1px 7px; border-radius: 6px; font-weight: 600; font-size: 11px; }
.chip-on  { background: rgba(70,224,138,0.18); color: var(--on); }
.chip-off { background: rgba(255,93,108,0.18); color: var(--off); }

/* ---------- LIVE mode ---------- */
#hitLayer .btn { transform-box: fill-box; transform-origin: center; will-change: transform; }
.mode-live #hitLayer .hit { cursor: pointer; pointer-events: all; }
.mode-config #hitLayer .live-only { pointer-events: none; }

.hit { fill: #ffffff; fill-opacity: 0; }

.glow {
  fill: url(#glowFill);
  opacity: 0;
  will-change: opacity, transform;
  transform-box: fill-box; transform-origin: center;
  /* the glow does NOT cut off at the mask edge — drop-shadow bleeds outward with falloff */
  filter:
    drop-shadow(0 0 6px rgba(160,240,255,0.85))
    drop-shadow(0 0 18px rgba(95,205,255,0.65))
    drop-shadow(0 0 42px rgba(63,150,255,0.45));
}
.mode-config #hitLayer .btn:not(.tag) { display: none; }

/* click bloom — "a drop in an ocean" */
.bloom { fill: url(#bloomGrad); pointer-events: none; }

/* launch transition flash (luminous wash that hides the video swap) */
.flash {
  position: absolute; inset: 0; z-index: 5;
  pointer-events: none; opacity: 0;
  background: radial-gradient(120% 120% at 28% 78%, #ffffff 0%, #d6f7ff 32%, #6fd8ff 60%, rgba(63,185,255,0) 100%);
}
.restart {
  position: absolute; top: 12px; right: 12px; z-index: 8;
  appearance: none; cursor: pointer;
  background: var(--panel); color: var(--aqua);
  border: 1px solid var(--hairline); border-radius: 8px;
  padding: 7px 12px; font-size: 12px; letter-spacing: 0.04em;
  backdrop-filter: blur(8px);
}
.restart:hover { background: rgba(143,233,255,0.12); }

/* ---------- HUD ---------- */
.hud {
  width: min(100%, calc((100vh - 120px) * 16 / 9));
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px;
  background: var(--panel);
  border: 1px solid var(--hairline);
  border-radius: 12px;
  padding: 8px 12px;
  backdrop-filter: blur(10px);
}
.hud-left, .hud-right { display: flex; align-items: center; gap: 10px; }
.brand { font-weight: 700; letter-spacing: 0.22em; font-size: 12px; color: var(--aqua); }
.mode-badge {
  font-size: 10px; text-transform: uppercase; letter-spacing: 0.12em;
  padding: 2px 8px; border-radius: 999px;
  background: rgba(143,233,255,0.12); color: var(--aqua); border: 1px solid var(--hairline);
}
.count { font-variant-numeric: tabular-nums; font-size: 12px; opacity: 0.8; }
.cfg-tools { display: flex; gap: 6px; }

.btn-primary {
  appearance: none; cursor: pointer;
  background: linear-gradient(180deg, #aef0ff, #4fc6ff);
  color: #042033; font-weight: 700; letter-spacing: 0.02em;
  border: none; border-radius: 9px; padding: 9px 16px;
  box-shadow: 0 6px 24px -8px rgba(79,198,255,0.8);
  transition: transform 0.12s ease, box-shadow 0.12s ease, filter 0.12s ease;
}
.btn-primary:hover { transform: translateY(-1px); filter: brightness(1.06); }
.btn-primary:active { transform: translateY(1px) scale(0.99); }

.btn-ghost {
  appearance: none; cursor: pointer;
  background: transparent; color: var(--ink);
  border: 1px solid var(--hairline); border-radius: 8px;
  padding: 6px 10px; font-size: 11px; letter-spacing: 0.02em;
  transition: background 0.12s ease, border-color 0.12s ease, color 0.12s ease;
}
.btn-ghost:hover { background: rgba(143,233,255,0.10); border-color: var(--aqua); color: var(--aqua); }
.mode-live .cfg-tools { opacity: 0.35; pointer-events: none; }

/* public (non-edit) view: hide the authoring HUD entirely — visitors just get the experience */
#app.public #hud { display: none; }
/* ...and let the stage fill the whole visible viewport (largest 16:9 that fits, no wasted
   HUD reservation, dvh so mobile address-bars don't leave a gap). Keeps every button on-screen. */
#app.public { padding: 0; gap: 0; }
#app.public .stage {
  width: min(100vw, calc(100vh * 16 / 9));
  width: min(100dvw, calc(100dvh * 16 / 9));
  max-width: none;
  border-radius: 0;
  box-shadow: none;
}

/* ---------- full-screen prompt (polite, optional) ---------- */
.fs-prompt {
  position: fixed; inset: 0; z-index: 50;
  display: none;                 /* shown via body.show-fs-prompt (JS, mobile + not fullscreen) */
  align-items: center; justify-content: center;
  padding: 24px;
  background: radial-gradient(900px 600px at 50% 32%, #0b1622, #04070b 72%);
  -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px);
}
body.show-fs-prompt .fs-prompt { display: flex; }
.fs-card { text-align: center; color: var(--ink); max-width: 360px; }
.fs-glyph {
  font-size: 46px; line-height: 1; color: var(--aqua);
  filter: drop-shadow(0 0 22px rgba(143,233,255,0.6));
  animation: fsPulse 2.6s ease-in-out infinite;
}
@keyframes fsPulse { 0%,100% { transform: scale(1); opacity: .9; } 50% { transform: scale(1.12); opacity: 1; } }
.fs-title { margin: 16px 0 4px; font-size: 19px; font-weight: 600; }
.fs-sub { display: block; color: rgba(232,243,247,0.55); margin-bottom: 22px; }
.fs-go {
  appearance: none; cursor: pointer;
  background: linear-gradient(180deg, #aef0ff, #4fc6ff);
  color: #042033; font-weight: 700; letter-spacing: 0.02em; font-size: 15px;
  border: none; border-radius: 11px; padding: 13px 26px;
  box-shadow: 0 8px 30px -8px rgba(79,198,255,0.85);
}
.fs-go:active { transform: scale(0.98); }
.pwa-hint {
  display: none;                 /* shown via body.fs-unsupported (iOS / no Fullscreen API) */
  margin: 4px auto 0; max-width: 320px;
  font-size: 13px; line-height: 1.6; color: rgba(232,243,247,0.8);
  background: var(--panel); border: 1px solid var(--hairline);
  border-radius: 12px; padding: 14px 16px;
}
.pwa-hint b { color: var(--aqua); }
.ios-share { color: var(--aqua); }
body.fs-unsupported .fs-go { display: none; }
body.fs-unsupported .pwa-hint { display: block; }
.fs-skip {
  display: block; margin: 18px auto 0;
  appearance: none; cursor: pointer; background: none; border: none;
  color: rgba(232,243,247,0.5); font-size: 12px; letter-spacing: 0.04em;
  text-decoration: underline; text-underline-offset: 3px;
}
.fs-skip:hover { color: var(--aqua); }
