/* ==========================================================================
   FlagWheel — design system
   Tokens, typography, layouts, animations.
   Palette: navy #0F1226, coral #FF6B5C, honey #FFB020, mint #3EE0A9, violet #8B7BFF
   ========================================================================== */

:root {
  /* Colour tokens ---------------------------------------------------------- */
  --bg:              #0F1226;
  --bg-elevated:     #1A1D3A;
  --bg-card:         #22254A;
  --border-subtle:   #2E3260;
  --border-strong:   #3A3E70;

  --text:            #F5F5FA;
  --text-muted:      #A8ADD1;
  --text-dim:        #6B6F92;

  --coral:           #FF6B5C;
  --coral-soft:      #FF8B7E;
  --honey:           #FFB020;
  --mint:            #3EE0A9;
  --mint-soft:       #6FE9BE;
  --violet:          #8B7BFF;

  --success:         var(--mint);
  --warning:         var(--honey);
  --error:           var(--coral);
  --info:            var(--violet);

  /* Spacing / radius ------------------------------------------------------- */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --space-7: 48px;
  --space-8: 64px;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --radius-pill: 999px;

  /* Elevation -------------------------------------------------------------- */
  --shadow-subtle:  0 2px 8px rgba(0, 0, 0, 0.25);
  --shadow-lifted:  0 12px 40px rgba(0, 0, 0, 0.45);
  --shadow-hero:    0 24px 60px rgba(255, 107, 92, 0.12);

  /* Motion ----------------------------------------------------------------- */
  --ease-out-expo: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-out:      cubic-bezier(0.33, 1, 0.68, 1);
  --dur-fast:      150ms;
  --dur:           250ms;
  --dur-slow:      400ms;

  /* Typography ------------------------------------------------------------- */
  --font-display: "Space Grotesk", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-body:    "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono:    "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;
}

/* ==========================================================================
   Reset + base
   ========================================================================== */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; min-height: 100%; }

body {
  font-family: var(--font-body);
  background:
    radial-gradient(circle at 20% -10%, rgba(139, 123, 255, 0.15), transparent 40%),
    radial-gradient(circle at 100% 100%, rgba(255, 107, 92, 0.10), transparent 40%),
    var(--bg);
  color: var(--text);
  line-height: 1.5;
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
}

button {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
  cursor: pointer;
}

/* Focus rings ------------------------------------------------------------- */
button:focus-visible, input:focus-visible, [role="option"]:focus-visible {
  outline: 2px solid var(--mint);
  outline-offset: 3px;
  border-radius: var(--radius-sm);
}

/* App container ----------------------------------------------------------- */
.app {
  max-width: 480px;
  margin: 0 auto;
  padding: var(--space-4) var(--space-4) var(--space-7);
  padding-top: max(var(--space-4), env(safe-area-inset-top));
}

/* Screens: only one is visible at a time -------------------------------- */
.screen { animation: screen-in var(--dur-slow) var(--ease-out-expo); }

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

.hidden { display: none !important; }

/* ==========================================================================
   Header (used on home + game)
   ========================================================================== */
.app-header, .game-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  margin-bottom: var(--space-5);
}

.brand {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

/* FlagWheel logo: a wheel with 5 flag-colour segments and a small navy hub
   with radial "spokes" scored across the segments. */
.brand-mark {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  position: relative;
  background:
    conic-gradient(from -90deg,
      var(--coral)  0deg   72deg,
      var(--honey)  72deg  144deg,
      var(--mint)   144deg 216deg,
      var(--violet) 216deg 288deg,
      var(--text)   288deg 360deg);
  box-shadow:
    inset 0 0 0 2px rgba(15, 18, 38, 0.6),
    0 3px 10px rgba(0, 0, 0, 0.35);
}
/* Spoke lines that make the wheel read as a wheel, not just a pie. */
.brand-mark::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background:
    repeating-conic-gradient(
      from -90deg,
      rgba(15, 18, 38, 0.55) 0deg 0.8deg,
      transparent 0.8deg 72deg
    );
  pointer-events: none;
}
.brand-mark-hub {
  position: absolute;
  inset: 36%;
  background: var(--bg);
  border-radius: 50%;
  box-shadow: inset 0 0 0 1.5px var(--text);
}

