:root {
  --bg: #0c0c0e;
  --bg2: #121214;
  --panel: #161618;
  --panel2: #1c1c1f;
  --line: #2a2a2e;
  --line2: #333338;
  --text: #ececee;
  --muted: #8b8b93;
  --muted2: #6a6a72;
  --accent: #e8e8ea;
  --btn: #f2f2f4;
  --btn-text: #111113;
  --danger: #e05555;
  --ok: #5cb87a;
  --radius: 12px;
  --radius-sm: 8px;
  --font: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  min-height: 100vh;
  font-size: 14px;
  line-height: 1.45;
}
button { font: inherit; cursor: pointer; }
a { color: inherit; text-decoration: none; }
input, select, textarea {
  font: inherit;
  color: var(--text);
  background: var(--bg2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 11px 12px;
  outline: none;
  width: 100%;
}
input:focus, select:focus, textarea:focus { border-color: #55555c; }
.hidden { display: none !important; }

/* Topbar */
.topbar {
  height: 56px;
  border-bottom: 1px solid var(--line);
  background: var(--bg2);
  display: flex;
  align-items: center;
  padding: 0 20px;
  gap: 28px;
  position: sticky;
  top: 0;
  z-index: 30;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 150px;
}
.brand-text b {
  display: block;
  font-size: 14px;
  letter-spacing: 0.8px;
  font-weight: 700;
}
.brand-mark { display: none; }
.brand small { display: none; }
nav { display: flex; gap: 2px; flex: 1; }
.nav-btn, .ghost {
  background: transparent;
  border: 0;
  color: var(--muted);
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 13px;
}
.nav-btn:hover, .ghost:hover { color: var(--text); background: rgba(255,255,255,0.04); }
.nav-btn.active { color: var(--text); background: rgba(255,255,255,0.07); }
.account { display: flex; gap: 8px; align-items: center; }
.user-chip {
  font-size: 12px;
  color: var(--muted);
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
}

/* Buttons */
.primary {
  background: var(--btn);
  color: var(--btn-text);
  border: 0;
  font-weight: 600;
  padding: 11px 16px;
  border-radius: var(--radius-sm);
}
.primary:hover { filter: brightness(0.95); }
.primary:disabled { opacity: 0.45; cursor: not-allowed; }
.small { padding: 7px 12px; font-size: 12px; }
.secondary-btn {
  border: 1px solid var(--line) !important;
  color: var(--text) !important;
  padding: 11px 16px !important;
  border-radius: var(--radius-sm);
  font-weight: 600;
  background: transparent !important;
}
.secondary-btn:hover { background: rgba(255,255,255,0.04) !important; }
.danger { color: var(--danger) !important; }

/* Pages */
.page { min-height: calc(100vh - 56px - 48px); }
.section-head { margin-bottom: 18px; }
.section-head h2 { margin: 6px 0 4px; font-size: 22px; font-weight: 650; letter-spacing: -0.3px; }
.section-head h3 { margin: 4px 0; font-size: 15px; font-weight: 600; }
.kicker, .eyebrow {
  color: var(--muted2);
  font-size: 11px;
  letter-spacing: 0.8px;
  font-weight: 600;
  text-transform: uppercase;
}
.sub { color: var(--muted); font-size: 13px; margin: 6px 0 0; }

/* Hero */
.hero {
  max-width: 1100px;
  margin: 0 auto;
  padding: 64px 24px 48px;
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 48px;
  align-items: center;
}
.hero h1 {
  font-size: clamp(32px, 4.5vw, 44px);
  line-height: 1.1;
  letter-spacing: -0.8px;
  margin: 12px 0 16px;
  font-weight: 650;
}
.hero h1 span { color: var(--muted); }
.hero p { color: var(--muted); max-width: 460px; font-size: 15px; line-height: 1.6; margin: 0; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 22px; align-items: center; }
.hero-btn { margin-top: 0; }
.hero-btn span { margin-left: 8px; opacity: 0.7; }

.hero-card {
  height: 280px;
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: var(--radius);
  position: relative;
  overflow: hidden;
  padding: 24px;
}
.hero-card-title {
  color: var(--muted2);
  font-size: 11px;
  letter-spacing: 1px;
  font-weight: 600;
}
.hero-card-big {
  font-size: 36px;
  font-weight: 700;
  letter-spacing: -1px;
  line-height: 1.05;
  margin-top: 18px;
}
.coords { position: absolute; bottom: 22px; left: 24px; color: var(--muted2); font-size: 12px; }
.scan { display: none; }

/* Auth / forms */
.auth-page { max-width: 420px; margin: 0 auto; padding: 56px 24px; }
.auth-card {
  background: var(--panel);
  border: 1px solid var(--line);
  padding: 24px;
  border-radius: var(--radius);
}
.auth-card h2, .auth-card h3 { margin: 6px 0 16px; font-weight: 650; }
.form-group { margin-bottom: 12px; }
.form-group label {
  display: block;
  font-size: 11px;
  letter-spacing: 0.4px;
  color: var(--muted2);
  margin-bottom: 6px;
  text-transform: uppercase;
  font-weight: 600;
}
.form-actions { display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.form-tip { font-size: 12px; color: var(--muted2); margin: 12px 0 0; line-height: 1.45; }
.coords-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* Leaderboard / tables */
.leaderboard { max-width: 800px; margin: 0 auto; padding: 48px 24px 80px; }
.table-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
.table-row {
  display: grid;
  grid-template-columns: 56px 1fr 1fr 100px;
  gap: 8px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  align-items: center;
  font-size: 13px;
}
.table-row:last-child { border-bottom: 0; }
.table-row.th {
  color: var(--muted2);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 600;
  background: var(--bg2);
}
.table-row b { text-align: right; font-weight: 650; }
.user-actions { display: flex; flex-wrap: wrap; gap: 4px; justify-content: flex-end; }
.user-row small { color: var(--muted2); }

/* Duels */
.duels-page { max-width: 960px; margin: 0 auto; padding: 48px 24px 80px; }
.duel-hero {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 24px;
  margin-bottom: 24px;
}
.duel-hero h2 { margin: 6px 0 8px; font-size: 24px; font-weight: 650; }
.duel-hero p { color: var(--muted); margin: 0; max-width: 480px; }
.duel-emblem {
  width: 88px;
  height: 88px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  display: grid;
  place-items: center;
  font-size: 28px;
  text-align: center;
}
.duel-emblem small { display: block; font-size: 10px; color: var(--muted2); margin-top: 4px; letter-spacing: 1px; }
.duel-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.duel-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
}
.duel-card h3 { font-size: 17px; margin: 6px 0 8px; font-weight: 650; }
.duel-card p { color: var(--muted); font-size: 13px; margin: 0 0 16px; }
.join-row { display: flex; gap: 8px; }
.join-row input {
  flex: 1;
  text-transform: uppercase;
  letter-spacing: 2px;
}
.duel-lobby {
  margin-top: 12px;
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: var(--radius);
  padding: 20px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.duel-lobby h3 { font-size: 18px; margin: 6px 0; font-weight: 650; }
.duel-lobby h3 b { letter-spacing: 2px; }
.duel-lobby p { color: var(--muted); margin: 0; }
.duel-players {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
}
.player {
  border: 1px solid var(--line);
  background: var(--bg2);
  padding: 14px 18px;
  text-align: center;
  font-size: 12px;
  letter-spacing: 0.5px;
  border-radius: var(--radius-sm);
  min-width: 110px;
}
.player span { display: block; color: var(--muted2); font-size: 10px; margin-top: 6px; }
.player.ready span { color: var(--ok); }
.vs { color: var(--muted2); font-weight: 700; font-size: 12px; }
.duel-lobby .primary { grid-column: 1 / -1; }

/* Admin */
.admin-page { max-width: 1280px; margin: 0 auto; padding: 40px 24px 80px; }
.admin-tabs { display: flex; gap: 4px; margin: 8px 0 16px; }
.admin-layout {
  display: grid;
  grid-template-columns: 340px 1fr;
  gap: 14px;
}
.admin-form-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  padding: 18px;
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  gap: 18px;
  max-height: calc(100vh - 160px);
  overflow: auto;
}
.admin-map-panel {
  position: relative;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--bg2);
}
#adminMap { height: min(680px, calc(100vh - 180px)); width: 100%; }
.admin-map-bg { filter: saturate(0.85) brightness(0.9); }
.map-hint {
  position: absolute;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(12, 12, 14, 0.88);
  border: 1px solid var(--line);
  padding: 7px 12px;
  font-size: 11px;
  color: var(--muted);
  border-radius: 6px;
  pointer-events: none;
  z-index: 500;
  white-space: nowrap;
}
.admin-list-wrap { border-top: 1px solid var(--line); padding-top: 14px; }
.admin-list-wrap h3 b { margin-left: 6px; color: var(--muted); font-weight: 600; }
.custom-list { display: flex; flex-direction: column; gap: 8px; max-height: 260px; overflow: auto; }
.custom-item {
  display: grid;
  grid-template-columns: 48px 1fr auto;
  gap: 10px;
  align-items: center;
  background: var(--bg2);
  border: 1px solid var(--line);
  padding: 8px;
  border-radius: var(--radius-sm);
}
.custom-item img {
  width: 48px;
  height: 36px;
  object-fit: cover;
  border-radius: 4px;
  background: var(--panel2);
}
.custom-meta h4 { margin: 0 0 2px; font-size: 13px; font-weight: 600; }
.custom-meta p { margin: 0; font-size: 11px; color: var(--muted2); }
.empty-list { color: var(--muted2); font-size: 13px; padding: 8px 0; }
.admin-marker {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--btn);
  border: 2px solid #fff;
  box-shadow: 0 1px 4px rgba(0,0,0,0.45);
}
.correct-marker {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--danger);
  border: 2px solid #fff;
  box-shadow: 0 1px 4px rgba(0,0,0,0.4);
}
.section-head.compact { margin-bottom: 0; }

