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

:root {
  --bg: #0f1220;
  --panel: #1a1f35;
  --panel-2: #232a4a;
  --accent: #e63946;
  --accent-2: #ff6b6b;
  --gold: #ffd166;
  --text: #f1f3f8;
  --muted: #9aa3c0;
  --ok: #4ade80;
  --hud-bg: rgba(15, 18, 32, .88);
  --border: rgba(255, 255, 255, .08);
}

body.light {
  --bg: #eef1f8;
  --panel: #ffffff;
  --panel-2: #e7ebf5;
  --accent: #d62839;
  --accent-2: #e05555;
  --gold: #b07d00;
  --text: #17203a;
  --muted: #5b6785;
  --ok: #15803d;
  --hud-bg: rgba(255, 255, 255, .92);
  --border: rgba(0, 0, 0, .1);
}

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

.hidden { display: none !important; }

/* ── EKRAN STARTOWY ── */
#start-screen, #final-screen {
  position: fixed; inset: 0; z-index: 300;
  display: flex;
  padding: 16px 0;
  background:
    radial-gradient(ellipse at 20% 20%, rgba(230, 57, 70, .18), transparent 50%),
    radial-gradient(ellipse at 80% 80%, rgba(69, 123, 157, .22), transparent 50%),
    var(--bg);
  overflow-y: auto;
}

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 26px 36px;
  max-width: 620px;
  width: calc(100% - 32px);
  text-align: center;
  box-shadow: 0 24px 80px rgba(0,0,0,.5);
  /* margin:auto zamiast align-items:center — przy przepełnieniu góra karty
     pozostaje osiągalna przewijaniem (fix ucinania na niskich ekranach) */
  margin: auto;
}

.logo {
  font-size: 40px; font-weight: 800; letter-spacing: -1px;
  margin-bottom: 4px;
}
.logo .q { color: var(--accent); }
.flag {
  display: inline-block; width: 34px; height: 22px; border-radius: 4px;
  vertical-align: middle; margin-left: 10px;
  border: 1px solid rgba(0,0,0,.3);
  cursor: pointer; transition: transform .12s;
}
.flag:hover { transform: scale(1.15); }
.flag-pl { background: linear-gradient(to bottom, #fff 50%, #dc143c 50%); }
.flag-es { background: linear-gradient(to bottom, #aa151b 0 25%, #f1bf00 25% 75%, #aa151b 75% 100%); }
.flag-szl { background: linear-gradient(to bottom, #ffd700 50%, #0033a0 50%); }
.tagline { color: var(--muted); font-size: 14px; margin-bottom: 16px; }

.brand-row {
  display: flex; align-items: center; justify-content: center;
  gap: 18px; margin-bottom: 14px; text-align: left;
}
.brand-text { min-width: 0; }
.brand-text .logo { margin-bottom: 2px; font-size: 38px; }
.brand-text .tagline { margin-bottom: 0; }

#logo-img {
  width: 118px; height: 118px; flex: 0 0 auto;
  border-radius: 22%; object-fit: cover;
  box-shadow: 0 8px 22px rgba(0,0,0,.4);
}

@media (max-width: 560px) {
  .brand-row { flex-direction: column; gap: 8px; text-align: center; }
  #logo-img { width: 96px; height: 96px; }
}

#ui-toggles {
  position: fixed; top: 14px; right: 14px; z-index: 500;
  display: flex; gap: 8px;
}
#ui-toggles button {
  width: 42px; height: 42px; border-radius: 50%; border: 1px solid var(--border);
  background: var(--panel); color: var(--text); font-size: 19px; cursor: pointer;
  box-shadow: 0 4px 16px rgba(0,0,0,.3);
  transition: transform .12s;
}
#ui-toggles button:hover { transform: scale(1.1); }

.rounds-row {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  margin-bottom: 12px; color: var(--muted); font-size: 13px;
}
.rounds-btn {
  width: 40px; padding: 6px 0; border-radius: 8px; cursor: pointer;
  background: var(--panel-2); border: 2px solid transparent; color: var(--text);
  font-size: 14px; font-weight: 700;
}
.rounds-btn.active { border-color: var(--accent); background: rgba(230,57,70,.12); }

#nick-input {
  width: 100%; padding: 10px 16px; margin-bottom: 12px;
  border-radius: 12px; border: 2px solid var(--panel-2);
  background: var(--panel-2); color: var(--text);
  font-size: 16px; text-align: center; outline: none;
  transition: border-color .15s;
}
#nick-input:focus { border-color: var(--accent); }
#nick-input.invalid { border-color: var(--accent); animation: shake .3s; }
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-6px); }
  75% { transform: translateX(6px); }
}

