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

html, body {
  height: 100%;
  background: #0d0f1a;
  font-family: "Courier New", ui-monospace, monospace;
  color: #fff;
  overflow: hidden;
}

body {
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(1200px 700px at 50% -10%, #1c2340 0%, #0d0f1a 60%);
}

#wrap { display: flex; flex-direction: column; align-items: center; gap: 10px; }

#frame {
  position: relative;
  line-height: 0;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 24px 80px rgba(0,0,0,.65), 0 0 0 3px #2a3158, 0 0 40px rgba(64,92,235,.18);
}

#game { display: block; width: min(96vw, 960px); height: auto; image-rendering: pixelated; }

/* ---------- HUD ---------- */
#hud {
  position: absolute; top: 10px; left: 12px; right: 12px;
  display: flex; justify-content: space-between; gap: 8px;
  pointer-events: none;
  font-weight: bold; letter-spacing: 1px;
  text-shadow: 2px 2px 0 rgba(0,0,0,.55);
  font-size: clamp(11px, 1.6vw, 17px);
}
.hud-item { display: flex; gap: 8px; align-items: baseline; }
.hud-label { opacity: .75; font-size: .8em; }

/* ---------- Overlay ---------- */
#overlay {
  position: absolute; inset: 0;
  display: none;
  align-items: center; justify-content: center;
  background: rgba(8, 10, 24, .78);
  backdrop-filter: blur(3px);
}
#overlay.show { display: flex; }

#overlay-box { text-align: center; padding: 24px; max-width: 92%; }

#ov-title {
  font-size: clamp(34px, 7vw, 68px);
  letter-spacing: 6px;
  color: #ff5a3c;
  text-shadow: 0 4px 0 #7a1d0e, 0 8px 24px rgba(255,90,60,.35);
  margin-bottom: 14px;
}

#ov-sub { font-size: clamp(15px, 2.4vw, 22px); letter-spacing: 3px; margin-bottom: 18px; }
.blink { animation: blink 1.1s steps(2) infinite; }
@keyframes blink { 50% { opacity: .15; } }

#ov-help p { margin: 6px 0; font-size: clamp(12px, 1.8vw, 16px); }
#ov-help .dim { opacity: .6; font-size: .85em; margin-top: 12px; }
#ov-help b { color: #ffd75e; }

.rotate-hint { display: none !important; opacity: .8; margin-top: 14px; font-size: .9em !important; }

/* ---------- Touch controls ---------- */
#touch {
  position: absolute; inset: auto 0 14px 0;
  display: none;
  justify-content: space-between;
  align-items: flex-end;
  padding: 0 16px;
}
.tgroup { display: flex; gap: 12px; }

.tbtn {
  width: 60px; height: 60px; border-radius: 50%;
  background: rgba(255,255,255,.16);
  border: 2px solid rgba(255,255,255,.35);
  display: flex; align-items: center; justify-content: center;
  font-size: 24px; user-select: none; -webkit-user-select: none;
  touch-action: none; cursor: pointer;
}
.tbtn:active { background: rgba(255,255,255,.34); }
.tbtn.jump { width: 80px; height: 80px; font-weight: bold; letter-spacing: 1px; }

/* ---------- Responsive ---------- */
@media (pointer: coarse) {
  #touch { display: flex; }
  .kbd-only { display: none !important; }
  .touch-only { display: block !important; }
}

@media (pointer: fine) {
  .touch-only { display: none !important; }
}

/* portrait phones: shrink HUD, hide world label to avoid crowding */
@media (max-width: 600px) and (orientation: portrait) {
  #hud { font-size: 10px; gap: 6px; top: 8px; left: 8px; right: 8px; }
  .hud-world { display: none; }
  #ov-help p { font-size: 12px; margin: 5px 0; }
  .rotate-hint { display: block !important; }
}

#footer { opacity: .45; font-size: 12px; letter-spacing: 1px; }
@media (max-width: 600px) { #footer { font-size: 10px; } }
