/* GeoHunt - macOS White Theme */
:root {
  --bg: #f5f5f7;
  --bg-card: #ffffff;
  --bg-elevated: #fafafa;
  --border: #e5e5e7;
  --border-strong: #d2d2d7;
  --text: #1d1d1f;
  --text-secondary: #86868b;
  --text-tertiary: #aeaeb2;
  --accent: #0071e3;
  --accent-hover: #0077ed;
  --accent-light: #e8f4fd;
  --success: #34c759;
  --error: #ff3b30;
  --warning: #ff9500;
  --gold: #ff9f0a;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.06);
  --shadow: 0 4px 16px rgba(0,0,0,0.08);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.12);
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ---- Layout ---- */
#app {
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px 24px;
}

/* ---- Header ---- */
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 0;
  margin-bottom: 20px;
}

.app-title {
  font-size: 1.5em;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.02em;
}

.app-subtitle {
  font-size: 0.85em;
  color: var(--text-secondary);
  margin-top: 2px;
}

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

#user-info {
  display: none;
  align-items: center;
  gap: 10px;
  font-size: 0.9em;
  background: var(--bg-card);
  padding: 6px 14px;
  border-radius: 20px;
  border: 1px solid var(--border);
}

#user-nickname { color: var(--text); font-weight: 600; }
#user-score { color: var(--text-secondary); font-size: 0.85em; }

/* ---- Buttons ---- */
.btn {
  padding: 8px 18px;
  border: none;
  border-radius: 20px;
  cursor: pointer;
  font-size: 0.88em;
  font-weight: 600;
  transition: all 0.2s;
  font-family: var(--font);
  letter-spacing: -0.01em;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}

.btn-primary:hover { background: var(--accent-hover); transform: translateY(-1px); box-shadow: var(--shadow-sm); }

.btn-secondary {
  background: var(--bg-card);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-secondary:hover { background: var(--bg-elevated); border-color: var(--border-strong); }

.btn-small {
  padding: 5px 14px;
  font-size: 0.8em;
}

.btn-lang {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border);
  padding: 5px 12px;
  font-size: 0.8em;
  border-radius: 20px;
}

.btn-lang:hover { background: var(--bg-card); }

/* ---- Pages ---- */
.page { display: none; animation: fadeIn 0.25s ease; }
.page.active { display: block; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ---- Login Page ---- */
.login-container {
  max-width: 400px;
  margin: 80px auto;
  text-align: center;
}

.login-container h2 {
  font-size: 1.8em;
  font-weight: 700;
  margin-bottom: 8px;
  letter-spacing: -0.03em;
}

.login-form {
  display: flex;
  gap: 8px;
  margin-top: 24px;
}

.login-form input {
  flex: 1;
  padding: 12px 16px;
  border: 1.5px solid var(--border);
  border-radius: 24px;
  background: var(--bg-card);
  color: var(--text);
  font-size: 0.95em;
  font-family: var(--font);
  transition: border-color 0.2s;
}

.login-form input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-light);
}

/* ---- Menu Page ---- */
.menu-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 14px;
  margin-top: 20px;
}

.menu-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  cursor: pointer;
  transition: all 0.2s;
}

.menu-card:hover {
  border-color: var(--accent);
  box-shadow: var(--shadow);
  transform: translateY(-2px);
}

.menu-card h3 { color: var(--text); font-size: 1.1em; margin-bottom: 6px; }
.menu-card p { color: var(--text-secondary); font-size: 0.82em; line-height: 1.5; }
.menu-card .mode-icon { font-size: 2em; margin-bottom: 10px; }

/* ---- Game Page ---- */
.game-layout {
  display: flex;
  gap: 16px;
  height: calc(100vh - 130px);
}

#map-container {
  flex: 1;
  min-height: 400px;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
  position: relative;
  box-shadow: var(--shadow-sm);
}

#map-click-hint {
  position: absolute;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(255,255,255,0.92);
  backdrop-filter: blur(10px);
  color: var(--text-secondary);
  padding: 8px 18px;
  border-radius: 20px;
  font-size: 0.88em;
  z-index: 1000;
  pointer-events: none;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}

#start-confirm {
  display: none;
  position: absolute;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-card);
  padding: 18px 24px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  z-index: 1000;
  text-align: center;
  backdrop-filter: blur(20px);
}

#start-confirm .confirm-buttons {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin-top: 12px;
}

/* Game Panel (right side) */
#game-panel {
  display: none;
  flex-direction: column;
  width: 340px;
  min-width: 300px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow-sm);
}

.game-stats {
  display: flex;
  justify-content: space-between;
  margin-bottom: 14px;
  font-size: 0.88em;
  color: var(--text-secondary);
}

#wrong-count { color: var(--warning); font-weight: 700; }

.hints-section { flex: 1; overflow-y: auto; margin-bottom: 12px; }

.hint-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px;
  margin-bottom: 10px;
}

.hint-number { color: var(--accent); font-weight: 700; font-size: 0.88em; margin-bottom: 6px; }
.hint-origin { color: var(--text-secondary); font-size: 0.82em; margin-bottom: 4px; }
.hint-distance { margin: 6px 0; font-size: 0.93em; font-weight: 500; }
.hint-angle { color: var(--text-secondary); font-size: 0.82em; line-height: 1.5; }

.guess-form {
  display: flex;
  gap: 8px;
}

.guess-form input {
  flex: 1;
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: 22px;
  background: var(--bg);
  color: var(--text);
  font-size: 0.93em;
  font-family: var(--font);
  transition: border-color 0.2s;
}

.guess-form input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-light);
}