.top10-box {
  margin-top: 14px; background: var(--panel-2); border-radius: 12px;
  padding: 10px 14px; text-align: left;
  max-height: 200px; overflow-y: auto;
}
.top10-title { font-weight: 700; margin-bottom: 6px; font-size: 14px; }
.top10-row {
  display: flex; justify-content: space-between; padding: 3px 8px;
  border-radius: 8px; font-size: 13px; color: var(--muted);
}
.top10-row b { color: var(--gold); }
.top10-row.me { background: rgba(230,57,70,.15); color: var(--text); }
.top10-empty { color: var(--muted); font-size: 13px; }

.mode-grid { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.mode-grid .mode-btn { flex: 1 1 30%; min-width: 140px; }

.version {
  margin-top: 12px; color: var(--muted); font-size: 12px; opacity: .7;
}
.mode-btn {
  flex: 1; padding: 9px 6px; border-radius: 12px; cursor: pointer;
  background: var(--panel-2); border: 2px solid transparent;
  color: var(--text); font-size: 13px; font-weight: 600;
  transition: all .15s;
}
.mode-btn small { display: block; color: var(--muted); font-weight: 400; margin-top: 2px; font-size: 11px; }
.mode-btn:hover { border-color: rgba(255,255,255,.2); }
.mode-btn.active { border-color: var(--accent); background: rgba(230,57,70,.12); }

.big-btn {
  width: 100%; padding: 13px; border: none; border-radius: 12px; cursor: pointer;
  background: linear-gradient(135deg, var(--accent), #c1121f);
  color: #fff; font-size: 19px; font-weight: 700;
  box-shadow: 0 8px 24px rgba(230,57,70,.35);
  transition: transform .1s, box-shadow .15s;
}
.big-btn:hover { transform: translateY(-2px); box-shadow: 0 12px 30px rgba(230,57,70,.45); }
.big-btn:active { transform: translateY(0); }

.rules { margin-top: 14px; color: var(--muted); font-size: 12px; line-height: 1.55; text-align: left; }
.rules b { color: var(--text); }

/* ── GRA ── */
#game-screen { position: fixed; inset: 0; }

#pano-frame {
  /* przesunięcie w górę ukrywa pasek Google z nazwą miejscowości (spoiler!) */
  position: absolute; top: -80px; left: 0;
  width: 100%; height: calc(100% + 80px); border: 0;
}

/* pasek HUD */
#hud {
  position: absolute; top: 14px; left: 50%; transform: translateX(-50%);
  z-index: 50; display: flex; gap: 12px; align-items: center;
  background: var(--hud-bg); backdrop-filter: blur(8px);
  border: 1px solid var(--border);
  padding: 10px 22px; border-radius: 14px;
  box-shadow: 0 6px 24px rgba(0,0,0,.4);
}
.hud-item { text-align: center; min-width: 84px; }
.hud-item .label { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; }
.hud-item .value { font-size: 19px; font-weight: 700; }
.hud-sep { width: 1px; height: 30px; background: rgba(255,255,255,.12); }

/* minimapa */
#map-panel {
  position: absolute; right: 18px; bottom: 18px; z-index: 60;
  width: 320px; height: 240px;
  border-radius: 14px; overflow: hidden;
  border: 2px solid rgba(255,255,255,.15);
  box-shadow: 0 12px 40px rgba(0,0,0,.55);
  transition: width .22s ease, height .22s ease, opacity .2s;
  opacity: .92;
  display: flex; flex-direction: column;
  background: var(--panel);
}
#map-panel:hover { width: 520px; height: 400px; opacity: 1; }
#mini-map { flex: 1; }

#guess-btn {
  border: none; padding: 13px; cursor: pointer;
  background: linear-gradient(135deg, var(--accent), #c1121f);
  color: #fff; font-size: 16px; font-weight: 700;
}
#guess-btn:disabled { background: #3a405e; color: var(--muted); cursor: not-allowed; }

/* ── WYNIK RUNDY ── */
#result-screen {
  position: fixed; inset: 0; z-index: 200;
  display: flex; flex-direction: column;
  background: var(--bg);
}
#result-map { flex: 1; }
#result-bar {
  padding: 20px 28px; background: var(--panel);
  border-top: 1px solid rgba(255,255,255,.08);
  display: flex; align-items: center; gap: 32px; flex-wrap: wrap;
}
.result-stat .label { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; }
.result-stat .value { font-size: 26px; font-weight: 800; }
.result-stat .value.points { color: var(--gold); }
#result-place { font-size: 15px; color: var(--muted); flex: 1; min-width: 200px; }
#result-place b { color: var(--text); font-size: 17px; }

.progress-track {
  width: 100%; height: 10px; border-radius: 6px; background: var(--panel-2);
  overflow: hidden; margin-top: 8px;
}
.progress-fill {
  height: 100%; width: 0%; border-radius: 6px;
  background: linear-gradient(90deg, var(--accent), var(--gold));
  transition: width .9s cubic-bezier(.2,.8,.2,1);
}
#result-progress-wrap { flex-basis: 100%; }
#result-player-total { color: var(--muted); font-size: 13px; margin-top: 8px; }

