/* ═══════════════ Weltenrater — Mitternachts-Atlas ═══════════════ */

:root {
  --ink: #0b1220;
  --ink-2: #101a2e;
  --ink-3: #16233d;
  --line: rgba(212, 175, 110, 0.18);
  --paper: #efe6d3;
  --paper-dim: #b8ad94;
  --amber: #e3a83b;
  --amber-bright: #f2c168;
  --teal: #4fd6c0;
  --red: #e05d5d;
  --font-display: 'Fraunces', serif;
  --font-body: 'Albert Sans', sans-serif;
  --font-mono: 'IBM Plex Mono', monospace;
}

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

html, body { height: 100%; }

body {
  background: radial-gradient(120% 90% at 50% 0%, var(--ink-2) 0%, var(--ink) 55%, #070c16 100%);
  color: var(--paper);
  font-family: var(--font-body);
  overflow: hidden;
}

/* Körnung + Meridianlinien für Atmosphäre */
.grain {
  position: fixed; inset: 0; z-index: 999; pointer-events: none; opacity: 0.05;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}
.meridians {
  position: fixed; inset: 0; z-index: 0; pointer-events: none; opacity: 0.5;
  background:
    repeating-linear-gradient(90deg, transparent 0 119px, var(--line) 119px 120px),
    repeating-linear-gradient(0deg, transparent 0 119px, var(--line) 119px 120px);
  mask-image: radial-gradient(80% 70% at 50% 40%, black 0%, transparent 85%);
  -webkit-mask-image: radial-gradient(80% 70% at 50% 40%, black 0%, transparent 85%);
}

/* ─────────── Screens ─────────── */
.screen { position: fixed; inset: 0; display: none; z-index: 1; overflow-y: auto; }
.screen.active { display: block; }

/* ─────────── Typo-Bausteine ─────────── */
.kicker {
  font-family: var(--font-mono); font-size: 12px; letter-spacing: 0.35em;
  text-transform: uppercase; color: var(--amber); margin-bottom: 10px;
}
.title {
  font-family: var(--font-display); font-weight: 900; font-size: clamp(52px, 9vw, 108px);
  line-height: 0.95; letter-spacing: -0.02em;
}
.title em { font-style: italic; font-weight: 400; color: var(--amber-bright); }
.title-small { font-size: clamp(40px, 6vw, 72px); }
.subtitle { color: var(--paper-dim); font-size: 17px; line-height: 1.55; margin-top: 18px; }
.byline {
  font-family: var(--font-display); font-style: italic; font-size: 13px;
  color: var(--amber); margin-top: 8px; letter-spacing: 0.04em; opacity: 0.85;
}
.byline::before, .byline::after { content: ' ~ '; opacity: 0.5; }
.copyright {
  margin-top: 34px; font-family: var(--font-mono); font-size: 11px;
  color: var(--paper-dim); opacity: 0.65; letter-spacing: 0.06em; text-align: center;
}

/* ─────────── Buttons & Inputs ─────────── */
.btn {
  font-family: var(--font-body); font-weight: 700; font-size: 16px;
  border: none; border-radius: 4px; padding: 14px 26px; cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.2s ease, background 0.2s ease;
}
.btn:active { transform: translateY(1px); }
.btn-primary {
  background: linear-gradient(180deg, var(--amber-bright), var(--amber));
  color: #211502;
  box-shadow: 0 0 0 1px rgba(242, 193, 104, 0.4), 0 8px 28px rgba(227, 168, 59, 0.25);
}
.btn-primary:hover { box-shadow: 0 0 0 1px var(--amber-bright), 0 10px 34px rgba(227, 168, 59, 0.45); }
.btn-primary:disabled { filter: grayscale(0.7) brightness(0.7); cursor: not-allowed; box-shadow: none; }
.btn-ghost {
  background: transparent; color: var(--paper);
  border: 1px solid rgba(239, 230, 211, 0.3);
}
.btn-ghost:hover { border-color: var(--amber); color: var(--amber-bright); }

input[type="text"] {
  font-family: var(--font-body); font-size: 16px; color: var(--paper);
  background: rgba(7, 12, 22, 0.7); border: 1px solid rgba(239, 230, 211, 0.2);
  border-radius: 4px; padding: 13px 16px; outline: none; width: 100%;
  transition: border-color 0.2s ease;
}
input[type="text"]:focus { border-color: var(--amber); }
input::placeholder { color: rgba(239, 230, 211, 0.35); }

.error-msg { color: var(--red); font-size: 14px; margin-top: 12px; }
.key-warning {
  margin-top: 14px; padding: 12px 14px; border: 1px dashed var(--red);
  border-radius: 4px; color: #f0b1b1; font-size: 13.5px; line-height: 1.5;
}
.key-warning code { font-family: var(--font-mono); color: var(--amber-bright); }

/* ─────────── Startscreen ─────────── */
.home-wrap {
  min-height: 100%; display: flex; flex-direction: column;
  align-items: center; justify-content: center; text-align: center;
  padding: 48px 24px; position: relative;
}
.compass-rose {
  width: 130px; height: 130px; color: var(--amber); margin-bottom: 26px; opacity: 0.9;
}
.rose-needle { transform-origin: 100px 100px; animation: needle-drift 9s ease-in-out infinite; }
@keyframes needle-drift {
  0%, 100% { transform: rotate(-8deg); }
  30% { transform: rotate(14deg); }
  60% { transform: rotate(-3deg); }
}
.home-card {
  margin-top: 40px; width: min(430px, 92vw);
  background: rgba(16, 26, 46, 0.75); border: 1px solid var(--line);
  border-radius: 8px; padding: 28px; backdrop-filter: blur(6px);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.45);
  animation: rise 0.7s cubic-bezier(0.2, 0.9, 0.3, 1) both 0.15s;
}
@keyframes rise { from { opacity: 0; transform: translateY(26px); } }
.field { display: block; text-align: left; }
.field-label {
  display: block; font-family: var(--font-mono); font-size: 11px;
  letter-spacing: 0.2em; text-transform: uppercase; color: var(--paper-dim); margin-bottom: 8px;
}
.home-actions { margin-top: 20px; display: flex; flex-direction: column; gap: 14px; }
.home-actions .btn-primary { width: 100%; padding: 16px; font-size: 17px; }
.join-row { display: flex; gap: 10px; }
.join-row input {
  width: 120px; text-transform: uppercase; font-family: var(--font-mono);
  letter-spacing: 0.25em; text-align: center;
}
.join-row .btn { flex: 1; }
.footnote {
  margin-top: 28px; font-family: var(--font-mono); font-size: 12px;
  color: var(--paper-dim); letter-spacing: 0.08em;
}
.footnote::before, .footnote::after { content: ' ─── '; opacity: 0.4; }

