@import url('https://fonts.googleapis.com/css2?family=Press+Start+2P&display=swap');

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

:root {
  --chrome: 150px;
}

html, body {
  height: 100%;
  width: 100%;
  background: #000;
  color: #ffd54a;
  font-family: 'Press Start 2P', 'Courier New', monospace;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  overscroll-behavior: none;
  touch-action: manipulation;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

.frame {
  width: min(100vw - 10px, 500px);
  border: 4px solid #ffd54a;
  padding: 14px 16px 12px;
  background: #050015;
  box-shadow: 0 0 0 4px #000, 0 0 24px rgba(255, 213, 74, 0.18);
  border-radius: 6px;
  display: flex;
  flex-direction: column;
  align-items: stretch;
}

.title-bar {
  text-align: center;
  font-size: 18px;
  letter-spacing: 3px;
  color: #ffd54a;
  text-shadow: 2px 2px 0 #b8860b;
  margin-bottom: 10px;
}

.hud {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 9px;
  margin-bottom: 8px;
  color: #fff;
  flex-wrap: nowrap;
}

.hud-cell {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  min-width: 0;
}

.hud-cell .label {
  color: #ff5c5c;
  font-size: 8px;
}

#lives {
  display: inline-flex;
  gap: 3px;
  flex-wrap: wrap;
}

.life-icon {
  width: 12px;
  height: 12px;
  background: #ffd54a;
  border-radius: 50%;
  box-shadow: inset -2px -2px 0 #b8860b;
}

.mute-btn {
  align-self: flex-end;
  background: transparent;
  border: 1px solid #ffd54a;
  color: #ffd54a;
  font: inherit;
  font-size: 7px;
  padding: 4px 6px;
  cursor: pointer;
  letter-spacing: 1px;
  border-radius: 2px;
}
.mute-btn:active { background: rgba(255, 213, 74, 0.2); }
.mute-btn.muted { color: #888; border-color: #888; }
@media (max-width: 480px) {
  .mute-btn { font-size: 6px; padding: 3px 4px; }
}

.stage {
  position: relative;
  background: #000;
  border: 2px solid #1a1a3a;
  width: min(100%, calc((100vh - var(--chrome)) * 456 / 528));
  width: min(100%, calc((100dvh - var(--chrome)) * 456 / 528));
  aspect-ratio: 456 / 528;
  margin: 0 auto;
  image-rendering: pixelated;
  touch-action: none;
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  touch-action: none;
}

.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  pointer-events: none;
  font-size: 12px;
  letter-spacing: 2px;
  text-shadow: 2px 2px 0 #000;
  gap: 14px;
  padding: 20px;
}

.overlay.hidden { display: none; }

.overlay .big {
  font-size: 22px;
  color: #ffd54a;
}

.overlay .blink {
  animation: blink 1s steps(2, start) infinite;
  color: #fff;
}

@keyframes blink { to { visibility: hidden; } }

.controls {
  display: flex;
  justify-content: space-between;
  font-size: 8px;
  color: #888;
  margin-top: 10px;
  letter-spacing: 1px;
  flex-wrap: wrap;
  gap: 6px;
}

.ctl-touch { display: none; width: 100%; text-align: center; }

@media (hover: none) and (pointer: coarse) {
  .ctl-key { display: none; }
  .ctl-touch { display: inline; }
}

@media (max-width: 480px) {
  :root { --chrome: 120px; }
  .frame {
    padding: 8px 10px 8px;
    border-width: 3px;
    width: min(100vw - 6px, 500px);
  }
  .title-bar { font-size: 13px; margin-bottom: 6px; letter-spacing: 2px; }
  .hud { font-size: 7px; gap: 4px; margin-bottom: 6px; }
  .hud-cell { gap: 3px; }
  .hud-cell .label { font-size: 6px; }
  .life-icon { width: 9px; height: 9px; }
  .controls { font-size: 7px; margin-top: 6px; letter-spacing: 0; }
  .overlay { font-size: 10px; gap: 10px; padding: 12px; }
  .overlay .big { font-size: 16px; }
}

@media (max-height: 700px) and (max-width: 480px) {
  .title-bar { display: none; }
  :root { --chrome: 95px; }
}

@media (orientation: landscape) and (max-height: 480px) {
  :root { --chrome: 80px; }
  .title-bar { display: none; }
  .controls { font-size: 6px; margin-top: 4px; }
}
