:root {
  --bg: #fff7e6;
  --ink: #2b2d42;
  --muted: #6b6f85;
  --card: #ffffff;
  --ocean: #8fd3f4;
  --ocean-deep: #5fb7e5;
  --accent: #ff7b54;
  --accent-2: #7b61ff;
  --good: #2ec27e;
  --bad: #ff5d5d;
  --gold: #ffc93c;
  --shadow: 0 6px 0 rgba(0, 0, 0, 0.12);
  --radius: 22px;
  --font: 'Baloo 2', 'Comic Sans MS', 'Chalkboard SE', system-ui, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}

button {
  font-family: inherit;
  color: inherit;
  cursor: pointer;
  border: none;
  -webkit-user-select: none;
  user-select: none;
  touch-action: manipulation;
}

[hidden] { display: none !important; }

.screen {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
}

/* ---------------- Ecran principal ---------------- */
.home {
  overflow-y: auto;
  background:
    radial-gradient(circle at 15% 20%, #ffe0a3 0 80px, transparent 81px),
    radial-gradient(circle at 85% 80%, #c7f0ff 0 120px, transparent 121px),
    var(--bg);
}

.home-inner, .setup-inner {
  width: 100%;
  max-width: 900px;
  margin: auto;
  padding: 24px 16px 32px;
  text-align: center;
}

.globe {
  font-size: clamp(64px, 16vw, 110px);
  line-height: 1;
  animation: spin-bob 4s ease-in-out infinite;
}

@keyframes spin-bob {
  0%, 100% { transform: translateY(0) rotate(-8deg); }
  50% { transform: translateY(-12px) rotate(8deg); }
}

.title {
  margin: 8px 0 0;
  font-size: clamp(34px, 8vw, 64px);
  font-weight: 800;
  line-height: 1;
  color: var(--accent-2);
  text-shadow: 3px 3px 0 #ffd6a5;
}

.title span { color: var(--accent); }

.subtitle {
  font-size: clamp(18px, 4vw, 24px);
  color: var(--muted);
  margin: 12px 0;
}

.total-stars {
  display: inline-block;
  background: var(--gold);
  padding: 4px 18px;
  border-radius: 999px;
  font-size: 22px;
  font-weight: 800;
  box-shadow: var(--shadow);
  margin-bottom: 20px;
}

.mode-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
}

.mode-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 20px 12px;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  color: #fff;
  transition: transform 0.12s;
}

