:root {
  --ink: #0b1f24;
  --ink-soft: #3d5c64;
  --paper: #e4eef0;
  --foam: #f2f8f9;
  --sea: #0f7a6c;
  --sea-deep: #0a4a42;
  --coral: #e4572e;
  --sand: #c9a66b;
  --shadow: 0 22px 55px rgba(11, 31, 36, 0.2);
  --radius: 18px;
  --font-display: "Bricolage Grotesque", Georgia, serif;
  --font-body: "Manrope", system-ui, sans-serif;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --panel: rgba(242, 248, 249, 0.9);
  --panel-border: rgba(11, 31, 36, 0.1);
}

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

[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  min-height: 100%;
  min-height: 100dvh;
}

body {
  font-family: var(--font-body);
  color: var(--ink);
  background: var(--paper);
  padding: var(--safe-top) 0 var(--safe-bottom);
}

.atmosphere {
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(900px 520px at 8% -10%, rgba(15, 122, 108, 0.38), transparent 55%),
    radial-gradient(720px 480px at 95% 5%, rgba(228, 87, 46, 0.2), transparent 50%),
    linear-gradient(165deg, #d3e8ea 0%, #e4eef0 45%, #cfe0e4 100%);
  animation: drift 18s ease-in-out infinite alternate;
}

@keyframes drift {
  from {
    filter: hue-rotate(0deg);
  }
  to {
    filter: hue-rotate(8deg);
  }
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  position: sticky;
  top: 0;
  z-index: 20;
  backdrop-filter: blur(10px);
}

.topbar-right,
.account-bar,
.cta-row,
.lobby-actions {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex-wrap: wrap;
}

.ghost {
  border: 0;
  background: transparent;
  color: var(--ink-soft);
  font: 600 0.9rem/1.2 var(--font-body);
  cursor: pointer;
  padding: 0.4rem 0.65rem;
  border-radius: 999px;
  text-decoration: none;
}

.ghost:hover {
  background: rgba(11, 31, 36, 0.06);
  color: var(--ink);
}

.ghost.sm {
  font-size: 0.8rem;
  padding: 0.25rem 0.5rem;
}

.danger-text {
  color: var(--coral);
}

main {
  width: min(1100px, 100% - 1.5rem);
  margin: 0 auto;
  padding-bottom: 2rem;
}

/* Spielansicht: FreeGuessr-Stil – Vollbild Street View */
body:has(#view-game.active) {
  overflow: hidden;
}

body:has(#view-game.active) .topbar {
  position: fixed;
  top: 0;
  right: 0;
  left: auto;
  z-index: 40;
  width: auto;
  padding: 0.45rem max(0.65rem, env(safe-area-inset-right)) 0.45rem 0.65rem;
  background: transparent;
  backdrop-filter: none;
}

body:has(#view-game.active) .topbar #btn-help {
  display: none;
}

body:has(#view-game.active) .topbar .ghost {
  color: #edf7f6;
  background: rgba(11, 31, 36, 0.55);
  backdrop-filter: blur(8px);
}

body:has(#view-game.active) .topbar .ghost:hover {
  background: rgba(11, 31, 36, 0.75);
  color: #fff;
}

body:has(#view-game.active) .atmosphere {
  display: none;
}

body:has(#view-game.active) main {
  width: 100%;
  max-width: none;
  margin: 0;
  padding: 0;
}

body:has(#view-game.active) #view-game {
  width: 100%;
  height: 100dvh;
}

.view {
  display: none;
  animation: rise 0.45s ease both;
}

.view.active {
  display: block;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.hero {
  min-height: calc(100dvh - 5rem);
  display: grid;
  align-content: center;
  gap: 1rem;
  padding: 1rem 0 2rem;
}

.brand {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(3rem, 10vw, 5.5rem);
  letter-spacing: -0.04em;
  line-height: 0.95;
  color: var(--sea-deep);
}

.brand.sm {
  font-size: 1.35rem;
  letter-spacing: -0.02em;
}

h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(1.6rem, 4vw, 2.4rem);
  font-weight: 600;
  letter-spacing: -0.02em;
  max-width: 16ch;
}

.lede {
  margin: 0;
  color: var(--ink-soft);
  font-size: 1.05rem;
  line-height: 1.5;
  max-width: 38ch;
}

.btn {
  border: 0;
  border-radius: 999px;
  padding: 0.75rem 1.25rem;
  font: 700 0.95rem/1.2 var(--font-body);
  cursor: pointer;
  transition: transform 0.15s ease, filter 0.15s ease;
}

.btn:hover:not(:disabled) {
  transform: translateY(-1px);
  filter: brightness(1.05);
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn.primary {
  background: var(--sea);
  color: #f5fffd;
}

.btn.secondary {
  background: rgba(11, 31, 36, 0.08);
  color: var(--ink);
}

.btn.sm {
  padding: 0.45rem 0.85rem;
  font-size: 0.85rem;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  padding: 1.15rem 1.25rem;
  box-shadow: var(--shadow);
}

.auth-panel,
.finish-panel {
  width: min(420px, 100%);
  margin: 2rem auto;
}

.subhead {
  margin: 0 0 0.85rem;
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.field {
  display: grid;
  gap: 0.35rem;
  margin-bottom: 0.85rem;
}

.field span,
.field-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--ink-soft);
}

.field input {
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  padding: 0.7rem 0.85rem;
  font: 600 1rem/1.2 var(--font-body);
  background: #fff;
  color: var(--ink);
}

.swatches {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.swatch {
  width: 1.7rem;
  height: 1.7rem;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
}

.swatch.active {
  border-color: var(--ink);
  transform: scale(1.08);
}

.error {
  color: var(--coral);
  font-size: 0.9rem;
  margin: 0 0 0.75rem;
}

.hint {
  color: var(--ink-soft);
  font-size: 0.85rem;
  margin: 0.5rem 0 0;
}

.account-panel {
  margin-top: 1.5rem;
  max-width: 420px;
}

.account-head {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  margin-bottom: 0.75rem;
}

.account-head img {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  object-fit: cover;
}

.account-name {
  margin: 0;
  font-weight: 700;
}

.player-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.45rem;
}

.player-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  padding: 0.55rem 0.65rem;
  border-radius: 12px;
  background: rgba(11, 31, 36, 0.04);
}

