:root {
  --bg: #11151c;
  --surface: #1b2230;
  --text: #eef1f6;
  --muted: #a9b3c4;
  --accent: #5aa9ff;
  --accent-text: #08121f;
  --danger: #ff8a80;
  --focus: #ffd166;
  --font: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
}

* { box-sizing: border-box; }

html, body { height: 100%; margin: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 1rem;
  line-height: 1.5;
}

#app { min-height: 100%; display: flex; flex-direction: column; }

.screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  padding: 1.5rem;
  text-align: center;
}

.screen h1 { margin: 0; font-size: clamp(2rem, 6vw, 3.25rem); }
.screen p { margin: 0; max-width: 36rem; color: var(--muted); }

.screen-fatal { background: var(--surface); }
.screen-fatal h1 { color: var(--danger); font-size: clamp(1.5rem, 4vw, 2.25rem); }
.screen-fatal p { color: var(--text); }

.btn {
  min-width: 44px;
  min-height: 44px;
  padding: 0.5rem 1.25rem;
  border: 0;
  border-radius: 0.5rem;
  background: var(--accent);
  color: var(--accent-text);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; box-shadow: 0 0 0 2px var(--bg); }

/* Érintés: nincs dupla koppintásos nagyítás a gombokon és a vezérlőkön */
button, a, label, input, select { touch-action: manipulation; }

/* Kezdőképernyő */
.screen-start { justify-content: flex-start; max-width: 44rem; margin: 0 auto; width: 100%; }
.btn-big { min-height: 56px; padding: 0.75rem 2.5rem; font-size: 1.25rem; }
.settings, .top { width: 100%; text-align: left; background: var(--surface); border-radius: 0.75rem; padding: 1rem 1.25rem; }
.settings h2, .top h2 { margin: 0 0 0.75rem; font-size: 1.15rem; }
.field { border: 0; margin: 0 0 1rem; padding: 0; }
.field legend { font-weight: 600; padding: 0; margin-bottom: 0.25rem; }
.choices { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.choice { display: inline-flex; align-items: center; gap: 0.4rem; min-height: 44px; padding: 0 0.75rem; border: 1px solid var(--muted); border-radius: 0.5rem; cursor: pointer; }
/* Saját rádió-jelölés: letiltott állapotban is látszik a kijelölés (a natív letiltott rádió halvány) */
.choice input { appearance: none; -webkit-appearance: none; margin: 0; width: 1.25rem; height: 1.25rem; flex: none; border: 2px solid var(--muted); border-radius: 50%; background: transparent; }
.choice input:checked { border-color: var(--accent); background: radial-gradient(circle, var(--accent) 0 45%, transparent 50%); }
@media (forced-colors: active) {
  .choice input:checked { background: radial-gradient(circle, Highlight 0 45%, transparent 50%); border-color: Highlight; border-width: 3px; forced-color-adjust: none; }
}
.choice:has(input:disabled) { cursor: not-allowed; }
.choice:has(input:disabled:not(:checked)) { opacity: 0.7; }
.choice:has(input:disabled:checked) { border-color: var(--accent); }
.screen .banner { width: 100%; padding: 0.75rem 1rem; border-radius: 0.5rem; background: var(--surface); border: 1px solid var(--accent); color: var(--text); }
.screen .banner-error, .screen .banner-warning { border-color: var(--danger); }
.locked-note { margin: 0; color: var(--muted); }
.top-table { width: 100%; border-collapse: collapse; }
.top-table th, .top-table td { padding: 0.35rem 0.5rem; text-align: left; border-bottom: 1px solid rgba(255, 255, 255, 0.12); }
.top-table .num, .top-table th:nth-child(3) { text-align: right; }
.top-empty { margin: 0; }

/* Töltés, hiba, eredmény-helyőrző */
.spinner { width: 48px; height: 48px; border: 4px solid rgba(255, 255, 255, 0.2); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 3s; } }
.screen-loading .btn { margin-top: 0.25rem; }

