:root {
  --bg-dark: #0d0f1a;
  --bg-panel: #1a1d33;
  --text: #e0e8ff;
  --muted: #a0a8c8;
  --accent-blue: #6fa8ff;
  --accent-pink: #ff7ac2;
  --accent-green: #6fe3a2;
  --accent-yellow: #ffd86b;
  --accent-red: #ff6f6f;
  --accent-orange: #ffaa4d;
  --shadow: 0 8px 30px rgba(0, 0, 0, 0.5);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  overflow: auto;
}

body {
  background: radial-gradient(circle at top, #1e2245, var(--bg-dark) 70%);
  color: var(--text);
  font-family: "Lexend", system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
}

/* Header */
.app-header {
  padding: 16px 24px;
  border-bottom: 1px solid #303560;
  background: rgba(13, 15, 26, 0.8);
  backdrop-filter: blur(10px);
}

.title-wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.help-btn {
  margin-left: 6px;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid #4a4f80;
  background: #2a2d4a;
  color: #fff;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.2s;
}

.help-btn:hover {
  background: #38406c;
  transform: scale(1.05);
}

.limit-badge,
.game-title {
  font-size: 32px;
  font-weight: 900;
  color: var(--accent-blue);
  line-height: 1;
  text-shadow: 0 0 6px #1a1d33;
}

.score-display {
  font-family: "Space Mono", monospace;
  font-size: 24px;
  font-weight: 700;
  color: var(--accent-yellow);
  text-shadow: 0 0 10px var(--accent-yellow);
}

.subtitle {
  color: var(--muted);
  font-size: 13px;
  margin-top: 2px;
}

/* Game Container */
.game-container {
  padding: 20px;
  max-width: 1400px;
  margin: 0 auto;
}

.hidden {
  display: none !important;
}

/* Round Container */
.round-container {
  background: var(--bg-panel);
  border: 1px solid #303560;
  border-radius: 16px;
  padding: 24px;
  box-shadow: var(--shadow);
}

.round-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 2px solid #303560;
}

.round-header h2 {
  margin: 0;
  color: var(--accent-blue);
  font-size: 28px;
}

.timer-display {
  font-family: "Space Mono", monospace;
  font-size: 24px;
  font-weight: 700;
  color: var(--accent-red);
  text-shadow: 0 0 8px var(--accent-red);
}

.progress {
  font-family: "Space Mono", monospace;
  font-size: 18px;
  color: var(--accent-green);
}

/* Conversion Grid (Round 1) */
.conversion-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 24px;
  margin-bottom: 32px;
}

.clock-pair {
  background: rgba(0, 0, 0, 0.3);
  border: 2px solid #303560;
  border-radius: 12px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  transition: all 0.3s;
}

.clock-pair:focus-within {
  border-color: var(--accent-blue);
  box-shadow: 0 0 20px rgba(111, 168, 255, 0.3);
}

.clock-pair.correct {
  border-color: var(--accent-green);
  background: rgba(111, 227, 162, 0.1);
}

.clock-pair.incorrect {
  border-color: var(--accent-red);
  background: rgba(255, 111, 111, 0.1);
}

/* Analog Clock */
.analog-clock {
  position: relative;
  width: 200px;
  height: 200px;
}

