/* The Mostly Grants arcade cabinet: one full-window layout for every arcade game.
   Desktop: HUD, screen, controls line. Phone upright: a handheld (screen on top, pad below).
   Phone sideways: the screen in the middle, D-pad left, buttons right. Fonts are self-hosted. */
@font-face { font-family: "Press Start 2P"; font-style: normal; font-weight: 400; font-display: swap; src: url("fonts/press-start-2p-latin-400-normal.woff2") format("woff2"); }
@font-face { font-family: "VT323"; font-style: normal; font-weight: 400; font-display: swap; src: url("fonts/vt323-latin-400-normal.woff2") format("woff2"); }
:root {
  --c0: #0f0e0c; --c1: #22243a; --c2: #b87333; --c3: #e0a660; --c4: #e8d5a3; --c5: #fff6e0; --c6: #d1352b; --c7: #3b6fd8;
  --c8: #7fd0ff; --c9: #3fbf5a; --c10: #1f6e3a; --c11: #ffd23f; --c12: #8a8f99; --c13: #c8ccd2; --c14: #7a3b78; --c15: #ff5fa2;
  --px: "Press Start 2P", monospace; --vt: "VT323", monospace;
  --pad-h: 0px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body.cabinet {
  margin: 0; background: var(--c0); color: var(--c5); font-family: var(--vt); font-size: 20px; line-height: 1.25;
  display: flex; flex-direction: column; height: 100vh; height: 100dvh; overflow: hidden;
  padding: env(safe-area-inset-top, 0px) env(safe-area-inset-right, 0px) env(safe-area-inset-bottom, 0px) env(safe-area-inset-left, 0px);
  -webkit-tap-highlight-color: transparent; -webkit-user-select: none; user-select: none; touch-action: manipulation;
  background-image: radial-gradient(ellipse at 50% 40%, #1a1c2e 0%, var(--c0) 70%);
}
a { color: var(--c3); }
button { font: inherit; cursor: pointer; }

/* HUD */
.hud { flex: none; display: flex; align-items: center; gap: 10px; padding: 8px 14px; font-family: var(--px); font-size: 10px; color: var(--c13); min-height: 44px; }
.hud .title { color: var(--c3); text-decoration: none; white-space: nowrap; display: inline-flex; align-items: center; min-height: 36px; }
.hud .title:hover { color: var(--c11); }
.hud .mid { flex: 1; text-align: center; color: var(--c13); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.hud .hi { white-space: nowrap; }
.hud .hi b { color: var(--c11); font-weight: 400; }
.hud .btns { display: flex; gap: 8px; align-items: center; }
.hbtn { font-family: var(--px); font-size: 9px; background: var(--c1); color: var(--c5); border: 2px solid var(--c13); padding: 6px 8px; box-shadow: 2px 2px 0 var(--c12); text-decoration: none; display: inline-flex; align-items: center; justify-content: center; min-height: 32px; min-width: 32px; white-space: nowrap; }
.hbtn:hover { background: var(--c2); color: var(--c0); border-color: var(--c3); }
.hbtn:active { transform: translate(2px, 2px); box-shadow: none; }
.hbtn.fb { background: var(--c11); color: var(--c1); border-color: var(--c11); box-shadow: 2px 2px 0 var(--c2); }
.hbtn.share { background: var(--c9); color: var(--c0); border-color: var(--c9); }
.hbtn[hidden] { display: none; }
.hbtn.off { opacity: .6; }
.hbtn .ico { display: none; }

/* screen */
.screen-wrap { flex: 1 1 auto; min-height: 0; display: grid; place-items: center; padding: 4px 12px; position: relative; }
canvas.screen { display: block; image-rendering: pixelated; image-rendering: crisp-edges; background: var(--c0); border: 4px solid var(--c1); outline: 2px solid var(--c2); box-shadow: 0 0 0 6px var(--c0), 0 0 48px rgba(184,115,51,0.22); touch-action: none; }
.under { flex: none; font-size: 18px; color: var(--c12); text-align: center; padding: 6px 16px 12px; margin: 0; }
.under b { color: var(--c4); font-weight: 400; }
.under kbd { font-family: var(--px); font-size: 9px; color: var(--c5); background: var(--c1); border: 1px solid var(--c12); border-bottom-width: 2px; padding: 2px 5px; border-radius: 3px; }

/* touch controls (shown on touch screens only) */
#pad { flex: none; display: none; padding: 6px 16px 10px; }
body.no-pad #pad { display: none !important; }
.pad-main { display: flex; justify-content: space-between; align-items: center; gap: 12px; max-width: 520px; margin: 0 auto; }
.dpad { position: relative; width: 150px; height: 150px; flex: none; }
.dpad button { position: absolute; width: 52px; height: 52px; font-family: var(--px); font-size: 14px; background: var(--c1); color: var(--c13); border: 2px solid var(--c12); border-radius: 8px; touch-action: none; padding: 0; }
.dpad .u { left: 49px; top: 0; } .dpad .d { left: 49px; bottom: 0; } .dpad .l { left: 0; top: 49px; } .dpad .r { right: 0; top: 49px; }
.dpad .hub { position: absolute; left: 51px; top: 51px; width: 48px; height: 48px; background: var(--c1); border-radius: 6px; }
.dpad-none { flex: 1; }
.ab { display: flex; gap: 14px; align-items: center; }
.ab button { width: 74px; height: 74px; border-radius: 50%; font-family: var(--px); font-size: 12px; background: var(--c6); color: var(--c5); border: 3px solid #7d1f19; box-shadow: 0 4px 0 #7d1f19; touch-action: none; padding: 0; line-height: 1.3; }
.ab button.b { background: var(--c7); border-color: #1e3a78; box-shadow: 0 4px 0 #1e3a78; transform: translateY(18px); }
.ab button.on, .dpad button.on { filter: brightness(1.35); }
.ab button.on { box-shadow: 0 1px 0 #000; }
.pad-main.nodpad { max-width: 520px; }
.pad-main.nodpad .dpad-none { display: none; }
.pad-main.nodpad .ab { flex: 1; }
.pad-main.nodpad .ab button { flex: 1; width: auto; height: 58px; border-radius: 12px; transform: none; font-size: 14px; }
.keys { display: none; grid-template-columns: repeat(7, 1fr); gap: 5px; max-width: 520px; margin: 0 auto 8px; }
.keys button { height: 42px; font-family: var(--px); font-size: 12px; background: var(--c4); color: var(--c1); border: 2px solid var(--c2); border-radius: 6px; touch-action: manipulation; padding: 0; }
.keys button:active { background: var(--c11); }
body.keys-on .keys { display: grid; }

@media (hover: none) and (pointer: coarse) {
  #pad { display: block; }
  .under { display: none; }
  .hud { padding: 6px 10px; gap: 8px; min-height: 40px; }
  .hud .mid { display: none; }
  .hud .title { flex: 1; }
  .hbtn { min-height: 36px; min-width: 36px; }
  .hbtn .lbl { display: none; }
  .hbtn .ico { display: inline; font-size: 13px; font-family: system-ui, sans-serif; }
  .screen-wrap { padding: 2px 6px; align-items: end; } /* upright phone: the screen sits on the controls, like a handheld */
  canvas.screen { border-width: 3px; box-shadow: 0 0 0 3px var(--c0); }
}
@media (hover: none) and (pointer: coarse) and (max-width: 380px) {
  .dpad { transform: scale(0.88); transform-origin: left center; }
  .ab button { width: 64px; height: 64px; }
  .hud .hi { display: none; }
}
/* sideways phone: screen centre, D-pad left, buttons right */
@media (hover: none) and (pointer: coarse) and (orientation: landscape) and (max-height: 560px) {
  .hud { min-height: 34px; padding-block: 2px; }
  .hud .mid { display: none; }
  #pad { position: absolute; inset: 40px 0 0 0; padding: 0 max(12px, env(safe-area-inset-right, 0px)) 14px max(12px, env(safe-area-inset-left, 0px)); pointer-events: none; display: flex; flex-direction: column; justify-content: flex-end; }
  .pad-main { max-width: none; width: 100%; margin: 0; align-items: flex-end; }
  .pad-main > * { pointer-events: auto; }
  .ab button.b { transform: translateY(-34px); }
  .screen-wrap { padding: 0 176px 4px; }
  .keys { pointer-events: auto; position: absolute; left: 176px; right: 176px; bottom: max(6px, env(safe-area-inset-bottom, 0px)); margin: 0; grid-template-columns: repeat(11, 1fr); }
  .keys button { height: 34px; font-size: 10px; }
  body.keys-on .screen-wrap { padding-bottom: 86px; }
  .pad-main.nodpad { justify-content: flex-end; max-width: none; }
  .pad-main.nodpad .ab { flex: none; width: 150px; }
  .pad-main.nodpad .ab button { height: 72px; }
}
:focus-visible { outline: 3px solid var(--c11); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
