/* ============================================================
   Diving Detective — design tokens
   ============================================================ */
:root {
  --surface-0: #05080b;
  --surface-1: #0a1118;
  --surface-2: #111c26;

  --text: #f0f3f5;
  --text-dim: #9ba6b0;

  --border-default: rgba(255, 255, 255, 0.10);
  --border-quiet: rgba(95, 181, 201, 0.30);
  --border-active: rgba(95, 181, 201, 0.65);
  --border-hover: rgba(95, 181, 201, 1.0);

  --accent-cool: #5fb5c9;
  --accent-warm: #e0b34a;
  --success: #4ade80;
  --error: #ef4444;

  --pill-radius: 999px;
  --stage-h: clamp(320px, 60vh, 540px);

  --font-ui: -apple-system, BlinkMacSystemFont, "Segoe UI", "Inter",
             system-ui, sans-serif;
  --font-sci: Georgia, "Times New Roman", serif;
}

*, *::before, *::after { box-sizing: border-box; }

html { font-size: 14px; }

body {
  background: var(--surface-0);
  color: var(--text);
  font-family: var(--font-ui);
  text-align: center;
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

.wrapper {
  flex: 1 0 auto;
  width: 100%;
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 1rem 2rem;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0;
}

/* ============================================================
   Title
   ============================================================ */
.title {
  position: sticky;
  top: 0;
  background: var(--surface-0);
  padding: 0.6rem 0 0.35rem;
  z-index: 10;
}

.title h1 {
  font-family: var(--font-ui);
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: 1.05rem;
  margin: 0;
  display: inline-block;
  color: var(--text);
  border-bottom: 2px solid var(--accent-warm);
  padding: 0 0.5em 0.2em;
}

.scientific {
  font-family: var(--font-sci);
  font-style: italic;
  color: var(--text-dim);
  margin: 0.35em 0 0;
  font-size: 0.9rem;
  min-height: 1.2em;
}

/* ============================================================
   Control row
   ============================================================ */
#control {
  display: grid;
  grid-template-columns: auto auto auto;
  gap: 0.5rem 1.25rem;
  justify-content: center;
  align-items: center;
  margin: 1rem 0 1.25rem;
}

#control select {
  background: var(--surface-1);
  color: var(--text);
  border: 1px solid var(--border-default);
  border-radius: var(--pill-radius);
  font-family: var(--font-ui);
  font-size: 0.9rem;
  padding: 0 1em;
  height: 2.4em;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--text-dim) 50%),
                    linear-gradient(135deg, var(--text-dim) 50%, transparent 50%);
  background-position: calc(100% - 1.1em) 50%, calc(100% - 0.75em) 50%;
  background-size: 0.35em 0.35em, 0.35em 0.35em;
  background-repeat: no-repeat;
  padding-right: 2em;
}

#control select:hover {
  border-color: var(--border-hover);
}

#control select:focus-visible {
  outline: 2px solid var(--accent-cool);
  outline-offset: 2px;
}

.scoring {
  display: flex;
  gap: 1rem;
  align-items: baseline;
  font-variant-numeric: tabular-nums;
}

.scoring h3 {
  margin: 0;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
}

/* ============================================================
   Game layout (default = single column)
   ============================================================ */
.game {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
  margin-top: 0.5rem;
}

.answer-panel {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

/* ============================================================
   Photo stage
   ============================================================ */
.stage {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  background: var(--surface-1);
  border: 1px solid var(--border-default);
  border-radius: 0.5rem;
  padding: 0.6rem 0.6rem 0.4rem;
  aspect-ratio: 3 / 2;
  min-height: 280px;
  max-height: var(--stage-h);
  width: 100%;
  max-width: 720px;
  justify-self: center;
  overflow: hidden;
  isolation: isolate;
}

.stage::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image: var(--photo-bg, none);
  background-size: cover;
  background-position: center;
  filter: blur(28px) saturate(1.15);
  transform: scale(1.18);
  opacity: 0.55;
  z-index: -2;
  pointer-events: none;
  transition: opacity 200ms ease;
}

/* Scrim for credit legibility — sits between blur and content,
 * so it only darkens regions of blur not covered by the photo.
 */
.stage::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(to top,
    rgba(0, 0, 0, 0.88) 0%,
    rgba(0, 0, 0, 0) 32%);
  z-index: -1;
  pointer-events: none;
}

.stage > * {
  position: relative;
}

