html, body { margin: 0; height: 100dvh; overflow: hidden; background: #0b0d12; }
#game { display: block; width: 100vw; height: 100dvh; cursor: crosshair; touch-action: none; -webkit-user-select: none; user-select: none; }

#overlay {
  position: fixed; inset: 0; display: flex; flex-direction: column; align-items: center;
  z-index: 10; cursor: pointer; overflow-y: auto;
  box-sizing: border-box;
  padding: max(14px, env(safe-area-inset-top)) max(14px, env(safe-area-inset-right))
           max(14px, env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left));
  font-family: 'Chakra Petch', 'Segoe UI', system-ui, sans-serif; color: #eef1f8;
  background:
    radial-gradient(120% 80% at 50% 118%, rgba(255, 106, 40, .22) 0%, rgba(255, 106, 40, 0) 55%),
    radial-gradient(90% 60% at 82% -10%, rgba(70, 90, 200, .35) 0%, rgba(70, 90, 200, 0) 60%),
    radial-gradient(70% 50% at 12% 8%, rgba(55, 200, 240, .22) 0%, rgba(55, 200, 240, 0) 55%),
    linear-gradient(180deg, #070912 0%, #0d1120 46%, #141024 100%);
  backdrop-filter: blur(4px);
}
.title {
  margin: auto; display: flex; flex-direction: column; align-items: center;
  gap: clamp(6px, 2.2vh, 18px); width: 100%; max-width: 720px;
}
#overlay::before {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background-image:
    linear-gradient(rgba(255,255,255,.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.045) 1px, transparent 1px);
  background-size: 44px 44px;
  mask-image: radial-gradient(70% 70% at 50% 45%, black 0%, transparent 78%);
  -webkit-mask-image: radial-gradient(70% 70% at 50% 45%, black 0%, transparent 78%);
}
#overlay.hidden { display: none; }

