/* Flags Game — quiet & happy. Hand-edited. */

:root {
  /* calm, warm pastel palette */
  --bg1: #fdf3e7;     /* warm cream */
  --bg2: #eaf4f4;     /* soft mint sky */
  --bg3: #f6ecfb;     /* faint lavender */
  --card: #ffffff;
  --ink: #4a4453;     /* soft charcoal, never pure black */
  --ink-soft: #8a8392;
  --accent: #ff9d8a;  /* gentle coral */
  --accent-deep: #f57e6b;
  --teal: #6fc7bb;    /* soft teal */
  --teal-deep: #4fb0a3;
  --sun: #ffd36e;     /* warm star yellow */
  --good: #8bd49b;    /* gentle green */
  --good-deep: #5fb878;
  --bad: #f6a5a5;     /* soft, non-alarming red */
  --bad-deep: #e87f7f;

  --radius: 26px;
  --radius-sm: 18px;
  --shadow: 0 10px 30px rgba(120, 100, 130, 0.16);
  --shadow-sm: 0 6px 16px rgba(120, 100, 130, 0.14);
  --font-display: "Fredoka", system-ui, sans-serif;
  --font-body: "Nunito", system-ui, sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  height: 100%;
}

body {
  font-family: var(--font-body);
  color: var(--ink);
  background: linear-gradient(160deg, var(--bg1) 0%, var(--bg2) 55%, var(--bg3) 100%);
  background-attachment: fixed;
  min-height: 100%;
  overflow-x: hidden;
  text-align: center;
  -webkit-font-smoothing: antialiased;
}

/* ── floating background stars ─────────────────────────────────────────── */
#sky {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}
.twinkle {
  position: absolute;
  font-size: 1rem;
  opacity: 0;
  animation: twinkle var(--dur, 4s) ease-in-out infinite;
  animation-delay: var(--delay, 0s);
  will-change: transform, opacity;
}
@keyframes twinkle {
  0%, 100% { opacity: 0; transform: scale(0.6) translateY(0); }
  50%      { opacity: 0.85; transform: scale(1) translateY(-8px); }
}

/* ── app + screens ─────────────────────────────────────────────────────── */
#app {
  position: relative;
  z-index: 1;
  max-width: 760px;
  margin: 0 auto;
  padding: clamp(18px, 4vw, 36px);
  min-height: 100%;
}

.screen {
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: clamp(16px, 3vh, 28px);
  min-height: 100vh;
  min-height: 100dvh;
}
.screen.active {
  display: flex;
  animation: screen-in 0.45s ease both;
}
@keyframes screen-in {
  from { opacity: 0; transform: translateY(14px) scale(0.99); }
  to   { opacity: 1; transform: none; }
}

.name { color: var(--accent-deep); white-space: nowrap; }

/* ── welcome ───────────────────────────────────────────────────────────── */
.welcome-stars { position: absolute; inset: 0; pointer-events: none; }
.hello {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(2.4rem, 9vw, 4rem);
  line-height: 1.05;
  letter-spacing: -0.5px;
}
.wave { display: inline-block; animation: wave 2.2s ease-in-out infinite; transform-origin: 70% 70%; }
@keyframes wave {
  0%, 60%, 100% { transform: rotate(0deg); }
  10% { transform: rotate(16deg); }
  20% { transform: rotate(-8deg); }
  30% { transform: rotate(16deg); }
  40% { transform: rotate(-4deg); }
  50% { transform: rotate(10deg); }
}
.tagline {
  font-size: clamp(1.1rem, 4vw, 1.5rem);
  color: var(--ink-soft);
}
.tagline strong { color: var(--teal-deep); }
.hint { font-size: 0.95rem; color: var(--ink-soft); margin-top: -6px; }