.brand-word {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 20px;
  letter-spacing: -0.02em;
}

.header-actions { display: flex; gap: var(--space-2); }

.header-btn {
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  color: var(--text);
  padding: 8px 12px;
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 600;
  transition: transform var(--dur-fast), background var(--dur-fast);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.header-btn:hover { background: var(--bg-card); }
.header-btn:active { transform: scale(0.96); }
.header-btn.ghost { background: transparent; border-color: transparent; }
.header-btn.ghost:hover { background: var(--bg-elevated); }

.streak-badge .streak-flame {
  display: inline-block;
  animation: flicker 2s ease-in-out infinite;
}
.streak-badge.hot { color: var(--honey); border-color: var(--honey); }
.streak-badge.hot .streak-flame {
  animation: flicker 0.9s ease-in-out infinite;
  filter: drop-shadow(0 0 6px rgba(255, 176, 32, 0.6));
}

@keyframes flicker {
  0%, 100% { transform: scale(1); }
  50%      { transform: scale(1.08) rotate(-2deg); }
}

.game-mode-label {
  font-family: var(--font-display);
  font-weight: 500;
  letter-spacing: 0.02em;
  color: var(--text-muted);
}

/* ==========================================================================
   HOME — daily card
   The preview graphic is intentionally small so it never competes with
   the "Today's puzzle" headline for attention.
   ========================================================================== */
.daily-card {
  background: linear-gradient(160deg, var(--bg-card), var(--bg-elevated));
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  padding: var(--space-5);
  text-align: center;
  box-shadow: var(--shadow-lifted);
  margin-bottom: var(--space-4);
  animation: card-in 500ms var(--ease-out-expo);
}

.daily-label {
  display: inline-block;
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 12px;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--violet);
  padding: 4px 10px;
  background: rgba(139, 123, 255, 0.12);
  border-radius: var(--radius-pill);
  margin-bottom: var(--space-4);
}

/* Small, restrained preview: 72×72, centered, generous margin below so the
   title and subtitle underneath are never crowded or covered. */
.daily-preview {
  width: 72px;
  height: 72px;
  margin: 0 auto var(--space-4);
  position: relative;
}

#daily-preview-canvas {
  width: 72px;
  height: 72px;
  display: block;
  border-radius: 50%;
  filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.35));
}

.daily-preview-badge {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 22px;
  color: var(--text);
  background: rgba(15, 18, 38, 0.55);
  border-radius: 50%;
  pointer-events: none;
}

.daily-preview-badge.completed { display: none; }

.daily-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 24px;
  margin-bottom: var(--space-1);
  /* Guarantee stacking above the preview and no overlap. */
  position: relative;
  z-index: 1;
}

.daily-sub {
  color: var(--text-muted);
  font-size: 14px;
  margin-bottom: var(--space-4);
  position: relative;
  z-index: 1;
}

.history-strip {
  display: flex;
  justify-content: center;
  gap: 6px;
  margin-top: var(--space-4);
}

.history-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--border-subtle);
}
.history-dot.win  { background: var(--mint); box-shadow: 0 0 6px rgba(62, 224, 169, 0.5); }
.history-dot.loss { background: var(--coral); }

/* ==========================================================================
   HOME — unlimited row + stats
   ========================================================================== */
.unlim-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
}

.unlim-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  text-align: left;
  transition: transform var(--dur-fast), border-color var(--dur-fast);
  animation: card-in 500ms var(--ease-out-expo) both;
}
.unlim-card:nth-child(1) { animation-delay: 60ms; }
.unlim-card:nth-child(2) { animation-delay: 120ms; }

.unlim-card:hover { border-color: var(--border-strong); transform: translateY(-2px); }
.unlim-card:active { transform: scale(0.98); }

.unlim-emoji { font-size: 28px; margin-bottom: 4px; }
.unlim-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 16px;
}
.unlim-sub { font-size: 12px; color: var(--text-muted); }

.stats-strip {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-3);
  padding: var(--space-4);
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  animation: card-in 500ms var(--ease-out-expo) 180ms both;
}