.stage img {
  flex: 1 1 0;
  min-height: 0;
  width: auto;
  max-width: 100%;
  object-fit: contain;
  border-radius: 0.25rem;
  cursor: zoom-in;
}

.credit {
  margin: 0.45rem 0 0.15rem;
  font-size: 0.9rem;
  color: rgba(255, 255, 255, 0.95);
  letter-spacing: 0.02em;
  flex: 0 0 auto;
}

/* ============================================================
   Answer pills
   ============================================================ */
.options-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.55rem;
}

.pill {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 2.9rem;
  padding: 0.55em 1.1em;
  border-radius: var(--pill-radius);
  background: var(--surface-1);
  color: var(--text);
  border: 1px solid var(--border-quiet);
  font-family: var(--font-ui);
  font-size: 0.95rem;
  font-weight: 500;
  text-align: center;
  cursor: pointer;
  user-select: none;
  transition: border-color 120ms ease, background-color 120ms ease;
}

.pill:hover {
  border-color: var(--border-hover);
  background: var(--surface-2);
}

/* State classes win over hover */
.pill--correct,
.pill--correct:hover {
  border-color: var(--success);
  background: rgba(74, 222, 128, 0.14);
}

.pill--wrong,
.pill--wrong:hover {
  border-color: var(--error);
  background: rgba(239, 68, 68, 0.14);
}

.pill h4 {
  margin: 0;
  font: inherit;
}

/* ============================================================
   Action row (Zoom / Skip / New Example)
   ============================================================ */
.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  justify-content: center;
  margin-top: 0.25rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border-default);
}

.action {
  background: var(--surface-1);
  color: var(--text);
  border: 1px solid var(--border-default);
  border-radius: var(--pill-radius);
  padding: 0.5em 1.25em;
  font-family: var(--font-ui);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  user-select: none;
  transition: color 120ms ease, border-color 120ms ease, background-color 120ms ease;
}

.action:hover {
  border-color: var(--border-hover);
  background: var(--surface-2);
}

.action:focus-visible {
  outline: 2px solid var(--accent-cool);
  outline-offset: 2px;
}

/* ============================================================
   Lightbox
   ============================================================ */
.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.94);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 1rem;
  cursor: zoom-out;
}

.lightbox[hidden] {
  display: none;
}

.lightbox img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 0.25rem;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.6);
  cursor: default;
}

.lightbox-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  background: var(--surface-1);
  color: var(--text-dim);
  border: 1px solid var(--border-default);
  border-radius: var(--pill-radius);
  padding: 0.45em 1em;
  font-family: var(--font-ui);
  font-size: 0.85rem;
  cursor: pointer;
}

.lightbox-close:hover {
  color: var(--text);
  border-color: var(--border-hover);
}

/* ============================================================
   Footer
   ============================================================ */
footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 1rem;
  color: var(--text-dim);
  font-size: 0.78rem;
}

footer p { margin: 0; }

footer a,
footer a:visited {
  color: var(--text-dim);
  text-decoration: underline;
}

footer a:hover { color: var(--text); }

/* ============================================================
   Responsive font scale (kept from original)
   ============================================================ */
@media (min-width: 480px) { html { font-size: 13px; } }
@media (min-width: 768px) { html { font-size: 14px; } }
@media (min-width: 992px) { html { font-size: 15px; } }
@media (min-width: 1200px) { html { font-size: 16px; } }

/* ============================================================
   Split layout — wide desktop
   ============================================================ */
@media (min-width: 1100px) {
  :root {
    --stage-h: clamp(440px, 72vh, 640px);
  }

  .game {
    grid-template-columns: minmax(0, 1.35fr) minmax(360px, 1fr);
    align-items: start;
    gap: 1.5rem;
  }

  .stage {
    max-width: none;
  }

  .answer-panel {
    position: sticky;
    top: 4rem;
  }
}

/* ============================================================
   Mobile — control row stacks, single-column options under 380
   ============================================================ */
@media (max-width: 600px) {
  :root {
    --stage-h: 52vh;
  }

  #control {
    grid-template-columns: 1fr 1fr;
    grid-template-areas:
      "region difficulty"
      "score  score";
    gap: 0.5rem 0.75rem;
  }

  #control select:nth-of-type(1) { grid-area: region; }
  #control select:nth-of-type(2) { grid-area: difficulty; }
  .scoring { grid-area: score; justify-content: center; }
}

@media (max-width: 380px) {
  .options-grid { grid-template-columns: 1fr; }
}
