* { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
  height: 100%;
  height: 100dvh;
  background:
    radial-gradient(ellipse at 50% 0%, #1a2030 0%, transparent 55%),
    radial-gradient(ellipse at 80% 90%, #0a2010 0%, transparent 40%),
    #05080e;
  color: #e8f0ff;
  font-family: 'VT323', monospace;
  overflow: hidden;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}
body {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100dvh;
  max-height: 100dvh;
}

.arcade-back {
  position: fixed;
  top: 8px;
  left: 8px;
  z-index: 50;
  background: #101828;
  border: 2px solid #39FF14;
  color: #E87820;
  padding: 8px 12px;
  font-family: 'Press Start 2P', monospace;
  font-size: 9px;
  text-decoration: none;
  box-shadow:
    0 3px 0 #05080e,
    0 0 12px rgba(57, 255, 20, 0.35),
    0 0 4px rgba(232, 120, 32, 0.35);
}
.arcade-back:active { transform: translateY(2px); box-shadow: 0 1px 0 #05080e; }

#wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 28px 8px 8px;
  width: 100%;
  height: 100dvh;
  max-height: 100dvh;
  box-sizing: border-box;
}

#hud {
  width: min(420px, calc(100vw - 16px));
  text-align: center;
  flex-shrink: 0;
  padding: 0 4px 0 72px; /* clear ◀ Arcade */
  box-sizing: border-box;
}
.hud-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-family: 'Press Start 2P', monospace;
  font-size: clamp(8px, 2.2vw, 10px);
  color: #39FF14;
  letter-spacing: 0.03em;
  text-shadow: 0 0 8px rgba(57, 255, 20, 0.45);
  gap: 8px;
}
.hud-row.sub {
  margin-top: 6px;
  font-size: clamp(7px, 1.9vw, 9px);
  color: #7a9ab8;
  text-shadow: none;
}
.hud-row b {
  color: #ffe08a;
  text-shadow: 0 0 10px rgba(255, 224, 138, 0.55);
}
#title {
  color: #E87820;
  text-shadow: 0 0 10px rgba(232, 120, 32, 0.7), 0 0 18px rgba(255, 0, 170, 0.25);
}
#status {
  color: #7dfffa;
  text-shadow: 0 0 8px rgba(125, 255, 250, 0.4);
  max-width: 46%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#canvas-wrap {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: min(420px, calc(100vw - 16px));
}
#game {
  display: block;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  background: #000814;
  border: 3px solid #1a4a9e;
  box-shadow:
    0 0 0 1px #000,
    0 0 18px rgba(40, 100, 255, 0.35),
    0 0 28px rgba(57, 255, 20, 0.12),
    0 8px 0 #05080e;
  width: min(380px, calc(100vw - 20px), calc((100dvh - 200px) * 304 / 336));
  max-height: calc(100dvh - 200px);
  height: auto;
  aspect-ratio: 304 / 336;
}
#overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(0, 8, 20, 0.72);
  pointer-events: none;
  gap: 12px;
  padding: 16px;
  text-align: center;
}
#overlay.hidden { display: none; }
#overlay-title {
  font-family: 'Press Start 2P', monospace;
  font-size: clamp(14px, 4vw, 20px);
  color: #E87820;
  text-shadow: 0 0 12px rgba(232, 120, 32, 0.8), 0 0 24px rgba(57, 255, 20, 0.35);
}
#overlay-msg {
  font-family: 'Press Start 2P', monospace;
  font-size: clamp(8px, 2.4vw, 11px);
  color: #39FF14;
  line-height: 1.6;
  text-shadow: 0 0 10px rgba(57, 255, 20, 0.5);
  animation: blink 1.1s steps(2, end) infinite;
}
@keyframes blink {
  0%, 49% { opacity: 1; }
  50%, 100% { opacity: 0.35; }
}

#pads {
  display: flex;
  gap: 14px;
  align-items: center;
  justify-content: center;
  width: min(420px, calc(100vw - 16px));
  padding: 4px 4px 8px;
  flex-shrink: 0;
}
.dpad {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}
.dpad .mid {
  display: flex;
  gap: 36px;
}
.dpad button,
#startBtn {
  font-family: 'Press Start 2P', monospace;
  font-size: 14px;
  color: #061018;
  background: linear-gradient(#b8f080, #39FF14);
  border: 3px solid #1a5a10;
  box-shadow: 0 4px 0 #0a3010;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  min-width: 48px;
  min-height: 44px;
  line-height: 1;
}
.dpad button:active,
#startBtn:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 #0a3010;
}
#startBtn {
  background: linear-gradient(#ffc070, #E87820);
  border-color: #8a4010;
  box-shadow: 0 4px 0 #4a2008;
  color: #1a0c04;
  font-size: 11px;
  padding: 8px 14px;
  min-width: 88px;
  line-height: 1.35;
}
#startBtn small {
  font-size: 7px;
  opacity: 0.8;
  letter-spacing: 0.04em;
}
#startBtn:active { box-shadow: 0 1px 0 #4a2008; }

@media (max-height: 700px) {
  #wrap { padding: 24px 6px 4px; gap: 4px; }
  #game { max-height: calc(100dvh - 180px); }
  .dpad button { min-height: 40px; min-width: 44px; }
}
@media (max-height: 600px) {
  #game { max-height: calc(100dvh - 160px); border-width: 2px; }
  .dpad button { min-height: 36px; font-size: 12px; }
  #startBtn { min-height: 40px; font-size: 9px; }
  .arcade-back { font-size: 8px; padding: 6px 8px; }
}
@media (max-width: 360px) {
  .hud-row { font-size: 7px; }
  .dpad .mid { gap: 28px; }
}
