:root {
  --bg: #0f1220;
  --card: #1a1f36;
  --accent: #ffb703;
  --good: #2ecc71;
  --bad: #e74c3c;
  --warm: #f39c12;
  --text: #f1f1f6;
  --muted: #9aa0b4;
  font-family: 'Segoe UI', system-ui, -apple-system, Roboto, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: radial-gradient(circle at top, #1c2138 0%, #0f1220 60%);
  color: var(--text);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 24px 16px 60px;
}

.back-link {
  align-self: flex-start;
  color: var(--muted);
  text-decoration: none;
  font-size: 0.85rem;
  margin-bottom: 12px;
}
.back-link:hover { color: var(--accent); }

.mode-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}
.mode-tab {
  flex: 1;
  background: #12162a;
  color: var(--muted);
  border: 1px solid #333a5c;
  padding: 10px;
  font-size: 0.9rem;
}
.mode-tab.active {
  background: var(--accent);
  color: #221a00;
  border-color: var(--accent);
  font-weight: 700;
}

.daily-countdown {
  text-align: center;
  color: var(--muted);
  font-size: 0.85rem;
  margin: -6px 0 12px;
}

.guest-notice {
  text-align: center;
  color: var(--warm);
  font-size: 0.8rem;
  background: rgba(243, 156, 18, 0.1);
  border: 1px solid rgba(243, 156, 18, 0.3);
  border-radius: 10px;
  padding: 8px 12px;
  margin: 0 0 12px;
}

.modal-overlay[hidden] {
  display: none;
}
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1100;
  padding: 16px;
}
.modal {
  background: var(--card);
  border-radius: 16px;
  padding: 24px;
  max-width: 360px;
  width: 100%;
  max-height: 80vh;
  overflow-y: auto;
}
.modal h3 { margin-top: 0; text-align: center; }
.leaderboard-list {
  list-style: none;
  padding: 0;
  margin: 0 0 16px;
}
.leaderboard-list li {
  display: flex;
  justify-content: space-between;
  padding: 6px 4px;
  border-bottom: 1px solid #2a3050;
}
.leaderboard-list li:first-child .rank { color: var(--accent); font-weight: 700; }
.leaderboard-list .rank { color: var(--muted); margin-right: 8px; }
.leaderboard-empty { color: var(--muted); text-align: center; font-size: 0.85rem; }

header { text-align: center; margin-bottom: 8px; }
header h1 { font-size: 2.4rem; margin: 0; }
.subtitle { color: var(--muted); margin-top: 4px; }

main {
  width: 100%;
  max-width: 480px;
  background: var(--card);
  border-radius: 20px;
  padding: 24px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.4);
  margin-top: 16px;
}

.stats {
  display: flex;
  justify-content: space-around;
  margin-bottom: 16px;
}
.stat { text-align: center; }
.stat span { font-size: 1.6rem; font-weight: 700; color: var(--accent); display:block; }
.stat label { font-size: 0.75rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }

.pie-wrap {
  display: flex;
  justify-content: center;
  margin: 12px 0 20px;
}
#pie {
  border-radius: 50%;
  box-shadow: 0 0 0 6px rgba(255,255,255,0.05), 0 20px 40px rgba(0,0,0,0.5);
}

.guess-row {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
}
#guessInput {
  flex: 1;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid #333a5c;
  background: #12162a;
  color: var(--text);
  font-size: 1rem;
}
#guessInput:focus { outline: 2px solid var(--accent); }

button {
  cursor: pointer;
  border: none;
  border-radius: 10px;
  padding: 12px 18px;
  font-size: 1rem;
  font-weight: 600;
  transition: transform 0.1s ease, opacity 0.2s ease;
}
button:active { transform: scale(0.97); }
button:disabled { opacity: 0.4; cursor: not-allowed; }

#guessBtn, .primary { background: var(--accent); color: #221a00; }
.secondary { background: #2a3050; color: var(--text); }

.tries-row {
  display: flex;
  gap: 6px;
  justify-content: center;
  margin-bottom: 12px;
}
.dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #333a5c;
}
.dot.used { background: var(--bad); }

.feedback {
  min-height: 60px;
  text-align: center;
  margin-bottom: 10px;
}
.feedback .correct { color: var(--good); font-size: 1.3rem; font-weight: 700; }
.feedback .wrong { color: var(--bad); font-weight: 600; }
.feedback .distance { color: var(--warm); font-weight: 700; }
.feedback .reveal { color: var(--muted); }

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  margin-bottom: 16px;
}

.history {
  list-style: none;
  padding: 0;
  margin: 0;
  max-height: 160px;
  overflow-y: auto;
  font-size: 0.85rem;
  color: var(--muted);
  border-top: 1px solid #2a3050;
  padding-top: 8px;
}
.history li { padding: 3px 0; display: flex; justify-content: space-between; }
.history li.correct-row span.mark { color: var(--good); }
.history li.wrong-row span.mark { color: var(--bad); }

footer {
  max-width: 480px;
  text-align: center;
  color: var(--muted);
  font-size: 0.75rem;
  margin-top: 24px;
}
footer a { color: var(--accent); }