.analog-clock canvas {
  border-radius: 50%;
  background: linear-gradient(135deg, #f0f0f0, #ffffff);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3), inset 0 2px 10px rgba(0, 0, 0, 0.1);
}

.analog-clock:focus-within canvas {
  box-shadow: 0 4px 20px rgba(111, 168, 255, 0.5), inset 0 2px 10px rgba(0, 0, 0, 0.1);
}

/* Digital Clock Display */
.digital-clock {
  background: linear-gradient(180deg, #0a0c18, #141938);
  border: 2px solid #4a4f80;
  border-radius: 12px;
  padding: 16px 24px;
  font-family: "Space Mono", monospace;
  font-size: 42px;
  font-weight: 700;
  color: var(--accent-green);
  text-align: center;
  text-shadow: 0 0 12px var(--accent-green);
  min-width: 180px;
  box-shadow: inset 0 2px 10px rgba(0, 0, 0, 0.6);
  transition: all 0.3s;
}

.digital-clock input {
  background: transparent;
  border: none;
  color: var(--accent-green);
  font-family: "Space Mono", monospace;
  font-size: 42px;
  font-weight: 700;
  text-align: center;
  width: 100%;
  outline: none;
  text-shadow: 0 0 12px var(--accent-green);
}

.digital-clock input::placeholder {
  color: #4a4f80;
  opacity: 0.6;
}

.digital-clock:focus-within {
  border-color: var(--accent-blue);
  box-shadow: 0 0 20px rgba(111, 168, 255, 0.3), inset 0 2px 10px rgba(0, 0, 0, 0.6);
}

/* Calculation Grid (Round 2) */
.calculation-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
  gap: 24px;
  margin-bottom: 32px;
}

.calculation-problem {
  background: rgba(0, 0, 0, 0.3);
  border: 2px solid #303560;
  border-radius: 12px;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition: all 0.3s;
}

.problem-clocks canvas {
  border-radius: 50%;
  background: linear-gradient(135deg, #f0f0f0, #ffffff);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
}

.calculation-problem:focus-within {
  border-color: var(--accent-blue);
  box-shadow: 0 0 20px rgba(111, 168, 255, 0.3);
}

.calculation-problem.correct {
  border-color: var(--accent-green);
  background: rgba(111, 227, 162, 0.1);
}

.calculation-problem.incorrect {
  border-color: var(--accent-red);
  background: rgba(255, 111, 111, 0.1);
}

.calculation-text {
  font-family: "Space Mono", monospace;
  font-size: 20px;
  color: var(--text);
  text-align: center;
  line-height: 1.6;
}

.calculation-answer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
}

.calculation-answer label {
  font-family: "Space Mono", monospace;
  font-size: 18px;
  color: var(--accent-yellow);
}

.calculation-answer input {
  background: linear-gradient(180deg, #0a0c18, #141938);
  border: 2px solid #4a4f80;
  border-radius: 8px;
  padding: 12px 16px;
  font-family: "Space Mono", monospace;
  font-size: 28px;
  font-weight: 700;
  color: var(--accent-green);
  text-align: center;
  width: 140px;
  outline: none;
  text-shadow: 0 0 10px var(--accent-green);
  box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.6);
  transition: all 0.3s;
}

.calculation-answer input:focus {
  border-color: var(--accent-blue);
  box-shadow: 0 0 15px rgba(111, 168, 255, 0.4), inset 0 2px 8px rgba(0, 0, 0, 0.6);
}

/* Stop Clock Container (Round 3) */
.stop-clock-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
  margin-bottom: 32px;
}

.question-display {
  background: rgba(0, 0, 0, 0.3);
  border: 2px solid var(--accent-yellow);
  border-radius: 12px;
  padding: 20px 32px;
  font-size: 22px;
  font-weight: 700;
  color: var(--accent-yellow);
  text-align: center;
  text-shadow: 0 0 8px var(--accent-yellow);
  min-height: 80px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.clock-control {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.clock-control canvas {
  border-radius: 50%;
  background: linear-gradient(135deg, #f0f0f0, #ffffff);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.4), inset 0 2px 10px rgba(0, 0, 0, 0.1);
}

.clock-speed {
  font-family: "Space Mono", monospace;
  font-size: 16px;
  color: var(--accent-orange);
  text-shadow: 0 0 8px var(--accent-orange);
}

.clock-time {
  font-family: "Space Mono", monospace;
  font-size: 36px;
  font-weight: 700;
  color: var(--accent-green);
  text-shadow: 0 0 12px var(--accent-green);
}

.clock-btn {
  width: 280px;
  font-size: 18px;
}

/* World Map */
.world-map-container {
  width: 100%;
  max-width: 900px;
  margin: 20px auto;
}

.world-map-container canvas {
  width: 100%;
  height: auto;
  border: 2px solid #4a4f80;
  border-radius: 12px;
  background: linear-gradient(180deg, #1a2845, #0d1628);
  box-shadow: var(--shadow);
}

/* Bomb Displays */
.bomb-display {
  display: flex;
  justify-content: center;
  padding: 20px;
  margin: 20px 0;
}

.bunny-bomb {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  animation: wobble 2s ease-in-out infinite;
}

.bunny {
  font-size: 48px;
  filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.5));
  animation: bunny-shake 0.5s ease-in-out infinite;
}

.dynamite {
  font-size: 64px;
  filter: drop-shadow(0 4px 12px rgba(255, 100, 50, 0.6));
}

.ball-bomb {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  animation: wobble 1.8s ease-in-out infinite;
}

.bunnies {
  font-size: 36px;
  filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.5));
  animation: bunny-shake 0.4s ease-in-out infinite;
}

