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

:root {
  --bg-primary: #0f1117;
  --bg-secondary: #1a1d27;
  --bg-card: #222632;
  --bg-hover: #2a2e3d;
  --text-primary: #e4e6ed;
  --text-secondary: #8b8fa3;
  --accent: #4f8cff;
  --accent-hover: #6ba0ff;
  --success: #34d399;
  --danger: #f87171;
  --warning: #fbbf24;
  --border: #2e3346;
  --radius: 8px;
  --radius-lg: 12px;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.3);
}

html, body {
  height: 100%;
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.5;
}

#app {
  height: 100%;
}

.screen {
  display: none;
  height: 100%;
}

.screen.active {
  display: flex;
  flex-direction: column;
}

.hidden {
  display: none !important;
}

/* Buttons */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 24px;
  border: none;
  border-radius: var(--radius);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s, opacity 0.2s;
  letter-spacing: 0.02em;
}

.btn:active {
  transform: scale(0.97);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

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

.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
}

.btn-large {
  padding: 14px 40px;
  font-size: 1.1rem;
  border-radius: var(--radius-lg);
}

/* Start Screen */

.start-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
  gap: 24px;
  padding: 32px;
}

.logo {
  font-size: 3rem;
  font-weight: 800;
  letter-spacing: -0.03em;
}

.logo-lite {
  color: var(--accent);
  font-weight: 400;
}

.tagline {
  color: var(--text-secondary);
  font-size: 1.1rem;
  text-align: center;
  max-width: 400px;
}

.error-msg {
  color: var(--danger);
  font-size: 0.9rem;
  padding: 8px 16px;
  background: rgba(248, 113, 113, 0.1);
  border-radius: var(--radius);
}

/* Game Header */

.game-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 20px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.round-info,
.score-info {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.round-info span,
.score-info span {
  color: var(--text-primary);
}

/* Game Layout */

.game-layout {
  display: flex;
  flex: 1;
  overflow: hidden;
}

.image-panel {
  flex: 1;
  position: relative;
  background: var(--bg-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  min-height: 0;
}

.image-panel img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.hint-badge {
  position: absolute;
  bottom: 16px;
  left: 16px;
  background: rgba(15, 17, 23, 0.85);
  color: var(--text-primary);
  padding: 8px 16px;
  border-radius: var(--radius);
  font-size: 0.85rem;
  backdrop-filter: blur(8px);
  border: 1px solid var(--border);
}

.map-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  position: relative;
}

.map-container {
  flex: 1;
  min-height: 200px;
}

.map-panel .btn {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
  box-shadow: var(--shadow);
}

/* Result Layout */

.result-layout {
  display: flex;
  flex-direction: column;
  flex: 1;
  overflow: hidden;
}

.result-stats {
  display: flex;
  gap: 16px;
  padding: 16px 20px;
  flex-shrink: 0;
}

.stat-card {
  flex: 1;
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 16px 20px;
  text-align: center;
  border: 1px solid var(--border);
}

.stat-label {
  font-size: 0.8rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 4px;
}

.stat-value {
  font-size: 1.6rem;
  font-weight: 700;
}

.result-layout .map-container {
  margin: 0 20px;
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 1px solid var(--border);
}

.result-layout .btn {
  margin: 16px auto;
  flex-shrink: 0;
}

/* Final Screen */

.final-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 40px 24px;
  overflow-y: auto;
  flex: 1;
  gap: 24px;
}

.final-title {
  font-size: 2rem;
  font-weight: 700;
}

.final-score {
  font-size: 3rem;
  font-weight: 800;
}

.final-score-max {
  font-size: 1.5rem;
  color: var(--text-secondary);
  font-weight: 400;
}

.final-rounds-list {
  width: 100%;
  max-width: 600px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.final-round-card {
  display: flex;
  align-items: center;
  gap: 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 12px 16px;
}

.final-round-num {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--bg-hover);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.9rem;
  flex-shrink: 0;
}

.final-round-thumb {
  width: 64px;
  height: 48px;
  object-fit: cover;
  border-radius: 6px;
  flex-shrink: 0;
}

.final-round-details {
  flex: 1;
  min-width: 0;
}

.final-round-hint {
  font-size: 0.85rem;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.final-round-score {
  font-weight: 700;
  text-align: right;
  flex-shrink: 0;
}

.final-round-distance {
  font-size: 0.8rem;
  color: var(--text-secondary);
  text-align: right;
}

/* Leaflet overrides for dark theme */

.leaflet-container {
  background: #1a1d27;
}

.leaflet-control-zoom a {
  background: var(--bg-card) !important;
  color: var(--text-primary) !important;
  border-color: var(--border) !important;
}

.leaflet-control-attribution {
  background: rgba(15, 17, 23, 0.7) !important;
  color: var(--text-secondary) !important;
  font-size: 0.7rem !important;
}

.leaflet-control-attribution a {
  color: var(--accent) !important;
}

/* Responsive */

@media (max-width: 768px) {
  .game-layout {
    flex-direction: column;
  }

  .image-panel {
    flex: none;
    height: 35vh;
  }

  .map-panel {
    flex: 1;
  }

  .logo {
    font-size: 2.2rem;
  }

  .result-stats {
    flex-direction: row;
  }

  .stat-value {
    font-size: 1.2rem;
  }

  .final-score {
    font-size: 2.2rem;
  }
}