/* Game */
.game { min-height: 100vh; display: flex; flex-direction: column; }
.gamebar {
  height: 52px;
  border-bottom: 1px solid var(--line);
  background: var(--bg2);
  display: flex;
  align-items: center;
  padding: 0 16px;
  gap: 20px;
}
.gamebar .back {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--muted);
  padding: 7px 12px;
  border-radius: 6px;
}
.gamebar .back:hover { color: var(--text); }
.gamebar .round, .gamebar .score {
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0.4px;
}
.gamebar b { color: var(--text); font-weight: 650; }
.game-layout {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr 1fr;
  min-height: 0;
}
.photo-panel, .map-panel {
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.map-panel { border-right: 0; }
.photo-placeholder {
  flex: 1;
  position: relative;
  background: var(--panel);
  min-height: 320px;
  overflow: hidden;
}
.scene-image {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: none;
}
.fake-scene {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--muted2);
  font-size: 14px;
  letter-spacing: 1px;
}
.photo-overlay {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 18px 16px;
  background: linear-gradient(transparent, rgba(0,0,0,0.72));
}
.photo-overlay span {
  font-size: 10px;
  letter-spacing: 1px;
  color: var(--muted);
  font-weight: 600;
}
.photo-overlay h2 { margin: 4px 0 2px; font-size: 18px; font-weight: 650; }
.photo-overlay p { margin: 0; color: #c8c8ce; font-size: 12px; }
.controls {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  border-top: 1px solid var(--line);
  color: var(--muted2);
  font-size: 12px;
  background: var(--bg2);
}
.controls b { color: var(--text); }
#map {
  flex: 1;
  min-height: 320px;
  background: var(--bg2);
}
.snap-map-bg { filter: saturate(0.85) brightness(0.9); }
.guess {
  margin: 12px;
  width: calc(100% - 24px);
}
.marker-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--btn);
  border: 2px solid #fff;
  box-shadow: 0 1px 4px rgba(0,0,0,0.4);
}
.result {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%);
  width: min(520px, calc(100% - 24px));
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
  display: flex;
  align-items: center;
  gap: 16px;
  z-index: 40;
  box-shadow: 0 12px 40px rgba(0,0,0,0.4);
}
.result h2 { margin: 4px 0 2px; font-size: 17px; font-weight: 650; }
.result p { margin: 0; color: var(--muted); font-size: 13px; }
.result-score {
  margin-left: auto;
  text-align: right;
  white-space: nowrap;
}
.result-score span {
  display: block;
  font-size: 10px;
  color: var(--muted2);
  letter-spacing: 0.5px;
}
.result-score b { font-size: 22px; font-weight: 700; }

