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

body {
  background: #1a1a2e;
  overflow: hidden;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  font-family: 'Press Start 2P', monospace;
}

canvas {
  display: block;
  width: 100vw;
  height: 100vh;
  image-rendering: pixelated;
}

/* === SCREEN SHAKE === */
.shake {
  animation: shake 0.3s ease-out;
}
@keyframes shake {
  0%, 100% { transform: translate(0); }
  10% { transform: translate(-4px, 2px); }
  20% { transform: translate(4px, -2px); }
  30% { transform: translate(-3px, -1px); }
  40% { transform: translate(3px, 1px); }
  50% { transform: translate(-2px, 2px); }
}

/* === UI OVERLAY === */
#ui-overlay {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 10;
}

.screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}
.screen.active {
  opacity: 1;
  pointer-events: auto;
}

/* === START SCREEN === */
.game-title {
  font-size: clamp(2rem, 8vw, 4rem);
  color: #FFD700;
  text-shadow: 0 0 20px rgba(255, 215, 0, 0.5), 0 4px 0 #B8860B;
  text-align: center;
  line-height: 1.3;
}

.subtitle {
  font-size: clamp(0.6rem, 2.5vw, 1rem);
  color: #10B981;
  margin-top: 0.5rem;
  letter-spacing: 0.2em;
}

.tap-prompt {
  font-size: clamp(0.5rem, 2vw, 0.8rem);
  color: #fff;
  margin-top: 2rem;
  animation: blink 1s ease-in-out infinite;
}
@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

/* Level selector */
.level-selector {
  display: flex;
  gap: 0.4rem;
  margin-top: 1.5rem;
  pointer-events: auto;
  justify-content: center;
}
.level-selector-go {
  margin-top: 0.5rem;
  margin-bottom: 0.5rem;
}
.level-btn {
  font-family: 'Press Start 2P', monospace;
  font-size: 0.45rem;
  padding: 0.5rem 0.8rem;
  border: 2px solid rgba(255,255,255,0.15);
  background: rgba(30, 41, 59, 0.8);
  color: #94A3B8;
  cursor: pointer;
  letter-spacing: 0.05em;
  transition: all 0.15s;
  border-radius: 4px;
  -webkit-appearance: none;
  appearance: none;
  outline: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  position: relative;
  z-index: 20;
}
.level-btn:active { transform: scale(0.95); }
.level-btn.active[data-level="easy"] { border-color: #10B981; color: #10B981; background: rgba(16,185,129,0.25); }
.level-btn.active[data-level="medium"] { border-color: #F59E0B; color: #F59E0B; background: rgba(245,158,11,0.25); }
.level-btn.active[data-level="hard"] { border-color: #EF4444; color: #EF4444; background: rgba(239,68,68,0.25); }

.high-score-display {
  font-size: 0.6rem;
  color: #94A3B8;
  margin-top: 1rem;
}

/* HUD level badge */
.hud-level {
  font-size: 0.45rem;
  letter-spacing: 0.1em;
}

/* === HUD === */
#hud {
  justify-content: flex-start;
  align-items: flex-end;
  padding: 1rem;
}
.hud-row {
  display: flex;
  gap: 1rem;
}
.hud-item {
  font-size: clamp(0.6rem, 2.5vw, 0.9rem);
  color: #FFD700;
  text-shadow: 0 2px 4px rgba(0,0,0,0.5);
  background: rgba(0,0,0,0.3);
  padding: 0.3rem 0.6rem;
  border-radius: 4px;
  backdrop-filter: blur(4px);
}

/* === GAME OVER === */
.gameover-title {
  font-size: clamp(1.5rem, 6vw, 3rem);
  color: #EF4444;
  text-shadow: 0 0 20px rgba(239, 68, 68, 0.5);
  margin-bottom: 1.5rem;
}

/* Breakdown */
.gameover-breakdown {
  display: flex;
  gap: 1.5rem;
  margin: 0.8rem 0;
}
.breakdown-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2rem;
}
.breakdown-icon { font-size: 1.2rem; }
.breakdown-label {
  font-size: 0.4rem;
  color: #94A3B8;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}
.breakdown-value {
  font-size: 0.8rem;
  color: #CBD5E1;
}

/* Total */
.gameover-total {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin: 0.8rem 0 0.3rem;
  padding-top: 0.6rem;
  border-top: 1px solid rgba(255,255,255,0.1);
}
.gameover-total .label {
  font-size: 0.5rem;
  color: #10B981;
  text-transform: uppercase;
  letter-spacing: 0.15em;
}
.gameover-total .value {
  font-size: clamp(1.2rem, 5vw, 2.5rem);
  color: #FFD700;
}

.gameover-score {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin: 0.3rem 0;
}
.gameover-score .label {
  font-size: 0.5rem;
  color: #94A3B8;
  text-transform: uppercase;
  letter-spacing: 0.15em;
}
.gameover-score .value {
  font-size: clamp(0.8rem, 3vw, 1.2rem);
  color: #94A3B8;
}

.gameover-new {
  font-size: 0.7rem;
  color: #10B981;
  margin: 0.5rem 0;
  animation: blink 0.5s ease-in-out infinite;
}

.btn-retry, .btn-share {
  font-family: 'Press Start 2P', monospace;
  font-size: 0.65rem;
  padding: 0.8rem 1.5rem;
  margin: 0.4rem;
  border: 2px solid;
  cursor: pointer;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  transition: transform 0.1s ease;
}
.btn-retry:active, .btn-share:active {
  transform: scale(0.95);
}
.btn-retry {
  background: #10B981;
  color: #fff;
  border-color: #059669;
}
.btn-share {
  background: transparent;
  color: #FFD700;
  border-color: #FFD700;
}

/* === HELP MODAL === */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}
.modal.active {
  opacity: 1;
  pointer-events: auto;
}
.modal-content {
  background: #1E293B;
  border: 2px solid #334155;
  border-radius: 8px;
  padding: 1.5rem;
  max-width: 320px;
  width: 90%;
  text-align: center;
}
.modal-content h3 {
  font-size: 0.8rem;
  color: #FFD700;
  margin-bottom: 1rem;
}
.modal-content p {
  font-size: 0.5rem;
  color: #CBD5E1;
  margin: 0.6rem 0;
  line-height: 1.8;
}
.btn-close-modal {
  font-family: 'Press Start 2P', monospace;
  font-size: 0.6rem;
  padding: 0.6rem 1.2rem;
  margin-top: 1rem;
  background: #10B981;
  color: #fff;
  border: 2px solid #059669;
  cursor: pointer;
}

/* === MOBILE CONTROLS === */
.mobile-controls {
  position: fixed;
  bottom: 3.5rem;
  left: 0;
  right: 0;
  z-index: 40;
  display: flex;
  justify-content: space-between;
  padding: 0 1.5rem;
  pointer-events: none;
}

.ctrl-btn {
  pointer-events: auto;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.2);
  background: rgba(30, 41, 59, 0.6);
  color: rgba(255, 255, 255, 0.7);
  font-size: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transition: transform 0.1s, background 0.1s;
  -webkit-tap-highlight-color: transparent;
}

