/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }

/* ── Variables (Kippi design system) ── */
:root {
  --bg:       #070e1b;
  --surface:  #0e1a2e;
  --surface2: #152236;
  --text:     #e8edf5;
  --muted:    #8892aa;
  --accent:   #7c6af7;
  --border:   rgba(255,255,255,0.07);
  --green:    #22c55e;
  --yellow:   #f59e0b;
  --orange:   #f97316;
  --red:      #ef4444;
}

/* ── Base ── */
html, body {
  height: 100%;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  min-height: 100dvh;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  user-select: none;
  overflow: hidden;
}

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

/* ════════════════════════════════════════════════════════════
   START SCREEN
   ════════════════════════════════════════════════════════════ */
#start-screen {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  overflow-y: auto;
}

.start-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 36px 28px;
  width: 100%;
  max-width: 400px;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.start-emoji { font-size: 3.2rem; line-height: 1; }

.start-card h1 {
  font-size: 1.9rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.start-desc {
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1.55;
}

.scoring-guide {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 10px;
  justify-content: center;
  font-size: 0.82rem;
  color: var(--muted);
}

.start-back {
  color: var(--muted);
  font-size: 0.85rem;
  text-decoration: none;
  margin-top: 4px;
}
.start-back:hover { color: var(--text); }

/* ── «Slik spiller du»-knapp + modal ──────────────────────────── */
.btn-text {
  background: none;
  border: none;
  color: var(--accent);
  font-family: inherit;
  font-size: .85rem;
  font-weight: 600;
  cursor: pointer;
  padding: 6px;
}
.btn-text:hover { text-decoration: underline; }

.howto-backdrop {
  position: fixed;
  inset: 0;
  z-index: 500;
  background: rgba(3, 8, 16, 0.74);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.howto-backdrop[hidden] { display: none; }
.howto-card {
  background: var(--surface, #0c1525);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 24px 22px;
  max-width: 380px;
  width: 100%;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.55);
}
.howto-card h2 {
  margin: 0 0 16px;
  font-size: 1.25rem;
  font-weight: 800;
  text-align: center;
}
.howto-list {
  display: flex;
  flex-direction: column;
  gap: 13px;
  margin-bottom: 20px;
}
.howto-item {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  font-size: .9rem;
  line-height: 1.4;
  color: var(--text);
}
.howto-icon { font-size: 1.2rem; line-height: 1.2; flex-shrink: 0; width: 24px; text-align: center; }

/* ── Mode picker ── */
.mode-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.mode-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  padding: 18px 10px;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text);
  cursor: pointer;
  font-family: inherit;
  transition: border-color 0.15s, background 0.15s, transform 0.1s;
  -webkit-tap-highlight-color: transparent;
}

.mode-btn:hover {
  border-color: var(--accent);
  background: rgba(124, 106, 247, 0.12);
}

.mode-btn:active { transform: scale(0.97); }

.mode-emoji {
  font-size: 2rem;
  line-height: 1;
}

.mode-label {
  font-size: 1rem;
  font-weight: 800;
  letter-spacing: -0.01em;
}

.mode-sub {
  font-size: 0.73rem;
  color: var(--muted);
  text-align: center;
  line-height: 1.35;
}

/* ════════════════════════════════════════════════════════════
   GAME SCREEN  (flex column, fills viewport)
   ════════════════════════════════════════════════════════════ */
#game-screen {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  background: var(--bg);
}

/* ── Game header ── */
.game-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  min-height: 56px;
}

.back-btn {
  color: var(--muted);
  display: flex;
  align-items: center;
  flex-shrink: 0;
  text-decoration: none;
}
.back-btn svg { width: 22px; height: 22px; }

.game-header__center {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  min-width: 0;
}

.country-question {
  font-size: clamp(0.95rem, 4vw, 1.15rem);
  font-weight: 800;
  letter-spacing: -0.01em;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.hint-text {
  font-size: 0.75rem;
  color: var(--muted);
  font-weight: 500;
  min-height: 1em;
}

.round-badge {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 3px 10px;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--muted);
  flex-shrink: 0;
  white-space: nowrap;
}

/* ── Map ── */
#map {
  flex: 1;
  min-height: 0;
  background: #0a1628; /* matches CartoDB dark ocean while tiles load */
  touch-action: none;  /* hand all touch events to Leaflet, no browser interference */
}

/* ── Feedback bar ── */
.feedback-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  flex-shrink: 0;
  border-top: 1px solid var(--border);
  transition: background 0.2s;
  gap: 12px;
}

.feedback-bar__left {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.feedback-dist {
  font-size: 0.95rem;
  font-weight: 700;
}

.feedback-score {
  font-size: 0.82rem;
  color: var(--muted);
  font-weight: 600;
}

.feedback-bar__right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  flex-shrink: 0;
}