/* ─────────── Lobby ─────────── */
.lobby-wrap { max-width: 1060px; margin: 0 auto; padding: 48px 28px 64px; }
.lobby-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 24px; flex-wrap: wrap; }
.lobby-title { font-family: var(--font-display); font-weight: 900; font-size: 56px; }
.code-badge {
  background: rgba(227, 168, 59, 0.08); border: 1px dashed var(--amber);
  border-radius: 6px; padding: 12px 22px; cursor: pointer; text-align: center;
  color: var(--paper); transition: background 0.2s ease;
}
.code-badge:hover { background: rgba(227, 168, 59, 0.16); }
.code-label { display: block; font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.3em; text-transform: uppercase; color: var(--paper-dim); }
.code-value { display: block; font-family: var(--font-mono); font-size: 34px; font-weight: 600; letter-spacing: 0.3em; color: var(--amber-bright); margin: 2px 0; }
.code-hint { display: block; font-size: 10px; color: var(--paper-dim); }

.lobby-grid { display: grid; grid-template-columns: 1.5fr 1fr; gap: 22px; margin-top: 32px; }
@media (max-width: 820px) { .lobby-grid { grid-template-columns: 1fr; } }

.panel {
  background: rgba(16, 26, 46, 0.75); border: 1px solid var(--line);
  border-radius: 8px; padding: 24px;
}
.panel-title { font-family: var(--font-display); font-size: 24px; font-weight: 600; margin-bottom: 18px; }
.count-badge {
  font-family: var(--font-mono); font-size: 13px; background: var(--ink-3);
  border-radius: 999px; padding: 3px 10px; vertical-align: 3px; color: var(--amber-bright);
}
.lock-note { font-size: 13px; color: var(--paper-dim); margin-bottom: 14px; font-style: italic; }

