/* ==========================================================================
   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);
}

/* Icon + text CTAs (Play again / Try again): leading icon, centered */
.btn-primary.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4em;
}
.btn-primary.icon-btn .icon {
  width: 1em;
  height: 1em;
}

.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; }
}

/* ==========================================================================
   Time Trial (shared across flags / phone / domain)
   Triggered when the player picks the .time-mode-btn. Layout is the same for
   every game; only the prompt-stage contents differ (an image for flags, big
   text for phone/domain). Game scripts use the FTSTime renderPrompt callback
   to inject the appropriate element.
   ========================================================================== */

.time-mode-btn {
  border-color: var(--accent) !important;
  background: linear-gradient(135deg, var(--surface), var(--accent-soft)) !important;
}

.screen.time { gap: var(--space-3); }

.time-head {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: var(--space-3);
  padding: var(--space-3);
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
}
.time-stat {
  display: flex; flex-direction: column;
  gap: 2px; align-items: center; text-align: center;
}
.time-stat-label {
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}
.time-stat-value {
  color: var(--text);
  font-size: 22px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}
.time-stat-value.dim { color: var(--muted); font-weight: 600; }
.time-stat-value.clock { letter-spacing: 0.04em; }
.time-stat-value.clock.danger {
  color: #ff7a8a;
  animation: pulse-danger 0.9s ease infinite;
}
@keyframes pulse-danger {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.65; }
}

/* Prompt stage — the big visual the player has to identify */
.time-prompt-stage {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: var(--space-3);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  min-height: 200px;
}
.time-prompt-stage > .time-flag-img {
  width: 100%;
  max-width: 360px;
  max-height: 30vh;
  height: auto;
  border-radius: 4px;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.45),
              0 0 0 1px rgba(255, 255, 255, 0.06);
  background: rgba(255, 255, 255, 0.04);
  display: block;
}
.time-prompt-stage > .time-prompt-text {
  font-family: var(--font-mono);
  font-size: clamp(48px, 12vw, 96px);
  font-weight: 800;
  letter-spacing: 0.04em;
  color: var(--text);
  text-shadow: 0 0 32px rgba(138, 124, 255, 0.25);
}

/* Input + Skip row */
.time-input-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: var(--space-2);
  align-items: stretch;
}
.time-input {
  width: 100%;
  padding: 16px 20px;
  background: var(--surface);
  border: 1.5px solid var(--accent);
  border-radius: var(--radius-md);
  color: var(--text);
  font-family: inherit;
  font-size: 18px;
  letter-spacing: 0.01em;
  outline: none;
  transition: border-color 0.15s ease, background 0.15s ease,
              box-shadow 0.25s ease;
}
.time-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
}
.time-input.hit {
  border-color: rgba(39, 209, 122, 0.9);
  background: rgba(39, 209, 122, 0.12);
}
.time-input.dup {
  border-color: rgba(255, 207, 100, 0.8);
  background: rgba(255, 207, 100, 0.10);
}
.time-input.miss { animation: shake 0.25s ease; }
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25%      { transform: translateX(-4px); }
  75%      { transform: translateX(4px); }
}

.time-skip {
  padding: 0 var(--space-4);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface);
  color: var(--muted);
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.time-skip:hover {
  background: var(--surface-hover);
  color: var(--text);
  border-color: var(--accent);
}

/* Recent chips */
.time-recent {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-height: 28px;
}
.time-recent-chip {
  display: inline-block;
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  background: rgba(39, 209, 122, 0.18);
  border: 1px solid rgba(39, 209, 122, 0.5);
  color: #c6f7da;
  font-size: 12px;
  letter-spacing: 0.02em;
  transition: opacity 1s ease;
}
.time-recent-chip.dup {
  background: rgba(255, 207, 100, 0.16);
  border-color: rgba(255, 207, 100, 0.45);
  color: #ffe8b3;
}
.time-recent-chip.fade { opacity: 0.45; }

/* Continent progress collapsed in a <details> */
.time-continents-wrap {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: var(--space-2) var(--space-3);
}
.time-continents-wrap summary {
  cursor: pointer;
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  padding: 4px 0;
  list-style: none;
}
.time-continents-wrap summary::-webkit-details-marker { display: none; }
.time-continents-wrap summary::before {
  content: "▸ ";
  display: inline-block;
  transition: transform 0.15s ease;
}
.time-continents-wrap[open] summary::before { transform: rotate(90deg); }
.time-continents-wrap[open] .time-continents {
  margin-top: var(--space-2);
  padding: 0;
  border: 0;
  background: transparent;
}

.time-continents {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: var(--space-2) var(--space-3);
}
.time-continent {
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-rows: auto auto;
  gap: 2px 8px;
  align-items: baseline;
}
.time-continent-name {
  font-size: 13px;
  color: var(--text);
  letter-spacing: 0.02em;
}
.time-continent-count {
  font-size: 12px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  text-align: right;
}
.time-continent-bar {
  grid-column: 1 / -1;
  display: block;
  height: 4px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 999px;
  overflow: hidden;
}
.time-continent-bar > span {
  display: block;
  height: 100%;
  background: var(--accent);
  border-radius: 999px;
  transition: width 0.3s ease;
}
.time-continent.full .time-continent-name,
.time-continent.full .time-continent-count { color: #6dd99c; }
.time-continent.full .time-continent-bar > span { background: #6dd99c; }

/* End screen — missed list */
.missed-block {
  text-align: left;
  margin-top: var(--space-3);
  width: 100%;
  max-width: 720px;
}
.missed-title {
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  margin-bottom: var(--space-3);
}
.missed-grid {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}
.missed-continent-title {
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: var(--space-2);
}
.missed-flags {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: var(--space-2);
}
.missed-flag {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 8px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  text-align: center;
}
.missed-flag img {
  width: 64px;
  height: auto;
  max-height: 44px;
  border-radius: 2px;
  object-fit: contain;
  background: rgba(255, 255, 255, 0.04);
}
.missed-flag .time-text-tile {
  font-family: var(--font-mono);
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: 0.02em;
  padding: 4px 0;
}
.missed-flag span {
  font-size: 11px;
  color: var(--muted);
  line-height: 1.2;
}

@media (max-width: 600px) {
  .time-head { gap: var(--space-2); padding: var(--space-2); }
  .time-stat-value { font-size: 18px; }
  .time-input { padding: 12px 16px; font-size: 16px; }
  .time-continents { grid-template-columns: 1fr; gap: var(--space-2); }
  .missed-flags { grid-template-columns: repeat(auto-fill, minmax(90px, 1fr)); }
}