.stat { text-align: center; }
.stat-value {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 22px;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
.stat-label {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-top: 2px;
}

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

/* ==========================================================================
   CTA buttons
   ========================================================================== */
.cta {
  border: none;
  border-radius: var(--radius-md);
  padding: 14px 20px;
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 15px;
  transition: transform 100ms var(--ease-out), background var(--dur-fast), box-shadow var(--dur-fast);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
}

.cta-primary {
  background: var(--coral);
  color: #1a0a08;
  box-shadow: 0 6px 20px rgba(255, 107, 92, 0.35);
}
.cta-primary:hover  { background: var(--coral-soft); }
.cta-primary:active { transform: scale(0.97); box-shadow: 0 3px 12px rgba(255, 107, 92, 0.35); }
.cta-primary:disabled { background: var(--bg-elevated); color: var(--text-dim); box-shadow: none; cursor: not-allowed; }

.cta-secondary {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border-strong);
}
.cta-secondary:hover  { background: var(--bg-elevated); }
.cta-secondary:active { transform: scale(0.97); }

#daily-cta { width: 100%; margin-top: var(--space-2); }

/* ==========================================================================
   GAMEPLAY — pie chart + chips + progress
   ========================================================================== */
.pie-wrapper {
  display: flex;
  justify-content: center;
  margin-bottom: var(--space-3);
  animation: pie-in 700ms var(--ease-out-expo);
}

#pie-canvas {
  filter: drop-shadow(0 20px 40px rgba(0, 0, 0, 0.45));
  border-radius: 50%;
}

@keyframes pie-in {
  from { opacity: 0; transform: scale(0.85) rotate(-25deg); }
  to   { opacity: 1; transform: scale(1) rotate(0deg); }
}

.colour-chips {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
  margin-bottom: var(--space-4);
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px 4px 4px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-pill);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  color: var(--text-muted);
}

.chip-swatch {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.15);
}

.guess-progress {
  display: flex;
  justify-content: center;
  margin-bottom: var(--space-3);
}

.guess-dots {
  display: inline-flex;
  gap: 8px;
}

.dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--coral);
  transition: transform var(--dur), background var(--dur);
}

.dot.spent {
  background: transparent;
  border: 2px solid var(--border-strong);
  box-sizing: border-box;
}

.dot.losing {
  animation: dot-lose 400ms ease-out;
}

@keyframes dot-lose {
  0%   { transform: scale(1); background: var(--coral); }
  40%  { transform: scale(1.5); background: var(--coral); }
  100% { transform: scale(1); background: transparent; }
}

/* ==========================================================================
   GAMEPLAY — input row + validation
   ========================================================================== */
.input-row {
  display: flex;
  gap: 8px;
  margin-bottom: 6px;
}

.input-wrapper { position: relative; flex: 1; }

#guess-input {
  width: 100%;
  padding: 14px 16px;
  font-size: 16px;   /* prevents iOS zoom */
  color: var(--text);
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  transition: border-color var(--dur-fast), background var(--dur-fast);
  min-height: 48px;
}
#guess-input:focus { border-color: var(--mint); outline: none; }
#guess-input:disabled { opacity: 0.5; cursor: not-allowed; }

#guess-input.input-correct {
  border-color: var(--mint);
  background: rgba(62, 224, 169, 0.12);
}
#guess-input.input-wrong {
  border-color: var(--coral);
  background: rgba(255, 107, 92, 0.08);
}

#guess-button {
  padding: 0 18px;
  font-weight: 700;
  color: #1a0a08;
  background: var(--coral);
  border: none;
  border-radius: var(--radius-md);
  min-width: 52px;
  transition: transform 100ms var(--ease-out), background var(--dur-fast);
}
#guess-button:hover { background: var(--coral-soft); }
#guess-button:active { transform: scale(0.94); }
#guess-button:disabled { background: var(--bg-elevated); color: var(--text-dim); cursor: not-allowed; }

.validation-message {
  min-height: 20px;
  margin: 0 0 var(--space-3);
  font-size: 13px;
  color: var(--coral);
  text-align: center;
}
.validation-message.info { color: var(--violet); }

/* Autocomplete ----------------------------------------------------------- */
.autocomplete-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  left: 0; right: 0;
  z-index: 20;
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-lifted);
  max-height: 300px;
  overflow-y: auto;
}

