:root {
  --bg: #0c1524;
  --panel: rgba(10, 16, 32, 0.92);
  --panel-border: rgba(120, 160, 255, 0.2);
  --text: #eef5ff;
  --muted: #9db2d0;
  --accent: #3b2f9b;
  --accent-bright: #4f46e5;
  --primary: #3b82f6;
  --glow: rgba(79, 70, 229, 0.4);
  --radius: 16px;
  --shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
  --side-w: min(360px, 92vw);
  --qubits-purple: #3b2f9b;
  font-family: "Nunito", system-ui, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  height: 100dvh; /* iPad Safari dynamic viewport */
  overflow: hidden;
  /* Sky / ocean tones from the aerial plate (no hard black frame) */
  background: #5a9ec4;
  color: var(--text);
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
}

#app, .image-app {
  position: relative;
  width: 100%;
  height: 100%;
  height: 100dvh;
  background: transparent;
}

a { color: #a5b4fc; text-decoration: none; }
a:hover { text-decoration: underline; color: #c7d2fe; }

/* ---- Viewport / pan-zoom stage ---- */
.viewport {
  position: absolute;
  inset: 0;
  overflow: hidden;
  touch-action: none;
  cursor: grab;
  background:
    radial-gradient(ellipse 90% 70% at 45% 40%, #8ec8e8 0%, #4a96c0 42%, #2a6f9a 78%, #1e5a7a 100%);
  z-index: 1;
  user-select: none;
}

.viewport.dragging { cursor: grabbing; }

/* Full-viewport living backdrop: same world, soft and extended */
.viewport-bleed {
  position: absolute;
  inset: -8%;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
}

.bleed-photo {
  position: absolute;
  inset: -12%;
  width: 124%;
  height: 124%;
  object-fit: cover;
  object-position: center 42%;
  filter: blur(42px) saturate(1.2) brightness(1.06);
  transform: scale(1.08);
  transform-origin: center center;
  /* Drift only when zoomed out — paused when .is-zoomed (set by JS) to free GPU */
  animation: bleed-drift 48s ease-in-out infinite alternate;
}

.viewport.is-zoomed .bleed-photo {
  animation-play-state: paused;
}

/* Reduce backdrop cost while closely inspecting the map */
.viewport.is-zoomed .viewport-bleed {
  opacity: 0.85;
}

.bleed-tint {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 70% 55% at 48% 42%, transparent 0%, rgba(40, 100, 140, 0.12) 55%, rgba(20, 60, 90, 0.28) 100%),
    linear-gradient(180deg, rgba(140, 190, 230, 0.22) 0%, transparent 38%, rgba(20, 90, 130, 0.18) 100%);
  pointer-events: none;
}

@keyframes bleed-drift {
  from { transform: scale(1.06) translate(-1.2%, -0.6%); }
  to   { transform: scale(1.12) translate(1.0%, 0.8%); }
}

.stage {
  position: absolute;
  top: 0;
  left: 0;
  transform-origin: 0 0;
  /* No CSS filter here — filter+scale causes tiled “square” shimmer when zoomed */
  will-change: transform;
  line-height: 0; /* tight wrap around image */
  z-index: 1;
  /* Promote a clean compositor layer without filter thrashing */
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}

.photo {
  display: block;
  width: auto;
  height: auto;
  max-width: none;
  pointer-events: none;
  border-radius: 3px;
  /* Shadow on the image itself (not a filtered parent) — stable under zoom */
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.12),
    0 12px 40px rgba(15, 50, 80, 0.28);
  /* Prefer smooth resampling; avoid browser “crisp tile” jumps mid-zoom */
  image-rendering: auto;
  -ms-interpolation-mode: bicubic;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}

.hotspots {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

/* Hotspot markers — positioned % of image */
.hotspot {
  position: absolute;
  transform: translate(-50%, -50%);
  border: none;
  background: transparent;
  padding: 0;
  cursor: pointer;
  pointer-events: auto;
  z-index: 2;
  font-family: inherit;
  --c: #818cf8;
  /* Large enough hit box even when zoomed out */
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  touch-action: manipulation;
}

.hotspot:hover,
.hotspot:focus-visible,
.hotspot.active,
.hotspot.quiz-active {
  z-index: 40 !important;
}

.hotspot-hit {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  /* invisible but receives clicks */
  background: transparent;
}

.hotspot.filtered-out { display: none !important; }

.hotspots.hide-hotspots .hotspot-dot,
.hotspots.hide-hotspots .hotspot-pulse {
  opacity: 0;
  pointer-events: none;
}

.hotspots.hide-labels .hotspot-label { display: none !important; }

/* Study mode: every landform name always visible */
.hotspots.show-all-labels .hotspot-label {
  opacity: 1 !important;
  display: block;
}

/* Quiz: hide all labels except ones already solved */
.hotspots.quiz-labels .hotspot-label {
  display: none !important;
  opacity: 0 !important;
}
.hotspots.quiz-labels .hotspot.revealed .hotspot-label,
.hotspots.quiz-labels .hotspot.correct .hotspot-label {
  display: block !important;
  opacity: 1 !important;
}

.hotspot-dot {
  display: block;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--c);
  border: 2.5px solid #fff;
  box-shadow:
    0 0 0 2px color-mix(in srgb, var(--c) 55%, transparent),
    0 4px 14px rgba(0, 0, 0, 0.45);
  position: relative;
  z-index: 2;
  transition: transform 0.15s, box-shadow 0.15s;
  pointer-events: none;
}

.hotspot-pulse {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 18px;
  height: 18px;
  margin: -9px 0 0 -9px;
  border-radius: 50%;
  background: var(--c);
  opacity: 0.45;
  animation: pulse 2.2s ease-out infinite;
  z-index: 1;
  pointer-events: none;
}

/* When zoomed in, stop continuous pulse on every marker (less GPU thrash) */
.viewport.is-zoomed .hotspot:not(.correct):not(.wrong):not(.quiz-active):not(.active) .hotspot-pulse {
  animation: none;
  opacity: 0.28;
}

.hotspot:hover .hotspot-dot,
.hotspot.active .hotspot-dot,
.hotspot.quiz-active .hotspot-dot {
  transform: scale(1.35);
  box-shadow:
    0 0 0 3px color-mix(in srgb, var(--c) 70%, transparent),
    0 6px 20px rgba(0, 0, 0, 0.5);
}

.hotspot.active .hotspot-pulse,
.hotspot.quiz-active .hotspot-pulse {
  animation-duration: 1.2s;
  opacity: 0.55;
}

/* Solved guess — gold/amber (not green: avoids clash with forest markers & “ok” UI) */
.hotspot.correct {
  --c: #f59e0b !important;
  z-index: 5;
}
.hotspot.correct .hotspot-dot {
  background: #f59e0b;
  border-color: #fffbeb;
  box-shadow:
    0 0 0 4px rgba(245, 158, 11, 0.55),
    0 0 28px 8px rgba(251, 191, 36, 0.7),
    0 4px 14px rgba(0, 0, 0, 0.35);
  transform: scale(1.4);
  animation: glow-ok 1.4s ease-out 1;
}
.hotspot.correct .hotspot-pulse {
  background: #fbbf24;
  opacity: 0.55;
  animation: pulse-ok 1.6s ease-out infinite;
}
.hotspot.correct .hotspot-label {
  border-color: rgba(251, 191, 36, 0.75);
  background: rgba(50, 30, 5, 0.92);
  color: #fef3c7;
}

/* Wrong guess — red glow */
.hotspot.wrong {
  --c: #ef4444 !important;
  z-index: 5;
}
.hotspot.wrong .hotspot-dot {
  background: #ef4444;
  border-color: #fef2f2;
  box-shadow:
    0 0 0 4px rgba(239, 68, 68, 0.55),
    0 0 28px 8px rgba(239, 68, 68, 0.7),
    0 4px 14px rgba(0, 0, 0, 0.35);
  transform: scale(1.45);
  animation: glow-bad 0.45s ease-out 2;
}
.hotspot.wrong .hotspot-pulse {
  background: #ef4444;
  opacity: 0.6;
  animation: pulse-bad 0.7s ease-out infinite;
}

@keyframes glow-ok {
  0% { box-shadow: 0 0 0 0 rgba(251, 191, 36, 0.95), 0 0 0 0 rgba(245, 158, 11, 0.5); }
  100% {
    box-shadow:
      0 0 0 4px rgba(245, 158, 11, 0.55),
      0 0 28px 8px rgba(251, 191, 36, 0.7),
      0 4px 14px rgba(0, 0, 0, 0.35);
  }
}
@keyframes glow-bad {
  0%, 100% { transform: scale(1.45) translateX(0); }
  25% { transform: scale(1.45) translateX(-3px); }
  75% { transform: scale(1.45) translateX(3px); }
}
@keyframes pulse-ok {
  0% { transform: scale(1); opacity: 0.55; }
  70% { transform: scale(2.8); opacity: 0; }
  100% { transform: scale(2.8); opacity: 0; }
}
@keyframes pulse-bad {
  0% { transform: scale(1); opacity: 0.65; }
  70% { transform: scale(2.4); opacity: 0; }
  100% { transform: scale(2.4); opacity: 0; }
}

.hotspot-label {
  position: absolute;
  left: 50%;
  top: calc(50% + 16px);
  transform: translateX(-50%);
  white-space: nowrap;
  font-family: "Space Grotesk", sans-serif;
  font-size: 11px;
  font-weight: 700;
  color: #fff;
  background: rgba(8, 12, 24, 0.88);
  border: 1px solid color-mix(in srgb, var(--c) 65%, transparent);
  border-radius: 999px;
  padding: 3px 9px 4px;
  backdrop-filter: blur(8px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.35);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s;
  z-index: 3;
}

/* Hover / selection still emphasize when not in study mode */
.hotspot:hover .hotspot-label,
.hotspot.active .hotspot-label {
  opacity: 1;
}

@keyframes pulse {
  0% { transform: scale(1); opacity: 0.5; }
  70% { transform: scale(2.6); opacity: 0; }
  100% { transform: scale(2.6); opacity: 0; }
}

/* ---- Top bar ---- */
.top-bar {
  position: absolute;
  top: 14px;
  left: 14px;
  right: calc(var(--side-w) + 28px);
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  pointer-events: none;
  z-index: 6;
}

.brand {
  display: flex;
  gap: 14px;
  align-items: center;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  backdrop-filter: blur(14px);
  padding: 10px 16px 10px 12px;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  pointer-events: auto;
  max-width: 560px;
}

.brand-logo-link {
  display: grid;
  place-items: center;
  background: #fff;
  border-radius: 12px;
  padding: 6px 10px;
  flex-shrink: 0;
  box-shadow: 0 0 0 1px rgba(59, 47, 155, 0.15), 0 4px 16px rgba(59, 47, 155, 0.2);
  transition: transform 0.15s, box-shadow 0.15s;
}

.brand-logo-link:hover {
  transform: translateY(-1px);
  box-shadow: 0 0 0 1px rgba(59, 47, 155, 0.25), 0 6px 20px rgba(59, 47, 155, 0.3);
  text-decoration: none;
}

.brand-logo {
  display: block;
  height: 36px;
  width: auto;
  object-fit: contain;
}

.brand-text h1 {
  margin: 0;
  font-family: "Space Grotesk", sans-serif;
  font-size: 1.08rem;
  letter-spacing: 0.01em;
  color: #fff;
}

.brand-text p {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.35;
}

.top-tools {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
  pointer-events: auto;
}

.zoom-readout,
.load-status {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  backdrop-filter: blur(12px);
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 0.8rem;
  color: var(--muted);
  white-space: nowrap;
}

.load-status.ready {
  color: #86efac;
  border-color: rgba(62, 207, 142, 0.35);
}

.zoom-readout {
  font-family: "Space Grotesk", sans-serif;
  font-weight: 700;
  color: #c7d2fe;
  min-width: 56px;
  text-align: center;
}

/* ---- Zoom dock ---- */
.zoom-dock {
  position: absolute;
  left: 14px;
  bottom: 56px;
  z-index: 6;
  display: flex;
  flex-direction: column;
  gap: 6px;
  pointer-events: auto;
}

.dock-btn {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  border: 1px solid var(--panel-border);
  background: var(--panel);
  color: var(--text);
  font-size: 1.25rem;
  font-weight: 700;
  cursor: pointer;
  backdrop-filter: blur(12px);
  box-shadow: var(--shadow);
  font-family: inherit;
  transition: background 0.15s, transform 0.12s;
}

.dock-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  transform: translateY(-1px);
}