.setting-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 13px 0; border-top: 1px solid rgba(239, 230, 211, 0.08); flex-wrap: wrap; }
.setting-label { font-size: 15px; font-weight: 500; }
.seg { display: flex; background: rgba(7, 12, 22, 0.6); border-radius: 5px; padding: 3px; gap: 3px; }
.seg-btn {
  font-family: var(--font-body); font-size: 13.5px; font-weight: 500; color: var(--paper-dim);
  background: transparent; border: none; border-radius: 3px; padding: 7px 13px; cursor: pointer;
  transition: all 0.15s ease;
}
.seg-btn:hover { color: var(--paper); }
.seg-btn.active { background: var(--amber); color: #211502; font-weight: 700; }
.seg[data-locked="1"] .seg-btn { pointer-events: none; opacity: 0.7; }

.country-picker { padding: 12px 0; border-top: 1px solid rgba(239, 230, 211, 0.08); }
.country-tools { display: flex; gap: 10px; margin-bottom: 12px; }
.country-tools input { flex: 1; padding: 9px 12px; font-size: 14px; }
.mini-btn {
  font-size: 12.5px; color: var(--paper-dim); background: transparent;
  border: 1px solid rgba(239, 230, 211, 0.2); border-radius: 4px; padding: 0 12px; cursor: pointer;
}
.mini-btn:hover { color: var(--paper); border-color: var(--paper-dim); }
.country-chips { display: flex; flex-wrap: wrap; gap: 7px; max-height: 220px; overflow-y: auto; padding-right: 4px; }
.chip {
  font-size: 13px; padding: 6px 12px; border-radius: 999px; cursor: pointer;
  background: rgba(7, 12, 22, 0.6); color: var(--paper-dim);
  border: 1px solid rgba(239, 230, 211, 0.15); transition: all 0.15s ease;
}
.chip:hover { color: var(--paper); }
.chip.selected { background: rgba(79, 214, 192, 0.15); color: var(--teal); border-color: var(--teal); }
.chip[data-locked="1"] { pointer-events: none; }

.player-list { list-style: none; margin-bottom: 20px; }
.player-list li {
  display: flex; align-items: center; gap: 10px; padding: 11px 6px;
  border-bottom: 1px solid rgba(239, 230, 211, 0.08); font-size: 15.5px;
  animation: rise 0.4s ease both;
}
.player-list .host-star { color: var(--amber); font-size: 13px; }
.player-list .you-tag { font-family: var(--font-mono); font-size: 10.5px; color: var(--teal); border: 1px solid var(--teal); border-radius: 3px; padding: 1px 6px; }
.btn-start { width: 100%; padding: 16px; font-size: 17px; }
.lobby-hint { color: var(--paper-dim); font-size: 14px; text-align: center; font-style: italic; }

/* ─────────── Loading ─────────── */
.loading-wrap { height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 22px; }
.loading-globe { font-size: 72px; animation: spin-bounce 1.6s ease-in-out infinite; }
@keyframes spin-bounce {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  50% { transform: translateY(-16px) rotate(180deg); }
}
.loading-text { font-family: var(--font-mono); letter-spacing: 0.12em; color: var(--paper-dim); }

/* ─────────── Spiel / Street View ─────────── */
#screen-game { overflow: hidden; }
#pano { position: absolute; inset: 0; background: #000; }

.hud-top {
  position: absolute; top: 18px; left: 50%; transform: translateX(-50%);
  display: flex; gap: 10px; z-index: 5;
}
.hud-pill {
  background: rgba(11, 18, 32, 0.88); border: 1px solid var(--line);
  border-radius: 6px; padding: 8px 18px; text-align: center; backdrop-filter: blur(4px);
}
.hud-label { display: block; font-family: var(--font-mono); font-size: 9.5px; letter-spacing: 0.25em; text-transform: uppercase; color: var(--paper-dim); }
.hud-value { font-family: var(--font-mono); font-size: 19px; font-weight: 600; color: var(--paper); }
.hud-timer.urgent .hud-value { color: var(--red); animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: 0.45; } }

