/* ==========================================================================
   FTS shared quiz UI
   Used by /fts/bollards/ and /fts/cars/. Loaded BEFORE each game's style.css
   so per-game overrides win. base.css provides tokens/reset/font/.home-btn.
   ========================================================================== */

body {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 56px 20px 24px;
}

/* --- Back-to-FTS button (sits next to .home-btn) --- */
.back-btn {
  position: fixed;
  top: 0.82rem;
  left: 3.6rem;  /* directly right of .home-btn */
  z-index: 9999;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 1.7rem;
  width: 2.1rem;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(6, 11, 26, 0.9);
  color: var(--muted);
  text-decoration: none;
  transition: background 0.15s ease, border-color 0.15s ease,
              color 0.15s ease, transform 0.08s ease;
}
.back-btn:hover,
.back-btn:focus-visible {
  background: rgba(40, 50, 70, 0.8);
  border-color: var(--accent);
  color: var(--accent);
  transform: translateY(-1px);
  opacity: 1;
}
.back-btn svg {
  width: 14px;
  height: 14px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.quiz {
  width: 100%;
  max-width: 720px;
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

/* --- Head --- */
.quiz-head { text-align: center; }

.kicker {
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  margin-bottom: var(--space-1);
}
.kicker a { color: var(--muted); transition: color 0.2s ease; }
.kicker a:hover { color: var(--accent); opacity: 1; }

.quiz-head h1 {
  font-size: clamp(22px, 4vw, 32px);
  letter-spacing: 0.04em;
  margin-bottom: 2px;
}

.subtitle {
  color: var(--muted);
  font-size: 13px;
}

/* Hide the subtitle in-game so the playing area gets more vertical room. */
body:has(#screen-game:not([hidden])) .subtitle { display: none; }
body:has(#screen-game:not([hidden])) .quiz-head h1 { font-size: clamp(20px, 3.5vw, 26px); }
body:has(#screen-game:not([hidden])) .kicker { margin-bottom: 0; }

/* --- Screens --- */
.screen {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: var(--shadow-soft);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}
.screen[hidden] { display: none; }

/* --- Menu: level card --- */
.level-card {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: var(--space-4) var(--space-5);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.level-title {
  color: var(--muted);
  font-size: 13px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.level-title strong {
  color: var(--text);
  font-weight: 700;
  font-size: 16px;
}
.level-title .all-unlocked {
  color: var(--accent);
  font-weight: 600;
  text-transform: none;
  letter-spacing: 0.02em;
}

.progress-track {
  height: 6px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: var(--radius-pill);
  overflow: hidden;
  position: relative;
}
.progress-fill {
  position: absolute;
  inset: 0;
  width: var(--p, 0%);
  background: linear-gradient(90deg, var(--accent-soft), var(--accent));
  border-radius: var(--radius-pill);
  transition: width 0.5s ease;
}

.level-sub {
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.country-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.country-tag {
  display: inline-block;
  padding: 5px 10px;
  background: var(--accent-soft);
  border: 1px solid rgba(138, 124, 255, 0.4);
  border-radius: var(--radius-pill);
  color: var(--text);
  font-size: 13px;
  letter-spacing: 0.01em;
}
.country-tag.muted {
  background: transparent;
  border-color: var(--line);
  color: var(--muted);
}

.modes {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.mode-btn {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  padding: 16px 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
  text-align: left;
  transition: background 0.2s ease, transform 0.15s ease,
              border-color 0.2s ease, box-shadow 0.2s ease;
}
.mode-btn:hover {
  background: var(--surface-hover);
  border-color: var(--accent);
  transform: translateY(-1px);
}
.mode-btn:active { transform: translateY(0); }
.mode-btn:first-of-type {
  background: var(--accent-soft);
  border-color: var(--accent);
}

.mode-title {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 0.02em;
}
.mode-sub {
  color: var(--muted);
  font-size: 13px;
  letter-spacing: 0.01em;
}

.status {
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  margin-top: var(--space-2);
}
.status.error {
  color: #ffb0bd;
}
.status code {
  background: rgba(255, 255, 255, 0.06);
  padding: 1px 6px;
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 12px;
}

/* Reset progress link */
.reset-link {
  background: transparent;
  border: none;
  color: var(--muted);
  font-family: inherit;
  font-size: 12px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  text-decoration: underline;
  text-underline-offset: 3px;
  align-self: center;
  padding: 8px 12px;
  margin-top: var(--space-2);
  opacity: 0.6;
  transition: opacity 0.2s ease, color 0.2s ease;
}
.reset-link:hover {
  opacity: 1;
  color: #ff9aab;
}

/* Level-up celebration on the reveal panel */
.reveal.level-up {
  border-color: var(--accent);
  box-shadow: 0 0 32px rgba(138, 124, 255, 0.35);
  background: linear-gradient(135deg, var(--surface), var(--accent-soft));
}
.reveal.level-up .reveal-result {
  color: var(--accent);
  font-size: 16px;
  letter-spacing: 0.15em;
}

/* --- Game --- */
.game-head {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
}

.stat {
  display: flex;
  flex-direction: column;
  gap: 2px;
  align-items: center;
  text-align: center;
}

.stat-label {
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.stat-value {
  color: var(--text);
  font-size: 16px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.stat-value.lives {
  letter-spacing: 0.15em;
  font-size: 20px;
}
.stat-value.lives .heart-empty { opacity: 0.25; }

/* --- Stage / image --- */
.stage {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.image-container {
  display: flex;
  justify-content: center;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: var(--space-2);
  overflow: hidden;
}

.image-container img {
  width: 100%;
  max-width: 520px;
  height: auto;
  max-height: 38vh;
  border-radius: var(--radius-sm);
  object-fit: contain;
  transition: opacity 0.2s ease;
}
.image-container img.loading { opacity: 0.4; }

/* --- Options --- */
.options {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-3);
}

.option {
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 0.01em;
  text-align: center;
  transition: background 0.2s ease, transform 0.15s ease,
              border-color 0.2s ease, color 0.2s ease,
              box-shadow 0.2s ease;
  min-height: 44px;
}

.option:hover:not(:disabled) {
  background: var(--surface-hover);
  border-color: var(--accent);
  transform: translateY(-1px);
}
.option:active:not(:disabled) { transform: translateY(0); }
.option:disabled { cursor: default; }

.option.correct {
  background: rgba(39, 209, 122, 0.18);
  border-color: rgba(39, 209, 122, 0.85);
  color: #c6f7da;
  box-shadow: 0 0 24px rgba(39, 209, 122, 0.18);
}

.option.wrong {
  background: rgba(255, 93, 122, 0.16);
  border-color: rgba(255, 93, 122, 0.75);
  color: #ffd0d8;
}

/* --- Reveal panel --- */
.reveal {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-4);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  animation: reveal-in 0.25s ease;
}

.reveal[hidden] { display: none; }

@keyframes reveal-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.reveal.correct { border-color: rgba(39, 209, 122, 0.5); }
.reveal.wrong   { border-color: rgba(255, 93, 122, 0.5); }

.reveal-result {
  font-size: 13px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-weight: 700;
}
.reveal.correct .reveal-result { color: #6dd99c; }
.reveal.wrong .reveal-result   { color: #ff9aab; }

.reveal-country {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
}

.reveal-meta {
  color: var(--muted);
  font-size: 12px;
}

.reveal-actions {
  display: flex;
  gap: var(--space-3);
  align-items: center;
  justify-content: space-between;
  margin-top: var(--space-2);
  flex-wrap: wrap;
}

/* --- Buttons --- */
.btn-primary, .btn-ghost {
  padding: 12px 22px;
  border-radius: var(--radius-md);
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-align: center;
  text-decoration: none;
  border: 1px solid var(--line);
  transition: background 0.2s ease, transform 0.15s ease,
              border-color 0.2s ease, opacity 0.2s ease;
  cursor: pointer;
  display: inline-block;
}

.btn-primary {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--text);
}
.btn-primary:hover {
  background: var(--accent);
  transform: translateY(-1px);
}

.btn-ghost {
  background: transparent;
  color: var(--muted);
}
.btn-ghost:hover {
  background: var(--surface-hover);
  color: var(--text);
  opacity: 1;
}

.game-exit {
  align-self: center;
  padding: 10px 18px;
  font-size: 13px;
}

/* --- End screen --- */
.end {
  text-align: center;
  align-items: center;
  padding: var(--space-7) var(--space-5);
  gap: var(--space-3);
}

.end-kicker {
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
}

.end-score {
  font-size: 64px;
  font-weight: 800;
  color: var(--accent);
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.end-out-of {
  color: var(--muted);
  font-size: 28px;
  font-weight: 600;
}

.end-detail {
  color: var(--muted);
  font-size: 14px;
  max-width: 360px;
}

.end-actions {
  display: flex;
  gap: var(--space-3);
  margin-top: var(--space-3);
  flex-wrap: wrap;
  justify-content: center;
}

/* --- Mobile --- */
@media (max-width: 600px) {
  body { padding: 70px 16px 30px; }

  .screen { padding: var(--space-4); }

  .game-head {
    grid-template-columns: 1fr 1fr;
    gap: var(--space-2);
  }
  #extra-stat { grid-column: 1 / -1; }

  .options {
    grid-template-columns: 1fr;
    gap: var(--space-2);
  }

  .option {
    min-height: 48px;
    font-size: 14px;
  }

  .image-container { min-height: 180px; }

  .scores { gap: var(--space-1); }
  .score-cell { padding: var(--space-2) 4px; }
  .score-cell-value { font-size: 18px; }
  .score-cell-value.dim { font-size: 15px; }

  .end-score { font-size: 48px; }
  .end-out-of { font-size: 22px; }
}