/* Text-only autocomplete rows: no colour previews (that would spoil the puzzle). */
.autocomplete-item {
  display: block;
  padding: 12px 14px;
  cursor: pointer;
  font-size: 14px;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text);
}
.autocomplete-item:last-child { border-bottom: none; }
.autocomplete-item.active,
.autocomplete-item:hover { background: var(--bg-card); }
.autocomplete-item.active { color: var(--mint); }

/* Manual hint button ----------------------------------------------------- */
.manual-hint {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 12px;
  margin-bottom: var(--space-3);
  background: rgba(139, 123, 255, 0.08);
  border: 1px dashed rgba(139, 123, 255, 0.4);
  border-radius: var(--radius-md);
  color: var(--violet);
  font-weight: 600;
  font-size: 14px;
  transition: background var(--dur-fast), transform 100ms var(--ease-out);
}
.manual-hint:hover:not(:disabled) {
  background: rgba(139, 123, 255, 0.15);
  border-style: solid;
}
.manual-hint:active { transform: scale(0.98); }
.manual-hint:disabled { opacity: 0.5; cursor: not-allowed; }
.manual-hint .cost {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 400;
}

/* Give-up link: text button below the hint button; low-emphasis but clearly
   present so players can always exit into the same rich result screen. */
.give-up-link {
  display: block;
  width: 100%;
  margin: 0 0 var(--space-4);
  padding: 6px;
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 13px;
  text-decoration: underline;
  text-underline-offset: 3px;
  transition: color var(--dur-fast);
}
.give-up-link:hover:not(:disabled) { color: var(--coral); }
.give-up-link:disabled { opacity: 0.4; cursor: not-allowed; text-decoration: none; }

/* Wrong guesses + hints -------------------------------------------------- */
.wrong-guesses-list {
  list-style: none; padding: 0; margin: 0 0 var(--space-3);
  display: flex; flex-wrap: wrap; gap: 6px;
  min-height: 0;
}
.wrong-guesses-list li {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: rgba(255, 107, 92, 0.10);
  color: var(--coral-soft);
  border: 1px solid rgba(255, 107, 92, 0.25);
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  font-size: 12px;
  animation: wrong-pop 300ms var(--ease-out-expo);
}
.wrong-guesses-list li::before { content: "✕"; opacity: 0.7; }

@keyframes wrong-pop {
  from { opacity: 0; transform: scale(0.8); }
  to   { opacity: 1; transform: scale(1); }
}

.hints-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.hint-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  background: rgba(139, 123, 255, 0.08);
  border-left: 3px solid var(--violet);
  border-radius: 4px 12px 12px 4px;
  font-size: 14px;
  animation: hint-in 350ms var(--ease-out-expo);
}

.hint-number {
  width: 22px;
  height: 22px;
  flex-shrink: 0;
  border-radius: 50%;
  background: rgba(139, 123, 255, 0.20);
  color: var(--violet);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.hint-text { flex: 1; color: var(--text); }

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

/* ==========================================================================
   RESULT SCREEN
   ========================================================================== */
.verdict {
  text-align: center;
  padding: var(--space-5) 0 var(--space-4);
  animation: verdict-in 500ms var(--ease-out-expo);
}

.verdict-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 36px;
  letter-spacing: -0.02em;
  margin-bottom: 4px;
}
.verdict.win  .verdict-title { color: var(--mint); }
.verdict.loss .verdict-title { color: var(--coral); }

.verdict-sub { color: var(--text-muted); font-size: 15px; }

@keyframes verdict-in {
  0%   { opacity: 0; transform: scale(0.85); }
  60%  { opacity: 1; transform: scale(1.05); }
  100% { opacity: 1; transform: scale(1); }
}

/* Flag hero: rectangular flag on top (always shown, win or lose), with a mini
   pie underneath as a colour recall aid. */
.flag-hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-3);
  margin: var(--space-4) 0 var(--space-5);
  animation: flag-in 700ms 200ms var(--ease-out-expo) both;
}

/* Frame around the real flag image. Off-white matting behind the flag
   gives it a printed / museum-plaque feel and keeps the image legible
   regardless of its dominant colour. */
