:root {
  --bg:       #1a1a2e;
  --bg2:      #16213e;
  --accent:   #e94560;
  --success:  #0f9b58;
  --warning:  #f0c040;
  --text:     #eaeaea;
  --text-dim: #8899aa;
  --border:   #0f3460;
  --overlay:  rgba(0, 0, 0, 0.90);
  --header-h: 60px;
  --bottom-h: 64px;
  --radius:   10px;
}

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  height: 100vh;
  overflow: hidden;
}

/* ── Header ── */
#header {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--header-h);
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  z-index: 200;
}

#streak-display {
  display: flex;
  align-items: center;
  gap: 20px;
  font-size: 15px;
}

#streak-val {
  font-size: 22px;
  font-weight: 700;
  color: var(--warning);
  transition: transform .15s;
}
#streak-val.pulse { animation: pulse .3s ease; }
@keyframes pulse {
  0%   { transform: scale(1); }
  50%  { transform: scale(1.45); }
  100% { transform: scale(1); }
}
#best-label { color: var(--text-dim); font-size: 13px; }

/* ── Panorama ── */
#panorama {
  position: fixed;
  top: var(--header-h);
  bottom: var(--bottom-h);
  left: 0; right: 0;
  width: 100%;
  height: 100%;
  background: #0a0a1a;
}

/* ── Bussola ── */
#compass {
  position: fixed;
  top: calc(var(--header-h) + 14px);
  right: 14px;
  width: 52px;
  height: 52px;
  z-index: 150;
  pointer-events: none;
  filter: drop-shadow(0 2px 6px rgba(0,0,0,0.5));
}

#compass-rose {
  width: 100%;
  height: 100%;
  transition: transform 0.15s ease;
}

/* ── Bottom bar ── */
#bottom-bar {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: var(--bottom-h);
  background: var(--bg);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
}

/* ── Buttons ── */
button {
  cursor: pointer;
  border: none;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 600;
  padding: 10px 28px;
  transition: opacity .15s, transform .1s;
}
button:disabled { opacity: 0.4; cursor: not-allowed; }
button:not(:disabled):hover  { opacity: 0.88; }
button:not(:disabled):active { transform: scale(0.97); }

#btn-guess {
  background: var(--accent);
  color: #fff;
  min-width: 160px;
  font-size: 16px;
}

/* ── Map overlay ── */
#map-overlay {
  position: fixed;
  inset: 0;
  background: var(--overlay);
  z-index: 300;
  display: flex;
  flex-direction: column;
}

#map-header {
  height: var(--header-h);
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  flex-shrink: 0;
  border-bottom: 1px solid var(--border);
}

#map-selected-label {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-dim);
}
#map-selected-label.has-selection { color: var(--text); }

#map-header-actions { display: flex; align-items: center; gap: 12px; }

#btn-map-close {
  background: transparent;
  color: var(--text-dim);
  font-size: 22px;
  padding: 4px 10px;
  border: 1px solid var(--border);
}
#btn-map-close:hover { color: var(--text); }

#btn-confirm {
  background: var(--success);
  color: #fff;
  min-width: 110px;
}
#btn-confirm:disabled { background: #1e5540; }

#map-container { flex: 1; overflow: hidden; }

/* D3 map */
.country-path {
  fill: #4a7fa5;
  cursor: pointer;
  transition: fill .1s;
}
.country-border {
  fill: none;
  stroke: #1a1a2e;
  stroke-width: 0.5px;
  pointer-events: none;
}

/* ── Generic overlay ── */
.overlay {
  position: fixed;
  inset: 0;
  background: var(--overlay);
  z-index: 400;
  display: flex;
  align-items: center;
  justify-content: center;
}

.overlay-box {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 40px 48px;
  text-align: center;
  max-width: 440px;
  width: 90%;
}

.overlay-box h2 { font-size: 24px; margin-bottom: 12px; }
.overlay-box p  { color: var(--text-dim); font-size: 15px; margin-bottom: 20px; line-height: 1.5; }

.flag-big   { font-size: 64px; margin-bottom: 12px; }
.result-correct { color: var(--success); }
.result-wrong   { color: var(--accent); }

.spinner {
  width: 48px; height: 48px;
  border: 4px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .7s linear infinite;
  margin: 0 auto 20px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Auth overlay ── */
.auth-tabs {
  display: flex;
  gap: 0;
  margin-bottom: 24px;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}
.auth-tab {
  flex: 1;
  background: transparent;
  color: var(--text-dim);
  border-radius: 0;
  padding: 10px;
  font-size: 14px;
  font-weight: 500;
  border: none;
}
.auth-tab.active {
  background: var(--accent);
  color: #fff;
}

.field-input {
  display: block;
  width: 100%;
  background: #0f1927;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 14px;
  padding: 11px 14px;
  margin-bottom: 12px;
  font-family: inherit;
}
.field-input:focus { outline: none; border-color: var(--accent); }

#token-input {
  display: block;
  width: 100%;
  background: #0f1927;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 14px;
  padding: 11px 14px;
  margin-bottom: 12px;
  font-family: monospace;
}
#token-input:focus { outline: none; border-color: var(--accent); }

.auth-error {
  color: var(--accent);
  font-size: 13px;
  margin-bottom: 12px;
  text-align: left;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
  width: 100%;
  padding: 12px;
  font-size: 16px;
  border-radius: 8px;
}

.btn-secondary {
  background: transparent;
  color: var(--text-dim);
  border: 1px solid var(--border) !important;
  padding: 8px 16px;
  font-size: 14px;
  border-radius: 8px;
}
.btn-secondary:hover { color: var(--text); }

.streak-badge {
  display: inline-block;
  background: var(--accent);
  color: #fff;
  border-radius: 6px;
  padding: 2px 10px;
  font-size: 20px;
  font-weight: 700;
  margin: 8px 0 16px;
}

.hidden { display: none !important; }

@media (max-width: 640px) {
  .overlay-box { padding: 28px 20px; }
  #map-selected-label { font-size: 15px; }
  #btn-confirm { min-width: 90px; padding: 10px 16px; }
}