.dock-wide { font-size: 1.05rem; }

/* ---- Side panel ---- */
.side-panel {
  position: absolute;
  top: 14px;
  right: 14px;
  bottom: 14px;
  width: var(--side-w);
  overflow-y: auto;
  z-index: 6;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  backdrop-filter: blur(16px);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  scrollbar-width: thin;
  scrollbar-color: rgba(120, 160, 255, 0.3) transparent;
}

.panel-block h2 {
  margin: 0 0 8px;
  font-family: "Space Grotesk", sans-serif;
  font-size: 1.12rem;
}

.panel-block h3 {
  margin: 0 0 8px;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.lede {
  margin: 0;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.45;
}

.lede strong { color: #c7d2fe; }

.detail-card {
  padding: 14px;
  border-radius: 14px;
  border: 1px solid rgba(79, 70, 229, 0.45);
  background: linear-gradient(160deg, rgba(59, 47, 155, 0.35), rgba(16, 24, 48, 0.7));
  animation: fadeIn 0.28s ease;
}

.detail-card[hidden],
.detail-placeholder[hidden] {
  display: none !important;
}

.detail-header {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  margin-bottom: 10px;
}

.detail-icon {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  font-size: 1.25rem;
  background: rgba(255, 255, 255, 0.1);
  flex-shrink: 0;
}

.detail-cat {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 800;
  margin-bottom: 2px;
}

.detail-card h3 {
  margin: 0;
  font-family: "Space Grotesk", sans-serif;
  font-size: 1.15rem;
  text-transform: none;
  letter-spacing: 0;
  color: #fff;
}

.detail-summary {
  margin: 0 0 8px;
  font-size: 0.9rem;
  font-weight: 700;
  color: #e0e7ff;
  line-height: 1.4;
}

.detail-body {
  margin: 0 0 12px;
  font-size: 0.84rem;
  color: var(--muted);
  line-height: 1.5;
}

.facts-heading {
  margin: 0 0 6px;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #a5b4fc;
}

.detail-facts {
  margin: 0;
  padding-left: 1.1rem;
  font-size: 0.82rem;
  color: var(--muted);
  line-height: 1.45;
}

.detail-facts li { margin-bottom: 4px; }

.detail-placeholder {
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px dashed rgba(120, 190, 255, 0.25);
  color: var(--muted);
  font-size: 0.85rem;
  line-height: 1.4;
  background: rgba(255, 255, 255, 0.03);
}

/* ---- Quiz panel ---- */
.quiz-card {
  padding: 14px;
  border-radius: 14px;
  border: 1px solid rgba(251, 191, 36, 0.45);
  background: linear-gradient(160deg, rgba(80, 55, 10, 0.4), rgba(16, 24, 48, 0.75));
  animation: fadeIn 0.28s ease;
}

.quiz-card[hidden] { display: none !important; }

.quiz-header {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 8px;
}

.quiz-badge {
  align-self: flex-start;
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #fde68a;
  background: rgba(251, 191, 36, 0.15);
  border: 1px solid rgba(251, 191, 36, 0.35);
  border-radius: 999px;
  padding: 3px 10px;
}

.quiz-header h3 {
  margin: 0;
  font-family: "Space Grotesk", sans-serif;
  font-size: 1.05rem;
  color: #fff;
  text-transform: none;
  letter-spacing: 0;
}

.quiz-hint {
  margin: 0 0 10px;
  font-size: 0.84rem;
  color: var(--muted);
  line-height: 1.4;
}

.quiz-form {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.quiz-input { flex: 1 1 140px; }

.quiz-check {
  flex: 0 0 auto;
  min-width: 88px;
}

.quiz-feedback {
  margin: 10px 0 0;
  font-size: 0.9rem;
  font-weight: 800;
  line-height: 1.35;
}

.quiz-feedback.ok { color: #86efac; }
.quiz-feedback.bad { color: #fca5a5; }

.quiz-score-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 0.82rem;
  font-weight: 700;
  color: #fde68a;
}

.btn.ghost {
  background: transparent;
  border-color: var(--panel-border);
  font-size: 0.78rem;
  padding: 6px 10px;
  color: var(--muted);
}

.btn.ghost:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.06);
}

.search {
  width: 100%;
  border: 1px solid var(--panel-border);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  border-radius: 12px;
  padding: 10px 12px;
  font-family: inherit;
  font-size: 0.9rem;
  outline: none;
  transition: border-color 0.15s, background 0.15s;
}

.search::placeholder { color: rgba(157, 178, 208, 0.7); }
.search:focus {
  border-color: rgba(79, 70, 229, 0.6);
  background: rgba(59, 47, 155, 0.15);
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chip {
  border: 1px solid var(--panel-border);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  border-radius: 999px;
  padding: 6px 11px;
  font-size: 0.74rem;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s, border-color 0.15s;
}

.chip:hover { background: rgba(255, 255, 255, 0.08); }
.chip.active {
  background: rgba(59, 47, 155, 0.45);
  border-color: rgba(129, 140, 248, 0.65);
  color: #e0e7ff;
}

.landform-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 220px;
  overflow-y: auto;
  padding-right: 4px;
  scrollbar-width: thin;
}

.list-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  text-align: left;
  border: 1px solid transparent;
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
  border-radius: 10px;
  padding: 8px 10px;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.12s, border-color 0.12s;
}

.list-item:hover { background: rgba(255, 255, 255, 0.07); }
.list-item.active {
  border-color: rgba(129, 140, 248, 0.5);
  background: rgba(59, 47, 155, 0.35);
}
.list-item[hidden] { display: none !important; }

.list-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.list-text {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}

.list-text strong { font-size: 0.86rem; font-weight: 800; }
.list-text small { font-size: 0.7rem; color: var(--muted); }

.check {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.86rem;
  color: var(--muted);
  margin: 4px 0;
  cursor: pointer;
  user-select: none;
}

.check input { accent-color: var(--accent-bright); }

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.btn {
  border: 1px solid var(--panel-border);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  border-radius: 12px;
  padding: 10px 14px;
  font-weight: 800;
  font-size: 0.84rem;
  cursor: pointer;
  font-family: inherit;
  transition: transform 0.12s, background 0.15s;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.btn:hover {
  background: rgba(255, 255, 255, 0.1);
  transform: translateY(-1px);
  text-decoration: none;
}

.btn.primary {
  background: linear-gradient(135deg, var(--qubits-purple), #6366f1);
  border-color: transparent;
  color: #fff;
}

.panel-footer {
  margin-top: auto;
  padding-top: 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  text-align: center;
}

.footer-logo {
  height: 26px;
  width: auto;
  object-fit: contain;
  background: #fff;
  border-radius: 8px;
  padding: 4px 8px;
  margin-bottom: 8px;
}

.panel-footer p {
  margin: 0 0 4px;
  font-size: 0.75rem;
  color: var(--muted);
  line-height: 1.35;
}

.panel-footer .fine {
  font-size: 0.68rem;
  opacity: 0.7;
}

/* ---- HUD ---- */
.hud-hint {
  position: absolute;
  left: 14px;
  bottom: 14px;
  right: calc(var(--side-w) + 28px);
  z-index: 5;
  pointer-events: none;
  text-align: center;
}

.hud-hint span {
  display: inline-block;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  backdrop-filter: blur(10px);
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 0.76rem;
  color: var(--muted);
  box-shadow: var(--shadow);
}

/* ---- Loading ---- */
.loading-overlay {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  background: rgba(8, 10, 20, 0.82);
  backdrop-filter: blur(10px);
  transition: opacity 0.45s;
}

.loading-overlay.done {
  opacity: 0;
  pointer-events: none;
}

.loader-card {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 20px;
  padding: 28px 36px;
  text-align: center;
  min-width: 300px;
  box-shadow: var(--shadow);
}

.loader-logo {
  height: 44px;
  width: auto;
  object-fit: contain;
  background: #fff;
  border-radius: 10px;
  padding: 6px 12px;
  margin-bottom: 16px;
}

.loader-card h2 {
  margin: 12px 0 4px;
  font-family: "Space Grotesk", sans-serif;
  font-size: 1.1rem;
}

.loader-card p {
  margin: 0 0 14px;
  color: var(--muted);
  font-size: 0.88rem;
}

.spinner {
  width: 36px;
  height: 36px;
  margin: 0 auto;
  border: 3px solid rgba(255, 255, 255, 0.12);
  border-top-color: #818cf8;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.progress-track {
  height: 6px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 999px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 8%;
  background: linear-gradient(90deg, var(--qubits-purple), #818cf8, #38bdf8);
  border-radius: 999px;
  transition: width 0.25s;
}

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ---- Victory celebration ---- */
.celebrate-overlay {
  position: absolute;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(6, 12, 24, 0.55);
  backdrop-filter: blur(8px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.35s ease;
}

.celebrate-overlay[hidden] {
  display: none !important;
}

.celebrate-overlay.visible {
  opacity: 1;
  pointer-events: auto;
}

.celebrate-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 0;
}

.celebrate-card {
  position: relative;
  z-index: 1;
  max-width: 440px;
  width: min(440px, 94vw);
  text-align: center;
  background: linear-gradient(165deg, rgba(30, 27, 75, 0.96), rgba(12, 20, 40, 0.96));
  border: 1px solid rgba(129, 140, 248, 0.45);
  border-radius: 22px;
  padding: 28px 28px 22px;
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.06) inset,
    0 24px 80px rgba(0, 0, 0, 0.55),
    0 0 60px rgba(79, 70, 229, 0.35);
  animation: celebrate-pop 0.55s cubic-bezier(0.22, 1.2, 0.36, 1) both;
}

.celebrate-logo {
  height: 48px;
  width: auto;
  object-fit: contain;
  background: #fff;
  border-radius: 12px;
  padding: 8px 14px;
  margin-bottom: 10px;
  box-shadow: 0 4px 20px rgba(59, 47, 155, 0.25);
}

.celebrate-burst {
  font-size: 2.6rem;
  line-height: 1;
  margin: 4px 0 6px;
  animation: celebrate-bounce 1.1s ease-in-out infinite;
}

.celebrate-kicker {
  margin: 0 0 6px;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: #fde68a;
}

.celebrate-title {
  margin: 0 0 10px;
  font-family: "Space Grotesk", sans-serif;
  font-size: clamp(1.35rem, 3.5vw, 1.75rem);
  color: #fff;
  line-height: 1.2;
  background: linear-gradient(90deg, #86efac, #7dd3fc, #c4b5fd);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.celebrate-body {
  margin: 0 0 14px;
  font-size: 0.92rem;
  color: var(--muted);
  line-height: 1.5;
}

.celebrate-score {
  margin: 0 0 18px;
  display: inline-block;
  font-family: "Space Grotesk", sans-serif;
  font-weight: 700;
  font-size: 0.95rem;
  color: #86efac;
  background: rgba(34, 197, 94, 0.12);
  border: 1px solid rgba(34, 197, 94, 0.35);
  border-radius: 999px;
  padding: 8px 16px;
}

.celebrate-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  margin-bottom: 12px;
}

.celebrate-fine {
  margin: 0;
  font-size: 0.72rem;
  color: var(--muted);
  opacity: 0.8;
}

body.celebrating .hotspot.correct .hotspot-dot {
  animation: celebrate-pulse-dot 1.2s ease-in-out infinite;
}

@keyframes celebrate-pop {
  from { opacity: 0; transform: scale(0.82) translateY(24px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

@keyframes celebrate-bounce {
  0%, 100% { transform: translateY(0) scale(1); }
  50% { transform: translateY(-8px) scale(1.08); }
}

@keyframes celebrate-pulse-dot {
  0%, 100% { transform: scale(1.35); }
  50% { transform: scale(1.55); }
}

/* ---- Tablet (iPad landscape & similar) ---- */
@media (max-width: 1180px) and (min-width: 821px) {
  :root { --side-w: min(320px, 34vw); }

  .top-bar {
    left: max(12px, env(safe-area-inset-left));
    right: calc(var(--side-w) + 20px);
    top: max(12px, env(safe-area-inset-top));
  }

  .side-panel {
    top: max(12px, env(safe-area-inset-top));
    right: max(12px, env(safe-area-inset-right));
    bottom: max(12px, env(safe-area-inset-bottom));
    padding: 14px;
  }

  .brand { max-width: 420px; padding: 8px 12px 8px 10px; }
  .brand-logo { height: 32px; }
  .brand-text h1 { font-size: 1rem; }
  .brand-text p { font-size: 0.75rem; }

  .landform-list { max-height: 180px; }
  .hotspot { width: 48px; height: 48px; }
  .hotspot-dot { width: 20px; height: 20px; }
  .dock-btn { width: 46px; height: 46px; }

  .zoom-dock {
    left: max(12px, env(safe-area-inset-left));
    bottom: max(52px, calc(12px + env(safe-area-inset-bottom)));
  }

  .hud-hint {
    left: max(12px, env(safe-area-inset-left));
    bottom: max(12px, env(safe-area-inset-bottom));
    font-size: 0.72rem;
  }
}

/* ---- Phone / iPad portrait (stacked bottom sheet) ---- */
@media (max-width: 820px) {
  :root { --side-w: 100%; }

  .side-panel {
    top: auto;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    max-height: min(40dvh, 360px);
    border-radius: 18px 18px 0 0;
    padding-bottom: max(16px, env(safe-area-inset-bottom));
    padding-left: max(14px, env(safe-area-inset-left));
    padding-right: max(14px, env(safe-area-inset-right));
  }

  .top-bar {
    right: max(12px, env(safe-area-inset-right));
    left: max(12px, env(safe-area-inset-left));
    top: max(10px, env(safe-area-inset-top));
  }

  .hud-hint { display: none; }
  .brand-text p { display: none; }
  .brand-logo { height: 30px; }
  .landform-list { max-height: 90px; }

  .zoom-dock {
    left: max(12px, env(safe-area-inset-left));
    bottom: calc(min(40dvh, 360px) + 10px);
  }

  .hotspot { width: 48px; height: 48px; }
  .hotspot-dot { width: 20px; height: 20px; }
  .dock-btn {
    width: 48px;
    height: 48px;
    font-size: 1.35rem;
  }

  .celebrate-card {
    max-height: min(85dvh, 640px);
    overflow-y: auto;
    padding: 22px 18px 18px;
  }

  /* Quiz typing: keep submit easy with on-screen keyboard */
  .quiz-form { flex-direction: column; }
  .quiz-check { width: 100%; min-height: 44px; }
  .quiz-input { min-height: 44px; font-size: 16px; /* prevents iOS zoom-on-focus */ }
}

/* Landscape phones / short iPad split views */
@media (max-height: 700px) and (max-width: 1100px) {
  .side-panel {
    max-height: min(42dvh, 280px);
  }
  .zoom-dock {
    bottom: calc(min(42dvh, 280px) + 8px);
  }
  .landform-list { max-height: 70px; }
  .panel-footer { display: none; }
}

@media (max-width: 480px) {
  .brand { padding: 8px 10px; gap: 8px; }
  .brand-text h1 { font-size: 0.92rem; }
  .load-status { display: none; }
  .zoom-readout { display: none; }
  .hotspot-label { font-size: 10px; }
  .top-tools { gap: 4px; }
}

/* Prefer coarse pointers (iPad / touch laptops): roomier hits */
@media (pointer: coarse) {
  .chip { padding: 8px 12px; min-height: 36px; }
  .list-item { padding: 10px 12px; min-height: 44px; }
  .check { min-height: 40px; font-size: 0.9rem; }
  .btn { min-height: 44px; padding: 12px 16px; }
}