.hud-compass {
  position: absolute; top: 18px; right: 18px; width: 62px; height: 62px;
  color: var(--paper); z-index: 5; background: rgba(11, 18, 32, 0.88);
  border: 1px solid var(--line); border-radius: 50%; padding: 4px;
}
.hud-compass .compass-n {
  position: absolute; top: 5px; left: 50%; transform: translateX(-50%);
  font-family: var(--font-mono); font-size: 8px; color: var(--amber);
}
#compass-needle { transform-origin: 30px 30px; transition: transform 0.1s linear; }

.game-controls { position: absolute; top: 18px; left: 18px; z-index: 5; display: flex; flex-direction: column; gap: 10px; align-items: flex-start; }
.ctrl-btn {
  font-family: var(--font-body); font-size: 13.5px; font-weight: 600; color: var(--paper);
  background: rgba(11, 18, 32, 0.88); border: 1px solid var(--line); border-radius: 6px;
  padding: 9px 15px; cursor: pointer; backdrop-filter: blur(4px);
}
.ctrl-btn:hover { border-color: var(--amber); color: var(--amber-bright); }
.ctrl-danger:hover { border-color: var(--red); color: #f0b1b1; }

/* Zugangs-Sperre */
.gate-text { font-size: 15px; line-height: 1.6; margin-bottom: 18px; text-align: center; color: var(--paper-dim); }
.btn-access { width: 100%; margin-top: 16px; }
.keys-hint {
  font-size: 12px; color: var(--paper-dim); background: rgba(11, 18, 32, 0.7);
  border-radius: 6px; padding: 7px 11px;
}
.keys-hint kbd {
  font-family: var(--font-mono); font-size: 11px; background: var(--ink-3);
  border: 1px solid rgba(239, 230, 211, 0.25); border-bottom-width: 2px;
  border-radius: 3px; padding: 1px 5px; margin-right: 3px; color: var(--paper);
}

/* Rate-Karte unten rechts — wächst bei Hover */
.guess-box {
  position: absolute; bottom: 22px; right: 22px; z-index: 6;
  width: 300px; display: flex; flex-direction: column; gap: 8px;
  transition: width 0.25s cubic-bezier(0.2, 0.9, 0.3, 1);
}
.guess-box:hover, .guess-box.pinned { width: min(560px, 46vw); }
#guess-map {
  height: 200px; border-radius: 8px; overflow: hidden;
  border: 2px solid rgba(227, 168, 59, 0.55);
  box-shadow: 0 14px 44px rgba(0, 0, 0, 0.6);
  transition: height 0.25s cubic-bezier(0.2, 0.9, 0.3, 1);
  opacity: 0.85;
}
.guess-box:hover #guess-map, .guess-box.pinned #guess-map { height: min(380px, 44vh); opacity: 1; }
.btn-guess { width: 100%; padding: 13px; font-size: 15.5px; }

/* ─────────── Rundenergebnis ─────────── */
.result-wrap { height: 100%; display: grid; grid-template-columns: 1fr 380px; }
@media (max-width: 880px) { .result-wrap { grid-template-columns: 1fr; grid-template-rows: 1fr auto; } }
#result-map { background: var(--ink-2); }
.result-panel {
  padding: 34px 28px; overflow-y: auto; background: rgba(11, 18, 32, 0.97);
  border-left: 1px solid var(--line); display: flex; flex-direction: column;
}
.result-country { font-family: var(--font-display); font-weight: 900; font-size: 36px; margin-bottom: 20px; }
.result-list { list-style: none; flex: 1; }
.result-list li {
  display: grid; grid-template-columns: 26px 1fr auto; gap: 10px; align-items: center;
  padding: 12px 4px; border-bottom: 1px solid rgba(239, 230, 211, 0.08);
  animation: rise 0.5s ease both;
}
.result-list li:nth-child(2) { animation-delay: 0.08s; }
.result-list li:nth-child(3) { animation-delay: 0.16s; }
.result-list li:nth-child(4) { animation-delay: 0.24s; }
.result-list .dot { width: 13px; height: 13px; border-radius: 50%; border: 2px solid var(--ink); }
.result-list .r-name { font-weight: 600; }
.result-list .r-dist { display: block; font-family: var(--font-mono); font-size: 11.5px; color: var(--paper-dim); }
.result-list .r-pts { font-family: var(--font-mono); font-size: 19px; font-weight: 600; color: var(--amber-bright); text-align: right; }
.result-list .r-total { display: block; font-family: var(--font-mono); font-size: 11px; color: var(--paper-dim); text-align: right; }
.result-panel .btn { margin-top: 18px; }