.flag-frame {
  display: inline-block;
  padding: 10px;
  background: linear-gradient(160deg, #f6f7fb 0%, #dfe2ec 100%);
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  box-shadow:
    0 16px 40px rgba(0, 0, 0, 0.55),
    0 4px 10px rgba(0, 0, 0, 0.35),
    inset 0 0 0 1px rgba(255, 255, 255, 0.55);
  line-height: 0;   /* remove any gap under inline canvas/img */
}

.flag-image {
  display: block;
  width: min(280px, 70vw);
  height: auto;
  max-height: 200px;
  object-fit: contain;
  border-radius: 6px;
  background: #ffffff;
  box-shadow:
    inset 0 0 0 1px rgba(0, 0, 0, 0.08),
    0 1px 2px rgba(0, 0, 0, 0.15);
}
.flag-image.hidden { display: none; }

/* Fallback canvas — sits in the same frame when the image can't load. */
.flag-rect {
  display: block;
  width: min(280px, 70vw);
  height: auto;
  aspect-ratio: 3 / 2;
  border-radius: 6px;
  background: var(--bg-elevated);
  box-shadow:
    inset 0 0 0 1px rgba(0, 0, 0, 0.08),
    0 1px 2px rgba(0, 0, 0, 0.15);
}

.flag-hero-sub {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px 6px 6px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-pill);
}

#result-pie-canvas {
  border-radius: 50%;
  display: block;
}

.flag-hero-note {
  font-size: 12px;
  color: var(--text-muted);
  font-family: var(--font-display);
  letter-spacing: 0.03em;
}

@keyframes flag-in {
  from { opacity: 0; transform: translateY(-16px) scale(0.9); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* Info card -------------------------------------------------------------- */
.info-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  padding: var(--space-5);
  box-shadow: var(--shadow-lifted);
  animation: card-in 500ms 400ms var(--ease-out-expo) both;
}

.info-country {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 32px;
  letter-spacing: -0.02em;
}
.info-continent {
  color: var(--violet);
  font-size: 14px;
  font-weight: 500;
  margin-bottom: var(--space-4);
}

.info-grid {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-bottom: var(--space-4);
}

.info-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--border-subtle);
  animation: row-in 350ms var(--ease-out-expo) both;
}
.info-row:last-child { border-bottom: none; }
.info-row:nth-child(1) { animation-delay: 500ms; }
.info-row:nth-child(2) { animation-delay: 560ms; }
.info-row:nth-child(3) { animation-delay: 620ms; }
.info-row:nth-child(4) { animation-delay: 680ms; }

.info-key { color: var(--text-muted); font-size: 13px; }
.info-value {
  color: var(--text);
  font-weight: 600;
  font-size: 14px;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

@keyframes row-in {
  from { opacity: 0; transform: translateX(-6px); }
  to   { opacity: 1; transform: translateX(0); }
}

.fun-fact {
  background: rgba(255, 176, 32, 0.10);
  border: 1px solid rgba(255, 176, 32, 0.3);
  border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-4);
  animation: card-in 400ms 800ms var(--ease-out-expo) both;
}

.fun-fact-label {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 11px;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--honey);
  margin-bottom: 4px;
}

.fun-fact-text {
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}

/* Result actions --------------------------------------------------------- */
.result-actions {
  display: flex;
  gap: 8px;
  margin-top: var(--space-5);
  animation: card-in 400ms 900ms var(--ease-out-expo) both;
}

.result-actions .cta { flex: 1; }

.back-link {
  display: block;
  margin: var(--space-4) auto 0;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 13px;
  padding: 8px;
  animation: card-in 400ms 1000ms var(--ease-out-expo) both;
}
.back-link:hover { color: var(--text); }

.share-text-hidden { display: none; }

.share-feedback {
  text-align: center;
  color: var(--mint);
  font-size: 13px;
  margin-top: 8px;
  min-height: 18px;
}

