@font-face { font-family: "Pixelify Sans"; font-weight: 400; src: url("../fonts/pixelify-sans-latin-400-normal.woff2") format("woff2"); font-display: block; }
@font-face { font-family: "Pixelify Sans"; font-weight: 700; src: url("../fonts/pixelify-sans-latin-700-normal.woff2") format("woff2"); font-display: block; }
@font-face { font-family: "Press Start 2P"; font-weight: 400; src: url("../fonts/press-start-2p-latin-400-normal.woff2") format("woff2"); font-display: block; }
@font-face { font-family: "Silkscreen"; font-weight: 400; src: url("../fonts/silkscreen-latin-400-normal.woff2") format("woff2"); font-display: block; }
@font-face { font-family: "Silkscreen"; font-weight: 700; src: url("../fonts/silkscreen-latin-700-normal.woff2") format("woff2"); font-display: block; }
/* Pixelify Sans digits are ambiguous at small sizes (5 reads as S), so digits come from Press Start 2P. */
@font-face { font-family: "PQ Digits"; font-weight: 400; src: url("../fonts/press-start-2p-latin-400-normal.woff2") format("woff2"); unicode-range: U+0030-0039; size-adjust: 72.7%; font-display: block; }
@font-face { font-family: "PQ Digits"; font-weight: 700; src: url("../fonts/press-start-2p-latin-400-normal.woff2") format("woff2"); unicode-range: U+0030-0039; size-adjust: 72.7%; font-display: block; }

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; height: 100%; overflow: hidden; background: #0b0814;
  color: #fff; font-family: "Pixelify Sans", monospace;
  overscroll-behavior: none; touch-action: none; user-select: none; -webkit-user-select: none;
  -webkit-touch-callout: none; -webkit-text-size-adjust: 100%;
}
#stage {
  position: fixed; inset: 0; display: flex; align-items: center; justify-content: center;
  background:
    radial-gradient(ellipse at 50% 40%, #2a1b4a 0%, #120d1f 60%, #0b0814 100%);
}
/* Decorative pixel bezel around the 16:9 game area */
#frame {
  position: relative;
  width: min(100vw - 12px, (100vh - 12px) * 16 / 9);
  height: calc(min(100vw - 12px, (100vh - 12px) * 16 / 9) * 9 / 16);
  background: #000;
  border: 4px solid #3a2a63;
  border-radius: 6px;
  box-shadow: 0 0 0 2px #120d1f, 0 0 0 4px #5a44a0, 0 10px 40px rgba(0,0,0,.7);
}
#game, #game canvas { width: 100% !important; height: 100% !important; display: block; }
#game canvas { image-rendering: pixelated; image-rendering: crisp-edges; }
#loading {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font: 700 18px "Pixelify Sans", monospace; letter-spacing: 2px; color: #cbb8ff; background: #120d1f;
  transition: opacity .3s;
}
#loading.hide { opacity: 0; pointer-events: none; }

