:root {
  --blue: #002F6C;
  --blue-light: #1E5FA8;
  --white: #ffffff;
  --bg: #f4f6f9;
  --panel: #ffffff;
  --border: #dfe4ea;
  --text: #1a1a1a;
  --muted: #6b7280;
  --green: #3aa655;
  --yellow: #e8b923;
  --orange: #e8792b;
  --red: #d64545;
  --radius: 10px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: 'Poppins', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
}

.app {
  max-width: 1100px;
  margin: 0 auto;
  padding: 16px 16px 40px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand .flag { font-size: 28px; }

.brand h1 {
  margin: 0;
  font-size: 26px;
  font-weight: 700;
  color: var(--blue);
  letter-spacing: 0.5px;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.countdown {
  font-variant-numeric: tabular-nums;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 6px 12px;
  font-size: 13px;
  color: var(--muted);
}

.lang-toggle {
  border: 1px solid var(--border);
  background: var(--panel);
  border-radius: 20px;
  padding: 6px 14px;
  font-weight: 600;
  cursor: pointer;
  color: var(--blue);
}
.lang-toggle:hover { background: #eef2f7; }

.subtitle {
  margin: 6px 0 18px;
  color: var(--muted);
  font-size: 14px;
}

.game-layout {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 18px;
}

@media (max-width: 800px) {
  .game-layout { grid-template-columns: 1fr; }
}

#map {
  height: 560px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  overflow: hidden;
}

@media (max-width: 800px) {
  #map { height: 380px; }
}

.side-col {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
}

.search-box {
  position: relative;
  display: flex;
  gap: 8px;
}

#cityInput {
  flex: 1;
  padding: 10px 12px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  font-size: 15px;
  font-family: inherit;
}
#cityInput:focus { outline: 2px solid var(--blue-light); }

#guessBtn {
  background: var(--blue);
  color: white;
  border: none;
  border-radius: var(--radius);
  padding: 0 18px;
  font-weight: 700;
  cursor: pointer;
  letter-spacing: 0.5px;
}
#guessBtn:disabled {
  background: #b7c3d1;
  cursor: not-allowed;
}
#guessBtn:not(:disabled):hover { background: var(--blue-light); }

.suggestions {
  position: absolute;
  top: 44px;
  left: 0;
  right: 60px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  max-height: 220px;
  overflow-y: auto;
  z-index: 500;
  box-shadow: 0 6px 16px rgba(0,0,0,0.08);
}
.suggestions:empty { display: none; }
.suggestion-item {
  padding: 8px 12px;
  cursor: pointer;
  font-size: 14px;
  display: flex;
  justify-content: space-between;
}
.suggestion-item:hover, .suggestion-item.active {
  background: #eef2f7;
}
.suggestion-item .admin {
  color: var(--muted);
  font-size: 12px;
}

.pending {
  font-size: 13px;
  color: var(--blue);
  background: #eaf1fb;
  border-radius: var(--radius);
  padding: 8px 12px;
}

.guesses-header {
  font-size: 13px;
  color: var(--muted);
  font-weight: 600;
}

.guesses-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 420px;
  overflow-y: auto;
}

.guess-row {
  display: grid;
  grid-template-columns: 1.3fr 0.9fr 0.9fr 0.7fr;
  gap: 6px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 10px;
  font-size: 13px;
  align-items: center;
}

.guess-row.correct {
  border-color: var(--green);
  background: #eaf7ee;
}

.guess-row .cell {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
}

.guess-row .city-name {
  font-weight: 600;
}
.guess-row .region-tag {
  font-size: 10px;
  color: var(--muted);
}
.guess-row .region-tag.match {
  color: var(--green);
  font-weight: 600;
}

.pop-pill, .dist-pill {
  font-size: 12px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 4px;
}

.dir-cell {
  font-size: 22px;
  text-align: center;
}

.proximity-bar {
  height: 4px;
  border-radius: 4px;
  margin-top: 3px;
  width: 100%;
  background: #eee;
  overflow: hidden;
}
.proximity-bar > div {
  height: 100%;
}

.tier-green { background: var(--green); }
.tier-yellow { background: var(--yellow); }
.tier-orange { background: var(--orange); }
.tier-red { background: var(--red); }

.win-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: #eaf7ee;
  border: 1px solid var(--green);
  border-radius: var(--radius);
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 600;
  color: #206b37;
}

