:root {
  color-scheme: dark;
  font-family: Inter, ui-rounded, "SF Pro Rounded", system-ui, sans-serif;
  --blue: #0d41d2;
  --blue-light: #456eff;
  --ink: #091333;
  --glass: rgba(7, 18, 51, 0.62);
}

* { box-sizing: border-box; }
html, body { width: 100%; height: var(--app-height, 100dvh); margin: 0; overflow: hidden; overscroll-behavior: none; }
body { background: #bceea1; color: white; }
button { font: inherit; }

.app { position: fixed; inset: 0; width: 100vw; height: var(--app-height, 100dvh); min-height: 0; overflow: hidden; }
.ar-canvas, .camera, .camera-fallback, .shade { position: absolute; inset: 0; width: 100vw; height: var(--app-height, 100dvh); }
.ar-canvas { position: fixed; z-index: 0; display: none; touch-action: none; border: 0; margin: 0; padding: 0; }
.app.ar-active .ar-canvas { display: block; }
.app.ar-active .camera { display: none; }
.app.ar-active .world { pointer-events: none; }
.camera { object-fit: cover; z-index: 0; }
.camera-fallback {
  z-index: -1;
  background:
    radial-gradient(circle at 70% 25%, rgba(255,255,255,.8), transparent 18%),
    linear-gradient(155deg, #c9f2b0 0%, #7ed2c9 45%, #4571c8 100%);
}
.shade { z-index: 1; pointer-events: none; background: linear-gradient(180deg, rgba(2,9,28,.55), transparent 28%, transparent 68%, rgba(2,9,28,.55)); }
.app.placement-active .shade { opacity: 0; }
.app.placement-active .hud, .app.placement-active .footer { opacity: .18; pointer-events: none; }

.hud, .footer { position: absolute; left: 0; right: 0; z-index: 4; display: flex; align-items: center; justify-content: space-between; padding: max(18px, env(safe-area-inset-top)) 20px 18px; gap: 12px; }
.hud { top: 0; }
.footer { bottom: 0; padding: 18px 20px max(20px, env(safe-area-inset-bottom)); }
.score, .timer-wrap { padding: 10px 14px; border: 1px solid rgba(255,255,255,.22); border-radius: 18px; background: var(--glass); box-shadow: 0 10px 30px rgba(0,0,0,.2); backdrop-filter: blur(14px); font-weight: 750; font-size: clamp(13px, 3.6vw, 17px); }

.world { position: absolute; inset: 90px 0 105px; z-index: 2; }
.target { position: absolute; width: clamp(88px, 25vw, 150px); height: clamp(88px, 25vw, 150px); border: 0; padding: 8px; border-radius: 28px; background: rgba(255,255,255,.86); box-shadow: 0 18px 45px rgba(7,22,72,.35); cursor: pointer; animation: arrive .55s cubic-bezier(.17,.89,.32,1.35), float 3.4s ease-in-out infinite .55s; }
.target img { width: 100%; height: 100%; object-fit: contain; filter: drop-shadow(0 7px 8px rgba(0,0,0,.18)); }
.target.legendary { outline: 4px solid #ffd657; box-shadow: 0 0 35px rgba(255,214,87,.75); }
.target.caught { animation: caught .45s ease forwards; pointer-events: none; }
@keyframes arrive { from { transform: scale(.15) rotate(-12deg); opacity: 0; } }
@keyframes float { 50% { transform: translateY(-12px) rotate(2deg); } }
@keyframes caught { to { transform: scale(0) rotate(18deg); opacity: 0; } }

.button { border: 0; border-radius: 999px; padding: 13px 22px; color: white; background: linear-gradient(135deg, var(--blue), var(--blue-light)); font-weight: 800; cursor: pointer; box-shadow: 0 12px 26px rgba(13,65,210,.3); }
.button:disabled { opacity: .45; cursor: wait; }
.button-secondary { color: var(--blue); background: white; }
.radar { width: 62px; height: 62px; border-radius: 50%; position: relative; border: 1px solid rgba(255,255,255,.5); background: repeating-radial-gradient(circle, rgba(255,255,255,.2) 0 1px, transparent 1px 10px), var(--glass); backdrop-filter: blur(10px); }
.radar-sweep { position: absolute; z-index: 1; left: 29px; top: 5px; width: 3px; height: 26px; transform-origin: 50% 100%; border-radius: 4px; background: linear-gradient(to top, rgba(207,255,114,.08), rgba(207,255,114,.95)); box-shadow: 0 0 7px rgba(207,255,114,.9); animation: radar-sweep 2.4s linear infinite; }
.radar-sweep::before { content: ""; position: absolute; top: -3px; left: -3px; width: 9px; height: 9px; border-radius: 50%; background: #cfff72; box-shadow: 0 0 10px 3px rgba(207,255,114,.8); }
.radar-points { position: absolute; z-index: 2; inset: 0; }
.radar i { position: absolute; width: 7px; height: 7px; background: #cfff72; border-radius: 50%; opacity: .9; box-shadow: 0 0 7px rgba(207,255,114,.9); }
.radar-heading { position: absolute; z-index: 3; inset: 19px; text-align: center; color: white; text-shadow: 0 0 5px rgba(255,255,255,.8); }
@keyframes radar-sweep { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .radar-sweep { animation: none; transform: rotate(45deg); opacity: .45; } }
.footer-actions { display: flex; align-items: center; gap: 10px; }
.recenter { width: 48px; height: 48px; border: 1px solid rgba(255,255,255,.5); border-radius: 50%; color: white; background: var(--glass); backdrop-filter: blur(10px); font-size: 28px; line-height: 1; cursor: pointer; }

.status { position: absolute; z-index: 8; top: 82px; left: 50%; max-width: min(90vw, 520px); transform: translate(-50%, -15px); opacity: 0; padding: 10px 16px; border-radius: 14px; background: rgba(150,30,30,.9); transition: .25s ease; pointer-events: none; }
.status.visible { opacity: 1; transform: translate(-50%, 0); }
.ar-attribution { position: absolute; z-index: 6; right: 14px; bottom: max(4px, env(safe-area-inset-bottom)); color: rgba(255,255,255,.76); font-size: 9px; text-decoration: none; text-shadow: 0 1px 3px rgba(0,0,0,.8); }

.modal { width: min(92vw, 560px); max-height: 90dvh; overflow: auto; border: 0; border-radius: 30px; padding: 0; color: var(--ink); background: rgba(255,255,255,.97); box-shadow: 0 30px 100px rgba(0,0,0,.38); }
.modal::backdrop { background: rgba(3,10,30,.62); backdrop-filter: blur(6px); }
.rules-modal > img { width: 100%; max-height: 260px; object-fit: cover; object-position: center 38%; }
.rules-modal > div, .quiz-modal, .compact-modal { padding: 26px; }
.eyebrow { margin: 0 0 8px; color: var(--blue); font-size: 13px; font-weight: 900; letter-spacing: .08em; text-transform: uppercase; }
h1, h2, h3 { margin: 0 0 14px; line-height: 1.08; }
.rules-modal p:not(.eyebrow) { white-space: pre-line; line-height: 1.5; color: #394567; }
.close { position: absolute; top: 14px; right: 14px; width: 36px; height: 36px; border: 0; border-radius: 50%; background: #eef1fa; color: var(--ink); font-size: 24px; cursor: pointer; }
.answers { display: grid; gap: 10px; }
.answer { text-align: left; border: 1px solid #dce2f3; border-radius: 16px; padding: 14px; color: var(--ink); background: #f7f9ff; cursor: pointer; font-weight: 650; }
.answer:hover { border-color: var(--blue-light); }
.answer.correct { background: #dff7d1; border-color: #69b944; }
.answer.wrong { background: #ffe2e2; border-color: #e15d5d; }
.answer:disabled { cursor: default; }
.quiz-result { text-align: center; padding-top: 18px; }
.quiz-result img { width: 88px; height: 88px; }
.hidden { display: none; }
.compact-modal { text-align: center; }
.compact-modal > img { max-width: 190px; }
.actions { display: flex; justify-content: center; gap: 10px; flex-wrap: wrap; }
.placement-modal {
  position: fixed;
  z-index: 7;
  inset: auto 12px max(88px, calc(env(safe-area-inset-bottom) + 72px));
  width: min(calc(100vw - 24px), 560px);
  max-height: none;
  margin: 0 auto;
  overflow: visible;
  padding: 16px;
  text-align: left;
  color: white;
  background: rgba(5,15,43,.76);
  border: 1px solid rgba(255,255,255,.28);
  border-radius: 22px;
  box-shadow: 0 14px 40px rgba(0,0,0,.28);
  backdrop-filter: blur(10px);
}
.placement-modal::backdrop { background: transparent; backdrop-filter: none; }
.placement-modal h2 { margin-bottom: 7px; font-size: 20px; }
.placement-modal .eyebrow { color: #cfff72; }
.placement-modal p:not(.eyebrow) { margin: 0 0 13px; color: rgba(255,255,255,.9); line-height: 1.35; font-size: 14px; }
.placement-modal .actions { justify-content: stretch; flex-wrap: nowrap; }
.placement-modal .button { flex: 1 1 0; min-width: 0; padding: 11px 12px; font-size: 13px; }
.placement-icon {
  position: fixed;
  z-index: 5;
  left: 50%;
  top: 56%;
  width: 78px;
  height: 78px;
  margin: -39px 0 0 -39px;
  border: 2px solid rgba(255,255,255,.82);
  border-radius: 50%;
  display: none;
  place-items: center;
  pointer-events: none;
  filter: drop-shadow(0 2px 6px rgba(0,0,0,.75));
  animation: scan 1.8s ease-in-out infinite;
}
.app.placement-active .placement-icon { display: grid; }
.placement-icon::before, .placement-icon::after { content: ""; position: absolute; background: rgba(255,255,255,.9); }
.placement-icon::before { width: 18px; height: 2px; }
.placement-icon::after { width: 2px; height: 18px; }
.placement-icon span { display: block; width: 48px; height: 18px; border: 3px solid white; border-radius: 50%; box-shadow: 0 0 14px rgba(255,255,255,.55); }
.app.surface-ready .placement-icon { border-color: #cfff72; filter: drop-shadow(0 0 9px rgba(207,255,114,.9)); animation: ready-pulse 1s ease-in-out infinite; }
.app.surface-ready .placement-icon::before, .app.surface-ready .placement-icon::after { background: #cfff72; }
.app.surface-ready .placement-icon span { border-color: #cfff72; box-shadow: 0 0 18px rgba(207,255,114,.9); }
@keyframes scan { 50% { transform: scale(.92); opacity: .72; } }
@keyframes ready-pulse { 50% { transform: scale(1.08); } }

@media (max-height: 650px) {
  .placement-modal { bottom: max(70px, calc(env(safe-area-inset-bottom) + 58px)); padding: 13px; }
  .placement-modal .eyebrow { display: none; }
}

@media (min-width: 760px) {
  .hud, .footer { padding-left: 36px; padding-right: 36px; }
  .target { width: 142px; height: 142px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
