/* Find & Glow — mobile-first portrait HO */
:root {
  --bg: #0c0e14;
  --bg-elev: #141824;
  --text: #f2f4f8;
  --muted: #9aa3b5;
  --accent: #a78bfa;
  --accent-2: #67e8f9;
  --gold: #fbbf24;
  --success: #6ee7b7;
  --danger: #fb7185;
  --glass: rgba(20, 24, 36, 0.62);
  --glass-border: rgba(255, 255, 255, 0.12);
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  --dock-h: clamp(118px, 22vh, 160px);
  --radius: 18px;
  --font: "Inter", system-ui, sans-serif;
  --font-body: "IBM Plex Sans", system-ui, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
html, body {
  margin: 0;
  height: 100%;
  height: 100dvh;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}

.aurora {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background:
    radial-gradient(ellipse 80% 50% at 20% 10%, rgba(167, 139, 250, 0.28), transparent 55%),
    radial-gradient(ellipse 70% 45% at 90% 20%, rgba(103, 232, 249, 0.18), transparent 50%),
    radial-gradient(ellipse 60% 40% at 50% 90%, rgba(251, 191, 36, 0.1), transparent 55%),
    var(--bg);
}

.screen {
  position: fixed;
  inset: 0;
  z-index: 1;
  display: none;
  flex-direction: column;
  padding:
    calc(12px + var(--safe-t))
    calc(16px + var(--safe-r))
    calc(16px + var(--safe-b))
    calc(16px + var(--safe-l));
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}
.screen.active { display: flex; }

.glass {
  background: var(--glass);
  backdrop-filter: blur(18px) saturate(140%);
  -webkit-backdrop-filter: blur(18px) saturate(140%);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
}

.eyebrow {
  margin: 0;
  font-size: 0.72rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--accent-2);
  font-family: var(--font);
  font-weight: 600;
}
.logo {
  margin: 0.35rem 0 0.5rem;
  font-family: var(--font);
  font-weight: 800;
  font-size: clamp(2.2rem, 9vw, 3rem);
  letter-spacing: -0.03em;
  background: linear-gradient(135deg, #fff 20%, var(--accent) 55%, var(--accent-2));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.tagline {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
  max-width: 28ch;
  font-size: 0.98rem;
}
.muted { color: var(--muted); }

/* HOME */
#screen-home {
  justify-content: space-between;
  max-width: 430px;
  margin: 0 auto;
  width: 100%;
}
.home-hero { padding: 12vh 4px 1.5rem; }
.home-panel {
  padding: 1.15rem;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}
.home-stats {
  display: flex;
  gap: 1.25rem;
  margin-bottom: 0.35rem;
}
.home-stats strong {
  display: block;
  font-family: var(--font);
  font-size: 1.35rem;
  margin-top: 0.15rem;
}

.btn {
  appearance: none;
  border: none;
  border-radius: 999px;
  padding: 0.9rem 1.25rem;
  font-family: var(--font);
  font-weight: 600;
  font-size: 1rem;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.2s ease, background 0.2s;
  min-height: 48px;
}
.btn:active { transform: scale(0.97); }
.btn.primary {
  background: linear-gradient(135deg, #8b5cf6, #6366f1 45%, #22d3ee);
  color: #0b0d14;
  box-shadow: 0 8px 28px rgba(99, 102, 241, 0.4);
}
.btn.ghost {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  border: 1px solid var(--glass-border);
}
.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.92rem;
  color: var(--muted);
  padding: 0.25rem 0.2rem;
  gap: 1rem;
}
.toggle-row input {
  width: 44px;
  height: 26px;
  accent-color: var(--accent);
}