/* Toast / footer */
.toast {
  position: fixed;
  top: 72px;
  left: 50%;
  transform: translateX(-50%) translateY(-12px);
  background: var(--panel2);
  border: 1px solid var(--line);
  color: var(--text);
  padding: 10px 16px;
  border-radius: 8px;
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transition: 0.2s ease;
  z-index: 50;
  max-width: 90vw;
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
footer { display: none !important; }

/* Leaflet tweaks */
.leaflet-container { background: var(--bg2); font: inherit; }
.leaflet-control-zoom a {
  background: var(--panel) !important;
  color: var(--text) !important;
  border-color: var(--line) !important;
}
.leaflet-bar { border-color: var(--line) !important; }

@media (max-width: 900px) {
  .hero { grid-template-columns: 1fr; padding-top: 40px; }
  .hero-card { height: 200px; }
  .admin-layout { grid-template-columns: 1fr; }
  #adminMap { height: 48vh; min-height: 280px; }
  .admin-form-panel { max-height: none; }
  .game-layout { grid-template-columns: 1fr; }
  .photo-panel { border-right: 0; border-bottom: 1px solid var(--line); min-height: 42vh; }
  .photo-placeholder { min-height: 42vh; }
  #map { min-height: 42vh; }
  .duel-grid, .duel-lobby { grid-template-columns: 1fr; }
  .duel-emblem { display: none; }
  .duels-page, .leaderboard, .admin-page, .auth-page { padding-left: 16px; padding-right: 16px; }
  .topbar {
    padding: 0 10px;
    gap: 8px;
    height: 52px;
  }
  .brand { min-width: auto; }
  .brand-text b { font-size: 12px; letter-spacing: 0.4px; }
  nav {
    overflow-x: auto;
    flex: 1;
    gap: 0;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  nav::-webkit-scrollbar { display: none; }
  .nav-btn { padding: 8px 10px; font-size: 12px; white-space: nowrap; }
  .account { gap: 4px; }
  .account .ghost, .account .small { padding: 6px 8px; font-size: 11px; }
  .user-chip { display: none; }
  .table-row { grid-template-columns: 40px 1fr 80px; padding: 10px 12px; }
  .table-row span:nth-child(3) { display: none; }
  .result {
    flex-wrap: wrap;
    bottom: 12px;
    width: calc(100% - 16px);
    padding: 14px;
  }
  .result .primary { width: 100%; }
  .gamebar { padding: 0 10px; gap: 10px; font-size: 12px; }
  .guess { margin: 10px; width: calc(100% - 20px); }
  .join-row { flex-direction: column; }
  .duel-players { justify-content: flex-start; }
}

@media (max-width: 480px) {
  .home-intro h1 { font-size: 26px; }
  .mode-block h2 { font-size: 20px; }
  .mode-block { min-height: 220px; }
  .photo-overlay h2 { font-size: 16px; }
}


/* Hide Leaflet branding / chrome */
.leaflet-control-attribution { display: none !important; }
.leaflet-control-container .leaflet-bottom { display: none !important; }


/* Home mode blocks */
.home-intro {
  max-width: 960px;
  margin: 0 auto;
  padding: 48px 24px 8px;
}
.home-intro h1 {
  font-size: clamp(28px, 4vw, 36px);
  font-weight: 650;
  letter-spacing: -0.5px;
  margin: 8px 0 10px;
}
.home-intro p {
  color: var(--muted);
  margin: 0;
  max-width: 520px;
  font-size: 15px;
  line-height: 1.55;
}
.mode-blocks {
  max-width: 960px;
  margin: 0 auto;
  padding: 24px 24px 64px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
.mode-block {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 32px 28px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  min-height: 320px;
  display: flex;
  flex-direction: column;
}
.mode-block:hover {
  border-color: #44444a;
  background: var(--panel2);
}
.mode-block-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}
.mode-tag {
  font-size: 11px;
  letter-spacing: 0.8px;
  font-weight: 600;
  color: var(--muted2);
  text-transform: uppercase;
}
.mode-arrow {
  color: var(--muted2);
  font-size: 18px;
}
.mode-block h2 {
  margin: 0 0 14px;
  font-size: 24px;
  font-weight: 650;
  letter-spacing: -0.3px;
}
.mode-block p {
  margin: 0;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.6;
  flex: 1;
}
@media (max-width: 700px) {
  .mode-blocks { grid-template-columns: 1fr; padding: 16px 16px 48px; gap: 12px; }
  .mode-block { min-height: 240px; padding: 24px 20px; }
  .home-intro { padding: 32px 16px 4px; }
}
