/* Games section — shared UI for the hub and individual games. */

.gm-page {
  position: relative;
  min-height: calc(100vh - var(--nav-h, 72px));
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  background:
    radial-gradient(120% 80% at 50% -10%, color-mix(in srgb, var(--accent) 7%, transparent), transparent 60%),
    linear-gradient(180deg, var(--bg) 0%, color-mix(in srgb, var(--bg-warm) 60%, var(--bg)) 55%, color-mix(in srgb, var(--accent) 6%, var(--bg)) 100%);
  color: var(--ink);
}

/* Decorative vector backdrop (soft horizon scenery + faint dot texture),
   injected by js/games/game-bg.js into every .gm-page. */
.gm-bg { position: fixed; inset: 0; z-index: 0; pointer-events: none; overflow: hidden; }
.gm-bg-dots {
  position: absolute; inset: 0;
  background-image: radial-gradient(color-mix(in srgb, var(--ink) 14%, transparent) 1.1px, transparent 1.2px);
  background-size: 16px 16px;
  -webkit-mask-image: radial-gradient(120% 70% at 50% 30%, #000 0%, transparent 70%);
          mask-image: radial-gradient(120% 70% at 50% 30%, #000 0%, transparent 70%);
  opacity: 0.5;
}
.gm-bg-scenery { position: absolute; left: 0; right: 0; bottom: 0; width: 100%; height: auto; display: block; }
[data-theme="dark"] .gm-bg-scenery { opacity: 0.5; }

.gm-main {
  position: relative;
  z-index: 1;
  flex: 1;
  width: 100%;
  max-width: 1040px;
  margin: 0 auto;
  padding: 32px 20px 64px;
  box-sizing: border-box;
}

/* Centre the playable games vertically in the viewport (hub stays top-aligned). */
.gm-main:has(.gm-shell) {
  display: flex;
  flex-direction: column;
  justify-content: center;
}

/* ── Hub ───────────────────────────────────────────────────────────────────── */
.gm-hero {
  text-align: center;
  margin: 8px 0 36px;
}
.gm-hero h1 {
  font-size: clamp(1.9rem, 4vw, 2.7rem);
  margin: 0 0 10px;
  letter-spacing: -0.02em;
}
.gm-hero p {
  margin: 0 auto;
  max-width: 540px;
  color: var(--ink-soft);
  font-size: 1.05rem;
  line-height: 1.5;
}

.gm-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 18px;
}

.gm-card {
  display: flex;
  flex-direction: column;
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: 18px;
  padding: 24px;
  text-decoration: none;
  color: inherit;
  box-shadow: var(--popup-shadow);
  transition: transform 0.18s ease, border-color 0.18s ease;
}
.gm-card:hover {
  transform: translateY(-4px);
  border-color: var(--accent);
}
.gm-card-emoji { font-size: 2.4rem; line-height: 1; margin-bottom: 14px; }
.gm-card h2 { margin: 0 0 6px; font-size: 1.25rem; }
.gm-card p { margin: 0 0 16px; color: var(--ink-soft); font-size: 0.95rem; line-height: 1.45; flex: 1; }
.gm-card-meta {
  display: flex; gap: 12px; align-items: center;
  font-size: 0.82rem; color: var(--ink-faint);
}
.gm-card-streak { color: var(--accent); font-weight: 600; }

/* ── Game shell ────────────────────────────────────────────────────────────── */
.gm-shell {
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: 20px;
  box-shadow: var(--popup-shadow);
  overflow: hidden;
}

.gm-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--rule);
  flex-wrap: wrap;
}
.gm-title { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 1.1rem; }
.gm-title .gm-back { color: var(--ink-faint); text-decoration: none; font-size: 0.9rem; }
.gm-title .gm-back:hover { color: var(--accent); }

.gm-controls { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }

.gm-continent {
  font: inherit; font-size: 0.88rem; color: var(--ink);
  background: var(--bg-warm); border: 1px solid var(--rule);
  border-radius: 999px; padding: 7px 30px 7px 14px; cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23888' d='M2 4l4 4 4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center;
}
.gm-continent:hover { border-color: var(--accent); }