.total-label {
  font-size: 0.72rem;
  color: var(--muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.total-score-val {
  font-size: 1.2rem;
  font-weight: 800;
  letter-spacing: -0.01em;
  color: var(--text);
}

/* Feedback colour variants */
.feedback--great { background: rgba(34, 197, 94, 0.1);  border-top-color: rgba(34,197,94,0.25); }
.feedback--good  { background: rgba(245,158, 11, 0.09); border-top-color: rgba(245,158,11,0.25); }
.feedback--ok    { background: rgba(249,115, 22, 0.09); border-top-color: rgba(249,115,22,0.25); }
.feedback--miss  { background: rgba(239, 68, 68, 0.09); border-top-color: rgba(239,68,68,0.25);  }

.feedback--great .feedback-score { color: var(--green); }
.feedback--good  .feedback-score { color: var(--yellow); }
.feedback--ok    .feedback-score { color: var(--orange); }
.feedback--miss  .feedback-score { color: var(--red); }

/* ── Action row ── */
.action-row {
  display: flex;
  gap: 8px;
  padding: 10px 14px;
  flex-shrink: 0;
  border-top: 1px solid var(--border);
}

.btn-action {
  flex: 1;
  border-radius: 12px;
  padding: 13px 16px;
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text);
  transition: opacity 0.15s, background 0.15s;
}

.btn-action:disabled {
  opacity: 0.3;
  cursor: default;
}

.btn-action--primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.btn-action--primary:hover:not(:disabled) { opacity: 0.88; }

.btn-action--next {
  background: var(--green);
  border-color: var(--green);
  color: #fff;
}
.btn-action--next:hover { opacity: 0.88; }

/* ════════════════════════════════════════════════════════════
   RESULT OVERLAY
   ════════════════════════════════════════════════════════════ */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(7, 14, 27, 0.92);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 200;
  overflow-y: auto;
}

.overlay[hidden] { display: none; }

.overlay-card {
  background: var(--surface);
  border: 1px solid rgba(255,255,255,0.09);
  border-radius: 24px;
  padding: 28px 22px;
  width: 100%;
  max-width: 380px;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.overlay-emoji { font-size: 2.8rem; line-height: 1; }

.overlay-card h2 {
  font-size: 1.6rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.result-score-block {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 6px;
  flex-wrap: wrap;
}

.result-total {
  font-size: 2.4rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--accent);
}

.result-of {
  font-size: 1rem;
  color: var(--muted);
  font-weight: 600;
}

.result-pct {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--muted);
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 2px 10px;
}

/* Round list */
.result-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 4px;
  text-align: left;
  max-height: 260px;
  overflow-y: auto;
  padding-right: 4px;
}

.result-item {
  display: grid;
  grid-template-columns: 1.4rem 1fr auto auto;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 8px;
  background: var(--surface2);
  font-size: 0.85rem;
}

.result-emoji { font-size: 0.9rem; }

.result-name {
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.result-km {
  color: var(--muted);
  font-size: 0.78rem;
  white-space: nowrap;
}

.result-pts {
  font-weight: 700;
  color: var(--accent);
  font-size: 0.82rem;
  white-space: nowrap;
}

/* Shared buttons */
.btn-primary {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 12px;
  padding: 13px;
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  transition: opacity 0.15s;
}
.btn-primary:hover { opacity: 0.88; }

.btn-primary--ghost {
  background: var(--surface2);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-share { display: inline-flex; align-items: center; gap: 6px; background: none; border: none; cursor: pointer; font-family: inherit; font-size: .82rem; font-weight: 600; color: var(--muted); padding: 8px 0; transition: color .15s; }
.btn-share:hover { color: var(--text); }
.btn-share svg { flex-shrink: 0; }

.btn-secondary {
  display: block;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 600;
  text-decoration: none;
  margin-top: 4px;
}
.btn-secondary:hover { color: var(--text); }

/* ════════════════════════════════════════════════════════════
   LEAFLET OVERRIDES
   ════════════════════════════════════════════════════════════ */
.leaflet-container {
  background: #0a1628 !important;
  font-family: inherit;
  cursor: crosshair;
}

/* Brighten tiles only — markers, lines and circles are unaffected */
.leaflet-tile-pane { filter: brightness(1.7); }

/* Subtle attribution */
.leaflet-control-attribution {
  background: rgba(7,14,27,0.65) !important;
  color: rgba(255,255,255,0.35) !important;
  font-size: 9px !important;
  padding: 2px 5px !important;
  backdrop-filter: blur(4px);
}

.leaflet-control-attribution a { color: rgba(255,255,255,0.4) !important; }

/* ════════════════════════════════════════════════════════════
   RESPONSIVE
   ════════════════════════════════════════════════════════════ */
@media (max-width: 380px) {
  .country-question { font-size: 0.9rem; }
  .start-card { padding: 28px 18px; }
}