.kicker {
  font-family: 'Rajdhani', system-ui, sans-serif; font-weight: 600;
  font-size: clamp(10px, 1.7vh, 13px); letter-spacing: .42em; color: #7f8bab; text-transform: uppercase;
  padding-left: .42em;
}
.logo {
  font-weight: 900; font-style: italic; font-size: clamp(48px, 16vh, 118px); letter-spacing: -5px; line-height: .9;
  background: linear-gradient(180deg, #ffffff 8%, #c7d2e8 55%, #8b9ac2 100%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 6px 30px rgba(0,0,0,.6));
}
.logo span {
  display: block;
  background: linear-gradient(180deg, #ffe27a 0%, #ffb02e 55%, #ff7a2e 100%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 0 26px rgba(255, 150, 40, .45));
}
.tag { font-family: 'Rajdhani', system-ui, sans-serif; font-weight: 600; font-size: clamp(13px, 2.2vh, 17px);
  letter-spacing: .3em; text-transform: uppercase; color: #9fb0d0; text-align: center; }

.controls { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; max-width: 640px; margin-top: 6px; }
.controls[hidden] { display: none; }
.chip {
  font-family: 'Rajdhani', system-ui, sans-serif; font-weight: 600; font-size: 13.5px; letter-spacing: .06em;
  color: #c4cfe4; background: rgba(255,255,255,.05);
  border: 1px solid rgba(255,255,255,.12); border-radius: 999px; padding: 6px 14px;
}
.chip b { color: #8ae4ff; font-weight: 700; margin-right: 2px; }

#startbtn {
  margin-top: 14px; font-weight: 700; font-size: clamp(15px, 2.4vh, 19px); letter-spacing: .28em; text-transform: uppercase;
  color: #0a0d14; padding: clamp(10px, 1.8vh, 14px) clamp(28px, 5vw, 40px); border-radius: 999px;
  background: linear-gradient(180deg, #ffe27a 0%, #ffb02e 100%);
  box-shadow: 0 0 0 1px rgba(255,190,80,.5), 0 8px 40px rgba(255,150,40,.4);
  animation: pulse 1.3s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 1px rgba(255,190,80,.35), 0 8px 26px rgba(255,150,40,.22); transform: scale(1); }
  50% { box-shadow: 0 0 0 1px rgba(255,210,110,.8), 0 8px 52px rgba(255,170,50,.5); transform: scale(1.03); }
}
.stats { font-size: 12px; letter-spacing: .12em; color: #77839c; font-family: ui-monospace, monospace; }
.highscores { margin-top: 14px; padding: 10px 16px 12px; border: 1px solid rgba(255,210,110,.28); background: rgba(8,10,16,.55); border-radius: 10px; min-width: 260px; }
.highscores[hidden] { display: none; }
.hs-title { font: 700 11px "Rajdhani", sans-serif; letter-spacing: .3em; color: #ffd21f; text-align: center; margin-bottom: 8px; }
.hs-row { display: flex; align-items: baseline; gap: 12px; font: 600 15px "Rajdhani", sans-serif; color: #e8ecf2; padding: 2px 0; }
.hs-row .hs-rank { width: 22px; color: #ffd21f; font-weight: 700; font-size: 13px; }
.hs-row .hs-ini { letter-spacing: .18em; font-weight: 700; }
.hs-row .hs-score { margin-left: auto; font-family: ui-monospace, monospace; font-size: 13px; color: #8ae4ff; letter-spacing: .06em; }

@media (max-width: 520px) {
  .kicker { letter-spacing: .22em; padding-left: .22em; }
  .tag { letter-spacing: .16em; }
  .logo { font-size: clamp(48px, 20vw, 100px); letter-spacing: -3px; }
  #startbtn { letter-spacing: .2em; }
}
@media (max-height: 700px) {
  .tag + .tag { display: none; }
  .achv-btn { margin-top: 4px; }
}
@media (max-height: 560px) {
  .title { gap: clamp(4px, 1.5vh, 10px); }
  .logo { font-size: clamp(34px, 12vh, 72px); letter-spacing: -2px; }
  .kicker { font-size: clamp(8px, 1.4vh, 11px); letter-spacing: .2em; }
  .tag { font-size: clamp(10px, 1.8vh, 13px); letter-spacing: .14em; }
  .tag + .tag { display: none; }
  .chip { font-size: 11px; padding: 3px 9px; }
  #startbtn { font-size: clamp(12px, 2vh, 15px); padding: 8px 22px; margin-top: 4px; }
  .stats { font-size: 10px; }
  .highscores { display: none; }
}

#demolog {
  position: fixed; left: 8px; bottom: 64px; width: 360px; max-height: 170px;
  overflow: hidden; padding: 6px 8px; font: 10px/1.5 "Courier New", monospace;
  color: #7dffa8; background: rgba(0,0,0,.55); border: 1px solid rgba(125,255,168,.35);
  pointer-events: none; white-space: pre; z-index: 10;
}
.achv-btn { margin-top: 10px; display: inline-block; padding: 6px 16px; border: 1px solid rgba(255,210,110,.35); border-radius: 999px; font: 700 11px "Rajdhani", sans-serif; letter-spacing: .25em; color: #ffd21f; cursor: pointer; }
.achv-btn:hover { background: rgba(255,210,110,.08); }
.achv-row { display: flex; gap: 10px; font: 600 14px "Rajdhani", sans-serif; color: #e8ecf2; padding: 2px 0; align-items: baseline; }
.achv-row.locked { opacity: .45; }
.achv-row .achv-mark { width: 16px; color: #ffd21f; font-weight: 700; }
.achv-row.locked .achv-mark { color: #667080; }
.achv-row .achv-name { font-weight: 700; letter-spacing: .06em; }
.achv-row .achv-desc { margin-left: auto; font-size: 12px; color: rgba(232,236,242,.55); }