.gm-mode {
  display: inline-flex;
  background: var(--bg-warm);
  border-radius: 999px;
  padding: 3px;
}
.gm-mode button {
  border: 0; background: transparent; cursor: pointer;
  padding: 7px 16px; border-radius: 999px;
  font: inherit; font-size: 0.88rem; color: var(--ink-soft);
}
.gm-mode button[aria-pressed="true"] { background: var(--accent); color: #fff; font-weight: 600; }

.gm-scorebar {
  display: flex; gap: 26px; align-items: center;
  padding: 12px 20px;
  background: var(--bg-warm);
  font-size: 0.9rem;
}
.gm-stat { display: flex; flex-direction: column; line-height: 1.2; }
.gm-stat b { font-size: 1.25rem; }
.gm-stat span { color: var(--ink-faint); font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.04em; }
/* Question progress bar (fills across the 10 questions) */
.gm-progress { flex: 1; height: 8px; min-width: 80px; border-radius: 99px; overflow: hidden; background: color-mix(in srgb, var(--rule) 55%, var(--paper)); }
.gm-progress-fill { height: 100%; width: 10%; border-radius: 99px; background: linear-gradient(90deg, color-mix(in srgb, var(--accent) 72%, #fff), var(--accent)); transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1); }

.gm-stage { padding: 28px 20px 32px; }
.gm-prompt { text-align: center; font-size: 1.15rem; margin: 0 0 22px; color: var(--ink-soft);
  min-height: 2.8em; display: flex; align-items: center; justify-content: center; }
.gm-prompt strong { color: var(--ink); }

/* ── Buttons ───────────────────────────────────────────────────────────────── */
.gm-btn {
  border: 0; cursor: pointer; font: inherit; font-weight: 600;
  padding: 12px 22px; border-radius: 12px;
  background: var(--accent); color: #fff;
  transition: filter 0.15s ease;
}
.gm-btn:hover { filter: brightness(1.06); }
.gm-btn--ghost { background: var(--bg-warm); color: var(--ink); }
.gm-btn:disabled { opacity: 0.5; cursor: default; }

/* ── Option buttons (quiz / greeting) ──────────────────────────────────────── */
.gm-options { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; max-width: 520px; margin: 0 auto; }
.gm-option {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  border: 1px solid var(--rule); background: var(--paper); color: var(--ink);
  cursor: pointer; font: inherit; font-size: 1rem;
  padding: 16px; border-radius: 14px; text-align: center;
  transition: border-color 0.15s ease, background 0.15s ease, opacity 0.15s ease;
}
.gm-option:hover:not(:disabled) { border-color: var(--accent); }
.gm-option.is-correct { background: var(--green-soft); border-color: var(--green); color: var(--ink); }
.gm-option.is-wrong   { background: #f6dcd6; border-color: var(--accent); }
[data-theme="dark"] .gm-option.is-wrong { background: #3a1a14; }
.gm-option:disabled { cursor: default; }
.gm-option.is-hint-out { opacity: 0.3; }
/* Country flag on each greeting option */
.gm-option-flag { width: 26px; height: 20px; flex-shrink: 0; border-radius: 3px; object-fit: cover; box-shadow: 0 1px 2px rgba(0,0,0,0.2); }
.gm-option-flag--blank { display: inline-block; background: var(--bg-warm); box-shadow: none; }

/* ── Higher / Lower cards ──────────────────────────────────────────────────── */
.gm-versus { display: grid; grid-template-columns: 1fr auto 1fr; align-items: stretch; gap: 14px; max-width: 620px; margin: 0 auto; }
.gm-vcard {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px;
  border: 1px solid var(--rule); border-radius: 18px; padding: 26px 18px;
  background: var(--paper); cursor: pointer; text-align: center;
  transition: border-color 0.15s ease, transform 0.12s ease;
}
.gm-vcard:hover:not(.is-locked) { border-color: var(--accent); transform: translateY(-3px); }
.gm-vcard.is-locked { cursor: default; }
.gm-vcard img { width: 84px; height: auto; border-radius: 6px; box-shadow: 0 2px 8px rgba(0,0,0,0.18); }
.gm-vcard-name { font-weight: 700; font-size: 1.15rem; }
.gm-vcard-value { font-size: 1.4rem; font-weight: 800; color: var(--accent); min-height: 1.5em; opacity: 0; transition: opacity 0.2s ease; }
.gm-vcard.is-revealed .gm-vcard-value { opacity: 1; }
.gm-vcard.is-win  { border-color: var(--green); background: var(--green-soft); }
.gm-vcard.is-lose { border-color: var(--accent); opacity: 0.7; }
.gm-versus-mid { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; color: var(--ink-faint); }
.gm-versus-mid .gm-vs { font-weight: 800; font-size: 1.1rem; }
.gm-versus-q { text-align: center; font-size: 1.1rem; margin: 0 0 22px; }
.gm-versus-q strong { color: var(--accent); }

/* ── Greeting audio button ─────────────────────────────────────────────────── */
.gm-audio-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  width: 96px; height: 96px; border-radius: 50%;
  border: 0; cursor: pointer; margin: 0 auto 24px; font-size: 2.2rem;
  background: var(--accent); color: #fff;
  box-shadow: 0 8px 24px -8px var(--accent);
}
.gm-audio-btn:hover { filter: brightness(1.06); }
.gm-audio-wrap { display: flex; justify-content: center; }

/* Waveform-flanked play button */
.gm-audio-wrap--wave { align-items: center; gap: 14px; margin-bottom: 24px; }
.gm-audio-wrap--wave .gm-audio-btn {
  margin: 0; flex-shrink: 0;
  box-shadow: 0 14px 34px -10px color-mix(in srgb, var(--accent) 75%, transparent),
              0 0 0 10px color-mix(in srgb, var(--accent) 12%, transparent);
  transition: transform 0.15s ease, box-shadow 0.2s ease, filter 0.15s ease;
}
.gm-audio-wrap--wave .gm-audio-btn:hover  { transform: scale(1.04); }
.gm-audio-wrap--wave .gm-audio-btn:active { transform: scale(0.97); }
.gm-wave { flex: 1; max-width: 190px; height: 56px; color: color-mix(in srgb, var(--ink-faint) 80%, transparent); }
.gm-wave svg { width: 100%; height: 100%; display: block; }
.gm-wave--r { transform: scaleX(-1); }
/* Bars ripple while a clip is playing, and tint to the accent colour. */
.gm-audio-wrap--wave.is-playing .gm-wave { color: color-mix(in srgb, var(--accent) 70%, var(--ink-faint)); }
.gm-audio-wrap--wave.is-playing .gm-wave rect {
  transform-box: fill-box;
  transform-origin: center;
  animation: gm-wave-pulse 0.8s ease-in-out infinite;
}
@keyframes gm-wave-pulse {
  0%, 100% { transform: scaleY(0.4); }
  50%      { transform: scaleY(1.15); }
}
@media (prefers-reduced-motion: reduce) {
  .gm-audio-wrap--wave.is-playing .gm-wave rect { animation: none; }
}

/* "Need a hint?" panel */
.gm-hint {
  display: flex; align-items: center; gap: 14px;
  max-width: 520px; margin: 18px auto 0;
  padding: 12px 14px; border-radius: 14px;
  background: color-mix(in srgb, var(--bg-warm) 55%, var(--paper));
  border: 1px solid var(--rule);
}
.gm-hint[hidden] { display: none; }
.gm-hint-ic { width: 42px; height: 42px; flex-shrink: 0; border-radius: 12px; display: grid; place-items: center; background: var(--paper); color: var(--accent); box-shadow: 0 2px 6px -3px rgba(26,58,92,0.2); }
.gm-hint-ic svg { width: 22px; height: 22px; }
.gm-hint-txt { flex: 1; min-width: 0; text-align: left; }
.gm-hint-txt b { display: block; font-size: 0.96rem; }
.gm-hint-txt span { font-size: 0.82rem; color: var(--ink-soft); }
.gm-hint-actions { display: flex; align-items: center; gap: 12px; flex-shrink: 0; }
.gm-coins { display: inline-flex; align-items: center; gap: 6px; font-weight: 800; font-size: 0.9rem; color: var(--ink-soft); }
.gm-coins i { width: 16px; height: 16px; border-radius: 50%; background: radial-gradient(circle at 35% 30%, #ffe08a, #f5b324); box-shadow: inset 0 0 0 1.5px #e09b16; font-style: normal; }
.gm-hint-btn {
  border: 1px solid var(--rule); background: var(--paper); color: var(--ink);
  font: inherit; font-weight: 700; font-size: 0.85rem; padding: 8px 14px; border-radius: 10px; cursor: pointer;
  transition: background 0.14s ease, border-color 0.14s ease;
}
.gm-hint-btn:hover:not(:disabled) { border-color: var(--accent); background: var(--bg-warm); }
.gm-hint-btn:disabled { opacity: 0.5; cursor: default; }
@media (max-width: 560px) { .gm-hint { flex-wrap: wrap; } }

/* ── Result modal ──────────────────────────────────────────────────────────── */
.gm-result {
  position: fixed; inset: 0; z-index: 1000;
  display: none; align-items: center; justify-content: center;
  background: rgba(8, 22, 38, 0.55); padding: 20px;
}
.gm-result.is-open { display: flex; }
.gm-result-box {
  background: var(--paper); border-radius: 20px; padding: 30px;
  width: 100%; max-width: 400px; text-align: center;
  box-shadow: var(--popup-shadow);
}
.gm-result-box h2 { margin: 0 0 6px; }
.gm-result-score { font-size: 2.6rem; font-weight: 800; color: var(--accent); margin: 8px 0; }
.gm-result-grid { font-size: 1.5rem; letter-spacing: 2px; margin: 12px 0 4px; line-height: 1.5; }
.gm-result-sub { color: var(--ink-soft); margin: 4px 0 20px; }
.gm-result-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.gm-toast {
  position: fixed; bottom: 26px; left: 50%; transform: translateX(-50%);
  background: var(--ink); color: var(--bg); padding: 10px 18px; border-radius: 10px;
  font-size: 0.9rem; opacity: 0; pointer-events: none; transition: opacity 0.2s ease; z-index: 1100;
}
.gm-toast.is-show { opacity: 1; }

/* ── Mode / date bar ───────────────────────────────────────────────────────── */
.gm-modebar {
  text-align: center;
  padding: 12px 20px 0;
  font-size: 0.92rem;
  color: var(--ink-soft);
}
.gm-daily-tag {
  color: var(--accent);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* ── "Daily already played" inline panel (no modal on revisit) ─────────────── */
.gm-done {
  max-width: 420px; margin: 8px auto 0; text-align: center;
  background: var(--paper); border: 1px solid var(--rule); border-radius: 18px;
  padding: 26px 24px; box-shadow: var(--popup-shadow);
}
.gm-done[hidden] { display: none; }
.gm-done-tag {
  color: var(--green); font-weight: 700; font-size: 0.95rem;
  text-transform: uppercase; letter-spacing: 0.05em;
}
.gm-done-grid { font-size: 1.4rem; letter-spacing: 2px; margin: 14px 0 6px; line-height: 1.5; }
.gm-done-score { font-size: 2.2rem; font-weight: 800; color: var(--accent); margin: 2px 0; }
.gm-done-sub { color: var(--ink-soft); margin: 6px 0 0; }
.gm-done-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin: 20px 0 14px; }
.gm-done-next { color: var(--ink-faint); font-size: 0.85rem; margin: 0; }
.gm-done-next b { color: var(--ink-soft); }
/* On the full-bleed map game, float the panel over the map. */
.gm-locate-stage .gm-done {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
  z-index: 7; width: calc(100% - 32px);
}

/* ── Per-answer feedback ───────────────────────────────────────────────────── */
.gm-feedback {
  text-align: center;
  font-size: 1.12rem;
  font-weight: 700;
  margin: 18px 0 0;
}
.gm-feedback[hidden] { display: none; }
.gm-feedback.is-correct { color: var(--green); }
.gm-feedback.is-wrong   { color: var(--accent); }
/* Reserve the feedback + Next zone so revealing them doesn't shift the card. */
.gm-answer-foot {
  min-height: 108px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px;
}
.gm-answer-foot .gm-feedback { margin: 0; }
.gm-answer-foot .gm-next-wrap { margin-top: 0; }

/* Checkmark / cross on the revealed answer */
.gm-option.is-correct::before { content: '✓ '; font-weight: 800; }
.gm-option.is-wrong::before   { content: '✗ '; font-weight: 800; }
.gm-vcard.is-win .gm-vcard-name::before { content: '✓ '; color: var(--green); font-weight: 800; }

/* ── Next button (advance on user action) ──────────────────────────────────── */
.gm-next-wrap { text-align: center; margin-top: 24px; }
.gm-next[hidden] { display: none; }
.gm-locate-next {

  position: absolute; bottom: calc(24px + env(safe-area-inset-bottom, 0px));
  left: 50%; transform: translateX(-50%);
  z-index: 7;
  box-shadow: 0 6px 20px rgba(0,0,0,0.18);
}
.gm-locate-next[hidden] { display: none; }
/* Touch confirm step: tap a country, then tap this to commit the guess. */
.gm-locate-confirm { max-width: calc(100% - 32px); }

/* ── Locate (full-bleed map) ───────────────────────────────────────────────── */
.gm-locate-page { height: 100%; display: flex; flex-direction: column; background: var(--bg); }
.gm-locate-page .gm-topbar { background: var(--paper); }

.gm-locate-page .gm-scorebar { border-bottom: 1px solid var(--rule); padding: 6px 20px; gap: 22px; }
.gm-locate-page .gm-stat { flex-direction: row; align-items: baseline; gap: 6px; }
.gm-locate-page .gm-stat b { font-size: 1.05rem; }
.gm-locate-page .gm-stat span { font-size: 0.66rem; }
.gm-locate-stage { position: relative; flex: 1; min-height: 0; }
.gm-locate-map { position: absolute; inset: 0; }
.gm-locate-banner {
  position: absolute; top: 18px; left: 50%; transform: translateX(-50%);
  z-index: 5; max-width: calc(100% - 32px);
  background: var(--paper); border: 1px solid var(--rule); border-radius: 14px;
  padding: 12px 22px; box-shadow: var(--popup-shadow);
  font-size: 1.05rem; text-align: center; color: var(--ink);
}
.gm-locate-banner strong { color: var(--accent); }
.gm-locate-banner.is-correct { border-color: var(--green); }
.gm-locate-banner.is-wrong { border-color: var(--accent); }

/* Country name that follows the cursor over the map */
.gm-locate-hover {
  position: absolute; z-index: 6; pointer-events: none;
  transform: translate(14px, 14px);
  background: var(--ink); color: var(--bg);
  padding: 4px 10px; border-radius: 8px;
  font-size: 0.9rem; font-weight: 600; white-space: nowrap;
  box-shadow: 0 4px 14px rgba(0,0,0,0.3);
}
.gm-locate-hover[hidden] { display: none; }

/* ── Desktop: give the games real presence ─────────────────────────────────── */
@media (min-width: 760px) {
  .gm-shell .gm-stage { padding: 52px 36px 60px; }

  .gm-versus { max-width: 780px; gap: 24px; }
  .gm-vcard { padding: 44px 28px; gap: 18px; }
  .gm-vcard img { width: 136px; }
  .gm-vcard-name { font-size: 1.55rem; }
  .gm-vcard-value { font-size: 1.95rem; }
  .gm-versus-q { font-size: 1.55rem; margin-bottom: 36px; }
  .gm-versus-mid .gm-vs { font-size: 1.4rem; }

  .gm-prompt { font-size: 1.5rem; margin-bottom: 34px; }
  .gm-options { max-width: 660px; gap: 16px; }
  .gm-option { padding: 24px; font-size: 1.25rem; }
  .gm-audio-btn { width: 132px; height: 132px; font-size: 3rem; margin-bottom: 34px; }

  .gm-scorebar { padding: 16px 36px; font-size: 1rem; }
  .gm-stat b { font-size: 1.55rem; }
  .gm-topbar { padding: 18px 28px; }
  .gm-title { font-size: 1.25rem; }

  .gm-controls { gap: 16px; }
  .gm-continent { font-size: 1rem; padding: 11px 38px 11px 18px; }
  .gm-continent { background-position: right 16px center; }
  .gm-mode { padding: 4px; }
  .gm-mode button { font-size: 1rem; padding: 10px 22px; }
}

@media (max-width: 560px) {
  .gm-options { grid-template-columns: 1fr; }
  .gm-versus { grid-template-columns: 1fr; }
  .gm-versus-mid { flex-direction: row; gap: 12px; }
  .gm-locate-banner { font-size: 0.95rem; padding: 10px 16px; }
}
