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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #0a0a1a;
  font-family: 'Courier New', monospace;
  color: #fff;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  touch-action: none;
}

.back-btn {
  touch-action: auto;
  position: fixed;
  top: 10px;
  left: 12px;
  z-index: 1001;
  font-family: 'Courier New', monospace;
  font-size: 11px;
  letter-spacing: 2px;
  color: #ff69b480;
  text-decoration: none;
  border: 1px solid #ff69b430;
  padding: 4px 10px;
  border-radius: 4px;
  background: rgba(10,10,26,0.7);
  transition: color 120ms, border-color 120ms;
  -webkit-user-select: none;
  user-select: none;
}
.back-btn:hover { color: #ff69b4; border-color: #ff69b4; }

.audio-btns { position: fixed; top: 10px; right: 12px; z-index: 1001; display: flex; gap: 6px; touch-action: auto; }
.audio-btn { font-family: 'Courier New', monospace; font-size: 10px; letter-spacing: 2px; color: #ff69b480; border: 1px solid #ff69b430; padding: 4px 8px; border-radius: 4px; background: rgba(10,10,26,0.7); cursor: pointer; touch-action: auto; -webkit-tap-highlight-color: transparent; }
.audio-btn.muted { color: #ff446660; border-color: #ff446630; }

#game-container { position: fixed; inset: 0; }

canvas {
  display: block;
  max-width: 100vw;
  max-height: 100vh;
  border: none;
  box-shadow: 0 0 30px #ff69b440;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  cursor: none;
  will-change: transform;
  transform: translateZ(0);
}

#ui {
  position: fixed;
  left:  var(--canvas-left,  0px);
  width: var(--canvas-width, 100%);
  top:   calc(var(--canvas-top, 0px) + var(--canvas-height, 640px) + 2px);
  display: flex;
  justify-content: space-between;
  padding: 6px 4px;
  font-size: clamp(10px, 1.8vw, 14px);
  color: #ff69b4;
  letter-spacing: 2px;
  overflow: hidden;
}

/* ── OVERLAYS ─────────────────────────────────────────── */
.overlay {
  display: none;
  position: fixed;
  inset: 0;
  align-items: center;
  justify-content: center;
  background: rgba(10,10,26,0.90);
  z-index: 1000;
  pointer-events: all;
  touch-action: auto;
}
.overlay.active { display: flex; }

.overlay-box {
  background: linear-gradient(160deg, #1a1a2e 0%, #0d0d1a 100%);
  border: 2px solid #ff69b4;
  box-shadow: 0 0 40px #ff69b440, inset 0 0 60px #ff69b408;
  border-radius: 12px;
  padding: 36px 44px;
  text-align: center;
  max-width: 400px;
  width: 90%;
  touch-action: auto;
}

.overlay-title {
  font-size: clamp(16px, 3.5vw, 22px);
  color: #ff69b4;
  letter-spacing: 3px;
  margin-bottom: 10px;
  text-shadow: 0 0 20px #ff69b480;
  line-height: 1.3;
}

.overlay-sub {
  font-size: clamp(13px, 2.4vw, 16px);
  color: #ff69b499;
  letter-spacing: 2px;
  margin-bottom: 20px;
}

.how-to {
  background: rgba(255,105,180,0.06);
  border: 1px solid #ff69b430;
  border-radius: 8px;
  padding: 14px 18px;
  margin-bottom: 24px;
  text-align: left;
}
.how-to p {
  font-size: clamp(12px, 2.2vw, 15px);
  color: #ff69b4cc;
  letter-spacing: 1px;
  margin-bottom: 6px;
}
.how-to p:last-child { margin-bottom: 0; }

.final-score {
  font-size: clamp(16px, 3vw, 22px);
  color: #ff69b4;
  letter-spacing: 3px;
  margin-bottom: 16px;
  text-shadow: 0 0 16px #ff69b460;
}

.menu-btn {
  display: inline-block;
  padding: 12px 32px;
  border: 2px solid #ff69b4;
  background: linear-gradient(160deg, #1a1a2e 0%, #0d0d1a 100%);
  color: #ff69b4;
  font-family: 'Courier New', monospace;
  font-size: clamp(11px, 2vw, 14px);
  letter-spacing: 3px;
  cursor: pointer;
  border-radius: 6px;
  box-shadow: 0 0 16px #ff69b450, inset 0 2px 0 #ff69b420;
  transition: transform 80ms, box-shadow 80ms, background 80ms;
  -webkit-tap-highlight-color: transparent;
  touch-action: auto;
}
.menu-btn:hover {
  background: linear-gradient(160deg, #2a1a3e 0%, #150d2a 100%);
  box-shadow: 0 0 28px #ff69b470, inset 0 2px 0 #ff69b430;
}
.menu-btn:active { transform: translateY(2px) scale(0.97); }

.menu-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  box-shadow: none;
  animation: loading-pulse 1s ease-in-out infinite;
}

@keyframes loading-pulse {
  0%, 100% { opacity: 0.45; }
  50%       { opacity: 0.25; }
}

/* ── HIGH SCORES ──────────────────────────────────────── */
.hs-table { width: 100%; border-collapse: collapse; margin-top: 14px; }
.hs-title {
  font-size: clamp(9px, 1.6vw, 11px);
  letter-spacing: 4px;
  color: #ff69b4;
  padding-bottom: 8px;
  text-align: center;
  border-bottom: 1px solid #ff69b430;
}
.hs-row {
  font-size: clamp(9px, 1.6vw, 11px);
  letter-spacing: 1px;
  color: #ff69b4bb;
  border-bottom: 1px solid #ff69b415;
}
.hs-row td { padding: 5px 4px; }
.hs-row.hs-new { color: #ffcc44; text-shadow: 0 0 8px #ffcc4460; }
.hs-rank  { width: 28px; text-align: center; }
.hs-score { text-align: right; font-weight: bold; padding-right: 8px; }
.hs-spacer { width: 16px; }
.hs-date  { text-align: right; opacity: 0.55; font-size: 0.9em; }
.hs-empty { font-size: 11px; color: #ff69b460; letter-spacing: 2px; text-align: center; padding: 10px 0; }

/* HUD drawn on canvas */
#ui { display: none !important; }
/* ── MOBILE: iPhone / small screens ──────────────────── */
@media (max-width: 500px) {
  .overlay-box {
    padding: 24px 20px;
  }

  .overlay-sub {
    font-size: 11px;
    margin-bottom: 14px;
  }

  .how-to {
    padding: 10px 12px;
    margin-bottom: 16px;
  }

  .how-to p {
    font-size: 11px;
    margin-bottom: 4px;
  }

  .menu-btn {
    padding: 10px 24px;
    font-size: 11px;
  }
}