.ball {
  font-size: 96px;
  filter: drop-shadow(0 6px 16px rgba(255, 100, 50, 0.8));
}

.mega-bomb {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  animation: wobble 1.5s ease-in-out infinite;
}

.many-bunnies {
  font-size: 28px;
  line-height: 1.2;
  text-align: center;
  filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.5));
  animation: bunny-shake 0.3s ease-in-out infinite;
}

.big-ball {
  font-size: 128px;
  filter: drop-shadow(0 8px 20px rgba(255, 100, 50, 0.9));
}

.fuse {
  position: absolute;
  top: -30px;
  left: 50%;
  transform: translateX(-50%);
  width: 4px;
  height: 30px;
  background: linear-gradient(to bottom, var(--accent-orange), transparent);
  animation: fuse-burn 120s linear;
}

.fuse::before {
  content: "✨";
  position: absolute;
  top: -8px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 16px;
  animation: sparkle 0.5s ease-in-out infinite;
}

@keyframes wobble {
  0%, 100% { transform: rotate(-2deg); }
  50% { transform: rotate(2deg); }
}

@keyframes bunny-shake {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-3px); }
}

@keyframes fuse-burn {
  0% { height: 30px; background: linear-gradient(to bottom, var(--accent-orange), transparent); }
  95% { height: 30px; background: linear-gradient(to bottom, var(--accent-orange), transparent); }
  100% { height: 0; background: transparent; }
}

@keyframes sparkle {
  0%, 100% { opacity: 1; transform: translateX(-50%) scale(1); }
  50% { opacity: 0.6; transform: translateX(-50%) scale(1.2); }
}

/* Explosion animations */
.explode {
  animation: explode-anim 1s ease-out forwards;
}

@keyframes explode-anim {
  0% {
    transform: scale(1);
    opacity: 1;
  }
  50% {
    transform: scale(1.5) translateY(-50px);
    opacity: 1;
  }
  100% {
    transform: scale(2) translateY(-100px);
    opacity: 0;
  }
}

/* Controls Hint */
.controls-hint {
  text-align: center;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.6;
  padding: 16px;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 8px;
  margin-top: 16px;
}

/* Buttons */
button.primary {
  width: 100%;
  background: linear-gradient(45deg, var(--accent-blue), var(--accent-pink));
  border: none;
  color: #fff;
  padding: 14px 24px;
  border-radius: 12px;
  font-weight: 700;
  font-size: 16px;
  cursor: pointer;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
  transition: transform 0.2s, box-shadow 0.2s;
  box-shadow: 0 4px 15px rgba(111, 168, 255, 0.4);
}

button.primary:hover {
  transform: scale(1.03);
  box-shadow: 0 6px 20px rgba(111, 168, 255, 0.6);
}

button.primary:active {
  transform: scale(0.98);
}

/* Overlays */
.overlay {
  position: fixed;
  inset: 0;
  display: none;
  place-items: center;
  background: rgba(13, 15, 26, 0.95);
  backdrop-filter: blur(10px);
  z-index: 100;
  overflow-y: auto;
  padding: 20px;
}

.overlay.visible {
  display: grid;
}