/* ---- Hint Map Panel ---- */
#hint-map-trigger {
  position: fixed;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  z-index: 2000;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-right: none;
  border-radius: 12px 0 0 12px;
  padding: 14px 8px;
  cursor: pointer;
  box-shadow: -2px 0 12px rgba(0,0,0,0.06);
  writing-mode: vertical-rl;
  font-size: 0.82em;
  font-weight: 600;
  color: var(--text-secondary);
  transition: all 0.2s;
  letter-spacing: 0.1em;
}

#hint-map-trigger:hover {
  color: var(--accent);
  background: var(--accent-light);
  padding-right: 12px;
}

#hint-map-panel {
  position: fixed;
  right: -520px;
  top: 0;
  width: 480px;
  height: 100vh;
  background: var(--bg-card);
  border-left: 1px solid var(--border);
  box-shadow: -4px 0 24px rgba(0,0,0,0.1);
  z-index: 3000;
  transition: right 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  flex-direction: column;
}

#hint-map-panel.open {
  right: 0;
}

.hint-map-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.hint-map-header h3 {
  font-size: 1em;
  font-weight: 600;
  color: var(--text);
}

.hint-map-close {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: none;
  background: var(--bg);
  color: var(--text-secondary);
  font-size: 1.1em;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.hint-map-close:hover {
  background: #eee;
  color: var(--text);
}

#hint-map-container {
  flex: 1;
  background: #e8ecf1;
}

.hint-map-info {
  padding: 12px 20px;
  border-top: 1px solid var(--border);
  font-size: 0.82em;
  color: var(--text-secondary);
}

/* ---- Overlay ---- */
#hint-map-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.2);
  z-index: 2999;
  transition: opacity 0.3s;
}

#hint-map-overlay.show {
  display: block;
}

/* ---- Results ---- */
#game-result {
  display: none;
  text-align: center;
  padding: 20px;
}

.result-win { font-size: 1.3em; font-weight: 700; color: var(--success); margin-bottom: 6px; }
.result-lose { font-size: 1.3em; font-weight: 700; color: var(--error); margin-bottom: 6px; }
.result-score { font-size: 1.1em; color: var(--accent); font-weight: 600; margin: 8px 0; }
.result-target { color: var(--text-secondary); margin: 8px 0; }
.result-actions { display: flex; gap: 8px; justify-content: center; margin-top: 16px; }

.new-achievements {
  color: var(--warning);
  font-weight: 600;
  margin-top: 12px;
}

.ach-badge {
  display: inline-block;
  background: var(--bg-elevated);
  border: 1px solid var(--gold);
  border-radius: 20px;
  padding: 4px 12px;
  margin: 4px;
  font-size: 0.82em;
}

/* ---- Pulse Marker ---- */
.pulse-marker { background: transparent; }
.pulse-circle {
  width: 22px; height: 22px;
  background: var(--error);
  border-radius: 50%;
  border: 3px solid #fff;
  box-shadow: 0 0 0 4px rgba(255,59,48,0.3);
  animation: pulse 2s ease-out infinite;
}
@keyframes pulse {
  0% { box-shadow: 0 0 0 4px rgba(255,59,48,0.4); }
  70% { box-shadow: 0 0 0 22px rgba(255,59,48,0); }
  100% { box-shadow: 0 0 0 4px rgba(255,59,48,0); }
}

/* ---- Leaderboard ---- */
.leaderboard-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 16px;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
}

.leaderboard-table th {
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 0.82em;
  background: var(--bg-elevated);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.leaderboard-table th, .leaderboard-table td {
  padding: 12px 16px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.leaderboard-table tr:last-child td { border-bottom: none; }
.leaderboard-table tr:hover td { background: var(--bg-elevated); }

.rank-cell { font-weight: 700; font-size: 1.1em; }

/* ---- Achievements ---- */
.achievement-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 10px;
  margin-bottom: 20px;
}

.achievement-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px;
  text-align: center;
  transition: all 0.2s;
}

.achievement-card.unlocked {
  border-color: var(--gold);
  background: #fffbf0;
}

.achievement-card.locked {
  opacity: 0.45;
}

.ach-icon { font-size: 1.4em; margin-bottom: 6px; }
.ach-name { font-weight: 600; font-size: 0.82em; margin-bottom: 4px; }
.ach-desc { font-size: 0.73em; color: var(--text-secondary); }
.ach-count { text-align: center; color: var(--text-secondary); margin-top: 8px; font-size: 0.85em; }

/* ---- Toast ---- */
#toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--text);
  color: #fff;
  padding: 10px 22px;
  border-radius: 20px;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  transition: opacity 0.3s;
  z-index: 9999;
  pointer-events: none;
  font-size: 0.88em;
}
#toast.show { opacity: 1; }

/* ---- Responsive ---- */
@media (max-width: 768px) {
  .game-layout { flex-direction: column; height: auto; }
  #map-container { height: 280px; }
  #game-panel { width: 100%; min-width: auto; }
  .menu-grid { grid-template-columns: 1fr; }
  #hint-map-panel { width: 100vw; right: -100vw; }
  #app { padding: 12px 14px; }
}

/* ---- Scrollbar ---- */
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-tertiary); }

/* ---- Leaflet Overrides ---- */
.leaflet-container {
  background: #e8ecf1 !important;
  font-family: var(--font);
}

.leaflet-control-zoom a {
  background: var(--bg-card) !important;
  color: var(--text) !important;
  border: 1px solid var(--border) !important;
  border-radius: 8px !important;
  font-size: 14px !important;
  width: 30px !important;
  height: 30px !important;
  line-height: 30px !important;
}

.leaflet-control-zoom a:hover {
  background: var(--bg-elevated) !important;
}

.leaflet-control-attribution {
  font-size: 10px !important;
  color: var(--text-tertiary) !important;
}