/* LEVELS */
.screen-head {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1rem;
}
.screen-head h2 {
  margin: 0;
  font-family: var(--font);
  font-size: 1.2rem;
}
.spacer { flex: 1; }
.icon-btn {
  width: 44px;
  height: 44px;
  min-width: 44px;
  border-radius: 999px;
  border: 1px solid var(--glass-border);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  font-size: 1rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  gap: 0.2rem;
  padding: 0 0.55rem;
}
.level-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  max-width: 430px;
  width: 100%;
  margin: 0 auto;
  padding-bottom: 2rem;
}
.level-card {
  position: relative;
  border: 1px solid var(--glass-border);
  border-radius: 16px;
  overflow: hidden;
  background: var(--bg-elev);
  text-align: left;
  color: inherit;
  padding: 0;
  cursor: pointer;
  min-height: 140px;
  font-family: inherit;
}
.level-card:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.level-card img {
  width: 100%;
  height: 88px;
  object-fit: cover;
  display: block;
}
.level-card .info {
  padding: 0.65rem 0.75rem 0.8rem;
}
.level-card .info strong {
  display: block;
  font-family: var(--font);
  font-size: 0.95rem;
}
.level-card .info span {
  font-size: 0.75rem;
  color: var(--muted);
}
.level-card .stars {
  color: var(--gold);
  font-size: 0.85rem;
  letter-spacing: 0.05em;
}
.level-card .lock {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(8, 10, 16, 0.55);
  font-size: 1.4rem;
}

/* GAME */
#screen-game {
  padding: 0;
  overflow: hidden;
}
.game-shell {
  display: flex;
  flex-direction: column;
  height: 100%;
  height: 100dvh;
  width: 100%;
  max-width: 520px;
  margin: 0 auto;
  position: relative;
}
.hud-top {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding:
    calc(10px + var(--safe-t))
    calc(10px + var(--safe-r))
    8px
    calc(10px + var(--safe-l));
  pointer-events: none;
}
.hud-top > * { pointer-events: auto; }
.glass-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 0 0.75rem;
  border-radius: 999px;
  background: rgba(12, 14, 20, 0.55);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--glass-border);
  color: var(--text);
  font-family: var(--font);
  font-weight: 600;
  font-size: 0.85rem;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
}
.hud-timer { font-variant-numeric: tabular-nums; color: var(--accent-2); }

.scene-viewport {
  flex: 1;
  position: relative;
  overflow: hidden;
  background: #05060a;
  touch-action: none;
  cursor: grab;
  margin-bottom: var(--dock-h);
}
.scene-viewport.dragging { cursor: grabbing; }
.scene-stage {
  position: absolute;
  inset: 0;
  transform-origin: 0 0;
  will-change: transform;
}
.scene-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  display: block;
  pointer-events: none;
  user-select: none;
}
.hotspots { position: absolute; inset: 0; }
/* Invisible generous tap targets — objects are baked into the scene image */
.hotspot {
  position: absolute;
  width: 44px;
  height: 44px;
  margin-left: -22px;
  margin-top: -22px;
  border: none;
  background: transparent;
  padding: 0;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2;
  -webkit-tap-highlight-color: transparent;
}
.hotspot .hit {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: transparent;
  border: 2px solid transparent;
  box-shadow: none;
  opacity: 0;
  transition: opacity 0.25s ease, box-shadow 0.25s ease, border-color 0.25s ease, transform 0.25s ease;
  pointer-events: none;
}
/* Optional ultra-subtle idle — nearly invisible */
.hotspot:not(.found):not(.hinting) .hit {
  opacity: 0.06;
  border-color: rgba(255, 255, 255, 0.25);
}
.hotspot.found {
  pointer-events: none;
}
.hotspot.found .hit {
  opacity: 0;
  transform: scale(1.4);
}
/* Hint: pulse outline only (no emoji sticker) */
.hotspot.hinting .hit {
  opacity: 1;
  border-color: var(--gold);
  box-shadow:
    0 0 0 3px rgba(251, 191, 36, 0.28),
    0 0 18px rgba(251, 191, 36, 0.55);
  animation: hint-pulse 1.1s ease-in-out infinite;
}
@keyframes hint-pulse {
  0%, 100% { transform: scale(1); opacity: 0.85; }
  50% { transform: scale(1.18); opacity: 1; }
}