.ctrl-btn:active {
  transform: scale(0.9);
  background: rgba(16, 185, 129, 0.3);
  border-color: rgba(16, 185, 129, 0.5);
}

/* Hide on desktop (keyboard available) */
@media (hover: hover) and (pointer: fine) {
  .mobile-controls { display: none; }
}

/* === FLOATING BUTTONS === */
.btn-floating {
  position: fixed;
  z-index: 50;
  height: 36px;
  border-radius: 18px;
  border: 1px solid rgba(255,255,255,0.15);
  background: rgba(30, 41, 59, 0.8);
  color: #CBD5E1;
  font-size: 12px;
  font-family: 'Press Start 2P', monospace;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  text-decoration: none;
  backdrop-filter: blur(8px);
  padding: 0 12px;
  min-width: 36px;
}
.btn-lang { top: 1rem; right: 1rem; font-size: 9px; letter-spacing: 0.05em; }
.btn-help { bottom: 1rem; left: 1rem; width: 36px; padding: 0; }

/* Tip button — prominent */
.btn-tip {
  bottom: 1rem;
  right: 1rem;
  gap: 6px;
  background: linear-gradient(135deg, #F59E0B, #D97706);
  border: 1px solid #FBBF24;
  color: #fff;
  box-shadow: 0 0 12px rgba(245, 158, 11, 0.3);
  animation: tipGlow 2s ease-in-out infinite;
}
.tip-icon { font-size: 14px; }
.tip-label { font-size: 8px; letter-spacing: 0.1em; }

@keyframes tipGlow {
  0%, 100% { box-shadow: 0 0 8px rgba(245, 158, 11, 0.2); }
  50% { box-shadow: 0 0 16px rgba(245, 158, 11, 0.5); }
}

/* Share links */
.share-link {
  font-family: 'Press Start 2P', monospace;
  font-size: 7px;
  padding: 0.5rem 0.8rem;
  border: none;
  border-radius: 4px;
  color: #fff;
  cursor: pointer;
  text-decoration: none;
  text-align: center;
  letter-spacing: 0.05em;
  transition: opacity 0.15s;
}
.share-link:hover { opacity: 0.85; }