/* ── big buttons ───────────────────────────────────────────────────────── */
.big-btn {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(1.2rem, 4.5vw, 1.6rem);
  color: #fff;
  border: none;
  border-radius: 999px;
  padding: clamp(14px, 2.6vh, 20px) clamp(28px, 7vw, 44px);
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-deep) 100%);
  box-shadow: 0 12px 24px rgba(245, 126, 107, 0.4);
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease, filter 0.12s ease;
  display: inline-flex;
  align-items: center;
  gap: 0.5em;
  touch-action: manipulation;
}
.big-btn:hover { filter: brightness(1.03); }
.big-btn:active { transform: scale(0.95); box-shadow: 0 6px 14px rgba(245, 126, 107, 0.4); }
.big-btn.soft {
  background: linear-gradient(135deg, var(--teal) 0%, var(--teal-deep) 100%);
  box-shadow: 0 12px 24px rgba(79, 176, 163, 0.4);
}
.big-btn.play { animation: breathe 2.6s ease-in-out infinite; }
@keyframes breathe {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.045); }
}
.big-btn-icon { font-size: 1.1em; }

.hidden { display: none !important; }

/* ── menu ──────────────────────────────────────────────────────────────── */
.menu-title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(1.6rem, 6vw, 2.4rem);
}
.pill-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
}
.mode-pill {
  font-family: var(--font-display);
  font-size: clamp(0.95rem, 3.4vw, 1.1rem);
  border: 2px solid transparent;
  background: #fff;
  color: var(--ink-soft);
  border-radius: 999px;
  padding: 10px 18px;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: transform 0.12s ease, color 0.12s ease, border-color 0.12s ease;
}
.mode-pill:active { transform: scale(0.95); }
.mode-pill.active {
  color: var(--teal-deep);
  border-color: var(--teal);
  background: #f1faf8;
}

.cat-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: clamp(12px, 3vw, 18px);
  width: 100%;
  max-width: 560px;
}
@media (min-width: 560px) {
  .cat-grid { grid-template-columns: repeat(2, 1fr); }
}
.cat-card {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: clamp(1rem, 3.6vw, 1.25rem);
  background: var(--card);
  border: none;
  border-radius: var(--radius);
  padding: clamp(16px, 4vw, 24px) 12px;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  color: var(--ink);
  transition: transform 0.14s ease, box-shadow 0.14s ease;
}
.cat-card:hover { transform: translateY(-3px); box-shadow: var(--shadow); }
.cat-card:active { transform: scale(0.96); }
.cat-emoji { font-size: clamp(2.2rem, 9vw, 3rem); line-height: 1; }
.cat-card.full { grid-column: 1 / -1; }
.cat-count {
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 0.82rem;
  color: var(--ink-soft);
}

/* ── game ──────────────────────────────────────────────────────────────── */
.game-top {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  max-width: 560px;
}
.icon-btn {
  font-size: 1.5rem;
  background: #fff;
  border: none;
  border-radius: 50%;
  width: 52px;
  height: 52px;
  flex: 0 0 auto;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: transform 0.12s ease;
}
.icon-btn:active { transform: scale(0.92); }
.progress-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 0;
}
.set-label {
  font-family: var(--font-display);
  font-size: 0.9rem;
  color: var(--ink-soft);
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.progress-bar {
  height: 12px;
  background: #ffffff;
  border-radius: 999px;
  overflow: hidden;
  box-shadow: inset 0 1px 3px rgba(120, 100, 130, 0.18);
}
.progress-fill {
  height: 100%;
  width: 0;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--teal) 0%, var(--teal-deep) 100%);
  transition: width 0.4s ease;
}
.score-pill {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.15rem;
  background: #fff;
  border-radius: 999px;
  padding: 8px 14px;
  flex: 0 0 auto;
  box-shadow: var(--shadow-sm);
  color: var(--ink);
}
.score-pill.bump { animation: pop 0.5s ease; }
@keyframes pop {
  0% { transform: scale(0.4) rotate(-20deg); }
  60% { transform: scale(1.4) rotate(10deg); }
  100% { transform: scale(1) rotate(0); }
}

.prompt {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: clamp(1.3rem, 5.5vw, 2rem);
  min-height: 1.2em;
}

.question { display: flex; justify-content: center; align-items: center; width: 100%; }

/* big flag shown in flag->name mode */
.flag-big {
  width: min(78vw, 340px);
  aspect-ratio: 3 / 2;
  object-fit: cover;
  border-radius: 16px;
  box-shadow: var(--shadow);
  border: 3px solid #fff;
  background: #fff;
  animation: drop-in 0.5s ease both;
}
@keyframes drop-in {
  from { opacity: 0; transform: translateY(-12px) scale(0.96); }
  to { opacity: 1; transform: none; }
}