.fx-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 5;
  overflow: hidden;
}
.sparkle {
  position: absolute;
  width: 10px;
  height: 10px;
  margin: -5px 0 0 -5px;
  border-radius: 50%;
  background: radial-gradient(circle, #fff, var(--accent-2) 40%, transparent 70%);
  animation: sparkle-fly 0.7s ease-out forwards;
}
@keyframes sparkle-fly {
  0% { opacity: 1; transform: translate(0, 0) scale(1); }
  100% { opacity: 0; transform: translate(var(--dx), var(--dy)) scale(0.2); }
}
.find-ring {
  position: absolute;
  width: 56px;
  height: 56px;
  margin: -28px 0 0 -28px;
  border-radius: 50%;
  border: 2px solid var(--success);
  box-shadow: 0 0 20px rgba(110, 231, 183, 0.6);
  animation: ring-pop 0.55s ease-out forwards;
}
@keyframes ring-pop {
  0% { opacity: 1; transform: scale(0.4); }
  100% { opacity: 0; transform: scale(1.8); }
}

.item-dock {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 25;
  height: var(--dock-h);
  padding:
    0.55rem 0.65rem
    calc(0.55rem + var(--safe-b));
  border-radius: 20px 20px 0 0;
  border-bottom: none;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}
.item-dock-meta {
  display: flex;
  justify-content: space-between;
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  font-family: var(--font);
  font-weight: 600;
  padding: 0 0.25rem;
}
.item-row {
  display: flex;
  gap: 0.5rem;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 0.15rem 0.1rem 0.35rem;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.item-row::-webkit-scrollbar { display: none; }
.item-chip {
  flex: 0 0 auto;
  scroll-snap-align: start;
  width: 72px;
  min-height: 68px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.2rem;
  padding: 0.35rem;
  transition: background 0.25s, border-color 0.25s, opacity 0.3s;
}
.item-chip .emoji { font-size: 1.35rem; line-height: 1; }
.item-chip .label {
  font-size: 0.62rem;
  text-align: center;
  color: var(--muted);
  line-height: 1.15;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.item-chip.found {
  background: rgba(110, 231, 183, 0.12);
  border-color: rgba(110, 231, 183, 0.35);
  opacity: 0.55;
}
.item-chip.found .emoji {
  filter: grayscale(0.3);
  position: relative;
}
.item-chip.found::after {
  content: "✓";
  position: absolute;
  font-size: 0.9rem;
  color: var(--success);
  font-weight: 700;
  margin-top: -28px;
  margin-left: 22px;
}
.item-chip { position: relative; }

/* RESULTS */
#screen-results {
  align-items: center;
  justify-content: center;
}
.results-card {
  width: min(100%, 380px);
  padding: 1.75rem 1.35rem;
  text-align: center;
}
.results-card h2 {
  margin: 0.4rem 0 1rem;
  font-family: var(--font);
  font-size: 1.65rem;
}
.star-row {
  display: flex;
  justify-content: center;
  gap: 0.55rem;
  margin-bottom: 0.85rem;
  font-size: 2rem;
  color: rgba(255, 255, 255, 0.15);
}
.star-row .star.on {
  color: var(--gold);
  text-shadow: 0 0 18px rgba(251, 191, 36, 0.55);
  animation: star-in 0.45s ease backwards;
}
.star-row .star.on:nth-child(2) { animation-delay: 0.12s; }
.star-row .star.on:nth-child(3) { animation-delay: 0.24s; }
@keyframes star-in {
  from { transform: scale(0.4) rotate(-20deg); opacity: 0; }
  to { transform: scale(1) rotate(0); opacity: 1; }
}
.results-meta { color: var(--muted); margin: 0 0 1.25rem; }
.results-actions {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

/* MODAL */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(4, 6, 12, 0.72);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
}
.modal-backdrop[hidden] { display: none !important; }
.modal {
  width: min(100%, 340px);
  padding: 1.5rem;
  text-align: center;
}
.modal h2 {
  margin: 0 0 0.35rem;
  font-family: var(--font);
}
.modal-btns {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: 1.1rem;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* Landscape soft note — still playable portrait-first */
@media (orientation: landscape) and (max-height: 500px) {
  :root { --dock-h: 96px; }
  .item-chip { width: 64px; min-height: 56px; }
  .home-hero { padding-top: 4vh; }
}