.overlay .card {
  width: min(1100px, 96vw);
  max-height: 90vh;
  background: linear-gradient(135deg, #1a1d33, #0d0f1a);
  border: 2px solid #303560;
  border-radius: 16px;
  padding: 32px;
  color: var(--text);
  box-shadow: var(--shadow);
  overflow-y: auto;
}

.overlay .card.instructions {
  min-height: 60vh;
}

.overlay .card.setup {
  max-width: 500px;
}

.overlay .card.victory,
.overlay .card.gameover {
  text-align: center;
  max-width: 700px;
}

.overlay h2 {
  margin: 0 0 20px 0;
  color: var(--accent-blue);
  font-size: 32px;
  text-align: center;
}

.overlay .instructions-text {
  line-height: 1.7;
  color: var(--text);
}

.overlay .instructions-text ul {
  margin: 12px 0;
  padding-left: 24px;
}

.overlay .instructions-text strong {
  color: var(--accent-yellow);
}

.practice-clocks {
  display: flex;
  justify-content: space-around;
  gap: 20px;
  margin: 24px 0;
  flex-wrap: wrap;
}

.practice-clock {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.practice-answers {
  text-align: center;
  font-family: "Space Mono", monospace;
  font-size: 18px;
  color: var(--accent-green);
  margin-top: 20px;
  line-height: 1.8;
}

.countdown {
  text-align: center;
  font-family: "Space Mono", monospace;
  font-size: 20px;
  color: var(--accent-orange);
  margin-top: 24px;
  text-shadow: 0 0 8px var(--accent-orange);
}

/* Setup Form */
.overlay form {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.overlay label {
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-weight: 600;
  color: var(--text);
}

.overlay input[type="text"],
.overlay select {
  padding: 12px 16px;
  border-radius: 8px;
  border: 2px solid #4a4f80;
  background: linear-gradient(180deg, #141938, #0d112b);
  color: var(--text);
  font-size: 16px;
  font-family: "Lexend", sans-serif;
  outline: none;
  transition: all 0.3s;
}

.overlay input[type="text"]:focus,
.overlay select:focus {
  border-color: var(--accent-blue);
  box-shadow: 0 0 15px rgba(111, 168, 255, 0.3);
}

/* Victory/Game Over */
.explosion-effect {
  font-size: 48px;
  margin: 20px 0;
  animation: spin-explode 2s ease-out;
}

.explosion-effect.boom {
  font-size: 128px;
  animation: boom-explode 1s ease-out;
}

@keyframes spin-explode {
  0% {
    transform: scale(0) rotate(0deg);
    opacity: 0;
  }
  50% {
    transform: scale(1.5) rotate(180deg);
    opacity: 1;
  }
  100% {
    transform: scale(1) rotate(360deg);
    opacity: 1;
  }
}

@keyframes boom-explode {
  0% {
    transform: scale(0);
    opacity: 0;
  }
  50% {
    transform: scale(1.3);
    opacity: 1;
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

.final-score {
  font-size: 36px;
  font-family: "Space Mono", monospace;
  color: var(--accent-yellow);
  margin: 24px 0;
  text-shadow: 0 0 12px var(--accent-yellow);
}

.score-breakdown {
  font-size: 16px;
  color: var(--muted);
  margin-top: 12px;
  line-height: 1.6;
}

.leaderboard-display {
  margin: 32px 0;
  padding: 20px;
  background: rgba(0, 0, 0, 0.3);
  border-radius: 12px;
  border: 1px solid #303560;
}

.leaderboard-display h3 {
  margin: 0 0 16px 0;
  color: var(--accent-blue);
  font-size: 20px;
}

.leaderboard-display ol {
  margin: 0;
  padding-left: 24px;
  text-align: left;
  font-family: "Space Mono", monospace;
  font-size: 14px;
  line-height: 2;
  max-height: 200px;
  overflow-y: auto;
}

.leaderboard-display li {
  color: var(--text);
}

/* Help Overlay */
.help-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.close-btn {
  background: #2a2d4a;
  border: 1px solid #4a4f80;
  color: #fff;
  border-radius: 8px;
  font-size: 24px;
  width: 40px;
  height: 40px;
  cursor: pointer;
  transition: all 0.2s;
}

.close-btn:hover {
  background: #38406c;
  transform: scale(1.1);
}

.help-content {
  line-height: 1.7;
}

.help-content h3 {
  color: var(--accent-yellow);
  margin-top: 24px;
  margin-bottom: 12px;
}

.help-content ul {
  margin: 8px 0;
  padding-left: 24px;
}

/* Responsive */
@media (max-width: 900px) {
  .conversion-grid,
  .calculation-grid {
    grid-template-columns: 1fr;
  }
  
  .round-header {
    flex-direction: column;
    text-align: center;
  }
  
  .limit-badge,
  .game-title {
    font-size: 24px;
  }
  
  .score-display {
    font-size: 18px;
  }
}

