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

body {
  background: #1a1a2e;
  color: #f0f0f0;
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  -webkit-user-select: none;
  user-select: none;
}

#game-wrapper {
  position: relative;
  width: 100%;
  max-width: 960px;
  aspect-ratio: 960 / 640;
}

#game-canvas {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 8px;
  cursor: crosshair;
  touch-action: none;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}

/* === Score HUD === */
#score-hud {
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.6);
  padding: 8px 24px;
  border-radius: 20px;
  font-size: 1.1rem;
  font-weight: 800;
  letter-spacing: 2px;
  color: #ffd700;
  pointer-events: none;
  z-index: 10;
}

#score-hud.hidden {
  display: none;
}

/* === Sound Button === */
#sound-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  background: rgba(0, 0, 0, 0.5);
  border: 2px solid rgba(255, 255, 255, 0.2);
  border-radius: 8px;
  color: #ccc;
  padding: 6px 12px;
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  z-index: 10;
}

#sound-btn:hover {
  border-color: #ffd700;
  color: #ffd700;
}

/* === Home Link === */
#home-link {
  position: absolute;
  top: 10px;
  left: 10px;
  color: #aaa;
  text-decoration: none;
  font-size: 0.85rem;
  z-index: 10;
  background: rgba(0, 0, 0, 0.5);
  padding: 6px 12px;
  border-radius: 8px;
}

#home-link:hover {
  color: #ffd700;
}

/* === Overlays === */
.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(10, 10, 30, 0.92);
  z-index: 20;
  border-radius: 8px;
}

.overlay.hidden {
  display: none;
}

.overlay h1 {
  font-size: 3.5rem;
  font-weight: 900;
  margin-bottom: 12px;
  background: linear-gradient(90deg, #ffd700, #ff6b35, #ff3860);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.overlay .subtitle {
  font-size: 1.3rem;
  color: #ccc;
  margin-bottom: 28px;
}

.play-btn {
  padding: 16px 48px;
  border: none;
  border-radius: 14px;
  background: linear-gradient(135deg, #ffd700, #ff6b35);
  color: #1a1a2e;
  font-size: 1.5rem;
  font-weight: 800;
  cursor: pointer;
  letter-spacing: 2px;
  transition: transform 0.15s, box-shadow 0.15s;
}

.play-btn:hover {
  transform: scale(1.05);
  box-shadow: 0 6px 24px rgba(255, 215, 0, 0.4);
}

.play-btn:active {
  transform: scale(0.96);
}

.controls-info {
  margin-top: 32px;
  text-align: center;
  color: #888;
  font-size: 0.9rem;
  line-height: 1.8;
}

.controls-info strong {
  color: #ccc;
}

/* === Debug Panel === */
#debug-panel {
  position: absolute;
  bottom: 10px;
  left: 10px;
  background: rgba(0, 0, 0, 0.7);
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 0.75rem;
  font-family: monospace;
  color: #88ff88;
  z-index: 10;
  line-height: 1.6;
}

#debug-panel.hidden {
  display: none;
}

/* === End Screen === */
#end-title {
  font-size: 3rem;
  font-weight: 900;
  margin-bottom: 24px;
}

/* === Mobile === */
@media (max-width: 640px) {
  body {
    padding: 0;
    justify-content: flex-start;
  }

  #game-wrapper {
    border-radius: 0;
    max-width: 100%;
  }

  #game-canvas {
    border-radius: 0;
  }

  .overlay {
    border-radius: 0;
    padding: 16px;
  }

  .overlay h1 {
    font-size: 2.2rem;
  }

  .overlay .subtitle {
    font-size: 1rem;
    margin-bottom: 20px;
  }

  .play-btn {
    padding: 14px 40px;
    font-size: 1.3rem;
  }

  #score-hud {
    font-size: 0.85rem;
    padding: 6px 16px;
    top: 6px;
  }

  #sound-btn {
    padding: 8px 14px;
    font-size: 0.75rem;
    top: 6px;
    right: 6px;
  }

  #home-link {
    padding: 8px 14px;
    font-size: 0.75rem;
    top: 6px;
    left: 6px;
  }

  #end-title {
    font-size: 2rem;
  }
}

@media (max-width: 640px) and (orientation: portrait) {
  #game-wrapper {
    width: 100%;
    aspect-ratio: auto;
    height: auto;
  }

  #game-canvas {
    width: 100%;
    height: auto;
    aspect-ratio: 960 / 640;
  }
}

@media (max-width: 640px) and (orientation: landscape) {
  #game-wrapper {
    width: auto;
    height: 100vh;
    height: 100dvh;
    max-width: none;
    aspect-ratio: 960 / 640;
  }
}