.player-meta {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 0;
}

.dot {
  width: 0.85rem;
  height: 0.85rem;
  border-radius: 50%;
  flex-shrink: 0;
}

.tag {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--sea-deep);
  white-space: nowrap;
}

.lobby-head {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: flex-start;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

.lobby-head h2 {
  margin: 0.2rem 0 0;
  font-family: var(--font-display);
  font-size: 1.8rem;
}

.lobby-grid {
  display: grid;
  gap: 0.85rem;
  grid-template-columns: 1.2fr 1fr;
}

@media (max-width: 720px) {
  .lobby-grid {
    grid-template-columns: 1fr;
  }
}

.friends-invite {
  margin-bottom: 0.85rem;
}

.game-shell {
  position: relative;
  width: 100%;
  height: 100dvh;
  min-height: 100dvh;
  overflow: hidden;
  background: #0b1f24;
}

.photo-stage {
  position: absolute;
  inset: 0;
  overflow: hidden;
  background: #0b1f24;
}

.street-view {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  background: #0b1f24;
}

.game-hud {
  position: absolute;
  top: max(0.65rem, env(safe-area-inset-top));
  left: max(0.65rem, env(safe-area-inset-left));
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0.45rem 0.85rem;
  border-radius: 12px;
  background: rgba(11, 31, 36, 0.78);
  color: #edf7f6;
  font-weight: 700;
  backdrop-filter: blur(10px);
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.28);
  pointer-events: none;
}

.hud-brand {
  font-family: var(--font-display);
  color: #7fd9c8;
}

.hud-timer {
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.04em;
  min-width: 3ch;
  text-align: center;
}

.scoreboard {
  position: absolute;
  top: max(0.65rem, env(safe-area-inset-top));
  right: max(4.5rem, env(safe-area-inset-right));
  z-index: 30;
  width: min(220px, 42vw);
  max-height: min(42dvh, 320px);
  overflow: auto;
  padding: 0.55rem 0.7rem;
  border-radius: 12px;
  background: rgba(242, 248, 249, 0.92);
  border: 1px solid rgba(11, 31, 36, 0.1);
  box-shadow: 0 10px 32px rgba(0, 0, 0, 0.22);
  backdrop-filter: blur(10px);
}

