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

html, body {
  height: 100%;
  background: #000;
  color: #fff;
  font-family: 'Press Start 2P', 'Courier New', monospace;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.game-container {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  max-width: 500px;
  margin: 0 auto;
  background: #000;
  position: relative;
}

/* ---------- HUD ---------- */
.hud {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
  padding: 12px 8px;
  background: #1a1a1a;
  border-bottom: 4px solid #333;
  box-shadow: 0 2px 0 #555 inset;
}

.hud-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  text-align: center;
}

.hud-label {
  color: #888;
  font-size: 8px;
  letter-spacing: 1px;
}

.hud-value {
  color: #fff;
  font-size: 14px;
  text-shadow: 2px 2px 0 #444;
}

.hud-value.lives {
  color: #ff3c3c;
}

.hud-value.flash {
  animation: flash 0.4s ease;
}

@keyframes flash {
  0%   { transform: scale(1);   color: #fff;    }
  50%  { transform: scale(1.4); color: #ffeb3b; }
  100% { transform: scale(1);   color: #fff;    }
}

/* ---------- Game Area ---------- */
.game-area {
  position: relative;
  flex: 1;
  overflow: hidden;
  background: #000;
}

#game-canvas {
  display: block;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

/* ---------- Overlays ---------- */
.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.85);
  text-align: center;
  gap: 18px;
  padding: 24px;
  z-index: 10;
}

.overlay.hidden {
  display: none;
}

.game-title {
  font-size: 38px;
  line-height: 1.2;
  color: #3cff3c;
  text-shadow:
    4px 4px 0 #18a018,
    8px 8px 0 #000;
  letter-spacing: 2px;
  margin-bottom: 12px;
}

.game-over-title {
  font-size: 28px;
  color: #ff3c3c;
  text-shadow: 4px 4px 0 #a01818, 8px 8px 0 #000;
  letter-spacing: 2px;
  margin-bottom: 8px;
}

.subtitle {
  font-size: 10px;
  color: #fff;
  animation: blink 1s steps(2) infinite;
}

.hint {
  font-size: 8px;
  color: #888;
}

.highscore-display {
  font-size: 12px;
  color: #ffeb3b;
  margin-top: 12px;
}

.final-line {
  font-size: 12px;
  color: #fff;
  letter-spacing: 2px;
}

.final-line span {
  color: #3cff3c;
  margin-left: 8px;
}

.new-high {
  font-size: 14px;
  color: #ffeb3b;
  text-shadow: 2px 2px 0 #b8a017;
  animation: blink 0.5s steps(2) infinite;
}

.new-high.hidden {
  display: none;
}

@keyframes blink {
  50% { opacity: 0; }
}

.restart-btn {
  font-family: inherit;
  font-size: 12px;
  padding: 14px 24px;
  margin-top: 12px;
  background: #3cff3c;
  color: #000;
  border: none;
  border-bottom: 6px solid #18a018;
  cursor: pointer;
  letter-spacing: 2px;
  transition: transform 0.05s, border-bottom-width 0.05s;
}

.restart-btn:active {
  transform: translateY(4px);
  border-bottom-width: 2px;
}

/* ---------- Controls ---------- */
.controls {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  padding: 14px 12px calc(14px + env(safe-area-inset-bottom)) 12px;
  background: #1a1a1a;
  border-top: 4px solid #333;
  box-shadow: 0 -2px 0 #555 inset;
}

.btn {
  position: relative;
  height: 80px;
  border: none;
  cursor: pointer;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.05s, border-bottom-width 0.05s;
  font-family: inherit;
}

.btn::before {
  content: '';
  position: absolute;
  inset: 4px;
  background: rgba(255, 255, 255, 0.18);
  pointer-events: none;
}

.btn::after {
  content: '';
  position: absolute;
  top: 4px;
  left: 4px;
  right: 4px;
  height: 12px;
  background: rgba(255, 255, 255, 0.35);
  pointer-events: none;
}

.btn-red {
  background: #ff3c3c;
  border-bottom: 8px solid #a01818;
}

.btn-green {
  background: #3cff3c;
  border-bottom: 8px solid #18a018;
}

.btn-blue {
  background: #3c78ff;
  border-bottom: 8px solid #1840a0;
}

.btn:active,
.btn.pressed {
  transform: translateY(4px);
  border-bottom-width: 4px;
}

.key-hint {
  position: relative;
  z-index: 1;
  color: rgba(0, 0, 0, 0.7);
  font-size: 16px;
  font-weight: bold;
  text-shadow: 1px 1px 0 rgba(255, 255, 255, 0.4);
}

/* ---------- Screen shake (for miss) ---------- */
.shake {
  animation: shake 0.3s ease;
}

@keyframes shake {
  0%, 100% { transform: translate(0, 0); }
  20%      { transform: translate(-4px, 2px); }
  40%      { transform: translate(4px, -2px); }
  60%      { transform: translate(-3px, 3px); }
  80%      { transform: translate(3px, -3px); }
}

/* ---------- Small phones ---------- */
@media (max-height: 640px) {
  .game-title { font-size: 28px; }
  .btn { height: 64px; }
  .hud-value { font-size: 12px; }
}
