/* ==========================================================================
   awsbjorn.com — arcade cabinet (monochrome chrome, game screen in colour)
   ========================================================================== */

:root {
  --bg: #000;
  --ink: #fff;
  --dim: #8a8a8a;
  --faint: #2a2a2a;
  --font-pixel: "Press Start 2P", "Courier New", monospace;
  --font-term: "VT323", "Courier New", monospace;
}

*, *::before, *::after { box-sizing: border-box; }

html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-term);
  font-size: 20px;
  line-height: 1.4;
  display: flex; flex-direction: column; align-items: center;
  -webkit-font-smoothing: none;
}

a { color: var(--ink); text-decoration: none; border-bottom: 2px solid var(--ink); }
a:hover, a:focus-visible { background: var(--ink); color: var(--bg); }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 3px; }

.crt {
  position: fixed; inset: 0; z-index: 10; pointer-events: none;
  background: repeating-linear-gradient(to bottom, transparent 0 2px, rgba(0, 0, 0, 0.3) 2px 3px);
}

/* ---- The Arcade: the game fills the page. 80s perspective grid behind the letterbox. ---- */
/* Page chrome follows the site style guide (STYLE.md): ink background, Inter, orange accent.
   Everything pixel lives inside the canvas. */
body.is-arcade {
  background: #0a0710 radial-gradient(ellipse at 50% 110%, rgba(255,153,0,0.10) 0%, transparent 55%);
  min-height: 100dvh; justify-content: center;
}
/* header: same pattern as the site, dark variant */
.top { width: min(100vw - 48px, 1200px); display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 14px 0 10px; }
.top__brand { display: inline-flex; align-items: center; gap: 10px; color: #f4f1fa; font: 500 17px "Newsreader", Georgia, serif; border: 0; -webkit-font-smoothing: antialiased; }
.top__brand:hover { background: transparent; color: #ff9900; }
.top__nav { display: flex; gap: 18px; }
.top__nav a { color: #b8b2c8; font: 500 14px "Inter", system-ui, sans-serif; border: 0; -webkit-font-smoothing: antialiased; }
.top__nav a:hover { background: transparent; color: #f4f1fa; }
.keys__set { display: none; gap: 6px 18px; flex-wrap: wrap; justify-content: center; }
.keys__set.is-on { display: flex; }
.arcade { position: relative; z-index: 1; width: min(100vw, calc((100dvh - 96px) * 16 / 9)); margin: 0 auto; padding: 0; display: flex; flex-direction: column; align-items: center; gap: 12px; }
.arcade .screen { width: 100%; border: 0; padding: 0; overflow: hidden; box-shadow: 0 0 0 2px rgba(255,255,255,0.14), 0 30px 80px rgba(0,0,0,0.6); }
.nojs { margin: 18px auto; max-width: 60ch; color: #b8b2c8; font: 400 16px/1.6 "Inter", system-ui, sans-serif; text-align: center; padding: 0 16px; }
.nojs a { color: #fff; }
.keys { margin: 0; color: #b8b2c8; font: 500 15px/1.6 "Inter", system-ui, sans-serif; -webkit-font-smoothing: antialiased; display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 6px 18px; padding: 0 12px 14px; }
.keys kbd { font: 10px "Press Start 2P", monospace; background: #1c1426; border: 2px solid rgba(255,255,255,0.14); padding: 3px 7px 1px; margin-right: 6px; color: #f4f1fa; -webkit-font-smoothing: none; }
.keys a:hover, .keys a:focus-visible { background: transparent; color: #ff9900; }
body.is-touch .keys, body.is-embed .keys, body.is-embed .top { display: none; }
body.is-embed .arcade { width: min(100vw, calc(100dvh * 16 / 9)); }
body.is-touch .touch-layer { display: block; position: fixed; inset: 0; z-index: 20; pointer-events: none; }
.tbtn--fs { position: absolute; top: max(10px, env(safe-area-inset-top)); right: max(60px, calc(env(safe-area-inset-right) + 50px)); width: 40px; height: 40px; font-size: 12px; }

.cabinet {
  width: min(100% - 32px, 960px);
  margin: 0 auto;
  padding: 32px 0 40px;
  display: flex; flex-direction: column; gap: 18px;
}

/* Marquee */
.marquee {
  border: 3px solid var(--ink);
  padding: 18px 20px 16px;
  text-align: center;
  position: relative;
}
.marquee::before, .marquee::after {
  content: ""; position: absolute; top: 8px; bottom: 8px; width: 6px;
  background: repeating-linear-gradient(to bottom, var(--ink) 0 6px, transparent 6px 12px);
}
.marquee::before { left: 10px; }
.marquee::after { right: 10px; }
.marquee__title {
  font-family: var(--font-pixel);
  font-size: clamp(24px, 6vw, 48px);
  margin: 0 0 10px;
  letter-spacing: 6px;
}
.marquee__tag { font-family: var(--font-pixel); font-size: clamp(8px, 1.6vw, 11px); color: var(--dim); margin: 0; letter-spacing: 3px; }

/* Screen */
.screen {
  border: 3px solid var(--ink);
  padding: 12px;
  background: #000;
  box-shadow: inset 0 0 0 6px #000, inset 0 0 0 8px var(--faint);
}
.screen__stack { position: relative; width: 100%; aspect-ratio: 16 / 9; background: #000; }
#game, #gl {
  position: absolute; inset: 0;
  display: block;
  width: 100%; height: 100%;
  background: #000;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  outline: none;
  cursor: pointer;
}
#gl { pointer-events: none; display: none; }
#gl.is-on { display: block; }
#game.is-hidden { opacity: 0; }   /* keep it in the DOM for focus + pointer input */
.screen:has(#gl.is-on) .crt-local { display: none; }

/* Control panel */
.panel {
  border: 3px solid var(--ink);
  padding: 18px 20px;
  display: flex; flex-direction: column; align-items: center; gap: 16px;
}
.coin {
  font-family: var(--font-pixel); font-size: 12px; letter-spacing: 2px;
  background: var(--ink); color: var(--bg);
  border: 3px solid var(--ink); padding: 14px 26px; cursor: pointer;
  animation: blink 1.4s steps(1) infinite;
}
.coin:hover, .coin:focus-visible { animation: none; background: var(--bg); color: var(--ink); }
.coin.is-hidden { visibility: hidden; }
@keyframes blink { 0%, 60% { opacity: 1; } 61%, 100% { opacity: 0.35; } }

.hint { margin: 0; color: var(--dim); font-family: var(--font-pixel); font-size: 9px; letter-spacing: 1px; line-height: 2; text-align: center; }
kbd { font: inherit; border: 2px solid var(--dim); padding: 2px 6px; margin-right: 4px; color: var(--ink); }

.pad { display: none; width: 100%; gap: 12px; }
.pad__btn {
  flex: 1; font-family: var(--font-pixel); font-size: 14px;
  background: var(--bg); color: var(--ink); border: 3px solid var(--ink);
  padding: 22px 0; touch-action: none; user-select: none; -webkit-user-select: none;
}
.pad__btn--smash { flex: 1.3; font-size: 11px; }
.pad__btn.is-down { background: var(--ink); color: var(--bg); }

@media (pointer: coarse) {
  .hint--keys { display: none; }
  .pad { display: flex; }
}
body.is-touch .hint--keys { display: none; }
body.is-touch .pad { display: flex; }

.fs { display: none; font-family: var(--font-pixel); font-size: 9px; letter-spacing: 1px; background: transparent; color: var(--dim); border: 2px solid var(--dim); padding: 8px 12px; cursor: pointer; }
body.is-touch .fs { display: inline-block; }

/* ---- Floating touch layer & rotate hint (hidden unless in landscape-play mode) ---- */
.touch-layer { display: none; }
.rotate-hint { display: none; }

/* ======================================================================
   LANDSCAPE PHONE / FULLSCREEN MODE
   The game screen fills the viewport (letterboxed 16:9), the cabinet chrome
   disappears, and semi-transparent thumb controls float over the picture.
   Activated by body.is-landscape (set from JS when touch + landscape + short).
   ====================================================================== */
body.is-landscape { overflow: hidden; height: 100dvh; }
body.is-landscape .cabinet { padding: 0; gap: 0; width: 100%; max-width: none; }
body.is-landscape .marquee, body.is-landscape .panel, body.is-landscape .foot { display: none; }
body.is-landscape .screen, body.is-landscape .arcade .screen {
  position: fixed; inset: 0; border: 0; padding: 0; box-shadow: none; background: #000;
  display: flex; align-items: center; justify-content: center;
}
body.is-landscape .arcade { width: 100%; }
body.is-landscape .keys { display: none; }
body.is-landscape .screen__stack {
  width: min(100vw, calc(100dvh * 16 / 9));
  height: min(100dvh, calc(100vw * 9 / 16));
  aspect-ratio: auto;
}
body.is-landscape .touch-layer {
  display: block; position: fixed; inset: 0; z-index: 20; pointer-events: none;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
.touch-layer__left, .touch-layer__right { position: absolute; bottom: max(14px, env(safe-area-inset-bottom)); display: flex; gap: 12px; pointer-events: none; }
.touch-layer__left { left: max(14px, env(safe-area-inset-left)); }
.touch-layer__right { right: max(14px, env(safe-area-inset-right)); align-items: flex-end; }
.tbtn {
  pointer-events: auto; touch-action: none; user-select: none; -webkit-user-select: none; -webkit-tap-highlight-color: transparent;
  width: 68px; height: 68px; border-radius: 50%;
  font-family: var(--font-pixel); font-size: 12px; color: #fff;
  background: rgba(255,255,255,0.10); border: 2px solid rgba(255,255,255,0.45);
  backdrop-filter: blur(2px);
}
.tbtn--jump { width: 76px; height: 76px; font-size: 9px; border-color: rgba(255,138,0,0.7); }
.tbtn--smash { width: 92px; height: 92px; font-size: 10px; border-color: rgba(57,255,20,0.7); background: rgba(57,255,20,0.10); }
.tbtn.is-down { background: rgba(255,255,255,0.4); transform: scale(0.94); }
.tbtn--smash.is-down { background: rgba(57,255,20,0.45); }
.tbtn--pause { position: absolute; top: max(10px, env(safe-area-inset-top)); right: max(10px, env(safe-area-inset-right)); width: 40px; height: 40px; font-size: 10px; }

/* Portrait phone: nudge toward landscape */
@media (pointer: coarse) and (orientation: portrait) and (max-width: 700px) {
  .rotate-hint { display: block; text-align: center; font-family: var(--font-pixel); font-size: 8px; color: var(--token, #ff8a00); letter-spacing: 1px; margin: 0; animation: blink 1.4s steps(1) infinite; }
}

/* Footer */
.foot { text-align: center; display: grid; gap: 14px; padding-top: 8px; }
.foot__rules { margin: 0; color: var(--dim); font-size: 19px; }
.sw { display: inline-block; width: 12px; height: 12px; vertical-align: -1px; margin-right: 6px; border: 2px solid currentColor; }
.sw--fluff { color: #39ff14; background: #39ff14; }
.sw--code  { color: #fff; background: #fff; }
.sw--power { color: #ff8a00; background: #ff8a00; }
.foot__links { margin: 0; font-family: var(--font-pixel); font-size: 10px; letter-spacing: 1px; }
.foot__fine { margin: 0; color: var(--dim); font-size: 17px; }

@media (max-width: 600px) {
  .cabinet { padding-top: 16px; gap: 12px; }
  .screen { padding: 6px; }
  .panel { padding: 14px; }
  .foot__rules { font-size: 17px; }
}

@media (prefers-reduced-motion: reduce) {
  .coin { animation: none; }
}
