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

body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #0d1117;
  font-family: "Segoe UI", system-ui, sans-serif;
  color: #e6edf3;
}

#game-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 20px;
}

#game-header {
  text-align: center;
}

#game-header h1 {
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: #f0f6fc;
}

#game-header .tagline {
  font-size: 0.85rem;
  color: #8b949e;
  margin-top: 4px;
}

.controls-hint {
  font-size: 0.75rem;
  color: #6e7681;
  margin-top: 6px;
}

kbd {
  display: inline-block;
  padding: 1px 5px;
  font-size: 0.7rem;
  font-family: inherit;
  background: #21262d;
  border: 1px solid #30363d;
  border-radius: 3px;
  color: #c9d1d9;
}

.global-stats {
  font-size: 0.8rem;
  color: #58a6ff;
  margin-top: 8px;
  font-weight: 600;
}

#hud {
  display: flex;
  gap: 16px;
  width: 100%;
  max-width: 900px;
}

#game-controls {
  display: flex;
  gap: 12px;
  width: 100%;
  max-width: 900px;
}

.game-btn {
  flex: 1;
  padding: 10px 16px;
  font-size: 0.9rem;
  font-weight: 600;
  font-family: inherit;
  color: #e6edf3;
  background: #21262d;
  border: 1px solid #30363d;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.game-btn:hover:not(:disabled) {
  background: #30363d;
  border-color: #484f58;
}

.game-btn:active:not(:disabled) {
  background: #161b22;
}

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

.game-btn-primary {
  background: #238636;
  border-color: #2ea043;
  color: #ffffff;
}

.game-btn-primary:hover:not(:disabled) {
  background: #2ea043;
  border-color: #3fb950;
}

.btn-key {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 6px;
  font-size: 0.75rem;
  font-weight: 700;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 3px;
}

.hud-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 10px 16px;
  background: #161b22;
  border: 1px solid #30363d;
  border-radius: 6px;
}

.hud-label {
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #8b949e;
}

.hud-value {
  font-size: 1.25rem;
  font-weight: 700;
  color: #f0f6fc;
  font-variant-numeric: tabular-nums;
}

.hud-value.lives {
  color: #f85149;
  letter-spacing: 0.15em;
}

.hud-value.nation {
  font-size: 1rem;
  letter-spacing: 0.02em;
  color: #58a6ff;
}

#canvas-wrap {
  position: relative;
  width: 100%;
  max-width: 900px;
}

#game-canvas {
  display: block;
  border: 3px solid #30363d;
  border-radius: 6px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
  cursor: crosshair;
  background: #1a472a;
  width: 100%;
  height: auto;
  aspect-ratio: 900 / 650;
}

#message-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.55);
  border-radius: 6px;
  pointer-events: none;
}

#message-overlay.hidden {
  display: none;
}

#message-text {
  font-size: 1.5rem;
  font-weight: 700;
  color: #f85149;
  text-align: center;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.8);
  padding: 16px 24px;
  background: rgba(22, 27, 34, 0.9);
  border: 2px solid #f85149;
  border-radius: 8px;
}

/* ─── Leaderboard Modal ─── */

.modal {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(13, 17, 23, 0.85);
  backdrop-filter: blur(8px);
  z-index: 100;
}

.hidden {
  display: none !important;
}

.modal-content {
  background: #161b22;
  border: 1px solid #30363d;
  border-radius: 12px;
  padding: 32px;
  width: 400px;
  box-shadow: 0 12px 48px rgba(0, 0, 0, 0.6);
  text-align: center;
}

.modal-content h2 {
  font-size: 2rem;
  color: #ffd700;
  margin-bottom: 16px;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}

.modal-content p {
  color: #8b949e;
  margin-bottom: 24px;
  font-size: 0.95rem;
}

.input-group {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}

.input-group input,
.input-group select {
  padding: 10px 12px;
  background: #0d1117;
  border: 1px solid #30363d;
  border-radius: 6px;
  color: #e6edf3;
  font-family: inherit;
  font-size: 0.95rem;
  outline: none;
  transition: border-color 0.2s;
}

.input-group input:focus,
.input-group select:focus {
  border-color: #58a6ff;
}

.input-group input {
  flex: 1;
  min-width: 0;
}

.input-group select {
  width: 160px;
  text-overflow: ellipsis;
}

#leaderboard-section h3 {
  color: #f0f6fc;
  margin-bottom: 16px;
  font-size: 1.25rem;
}

#leaderboard-list {
  list-style: none;
  padding: 0;
  margin: 0;
  text-align: left;
  max-height: 250px;
  overflow-y: auto;
}

#leaderboard-list li {
  display: flex;
  justify-content: space-between;
  padding: 8px 12px;
  border-bottom: 1px solid #30363d;
  font-size: 0.95rem;
}

#leaderboard-list li:last-child {
  border-bottom: none;
}

#leaderboard-list .lb-rank {
  color: #8b949e;
  width: 24px;
  font-weight: bold;
}

#leaderboard-list .lb-name {
  flex: 1;
  color: #e6edf3;
  font-weight: 600;
}

#leaderboard-list .lb-score {
  color: #58a6ff;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