.mode-btn:active { transform: translateY(4px); box-shadow: none; }
.mode-btn.find { background: linear-gradient(160deg, #ff9a62, #ff6b6b); }
.mode-btn.capitals { background: linear-gradient(160deg, #9b8cff, #6a4cff); }
.mode-btn.explore { background: linear-gradient(160deg, #3ed6a0, #1fa37a); }
.mode-emoji { font-size: 54px; line-height: 1.1; }
.mode-name { font-size: 28px; font-weight: 800; }
.mode-desc { font-size: 17px; opacity: 0.95; }

/* ---------------- Alege regiunea ---------------- */
.setup { overflow-y: auto; }
.setup-inner { position: relative; }
.setup h2 { font-size: clamp(26px, 6vw, 40px); margin: 8px 0 16px; padding: 0 64px; color: var(--accent-2); text-wrap: balance; }
.setup h3 { font-size: 26px; margin: 24px 0 10px; }

.back-btn {
  position: absolute;
  left: 16px;
  top: 20px;
  font-size: 30px;
  background: var(--card);
  border-radius: 16px;
  width: 56px;
  height: 56px;
  box-shadow: var(--shadow);
}

.region-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
}

.region-btn, .level-btn {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 12px 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  font-size: 20px;
  font-weight: 700;
  border: 4px solid transparent;
  transition: transform 0.12s;
}

.region-btn .emoji { font-size: 44px; line-height: 1.1; }
.region-btn.selected, .level-btn.selected {
  border-color: var(--accent);
  background: #fff1e8;
  transform: scale(1.04);
}

.level-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.level-btn { font-size: 24px; }
.level-btn span { font-size: 20px; }

.play-btn {
  margin-top: 24px;
  background: var(--accent);
  color: #fff;
  font-size: 30px;
  font-weight: 800;
  padding: 10px 40px;
  border-radius: 999px;
  box-shadow: 0 6px 0 #d8572f;
}

.play-btn:active { transform: translateY(4px); box-shadow: none; }
.play-btn.secondary { background: var(--accent-2); box-shadow: 0 6px 0 #4b33c9; }

/* ---------------- Jocul ---------------- */
.game { background: var(--ocean-deep); }

.topbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: var(--bg);
}

.icon-btn {
  background: var(--card);
  border-radius: 14px;
  width: 48px;
  height: 48px;
  font-size: 24px;
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.12);
  flex: none;
  display: grid;
  place-items: center;
}

.icon-btn:active { transform: translateY(3px); box-shadow: none; }

.progress {
  flex: 1;
  display: flex;
  gap: 6px;
  justify-content: center;
  flex-wrap: wrap;
}

.progress .dot {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #e8e2d6;
  display: grid;
  place-items: center;
  font-size: 12px;
}

.progress .dot.current { outline: 3px solid var(--accent); }
.progress .dot.star { background: var(--gold); }
.progress .dot.helped { background: #b9e6c9; }

.score {
  font-size: 24px;
  font-weight: 800;
  background: var(--gold);
  border-radius: 999px;
  padding: 0 14px;
  min-width: 72px;
  text-align: center;
}

.prompt {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0 12px 8px;
  padding: 8px 12px;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  flex-wrap: wrap;
}

.flag {
  width: 84px;
  height: 56px;
  flex: none;
  display: grid;
  place-items: center;
  font-size: 48px;
  line-height: 1;
}

.flag img {
  max-width: 100%;
  max-height: 100%;
  border-radius: 6px;
  box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.08);
}

.prompt-text { flex: 1; min-width: 160px; }
.prompt-small { font-size: 18px; color: var(--muted); line-height: 1.1; }
.prompt-big {
  font-size: clamp(26px, 6vw, 40px);
  font-weight: 800;
  line-height: 1.05;
  color: var(--accent-2);
}
.prompt-extra { font-size: 20px; line-height: 1.2; }
.prompt-extra b { color: var(--accent); }

.next-btn {
  background: var(--good);
  color: #fff;
  font-size: 24px;
  font-weight: 800;
  border-radius: 999px;
  padding: 6px 22px;
  box-shadow: 0 5px 0 #1f8f5b;
  animation: pop 0.4s ease-out, wiggle 1.6s ease-in-out 1.5s infinite;
}

.next-btn:active { transform: translateY(4px); box-shadow: none; }

@keyframes pop { from { transform: scale(0.3); } to { transform: scale(1); } }
@keyframes wiggle {
  0%, 100% { transform: rotate(0); }
  10% { transform: rotate(-4deg); }
  20% { transform: rotate(4deg); }
  30% { transform: rotate(0); }
}

.answers {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin: 0 12px 8px;
}

.answer-btn {
  background: var(--card);
  border-radius: 18px;
  font-size: clamp(18px, 4.5vw, 28px);
  font-weight: 800;
  padding: 10px 6px;
  box-shadow: var(--shadow);
  border: 4px solid transparent;
  line-height: 1.1;
}

.answer-btn:active { transform: translateY(4px); box-shadow: none; }
.answer-btn.right { background: var(--good); color: #fff; border-color: #1f8f5b; }
.answer-btn.wrong { background: #ffe1e1; color: #b04040; animation: shake 0.4s; opacity: 0.7; }

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-8px); }
  75% { transform: translateX(8px); }
}

.map-wrap {
  position: relative;
  flex: 1;
  min-height: 0;
  background: var(--ocean-deep);
  overflow: hidden;
}

#map {
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  cursor: grab;
}

#map .sphere { fill: var(--ocean); }
#map .graticule { fill: none; stroke: #ffffff; stroke-opacity: 0.25; stroke-width: 0.6px; vector-effect: non-scaling-stroke; }

#map .country {
  stroke: #ffffff;
  stroke-width: 0.8px;
  vector-effect: non-scaling-stroke;
  cursor: pointer;
  transition: fill 0.25s;
}

#map .country:hover { filter: brightness(1.08); }
#map .country.found { fill: #8ee4af !important; }
#map .country.correct { fill: var(--good) !important; }
#map .country.wrong { fill: var(--bad) !important; }
#map .country.target { fill: var(--gold) !important; stroke: #b87d00; stroke-width: 2px; }
#map .country.selected { fill: var(--gold) !important; stroke: #b87d00; stroke-width: 2px; }
#map .country.hint { animation: blink 0.7s ease-in-out infinite; stroke: #b87d00; stroke-width: 2px; }

@keyframes blink {
  0%, 100% { fill: var(--gold); }
  50% { fill: #ff8a3d; }
}

#map .label text {
  font-family: var(--font);
  font-weight: 800;
  paint-order: stroke;
  stroke: #ffffff;
  stroke-width: 5px;
  stroke-linejoin: round;
  text-anchor: middle;
  pointer-events: none;
}

#map .label .country-name { font-size: 22px; fill: var(--ink); }
#map .label .country-name.bad { fill: #c23a3a; }
#map .label .capital-name { font-size: 17px; fill: #7a2cff; }
#map .label .capital-dot { fill: #7a2cff; stroke: #fff; stroke-width: 3px; }
#map .label { pointer-events: none; animation: label-in 0.35s ease-out; }

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

.map-controls {
  position: absolute;
  right: 12px;
  bottom: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.hint-btn { background: #fff4c2; }

.toast {
  position: absolute;
  left: 50%;
  bottom: 16px;
  transform: translateX(-50%);
  background: rgba(43, 45, 66, 0.9);
  color: #fff;
  font-size: 22px;
  font-weight: 700;
  padding: 6px 18px;
  border-radius: 999px;
  max-width: calc(100% - 100px);
  text-align: center;
  pointer-events: none;
}

/* ---------------- Sfârșit de rundă ---------------- */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(43, 45, 66, 0.55);
  display: grid;
  place-items: center;
  padding: 16px;
  z-index: 10;
}

.end-card {
  background: var(--card);
  border-radius: 28px;
  padding: 24px 20px;
  text-align: center;
  max-width: 480px;
  width: 100%;
  box-shadow: 0 10px 0 rgba(0, 0, 0, 0.15);
  animation: pop 0.45s ease-out;
}

.trophy { font-size: 90px; line-height: 1; animation: spin-bob 2.5s ease-in-out infinite; }
.end-card h2 { font-size: 36px; margin: 8px 0 0; color: var(--accent-2); }
.end-card p { font-size: 22px; margin: 6px 0; }
.end-stars { font-size: 34px; letter-spacing: 2px; word-break: break-all; }
.end-buttons { display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; }
.end-buttons .play-btn { font-size: 24px; padding: 8px 24px; }

#confetti {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 20;
}

/* Ecrane mici în mod peisaj: comprimăm antetul */
@media (max-height: 500px) {
  .topbar { padding: 4px 8px; }
  .icon-btn { width: 40px; height: 40px; font-size: 20px; }
  .prompt { margin-bottom: 4px; padding: 4px 10px; }
  .flag { width: 60px; height: 40px; font-size: 34px; }
  .prompt-big { font-size: 26px; }
  .answer-btn { padding: 4px; }
}

@media (max-width: 520px) {
  .prompt { gap: 8px; }
  .flag { width: 64px; height: 44px; font-size: 38px; }
  .next-btn { width: 100%; }
  .answers { gap: 6px; }
  .progress { gap: 4px; }
  .progress .dot { width: 13px; height: 13px; }
  .score { font-size: 20px; min-width: 60px; padding: 0 10px; }
}