/* ─────────── Endstand ─────────── */
.final-wrap {
  min-height: 100%; display: flex; flex-direction: column; align-items: center;
  justify-content: center; padding: 48px 24px; text-align: center;
}
.final-list { list-style: none; margin-top: 36px; width: min(520px, 92vw); counter-reset: rank; }
.final-list li {
  counter-increment: rank;
  display: flex; align-items: center; gap: 18px;
  background: rgba(16, 26, 46, 0.75); border: 1px solid var(--line);
  border-radius: 8px; padding: 18px 24px; margin-bottom: 12px;
  animation: rise 0.6s cubic-bezier(0.2, 0.9, 0.3, 1) both;
}
.final-list li::before {
  content: counter(rank);
  font-family: var(--font-display); font-style: italic; font-size: 30px; color: var(--paper-dim);
  min-width: 36px;
}
.final-list li:first-child {
  border-color: var(--amber); background: rgba(227, 168, 59, 0.1);
  box-shadow: 0 0 44px rgba(227, 168, 59, 0.2);
  transform: scale(1.04);
}
.final-list li:first-child::before { content: '👑'; font-size: 26px; }
.final-list li:nth-child(2) { animation-delay: 0.1s; }
.final-list li:nth-child(3) { animation-delay: 0.2s; }
.final-list li:nth-child(4) { animation-delay: 0.3s; }
.final-list .f-name { flex: 1; text-align: left; font-size: 19px; font-weight: 700; }
.final-list .f-pts { font-family: var(--font-mono); font-size: 21px; color: var(--amber-bright); }
.final-actions { margin-top: 30px; }

/* ─────────── Highscores / Ruhmeshalle ─────────── */
.highscore-box {
  margin-top: 30px; width: min(520px, 92vw);
  background: rgba(16, 26, 46, 0.6); border: 1px solid var(--line);
  border-radius: 8px; padding: 20px 24px; text-align: left;
  animation: rise 0.7s cubic-bezier(0.2, 0.9, 0.3, 1) both 0.3s;
}
.highscore-title {
  font-family: var(--font-display); font-size: 20px; font-weight: 600;
  margin-bottom: 12px; color: var(--amber-bright);
}
.highscore-list { list-style: none; counter-reset: hs; }
.highscore-list li {
  counter-increment: hs;
  display: grid; grid-template-columns: 28px 1fr auto; gap: 10px; align-items: baseline;
  padding: 7px 4px; border-bottom: 1px solid rgba(239, 230, 211, 0.07);
  font-size: 14.5px;
}
.highscore-list li:last-child { border-bottom: none; }
.highscore-list li::before {
  content: counter(hs) '.';
  font-family: var(--font-mono); font-size: 12.5px; color: var(--paper-dim);
}
.highscore-list li:first-child::before { content: '👑'; }
.highscore-list .hs-name { font-weight: 600; }
.highscore-list .hs-meta { display: block; font-family: var(--font-mono); font-size: 10.5px; color: var(--paper-dim); }
.highscore-list .hs-pts { font-family: var(--font-mono); font-size: 15px; color: var(--amber-bright); text-align: right; }
.highscore-list .hs-avg { display: block; font-family: var(--font-mono); font-size: 10px; color: var(--paper-dim); text-align: right; }
.highscore-list li.hs-new {
  background: rgba(79, 214, 192, 0.08); border-radius: 4px;
  outline: 1px solid rgba(79, 214, 192, 0.4);
}

/* ─────────── Toast ─────────── */
.toast {
  position: fixed; bottom: 28px; left: 50%; transform: translateX(-50%);
  background: var(--ink-3); border: 1px solid var(--amber); color: var(--paper);
  border-radius: 6px; padding: 12px 22px; font-size: 14.5px; z-index: 1000;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
  animation: rise 0.3s ease both;
}

/* Scrollbars */
::-webkit-scrollbar { width: 9px; }
::-webkit-scrollbar-thumb { background: var(--ink-3); border-radius: 5px; }
::-webkit-scrollbar-track { background: transparent; }
