*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0f1117;
  --surface: #1a1d2e;
  --border: #2a2d3e;
  --text: #e8eaf0;
  --muted: #7b7f96;
  --accent-1: #4f8ef7;
  --accent-2: #f7824f;
  --accent-3: #4fd4a0;
  --radius: 16px;
  --shadow: 0 8px 32px rgba(0,0,0,0.4);
}

html, body {
  height: 100%;
  font-family: 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

/* ── Layout ── */
#app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

header {
  text-align: center;
  padding: 2.5rem 1rem 1rem;
}

header h1 {
  font-size: clamp(2rem, 6vw, 3.5rem);
  font-weight: 800;
  letter-spacing: -1px;
  background: linear-gradient(135deg, var(--accent-1), var(--accent-3));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

header p {
  color: var(--muted);
  font-size: 1.05rem;
  margin-top: 0.4rem;
}

main {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem 1rem;
  gap: 1.5rem;
}

/* ── Screens ── */
.screen { display: none; width: 100%; max-width: 900px; }
.screen.active { display: flex; flex-direction: column; align-items: center; }

/* ── Home cards ── */
#home-screen {
  flex-direction: row;
  flex-wrap: wrap;
  justify-content: center;
  gap: 1.5rem;
}

.game-card {
  flex: 1 1 260px;
  max-width: 280px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem 1.5rem;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s;
  box-shadow: var(--shadow);
  text-align: center;
  user-select: none;
}

.game-card:hover {
  transform: translateY(-6px);
  box-shadow: 0 16px 48px rgba(0,0,0,0.5);
}

.game-card:nth-child(1) { border-top: 4px solid var(--accent-1); }
.game-card:nth-child(1):hover { border-color: var(--accent-1); }
.game-card:nth-child(2) { border-top: 4px solid var(--accent-2); }
.game-card:nth-child(2):hover { border-color: var(--accent-2); }
.game-card:nth-child(3) { border-top: 4px solid var(--accent-3); }
.game-card:nth-child(3):hover { border-color: var(--accent-3); }

.game-card .icon {
  font-size: 3rem;
  margin-bottom: 1rem;
  display: block;
}

.game-card h2 {
  font-size: 1.3rem;
  font-weight: 700;
  margin-bottom: 0.6rem;
}

.game-card p {
  color: var(--muted);
  font-size: 0.9rem;
}

/* ── Back button ── */
.btn-back {
  background: none;
  border: 1px solid var(--border);
  color: var(--muted);
  padding: 0.5rem 1.2rem;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.9rem;
  margin-bottom: 1.5rem;
  transition: color 0.2s, border-color 0.2s;
  align-self: flex-start;
}

.btn-back:hover { color: var(--text); border-color: var(--text); }

/* ── Difficulty selector ── */
.difficulty-bar {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
}

.difficulty-bar button {
  flex: 1;
  padding: 0.5rem 1rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
  font-size: 0.85rem;
  transition: all 0.15s;
}

.difficulty-bar button.active {
  background: var(--accent-1);
  border-color: var(--accent-1);
  color: #fff;
  font-weight: 600;
}

/* ── Map container ── */
#map-svg {
  width: 100%;
  max-width: 860px;
  height: auto;
  border-radius: var(--radius);
  overflow: hidden;
  background: #1a2540;
  border: 1px solid var(--border);
  touch-action: none;
}

#map-svg svg {
  width: 100%;
  height: 100%;
}

.country {
  fill: #2a3f6f;
  stroke: #0f1117;
  stroke-width: 0.5px;
  transition: fill 0.15s;
  cursor: default;
}

.country:hover { fill: #3a5080; }
.country.highlight { fill: var(--accent-1); }
.country.correct { fill: var(--accent-3); }
.country.wrong { fill: var(--accent-2); }

/* ── Options grid ── */
.options-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 0.75rem;
  width: 100%;
  max-width: 860px;
  margin-top: 1.2rem;
}

.option-btn {
  padding: 0.9rem 1rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 0.95rem;
  cursor: pointer;
  transition: all 0.15s;
  text-align: center;
}

.option-btn:hover:not(:disabled) { background: #252840; border-color: var(--accent-1); }
.option-btn.correct { background: #1a3d2a; border-color: var(--accent-3); color: var(--accent-3); }
.option-btn.wrong { background: #3d1a1a; border-color: var(--accent-2); color: var(--accent-2); }
.option-btn:disabled { cursor: default; opacity: 0.7; }

/* ── Score bar ── */
.score-bar {
  display: flex;
  justify-content: space-between;
  width: 100%;
  max-width: 860px;
  margin-bottom: 0.8rem;
  font-size: 0.9rem;
  color: var(--muted);
}

.score-bar span b { color: var(--text); }

/* ── Question label ── */
.question-label {
  font-size: 1.2rem;
  font-weight: 600;
  margin-bottom: 0.8rem;
  text-align: center;
  min-height: 1.8rem;
}

/* ── Explorer ── */
#explorer-screen {
  max-width: 1100px;
  width: 100%;
}

#explorer-content {
  display: flex;
  flex-direction: row;
  align-items: flex-start;
  gap: 1.5rem;
  width: 100%;
}

#explorer-list {
  width: 220px;
  flex-shrink: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  max-height: 560px;
}

#explorer-search {
  padding: 0.7rem 1rem;
  border: none;
  border-bottom: 1px solid var(--border);
  background: #12151f;
  color: var(--text);
  font-size: 0.9rem;
  outline: none;
}

#explorer-search::placeholder { color: var(--muted); }

#country-list {
  overflow-y: auto;
  flex: 1;
  list-style: none;
  padding: 0.3rem 0;
}

#country-list li {
  padding: 0.45rem 1rem;
  font-size: 0.88rem;
  cursor: pointer;
  color: var(--muted);
  transition: background 0.1s, color 0.1s;
}

#country-list li:hover { background: #20243a; color: var(--text); }
#country-list li.active { background: #1a2d50; color: var(--accent-1); font-weight: 600; }

#explorer-map {
  flex: 1;
  min-width: 0;
}

/* ── Tooltip ── */
#tooltip {
  position: fixed;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.4rem 0.8rem;
  font-size: 0.85rem;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s;
  z-index: 100;
  white-space: nowrap;
}

/* ── Footer ── */
footer {
  text-align: center;
  padding: 1rem;
  color: var(--muted);
  font-size: 0.8rem;
}

footer a { color: var(--muted); }

/* ── Next button ── */
.btn-next {
  margin-top: 1rem;
  padding: 0.7rem 2rem;
  border-radius: 10px;
  border: none;
  background: var(--accent-1);
  color: #fff;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.2s;
}
.btn-next:hover { opacity: 0.85; }

/* ── Responsive ── */
@media (max-width: 640px) {
  #home-screen { flex-direction: column; align-items: center; }
  .game-card { max-width: 100%; }
  #explorer-content { flex-direction: column; }
  #explorer-list { width: 100%; max-height: 200px; }
  .options-grid { grid-template-columns: 1fr 1fr; }
}