#result-bonuses {
  flex-basis: 100%; display: flex; flex-wrap: wrap; gap: 8px;
}
.chip {
  padding: 5px 12px; border-radius: 999px; font-size: 13px; font-weight: 600;
}
.chip.hit { background: rgba(74,222,128,.15); color: var(--ok); }
.chip.miss { background: rgba(255,255,255,.06); color: var(--muted); }

#next-btn { min-width: 220px; padding: 15px 28px; font-size: 17px; width: auto; }

/* ── WYNIK KOŃCOWY ── */
#final-screen .card { max-width: 640px; }
#final-total { font-size: 56px; font-weight: 800; color: var(--gold); margin: 8px 0 2px; }
#final-sub { color: var(--muted); margin-bottom: 24px; }
.round-list { text-align: left; margin-bottom: 26px; }
.round-row {
  display: flex; justify-content: space-between; gap: 10px;
  padding: 10px 14px; border-radius: 10px; background: var(--panel-2);
  margin-bottom: 6px; font-size: 14px;
}
.round-row .pts { color: var(--gold); font-weight: 700; }
.round-row .dist { color: var(--muted); }
.btn-row { display: flex; gap: 10px; }
.btn-row .big-btn.secondary {
  background: var(--panel-2); box-shadow: none; color: var(--text);
}

/* ── QUIZ ── */
#quiz-btn {
  position: absolute; left: 18px; bottom: 18px; z-index: 60;
  padding: 12px 20px; border: none; border-radius: 14px; cursor: pointer;
  background: linear-gradient(135deg, #7c3aed, #4c1d95);
  color: #fff; font-size: 16px; font-weight: 700;
  box-shadow: 0 8px 24px rgba(124,58,237,.4);
  transition: transform .1s;
}
#quiz-btn:hover:not(:disabled) { transform: translateY(-2px); }
#quiz-btn:disabled { background: #3a405e; color: var(--muted); cursor: not-allowed; box-shadow: none; }
#quiz-btn small { display: block; font-weight: 400; font-size: 11px; opacity: .8; }

#quiz-modal {
  position: fixed; inset: 0; z-index: 400;
  display: flex; align-items: center; justify-content: center;
  background: rgba(10, 12, 24, .85); backdrop-filter: blur(6px);
}
.quiz-card {
  background: var(--panel); border: 1px solid rgba(124,58,237,.4);
  border-radius: 20px; padding: 28px 32px; max-width: 640px; width: calc(100% - 32px);
  box-shadow: 0 24px 80px rgba(0,0,0,.6);
}
.quiz-head {
  display: flex; justify-content: space-between; align-items: center;
  font-weight: 700; margin-bottom: 10px;
}
#quiz-timer { color: var(--gold); font-size: 20px; min-width: 52px; text-align: right; }
#quiz-progress { color: var(--muted); font-size: 13px; font-weight: 600; }
.quiz-card .btn-row { margin-top: 4px; }
.quiz-track { margin-bottom: 18px; }
.quiz-track .progress-fill { transition: width 1s linear; background: linear-gradient(90deg, #7c3aed, var(--gold)); }
#quiz-relation {
  background: rgba(124,58,237,.15); border: 1px solid rgba(124,58,237,.35);
  color: #d6bcfa; border-radius: 10px; padding: 10px 14px;
  font-size: 14px; margin-bottom: 16px;
}
#quiz-question { font-size: 19px; font-weight: 700; margin-bottom: 18px; line-height: 1.45; }
#quiz-answers { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.quiz-answer {
  padding: 13px 16px; border-radius: 12px; cursor: pointer; text-align: left;
  background: var(--panel-2); border: 2px solid transparent;
  color: var(--text); font-size: 15px;
  transition: border-color .12s;
}
.quiz-answer:hover:not(:disabled) { border-color: #7c3aed; }
.quiz-answer:disabled { opacity: .55; cursor: default; }
.quiz-answer b { color: var(--gold); margin-right: 4px; }
#quiz-result { text-align: center; font-size: 22px; font-weight: 800; margin: 18px 0 6px; min-height: 28px; }
#quiz-result.quiz-ok { color: var(--ok); }
#quiz-result.quiz-bad { color: var(--accent-2); }
#quiz-close { margin-top: 8px; }

@media (max-width: 640px) {
  #quiz-answers { grid-template-columns: 1fr; }
  #quiz-btn { left: 12px; bottom: auto; top: 80px; }
}

/* pinezki */
.pin-guess { filter: hue-rotate(120deg); }

@media (max-width: 640px) {
  .card { padding: 28px 20px; }
  #map-panel { width: calc(100vw - 36px); height: 220px; }
  #map-panel:hover { width: calc(100vw - 36px); height: 300px; }
  #hud { padding: 8px 12px; gap: 8px; }
}
