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

html, body {
  width: 100%; height: 100%;
  background: #05121f;
  overflow: hidden;
  font-family: "Trebuchet MS", "Segoe UI", system-ui, sans-serif;
  color: #eaf6ff;
}

#stage {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

#game {
  /* keep crisp pixel art when scaled up */
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  background: #0a2740;
  max-width: 100vw;
  max-height: 100vh;
  width: min(100vw, 160vh);   /* preserve 960:600 (8:5) */
  aspect-ratio: 8 / 5;
  height: auto;
  box-shadow: 0 0 60px rgba(0,0,0,.6), inset 0 0 0 2px rgba(255,255,255,.04);
  cursor: crosshair;
  /* stop the browser hijacking touches for scroll/zoom/pull-to-refresh */
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

/* ---- rotate-to-landscape nudge for portrait phones ---- */
#rotate {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  text-align: center;
  padding: 24px;
  background: #05121f;
  color: #cfeeff;
  font-size: 18px;
}
#rotate .rot-icon { font-size: 64px; animation: rotwig 1.6s ease-in-out infinite; }
@keyframes rotwig { 0%,100% { transform: rotate(0); } 50% { transform: rotate(-90deg); } }
@media (max-width: 900px) and (orientation: portrait) {
  #rotate { display: flex; }
}

/* ---- overlays ---- */
.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 14px;
  background: radial-gradient(ellipse at center, rgba(5,30,55,.78), rgba(2,12,24,.94));
  backdrop-filter: blur(2px);
  z-index: 5;
  padding: 20px;
}
.overlay.hidden, .toast.hidden { display: none; }

h1 {
  font-size: clamp(40px, 8vw, 92px);
  letter-spacing: 6px;
  color: #ffd766;
  text-shadow: 0 4px 0 #b9791b, 0 0 30px rgba(255,200,80,.5);
}
h2 {
  font-size: clamp(30px, 6vw, 60px);
  letter-spacing: 3px;
  color: #ff8c6b;
  text-shadow: 0 3px 0 #7a2d1b;
}
.tag { font-size: clamp(14px, 2.2vw, 20px); color: #bfe2ff; max-width: 560px; }
.best { color: #ffd766; margin-top: 8px; }

.controls {
  list-style: none;
  display: grid;
  gap: 6px;
  font-size: clamp(13px, 1.8vw, 17px);
  color: #d6ecff;
  background: rgba(0,0,0,.25);
  padding: 14px 22px;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,.08);
}
.controls b { color: #7fd3ff; }

button {
  margin-top: 10px;
  font: inherit;
  font-weight: 700;
  letter-spacing: 2px;
  font-size: clamp(16px, 2.6vw, 22px);
  color: #06243c;
  background: linear-gradient(#ffe07a, #ffc02e);
  border: none;
  padding: 14px 34px;
  border-radius: 999px;
  cursor: pointer;
  box-shadow: 0 5px 0 #b9791b, 0 8px 22px rgba(0,0,0,.4);
  transition: transform .05s ease, box-shadow .05s ease;
}
button:hover { transform: translateY(-1px); }
button:active { transform: translateY(4px); box-shadow: 0 1px 0 #b9791b; }

.toast {
  position: absolute;
  top: 16%;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(8,40,66,.92);
  border: 1px solid #ffd766;
  color: #ffe79b;
  font-weight: 700;
  padding: 12px 22px;
  border-radius: 10px;
  font-size: clamp(15px, 2.2vw, 20px);
  z-index: 4;
  box-shadow: 0 6px 20px rgba(0,0,0,.5);
  animation: pop .25s ease;
}
@keyframes pop { from { transform: translate(-50%, -8px); opacity: 0; } }

#credits {
  position: absolute;
  bottom: 6px;
  right: 10px;
  font-size: 11px;
  color: rgba(200,225,255,.35);
  z-index: 3;
  pointer-events: none;
}