/* ---- touch controls ---- */
#touch { display: none; position: fixed; inset: 0; pointer-events: none; z-index: 10; }
body.touch #touch { display: block; }
.tb {
  pointer-events: auto; position: absolute; border: 2px solid rgba(255,255,255,.35);
  background: rgba(20, 14, 40, .45); color: rgba(255,255,255,.9);
  width: 62px; height: 62px; border-radius: 50%; font: 700 24px "Pixelify Sans", monospace;
  display: flex; align-items: center; justify-content: center; padding: 0;
  backdrop-filter: blur(2px); touch-action: none;
  -webkit-touch-callout: none; -webkit-user-select: none; user-select: none;
}
.tb.on { background: rgba(255,255,255,.35); transform: scale(.94); }
#dpad { position: absolute; left: max(14px, env(safe-area-inset-left)); bottom: max(12px, env(safe-area-inset-bottom)); width: 190px; height: 130px; }
#dpad [data-k=left]  { left: 0;     bottom: 0; }
#dpad [data-k=right] { left: 70px;  bottom: 0; }
#dpad [data-k=up]    { left: 140px; bottom: 62px; }
#dpad [data-k=down]  { left: 140px; bottom: 0; }
.tb.sm { width: 48px; height: 48px; font-size: 18px; }
#actions { position: absolute; right: max(14px, env(safe-area-inset-right)); bottom: max(12px, env(safe-area-inset-bottom)); width: 210px; height: 140px; }
.tb.act { width: 60px; height: 60px; }
#actions [data-k=jump]   { right: 0;    bottom: 0;   width: 78px; height: 78px; font-size: 30px; background: rgba(60,160,255,.35); }
#actions [data-k=attack] { right: 88px; bottom: 6px; background: rgba(255,90,90,.35); }
#actions [data-k=power]  { right: 44px; bottom: 86px; background: rgba(255,200,60,.35); }
#actions [data-k=hook]   { display: none; right: 132px; bottom: 70px; width: 50px; height: 50px; font-size: 20px; background: rgba(120,220,160,.35); }
body.has-hook #actions [data-k=hook] { display: flex; }
/* fullscreen button: top centre (the HUD leaves that free); also shown on desktop */
#tfull { position: fixed; z-index: 11; pointer-events: auto; left: 50%; transform: translateX(-50%); top: max(6px, env(safe-area-inset-top)); width: 36px; height: 36px; font-size: 17px; opacity: 0.75; }
#tfull.on { transform: translateX(-50%) scale(.94); }
body:not(.touch) #tfull { opacity: 0.55; }
body:not(.touch) #tfull:hover { opacity: 1; }
#fstip { display: none; position: fixed; inset: 0; z-index: 30; background: rgba(8, 6, 16, 0.82); align-items: center; justify-content: center; padding: 16px; }
#fstip.show { display: flex; }
#fstip .box { max-width: 420px; background: #141a2e; border: 3px solid #5a44a0; border-radius: 8px; padding: 16px 18px; color: #e8e8ff; font: 400 15px/1.55 "Pixelify Sans", monospace; }
#fstip b { color: #ffd24a; }
#fstip .box > b:first-child { display: block; font-size: 18px; margin-bottom: 8px; }
#fstip .ico { display: inline-block; border: 1px solid #9aa4d8; border-radius: 3px; padding: 0 4px; font-size: 12px; }
#fstip .ok { margin-top: 12px; text-align: center; color: #9aa4d8; font-size: 13px; }
#tpause { right: max(10px, env(safe-area-inset-right)); top: max(8px, env(safe-area-inset-top)); width: 40px; height: 40px; font-size: 13px; }

#rotate { display: none; position: fixed; inset: 0; z-index: 20; background: #120d1f; color: #cbb8ff; text-align: center; align-items: center; justify-content: center; font: 700 22px "Pixelify Sans", monospace; line-height: 1.6; }
@media (orientation: portrait) and (pointer: coarse) { #rotate { display: flex; } }

/* Hall of Fame name box */
#nameEntry { position: fixed; inset: 0; z-index: 30; display: flex; align-items: center; justify-content: center; background: rgba(8, 6, 16, 0.6); padding: 16px; }
#nameEntry .box { background: #141a2e; border: 3px solid #5a44a0; border-radius: 8px; padding: 16px 20px; color: #e8e8ff; font: 400 16px/1.5 "Pixelify Sans", monospace; text-align: center; max-width: 360px; }
#nameEntry b { color: #ffd24a; font-size: 20px; }
#nameEntry input { display: block; width: 100%; margin: 12px 0; padding: 8px 10px; font: 700 20px "Pixelify Sans", monospace; text-align: center; background: #0b0f1e; color: #ffffff; border: 2px solid #6a78d0; border-radius: 4px; user-select: text; -webkit-user-select: text; }
#nameEntry .row { display: flex; gap: 10px; justify-content: center; }
#nameEntry button { font: 700 15px "Pixelify Sans", monospace; padding: 6px 16px; border-radius: 4px; border: 2px solid #8a9af0; background: #2a2f66; color: #fff; cursor: pointer; }
#nameEntry button.ok { background: #4a52a8; border-color: #ffd24a; }
