:root {
  --bg: #f6f7f9;
  --panel: #ffffff;
  --ink: #1a2233;
  --muted: #66708a;
  --accent: #2f6fed;
  --accent-dark: #2050b8;
  --danger: #ff3b30;
  --line: #e2e6ee;
  --radius: 12px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--ink);
}

.hidden { display: none !important; }

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

.user-label {
  color: var(--muted);
  font-size: 13px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}

.brand {
  margin: 0;
  font-size: 18px;
  letter-spacing: 0.02em;
}

.ghost {
  background: none;
  border: 1px solid var(--line);
  color: var(--muted);
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 13px;
  cursor: pointer;
}

.ghost:hover { color: var(--ink); border-color: var(--ink); }

.screen {
  min-height: calc(100vh - 45px);
  display: flex;
  flex-direction: column;
}

#start-screen {
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 32px 28px;
  width: 100%;
  max-width: 520px;
  max-height: calc(100vh - 90px);
  overflow-y: auto;
  box-shadow: 0 8px 24px rgba(20, 30, 60, 0.06);
}

.panel h2 { margin: 0 0 8px; font-size: 24px; }

.tagline {
  color: var(--muted);
  margin: 0 0 24px;
  line-height: 1.5;
}

.field-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 6px;
}

select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 15px;
  background: var(--panel);
  margin-bottom: 16px;
}

.text-input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 15px;
  margin-bottom: 10px;
}

.text-input:focus, select:focus {
  outline: 2px solid var(--accent);
  outline-offset: -1px;
}

.auth-actions {
  display: flex;
  gap: 10px;
  margin-bottom: 8px;
}

.auth-actions .primary { width: auto; flex: 1; }
.auth-actions .ghost { flex: 0 0 auto; padding: 12px 16px; border-radius: 8px; }

.auth-msg {
  color: var(--danger);
  font-size: 13px;
  margin: 4px 0 0;
  min-height: 18px;
}

.lb-row {
  display: flex;
  gap: 16px;
}

.lb-col {
  flex: 1;
  min-width: 0;
}

.lb-title {
  margin: 18px 0 8px;
  font-size: 14px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.lb-row .lb-title { margin-top: 22px; }

.lb-list {
  margin: 0;
  padding-left: 20px;
  font-size: 13px;
  line-height: 1.7;
  color: var(--ink);
}

.lb-list .muted { color: var(--muted); }

button.primary {
  width: 100%;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 12px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}

button.primary:hover { background: var(--accent-dark); }
button.primary:disabled { background: #b9c4dd; cursor: default; }

#game-screen { height: calc(100vh - 45px); position: relative; }

.gamebar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}

.address {
  font-size: 15px;
  font-weight: 600;
  line-height: 1.4;
}

.timer {
  flex: none;
  min-width: 48px;
  text-align: center;
  font-variant-numeric: tabular-nums;
  font-size: 20px;
  font-weight: 700;
  padding: 6px 10px;
  border-radius: 8px;
  background: #edf1f8;
  color: var(--ink);
}

.timer.low { background: #fdeceb; color: var(--danger); }

#map {
  flex: 1;
  min-height: 0;
  z-index: 0;
}

.controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 16px;
  background: var(--panel);
  border-top: 1px solid var(--line);
}

.controls button.primary { width: auto; padding: 10px 22px; }

.hint { color: var(--muted); font-size: 13px; }

.result {
  position: absolute;
  left: 50%;
  bottom: 84px;
  transform: translateX(-50%);
  width: min(600px, calc(100vw - 32px));
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 20px 18px;
  box-shadow: 0 10px 30px rgba(20, 30, 60, 0.18);
  z-index: 1000;
  text-align: center;
}

.result-text { margin: 0 0 12px; font-size: 14px; line-height: 1.5; }

.scorebar {
  height: 8px;
  border-radius: 4px;
  background: var(--line);
  overflow: hidden;
  margin-bottom: 14px;
}

.scorefill {
  height: 100%;
  width: 0;
  background: var(--accent);
  transition: width 0.6s ease;
}

.result .result-actions { display: flex; gap: 10px; margin: 4px 0 0; }
.result .result-actions button { flex: 1; }

.dist-label {
  background: var(--ink);
  color: #fff;
  padding: 3px 8px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
  transform: translate(-50%, -50%);
}

.toast {
  position: fixed;
  top: 58px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--ink);
  color: #fff;
  padding: 10px 18px;
  border-radius: 8px;
  font-size: 13px;
  z-index: 2000;
}