.scoreboard .subhead {
  margin: 0 0 0.35rem;
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

/* FreeGuessr-Minimap: unten links, expandiert bei Hover / Angeheftet */
.minimap-dock {
  --mini-w: min(280px, 42vw);
  --mini-h: min(200px, 28dvh);
  --mini-w-lg: min(460px, 56vw);
  --mini-h-lg: min(340px, 48dvh);
  position: absolute;
  left: max(0.75rem, env(safe-area-inset-left));
  bottom: max(0.75rem, env(safe-area-inset-bottom));
  z-index: 35;
  display: grid;
  gap: 0.4rem;
  width: var(--mini-w);
  transition: width 0.22s ease;
}

.minimap-dock:hover,
.minimap-dock:focus-within,
.minimap-dock.is-pinned {
  width: var(--mini-w-lg);
}

.minimap-frame {
  position: relative;
  height: var(--mini-h);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.35);
  border: 2px solid rgba(255, 255, 255, 0.55);
  background: #d9e2e8;
  transition: height 0.22s ease;
}

.minimap-dock:hover .minimap-frame,
.minimap-dock:focus-within .minimap-frame,
.minimap-dock.is-pinned .minimap-frame {
  height: var(--mini-h-lg);
}

.guess-map {
  width: 100%;
  height: 100%;
  min-height: 0;
  background: #d9e2e8;
}

.minimap-pin {
  position: absolute;
  top: 0.4rem;
  left: 0.4rem;
  z-index: 500;
  border: 0;
  border-radius: 8px;
  padding: 0.28rem 0.5rem;
  font: 600 0.68rem/1 var(--font-body);
  color: var(--ink);
  background: rgba(255, 255, 255, 0.92);
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.18);
}

.minimap-pin[aria-pressed="true"] {
  background: var(--sea);
  color: #fff;
}

.guess-submit {
  width: 100%;
  justify-content: center;
  font-size: 0.82rem;
  padding: 0.7rem 0.75rem;
  border-radius: 10px;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.28);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.guess-submit:disabled {
  opacity: 0.85;
  cursor: not-allowed;
  background: #4a5c62;
  color: #edf7f6;
  border-color: transparent;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.reveal-map {
  width: 100%;
  height: 100%;
  min-height: 280px;
  border-radius: 12px;
  overflow: hidden;
  background: #d9e2e8;
}

@media (max-width: 720px) {
  .minimap-dock {
    --mini-w: min(220px, 58vw);
    --mini-h: min(150px, 22dvh);
    --mini-w-lg: min(100% - 1.5rem, 92vw);
    --mini-h-lg: min(280px, 40dvh);
  }

  .scoreboard {
    top: auto;
    bottom: calc(var(--mini-h) + 4.5rem);
    right: max(0.65rem, env(safe-area-inset-right));
    left: auto;
    width: min(180px, 46vw);
    max-height: 22dvh;
  }

  .game-hud {
    font-size: 0.85rem;
    gap: 0.55rem;
    padding: 0.4rem 0.65rem;
  }
}

.reveal-shell {
  display: grid;
  gap: 0.85rem;
  padding: 0.5rem 0 2rem;
}

.reveal-head h2 {
  margin: 0.2rem 0;
  font-family: var(--font-display);
  font-size: clamp(1.6rem, 4vw, 2.2rem);
}

.reveal-map-wrap {
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}

.reveal-map {
  height: min(48dvh, 420px);
}

.reveal-results li strong {
  font-variant-numeric: tabular-nums;
}

.podium {
  list-style: none;
  margin: 1rem 0;
  padding: 0;
  display: grid;
  gap: 0.5rem;
}

.podium li {
  display: flex;
  justify-content: space-between;
  padding: 0.7rem 0.85rem;
  border-radius: 12px;
  background: rgba(15, 122, 108, 0.1);
  font-weight: 700;
}

.podium li:first-child {
  background: rgba(228, 87, 46, 0.14);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: max(1.25rem, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 50;
  background: var(--ink);
  color: #edf7f6;
  padding: 0.7rem 1.1rem;
  border-radius: 999px;
  font-weight: 600;
  box-shadow: var(--shadow);
}

.leaflet-container {
  font: inherit;
}
