:root {
  --primary-color: #3498db;
  --secondary-color: #e74c3c;
  --bg-color: #f4f4f4;
  --text-color: #333;
  --overlay-bg: rgba(255, 255, 255, 0.9);
  --font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

body.dark-mode {
  --primary-color: #2980b9;
  --secondary-color: #c0392b;
  --bg-color: #2c3e50;
  --text-color: #ecf0f1;
  --overlay-bg: rgba(0, 0, 0, 0.9);
}

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

body {
  font-family: var(--font-family);
  background-color: var(--bg-color);
  color: var(--text-color);
  overflow: hidden; /* Prevent scroll on mobile */
  touch-action: none; /* Prevent default touch actions like scroll */
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100vh;
  width: 100vw;
}

#game-wrapper {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
}

#game-container {
  width: 100%;
  height: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
}

canvas {
  display: block;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

#ui-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none; /* Allow clicks through to canvas when hidden */
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
}

.screen {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: var(--overlay-bg);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  pointer-events: auto; /* Block clicks when visible */
  transition: opacity 0.3s ease, visibility 0s linear 0s;
  opacity: 1;
  visibility: visible;
  z-index: 10;
}

.screen.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.3s ease, visibility 0s linear 0.3s;
}

.screen.visible {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transition: opacity 0.3s ease, visibility 0s linear 0s;
}

.hud {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  padding: 20px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  pointer-events: none; /* Allow clicks through */
  z-index: 5;
}

.hud-top {
  display: flex;
  gap: 20px;
}

.stat-box {
  background: rgba(0, 0, 0, 0.5);
  color: white;
  padding: 10px 15px;
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  backdrop-filter: blur(5px);
}

.stat-box .label {
  font-size: 0.8rem;
  opacity: 0.8;
}

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

.title {
  font-size: 3rem;
  margin-bottom: 10px;
  text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
}

.subtitle {
  font-size: 1.5rem;
  margin-bottom: 30px;
  opacity: 0.8;
}

.instructions {
  margin-bottom: 40px;
  text-align: center;
  line-height: 1.6;
}

.btn {
  padding: 15px 30px;
  font-size: 1.2rem;
  border: none;
  border-radius: 50px;
  cursor: pointer;
  margin: 10px;
  transition: transform 0.2s, box-shadow 0.2s;
  pointer-events: auto;
}

.btn.primary {
  background-color: var(--primary-color);
  color: white;
  box-shadow: 0 4px 6px rgba(0,0,0,0.2);
}

.btn.secondary {
  background-color: transparent;
  border: 2px solid var(--primary-color);
  color: var(--primary-color);
}

.btn.icon {
  background: rgba(0, 0, 0, 0.5);
  color: white;
  width: 50px;
  height: 50px;
  padding: 0;
  border-radius: 50%;
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 1.5rem;
  backdrop-filter: blur(5px);
}

.btn:hover {
  transform: scale(1.05);
  box-shadow: 0 6px 8px rgba(0,0,0,0.3);
}

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

.high-score-display {
  margin-top: 20px;
  font-size: 1rem;
  opacity: 0.7;
}

/* Animations */
@keyframes pulse {
  0% { transform: scale(1); }
  50% { transform: scale(1.1); }
  100% { transform: scale(1); }
}

.pulse {
  animation: pulse 2s infinite;
}