/* ==========================================================================
   MODAL — continent picker + settings
   ========================================================================== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 18, 38, 0.7);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 100;
  animation: overlay-in var(--dur) var(--ease-out);
  padding: 0;
}

@keyframes overlay-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.modal-sheet {
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  padding: var(--space-4) var(--space-4) calc(var(--space-4) + env(safe-area-inset-bottom));
  width: 100%;
  max-width: 480px;
  max-height: 85vh;
  overflow-y: auto;
  animation: sheet-up var(--dur-slow) var(--ease-out-expo);
  box-shadow: 0 -20px 60px rgba(0, 0, 0, 0.5);
}

@keyframes sheet-up {
  from { transform: translateY(100%); }
  to   { transform: translateY(0); }
}

@media (min-width: 600px) {
  .modal-overlay { align-items: center; padding: var(--space-4); }
  .modal-sheet { border-radius: var(--radius-xl); max-width: 440px; }
  @keyframes sheet-up {
    from { transform: translateY(20px); opacity: 0; }
    to   { transform: translateY(0); opacity: 1; }
  }
}

.modal-handle {
  width: 36px; height: 4px;
  background: var(--border-strong);
  border-radius: var(--radius-pill);
  margin: 0 auto var(--space-3);
}

.modal-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 22px;
  margin: 0 0 4px;
}
.modal-sub { color: var(--text-muted); font-size: 13px; margin: 0 0 var(--space-4); }

.continent-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: var(--space-4);
}

.continent-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 12px;
  background: var(--bg-card);
  border: 1.5px solid var(--border-subtle);
  border-radius: var(--radius-md);
  text-align: left;
  transition: all var(--dur-fast);
}
.continent-pill:hover { border-color: var(--border-strong); }
.continent-pill.selected {
  border-color: var(--coral);
  background: rgba(255, 107, 92, 0.12);
  color: var(--text);
}
.continent-pill:active { transform: scale(0.97); }

.continent-emoji { font-size: 22px; }
.continent-name {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 14px;
  flex: 1;
}
.continent-count { font-size: 11px; color: var(--text-muted); }

.modal-actions {
  display: flex;
  gap: 8px;
  margin-top: var(--space-3);
}
.modal-actions .cta { flex: 1; }

/* Settings toggle -------------------------------------------------------- */
.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-3) 0;
  border-bottom: 1px solid var(--border-subtle);
  cursor: pointer;
}
.setting-row:last-of-type { border-bottom: none; }

.setting-name { font-weight: 600; font-size: 15px; }
.setting-desc { font-size: 12px; color: var(--text-muted); }

.toggle {
  appearance: none;
  width: 44px; height: 26px;
  background: var(--border-subtle);
  border-radius: 999px;
  position: relative;
  cursor: pointer;
  transition: background var(--dur-fast);
  flex-shrink: 0;
}
.toggle::after {
  content: "";
  position: absolute;
  top: 3px; left: 3px;
  width: 20px; height: 20px;
  background: var(--text);
  border-radius: 50%;
  transition: transform var(--dur-fast) var(--ease-out);
}
.toggle:checked { background: var(--mint); }
.toggle:checked::after { transform: translateX(18px); }

/* ==========================================================================
   CONFETTI + FX
   ========================================================================== */
.confetti-canvas {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 200;
}

.fx-shake { animation: shake 320ms cubic-bezier(0.36, 0.07, 0.19, 0.97); }
@keyframes shake {
  10%, 90% { transform: translateX(-2px); }
  20%, 80% { transform: translateX(4px); }
  30%, 50%, 70% { transform: translateX(-6px); }
  40%, 60% { transform: translateX(6px); }
}

.fx-pulse { animation: pulse 400ms var(--ease-out-expo); }
@keyframes pulse {
  0%   { transform: scale(1); }
  40%  { transform: scale(1.06); }
  100% { transform: scale(1); }
}

/* ==========================================================================
   ACCESSIBILITY — reduced motion & colour-blind
   ========================================================================== */

/* Respect the OS-level preference. Users can also toggle in-app,
   which sets a body class for finer control. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

body.reduced-motion *, body.reduced-motion *::before, body.reduced-motion *::after {
  animation-duration: 0.01ms !important;
  animation-iteration-count: 1 !important;
  transition-duration: 0.01ms !important;
}

body.reduced-motion .streak-flame { animation: none !important; }

/* Colour-blind mode: the pie chart itself uses patterns via piechart.js.
   Here we bump the contrast on validation and dots. */
body.colorblind .dot.spent { border-color: var(--text); }

/* ==========================================================================
   Small screens
   ========================================================================== */
@media (max-width: 380px) {
  .app { padding: var(--space-3); }
  .brand-word { font-size: 18px; }
  .daily-title { font-size: 20px; }
  .verdict-title { font-size: 30px; }
  .info-country { font-size: 26px; }
  .flag-image, .flag-rect { width: min(240px, 78vw); }
  .flag-frame { padding: 8px; }
}