/* big country name shown in name->flag mode */
.country-big {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(2rem, 8vw, 3.2rem);
  color: var(--teal-deep);
  padding: 8px 4px;
  animation: drop-in 0.5s ease both;
}

/* choices */
.choices {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: clamp(10px, 2.6vw, 16px);
  width: 100%;
  max-width: 560px;
}
.choices.names { grid-template-columns: 1fr 1fr; }
.choice {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: clamp(1rem, 4vw, 1.3rem);
  background: var(--card);
  color: var(--ink);
  border: 3px solid transparent;
  border-radius: var(--radius-sm);
  padding: clamp(14px, 3.4vw, 20px) 10px;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: transform 0.12s ease, box-shadow 0.12s ease, border-color 0.2s ease, background 0.2s ease;
  min-height: 64px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.choice:active { transform: scale(0.96); }
/* soft gray outline on hover (before it's answered) — clear "you can pick this" cue */
.choice:not(:disabled):hover {
  border-color: #cfc8d6;
  box-shadow: var(--shadow);
}
.choice.flag { padding: 8px; }
.choice.flag img {
  width: 100%;
  aspect-ratio: 3 / 2;
  object-fit: cover;
  border-radius: 10px;
  border: 2px solid #f0eef2;
  display: block;
}
.choice.correct {
  border-color: var(--good-deep);
  background: #effaf1;
  animation: pop 0.5s ease;
}
.choice.wrong {
  border-color: var(--bad-deep);
  background: #fdeeee;
  animation: shake 0.45s ease;
}
.choice.reveal { border-color: var(--good-deep); background: #effaf1; }
.choice.dim { opacity: 0.5; }
.choice[disabled] { cursor: default; }
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-8px); }
  40% { transform: translateX(8px); }
  60% { transform: translateX(-5px); }
  80% { transform: translateX(5px); }
}

.feedback {
  font-family: var(--font-display);
  font-size: clamp(1.1rem, 4.4vw, 1.5rem);
  min-height: 1.5em;
  font-weight: 500;
}
.feedback.good { color: var(--good-deep); }
.feedback.bad { color: var(--bad-deep); }

/* ── win ───────────────────────────────────────────────────────────────── */
.win-burst { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.win-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(2rem, 8vw, 3.2rem);
}
.win-score {
  font-size: clamp(1.2rem, 5vw, 1.7rem);
  color: var(--ink-soft);
}
.win-buttons { display: flex; flex-wrap: wrap; gap: 14px; justify-content: center; }

/* ── try again (after 3 misses in a row) — calm, hopeful, not a "game over" ── */
.retry-sky { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.retry-emoji {
  font-size: clamp(3rem, 14vw, 5rem);
  line-height: 1;
  animation: breathe 2.6s ease-in-out infinite;
}

/* a burst sparkle (used on win + correct) */
.spark {
  position: absolute;
  font-size: 1.4rem;
  animation: spark-fly 1.1s ease-out forwards;
  pointer-events: none;
}
@keyframes spark-fly {
  0% { opacity: 0; transform: translate(0, 0) scale(0.3); }
  30% { opacity: 1; }
  100% { opacity: 0; transform: translate(var(--dx), var(--dy)) scale(1.1); }
}

/* ── daily play-time limit curtain (timer.js) ──────────────────────────── */
.time-lock {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: linear-gradient(160deg, rgba(44, 33, 64, 0.88), rgba(30, 41, 74, 0.93));
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  animation: lock-in 0.5s ease both;
}
@keyframes lock-in {
  from { opacity: 0; }
  to { opacity: 1; }
}
.time-lock-card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 38px 30px;
  max-width: 360px;
  width: 100%;
}
.time-lock-moon {
  font-size: 4rem;
  line-height: 1;
  margin-bottom: 6px;
}
.time-lock-title {
  font-family: var(--font-display);
  color: var(--ink);
  font-size: 1.7rem;
  margin-bottom: 14px;
}
.time-lock-msg {
  color: var(--ink);
  font-size: 1.15rem;
  line-height: 1.5;
}
.time-lock-name {
  color: var(--accent-deep);
  font-weight: 800;
}
.time-lock-when {
  color: var(--ink-soft);
  margin-top: 16px;
  font-size: 1rem;
}

/* ── motion-sensitive users ────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}