/* Kör képernyő */
.screen-round { position: fixed; inset: 0; overflow: hidden; background: #000; }
.round-pano { position: absolute; inset: 0; }
/* NMPZ: átlátszó réteg a teljes panorámán (csak eseményt fog; a Google-logó és a szerzői jogi sor látszik) */
.nmpz-shield { position: absolute; top: 0; left: 0; right: 0; bottom: 0; z-index: 2; touch-action: none; cursor: default; }

.round-bar {
  position: absolute; top: 0.75rem; left: 50%; transform: translateX(-50%); z-index: 3;
  display: flex; gap: 0.25rem; padding: 0.25rem; border-radius: 0.75rem;
  background: rgba(17, 21, 28, 0.78); color: var(--text); font-weight: 600; white-space: nowrap;
}
.round-item { padding: 0.35rem 0.85rem; border-radius: 0.5rem; }
.round-item + .round-item { border-left: 1px solid rgba(255, 255, 255, 0.15); border-radius: 0 0.5rem 0.5rem 0; }
.round-clock { font-variant-numeric: tabular-nums; min-width: 4.5rem; text-align: center; }
.round-clock.warn { background: #c62828; color: #fff; border-radius: 0.5rem; }

.round-tools { position: absolute; top: 0.75rem; left: 0.75rem; z-index: 3; display: flex; flex-direction: column; align-items: center; gap: 0.5rem; }
.round-back { width: 48px; height: 48px; padding: 0; display: grid; place-items: center; border-radius: 50%; background: rgba(17, 21, 28, 0.78); color: var(--text); }
.round-back:hover { background: rgba(27, 34, 48, 0.95); }

.compass { width: 56px; height: 56px; border-radius: 50%; background: rgba(17, 21, 28, 0.92); border: 2px solid rgba(255, 255, 255, 0.25); }
.compass-dial { position: relative; width: 100%; height: 100%; transition: transform 0.1s linear; }
.compass-needle { position: absolute; left: 50%; top: 50%; width: 8px; height: 36px; margin: -18px 0 0 -4px; background: linear-gradient(#ff5a4f 50%, #eef1f6 50%); clip-path: polygon(50% 0, 100% 50%, 50% 100%, 0 50%); }
.compass-n { position: absolute; top: -1px; left: 50%; transform: translateX(-50%); font-size: 0.7rem; font-weight: 700; color: #ffb4ac; line-height: 1; }

/* Kis térkép: jobb alul, a panoráma alsó attribúciós sávja fölött */
.minimap {
  position: absolute; right: 0.75rem; bottom: 36px; z-index: 3;
  display: flex; flex-direction: column; gap: 0.4rem; width: 300px;
  opacity: 0.85; transition: width 0.2s ease, opacity 0.2s ease;
}
.minimap-map { width: 100%; height: 200px; border-radius: 0.5rem; overflow: hidden; border: 2px solid rgba(255, 255, 255, 0.3); transition: height 0.2s ease; }
.minimap-actions { display: flex; flex-direction: column; gap: 0.4rem; }
.minimap-close, .map-toggle { display: none; }
@media (min-width: 769px) and (min-height: 521px) {
  .minimap:hover, .minimap.pinned, .minimap.open { width: min(600px, calc(100vw - 1.5rem)); opacity: 1; }
  .minimap:hover .minimap-map, .minimap.pinned .minimap-map, .minimap.open .minimap-map { height: min(450px, calc(100vh - 12rem)); }
}
.minimap-pin {
  position: absolute; top: 6px; left: 6px; z-index: 1; width: 44px; height: 44px; padding: 0;
  display: grid; place-items: center; border: 0; border-radius: 0.5rem; cursor: pointer;
  background: rgba(17, 21, 28, 0.85); color: var(--muted);
}
.minimap.pinned .minimap-pin { color: var(--focus); }
.minimap-guess { width: 100%; min-height: 48px; font-size: 1.05rem; letter-spacing: 0.05em; }
@media (prefers-reduced-motion: reduce) { .minimap, .minimap-map, .compass-dial { transition: none; } }

/* Mobil (≤ 768 px széles vagy ≤ 520 px magas, pl. fekvő telefon): a kis térkép rejtve, a "Térkép"
   gomb teljes képernyős tippelő térképet nyit. A rejtett térkép is teljes méretű marad (visibility),
   így a jelölő és a nézet megmarad a váltások között. */
@media (max-width: 768px), (max-height: 520px) {
  .minimap {
    position: fixed; inset: 0; z-index: 5; width: 100%; gap: 0; opacity: 1; transition: none;
    background: var(--bg); visibility: hidden; pointer-events: none;
  }
  .minimap.mobile-open { visibility: visible; pointer-events: auto; }
  .minimap-map { flex: 1; height: auto; border: 0; border-radius: 0; transition: none; }
  .minimap-pin { display: none; }
  .minimap-actions { flex-direction: row; gap: 0.5rem; padding: 0.5rem; background: var(--surface); }
  .minimap-actions .btn { flex: 1; min-height: 48px; padding: 0.5rem 0.75rem; }
  .minimap-close { display: inline-block; }
  .map-toggle {
    display: inline-flex; align-items: center; justify-content: center;
    position: absolute; right: 0.75rem; bottom: 36px; z-index: 3; min-width: 96px; min-height: 48px;
    background: rgba(17, 21, 28, 0.92); color: var(--text); border: 2px solid rgba(255, 255, 255, 0.4);
  }
  .map-toggle.has-guess { border-color: var(--accent); }
  .round-bar { z-index: 6; top: 0.5rem; max-width: calc(100vw - 1rem); font-size: 0.9rem; }
  .round-item { padding: 0.3rem 0.55rem; }
  .round-clock { min-width: 3.6rem; }
  .round-tools { top: 3.4rem; left: 0.5rem; }
}
@media (max-width: 768px) and (min-height: 521px) {
  /* Álló telefon: a felső sáv és az eszközök egymás alatt, az iránytű nem lóg a sáv alá */
  .round-tools { top: 3.6rem; }
}

/* Saját térképjelölők (ui/marker.js) */
.map-marker { position: absolute; pointer-events: none; }
.map-marker-guess, .map-marker-flag { transform: translate(-50%, -100%); }
.map-marker-flag { transform: translate(-16%, -100%); }
.map-marker svg { display: block; filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.5)); }
.map-marker-numbered {
  transform: translate(-50%, -50%); width: 26px; height: 26px; border-radius: 50%;
  display: grid; place-items: center; background: var(--accent); color: var(--accent-text);
  border: 2px solid #08121f; font: 700 0.8rem/1 var(--font);
}

/* Köreredmény: teljes képernyős térkép, felül az eredménypanel (az alsó attribúciós sáv szabad) */
.screen-result-map { position: fixed; inset: 0; overflow: hidden; background: #000; }
.result-map { position: absolute; inset: 0; }
.result-panel {
  position: absolute; top: 0.75rem; left: 50%; transform: translateX(-50%); z-index: 3;
  width: min(30rem, calc(100vw - 1.5rem)); max-height: calc(100vh - 5rem); overflow-y: auto;
  display: flex; flex-direction: column; gap: 0.5rem; padding: 1rem 1.25rem; text-align: center;
  border-radius: 0.75rem; background: rgba(17, 21, 28, 0.92); color: var(--text);
}
.result-panel:focus { outline: none; }
.result-panel p { margin: 0; }
.result-title { margin: 0; font-size: 1rem; font-weight: 600; color: var(--muted); }
.result-distance { font-size: 1.35rem; font-weight: 700; }
.result-near { color: var(--muted); }
.result-legend { display: flex; justify-content: center; flex-wrap: wrap; gap: 0.25rem 1rem; margin: 0; padding: 0; list-style: none; color: var(--muted); font-size: 0.9rem; }
.legend-dot { display: inline-block; width: 0.85rem; height: 0.85rem; margin-right: 0.4rem; border-radius: 50%; border: 2px solid #08121f; vertical-align: -0.1rem; }
.legend-guess { background: #5aa9ff; }
.legend-flag { background: #ff5a4f; }
.result-bar { width: 100%; height: 0.85rem; accent-color: var(--accent); }
.result-points { font-weight: 600; }
.result-actions { display: flex; flex-direction: column; align-items: center; gap: 0.5rem; margin-top: 0.25rem; }
.result-link { color: var(--accent); min-height: 44px; display: inline-flex; align-items: center; }
.result-next { width: 100%; }
/* Fekvő telefon: a panel bal oldalon áll (transform nélkül: a fit.js ebből ismeri fel), a térkép
   a jobb oldali szabad területre illeszkedik */
@media (max-height: 520px) and (orientation: landscape) {
  .result-panel { left: 0.75rem; transform: none; width: min(19rem, 45vw); max-height: calc(100vh - 0.75rem - 36px); gap: 0.25rem; padding: 0.5rem 0.75rem; }
  .result-legend { display: none; }
  .result-distance { font-size: 1.1rem; }
  .result-next { min-height: 44px; padding: 0.25rem 1rem; font-size: 1rem; }
}
/* Alacsony álló nézet (pl. 320×480): a panel felül marad, középre igazítva (van transform), tömörebben */
@media (max-height: 520px) and (orientation: portrait) {
  .result-panel { max-height: 58vh; gap: 0.25rem; padding: 0.5rem 0.75rem; }
  .result-legend { display: none; }
  .result-distance { font-size: 1.1rem; }
  .result-next { min-height: 44px; padding: 0.25rem 1rem; font-size: 1rem; }
}

/* Végeredmény (ui/summary.js): a panel a köreredmény panelére épül, de szélesebb és balra igazított */
.map-marker-real { background: #ff5a4f; color: #08121f; }
.summary-panel { width: min(34rem, calc(100vw - 1.5rem)); max-height: calc(100vh - 0.75rem - 36px); text-align: left; gap: 0.75rem; }
.summary-panel h2 { margin: 0; font-size: 1.05rem; }
.summary-title { text-align: center; }
.summary-score { text-align: center; font-size: 1.75rem; font-weight: 700; }
.summary-rating { text-align: center; color: var(--accent); font-weight: 600; }
.summary-table { width: 100%; border-collapse: collapse; font-size: 0.95rem; }
.summary-table th, .summary-table td { padding: 0.3rem 0.5rem; text-align: left; border-bottom: 1px solid rgba(255, 255, 255, 0.12); }
.summary-table th[scope="row"] { font-weight: 600; }
.summary-table .num { text-align: right; }
.summary-table tfoot th, .summary-table tfoot td { font-weight: 700; border-bottom: 0; }
.summary-box, .summary-compare { display: flex; flex-direction: column; gap: 0.5rem; }
.summary-form { display: flex; flex-direction: column; gap: 0.5rem; }
.name-field { display: flex; flex-direction: column; gap: 0.25rem; }
.name-input, .link-input { min-height: 44px; padding: 0.4rem 0.6rem; border: 1px solid var(--muted); border-radius: 0.5rem; background: var(--bg); color: var(--text); font: inherit; width: 100%; }
.summary-msg { min-height: 1.5em; color: var(--accent); font-weight: 600; }
.cmp-verdict { font-weight: 700; text-align: center; }
.summary-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 0.5rem; }
.btn:disabled { background: #3a4456; color: #c9d1de; cursor: not-allowed; }
.btn-secondary { background: transparent; color: var(--text); border: 1px solid var(--muted); }
@media (min-width: 900px) {
  .summary-panel { left: 0.75rem; transform: none; width: 30rem; }
}
@media (max-height: 520px) and (orientation: landscape) {
  .summary-panel { left: 0.75rem; transform: none; width: min(26rem, 50vw); }
  .summary-panel .result-legend { display: flex; }
}
@media (max-width: 768px) and (orientation: portrait) {
  /* Álló telefon: a panel legfeljebb a kép 58%-a, a többit a térkép kapja (a panel görgethető) */
  .summary-panel { max-height: 58vh; }
}
