:root {
  --bg: #0f1220;
  --panel: #171b2e;
  --panel-2: #1e2338;
  --text: #eef0fb;
  --muted: #9aa0c3;
  --accent: #7aa2ff;
  --accent-2: #7ae582;
  --warn: #ffb347;
  --radius: 14px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: radial-gradient(1200px 800px at 50% -10%, #1a2040, var(--bg));
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  display: flex;
  flex-direction: column;
}

.app-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.app-header h1 {
  font-size: 1.15rem;
  margin: 0;
  margin-right: auto;
}

.tabs-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  padding: 0 20px 14px;
}

.mode-tabs {
  display: flex;
  gap: 6px;
  background: var(--panel);
  padding: 4px;
  border-radius: 999px;
}

.dataset-tabs .tab.active {
  background: var(--accent-2);
}

.tab {
  border: none;
  background: transparent;
  color: var(--muted);
  padding: 8px 14px;
  border-radius: 999px;
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 600;
}

.tab.active {
  background: var(--accent);
  color: #0b0e1a;
}

.stats {
  display: flex;
  gap: 12px;
  font-size: 0.8rem;
  color: var(--muted);
}

.stats b { color: var(--text); }

main {
  flex: 1;
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.hidden { display: none !important; }

.loading { text-align: center; color: var(--muted); }

/* Pick a country panel */
.pick-panel {
  background: var(--panel);
  border-radius: var(--radius);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

#pick-search {
  width: 100%;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: var(--panel-2);
  color: var(--text);
  font-size: 0.95rem;
}

.region-chips {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.chip {
  border: 1px solid rgba(255, 255, 255, 0.15);
  background: transparent;
  color: var(--muted);
  padding: 5px 10px;
  border-radius: 999px;
  font-size: 0.78rem;
  cursor: pointer;
}

.chip.active {
  background: var(--accent);
  color: #0b0e1a;
  border-color: var(--accent);
}

.country-list {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 260px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.country-list li button {
  width: 100%;
  text-align: left;
  padding: 8px 10px;
  border-radius: 8px;
  border: none;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  font-size: 0.9rem;
  display: flex;
  justify-content: space-between;
}

.country-list li button:hover {
  background: var(--panel-2);
}

.country-list .region-tag {
  color: var(--muted);
  font-size: 0.75rem;
}

/* Game panel */
.game-panel {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.prompt {
  text-align: center;
}

.country-name {
  font-size: 1.6rem;
  font-weight: 800;
  letter-spacing: 0.02em;
}

.country-region {
  color: var(--muted);
  font-size: 0.85rem;
}

.canvas-wrap {
  background: var(--panel);
  border-radius: var(--radius);
  padding: 10px;
}

#draw-canvas {
  width: 100%;
  aspect-ratio: 1 / 1;
  display: block;
  border-radius: 10px;
  background: var(--panel-2);
  touch-action: none;
  cursor: crosshair;
}

.controls {
  display: flex;
  gap: 10px;
}

.btn {
  flex: 1;
  padding: 12px;
  border-radius: 10px;
  border: none;
  font-weight: 700;
  font-size: 0.95rem;
  cursor: pointer;
}

.btn-primary {
  background: var(--accent);
  color: #0b0e1a;
}

.btn-primary:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.btn-secondary {
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.result {
  background: var(--panel);
  border-radius: var(--radius);
  padding: 18px;
  text-align: center;
}

.score-big {
  font-size: 3rem;
  font-weight: 800;
  color: var(--accent-2);
  line-height: 1;
}

.rating {
  font-size: 1.1rem;
  font-weight: 700;
  margin-top: 4px;
  color: var(--warn);
}

.subscores {
  margin-top: 10px;
  display: flex;
  justify-content: center;
  gap: 24px;
  color: var(--muted);
  font-size: 0.85rem;
}

.share-row {
  margin-top: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

#share-status {
  color: var(--muted);
  font-size: 0.8rem;
}

.app-footer {
  text-align: center;
  color: var(--muted);
  font-size: 0.75rem;
  padding: 16px 20px 28px;
  max-width: 560px;
  margin: 0 auto;
}

.app-footer a {
  color: var(--accent);
}