.win-banner button {
  background: var(--green);
  color: white;
  border: none;
  border-radius: 8px;
  padding: 6px 12px;
  font-weight: 700;
  font-size: 12px;
  cursor: pointer;
  white-space: nowrap;
}
.win-banner button:hover { filter: brightness(1.08); }

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 20, 35, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 16px;
  animation: fadeIn 0.15s ease-out;
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes popIn {
  from { opacity: 0; transform: scale(0.92) translateY(8px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-box {
  position: relative;
  background: var(--panel);
  border-radius: 14px;
  padding: 28px 24px 22px;
  max-width: 360px;
  width: 100%;
  text-align: center;
  box-shadow: 0 20px 50px rgba(0,0,0,0.25);
  animation: popIn 0.18s ease-out;
}

.modal-close {
  position: absolute;
  top: 10px;
  right: 12px;
  background: none;
  border: none;
  font-size: 22px;
  line-height: 1;
  color: var(--muted);
  cursor: pointer;
  padding: 4px;
}
.modal-close:hover { color: var(--text); }

.modal-box h2 {
  margin: 4px 0 4px;
  color: var(--blue);
}

.modal-box .flavor {
  margin: 0 0 10px;
  font-weight: 600;
  color: var(--orange);
  font-size: 15px;
}

.modal-box p#winSubtext {
  margin: 0 0 14px;
  color: var(--muted);
  font-size: 14px;
}

.share-grid {
  font-size: 22px;
  line-height: 1.3;
  margin-bottom: 16px;
  white-space: pre;
}

#shareBtn {
  background: var(--blue);
  color: white;
  border: none;
  border-radius: var(--radius);
  padding: 10px 20px;
  font-weight: 700;
  cursor: pointer;
}
#shareBtn:hover { background: var(--blue-light); }

.attribution {
  margin-top: 24px;
  text-align: center;
  font-size: 11px;
  color: var(--muted);
}
.attribution a { color: var(--muted); }
.footer-sep { margin: 0 6px; }

.icon-btn {
  border: 1px solid var(--border);
  background: var(--panel);
  border-radius: 20px;
  padding: 6px 10px;
  cursor: pointer;
  font-size: 15px;
}
.icon-btn:hover { background: #eef2f7; }

.account-area { display: flex; align-items: center; }

.signin-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--border);
  background: var(--panel);
  border-radius: 20px;
  padding: 6px 14px;
  font-weight: 600;
  cursor: pointer;
  color: var(--text);
  font-size: 13px;
}
.signin-btn:hover { background: #eef2f7; }
.signin-btn .google-g {
  font-weight: 700;
  color: #4285F4;
  font-family: Arial, sans-serif;
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--border);
  background: var(--panel);
  border-radius: 20px;
  padding: 4px 6px 4px 4px;
  font-size: 13px;
}
.user-chip .avatar {
  width: 24px;
  height: 24px;
  border-radius: 50%;
}
.signout-btn {
  border: none;
  background: none;
  cursor: pointer;
  color: var(--muted);
  font-size: 14px;
  padding: 2px 4px;
}
.signout-btn:hover { color: var(--red); }

.dev-mode-banner {
  background: #fff4e0;
  border: 1px solid var(--orange);
  color: #8a5a12;
  border-radius: var(--radius);
  padding: 8px 12px;
  font-size: 12px;
  margin: 10px 0;
}

.guess-row.header-row {
  background: transparent;
  border: none;
  padding: 0 10px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  font-weight: 700;
}
.dir-cell-header { text-align: center; }

.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin: 14px 0;
}
.stats-grid .stat-box {
  background: var(--bg);
  border-radius: 10px;
  padding: 10px 4px;
}
.stats-grid .stat-num {
  font-size: 22px;
  font-weight: 700;
  color: var(--blue);
  display: block;
}
.stats-grid .stat-label {
  font-size: 10px;
  color: var(--muted);
  text-transform: uppercase;
}

#statsDistTitle {
  font-size: 13px;
  color: var(--muted);
  margin: 4px 0 8px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.dist-chart {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-bottom: 14px;
}
.dist-row {
  display: grid;
  grid-template-columns: 20px 1fr 24px;
  align-items: center;
  gap: 8px;
  font-size: 12px;
}
.dist-bar-track { background: #eee; border-radius: 4px; overflow: hidden; height: 16px; }
.dist-bar-fill {
  background: var(--blue-light);
  height: 100%;
  min-width: 4px;
  border-radius: 4px;
}

.danger-link {
  background: none;
  border: none;
  color: var(--red);
  font-size: 12px;
  cursor: pointer;
  text-decoration: underline;
  padding: 4px;
}
.city-marker {
  border-radius: 50%;
  background: var(--blue-light);
  border: 2px solid white;
  box-shadow: 0 0 4px rgba(0,0,0,0.4);
}
.city-marker.guessed-correct {
  background: var(--green);
}
.city-marker.guessed-wrong {
  background: var(--muted);
}
.city-marker.pending {
  background: var(--orange);
  transform: scale(1.3);
}
