:root {
  color-scheme: dark;
  font: 1rem/1.5 system-ui, sans-serif;
  color: #f7f5f2;
  background: #12141b;
  --muted: #bdc3cf;
  --line: #343946;
  --accent: #ffba73;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; }
.arcade { width: min(100%, 940px); margin: auto; padding: clamp(14px, 4vw, 36px); }
.brand { margin: 0; color: var(--muted); font-size: .72rem; font-weight: 750; text-transform: uppercase; letter-spacing: .14em; }
.brand span { color: var(--accent); padding-inline: .3em; }
h1 { margin: .08em 0 0; font-size: clamp(2.6rem, 7vw, 4.3rem); line-height: 1.07; letter-spacing: -.05em; }
h1 span { color: var(--accent); }
.lede { margin: .45rem 0 1rem; color: var(--muted); }
.cabinet {
  isolation: isolate; position: relative; display: grid; overflow: hidden; margin: auto;
  width: min(100%, 690px, max(300px, calc((100svh - 145px) * 4 / 3)));
  aspect-ratio: 4 / 3; background: #07080c; border: 1px solid var(--line); border-radius: 13px;
}
#game { position: absolute; inset: 0; }
#splash { z-index: 2; display: grid; align-content: center; justify-items: center; gap: .7rem; padding: .8rem; text-align: center; background: radial-gradient(ellipse at 50% 28%, #242632, #0a0b10 72%); }
#splash p { max-width: 36ch; min-height: 3em; margin: 0; color: var(--muted); font-size: .87rem; }
#splash p[data-error="true"] { color: #ffc1ad; }
#play, #retry {
  min-height: 44px; border: 1px solid transparent; border-radius: 8px; padding: .65rem .95rem;
  color: #23170c; background: var(--accent); font: inherit; font-weight: 750; cursor: pointer;
}
#play span { margin-right: .28em; }
#play:disabled { opacity: .75; cursor: wait; }
#retry { color: #f7f5f2; background: #262a34; border-color: var(--line); }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }
.device-tip { max-width: 690px; margin: .55rem auto; font-size: .88rem; color: var(--muted); }
#mobile-tip { display: none; }
.details { max-width: 690px; margin: 1rem auto; padding: .65rem .9rem; border: 1px solid var(--line); border-radius: 9px; }
.details summary { font-weight: 700; cursor: pointer; min-height: 28px; }
.details p { color: var(--muted); margin: .45rem 0 .7rem; font-size: .9rem; }
table { width: 100%; border-collapse: collapse; font-size: .9rem; text-align: left; }
th, td { padding: .35rem .3rem; border-bottom: 1px solid var(--line); }
kbd { display: inline-block; white-space: nowrap; font: .87em ui-monospace, monospace; background: #262a34; border-radius: 4px; padding: .05em .25em; margin: .06em 0; }
@media (any-pointer: coarse) {
  #mobile-tip { display: block; }
  #desktop-tip { display: none; }
  .cabinet { width: min(100%, 690px); }
}
@media (orientation: landscape) and (max-height: 600px) and (any-pointer: coarse) {
  .arcade { padding: 7px max(9px, env(safe-area-inset-right)) 10px max(9px, env(safe-area-inset-left)); }
  body[data-playing] header { display: none; }
  .cabinet { width: min(100%, calc((100svh - 22px) * 4 / 3)); }
}

.screen-toolbar {
  display: flex; justify-content: flex-end; width: min(100%, 690px);
  margin: 0 auto .45rem;
}
#screen-toggle {
  min-height: 44px; padding: .42rem .75rem; border: 1px solid var(--line);
  border-radius: 8px; color: #f7f5f2; background: #262a34;
  font: inherit; font-size: .88rem; font-weight: 700; cursor: pointer;
}
body.screen-expanded { overflow: hidden; }
.safari-swipe-tip { display: none; }
/* Real page scroll gives Safari room to collapse its toolbar. The fixed
   cabinet stays in place, and touches on the game never scroll the page. */
body.screen-expanded.safari-game-scroll { overflow: visible; }
body.safari-game-scroll .arcade {
  min-height: calc(100lvh + 120px);
  padding: 0;
}
body.safari-game-scroll .arcade > :not(#play-area) { display: none; }
body.safari-game-scroll #play-area.is-expanded #game { touch-action: none; }
body.safari-game-scroll .safari-swipe-tip {
  display: inline-block;
  padding: .28rem .5rem;
  border-radius: .4rem;
  background: #11141bd9;
  color: var(--muted);
  font-size: .65rem;
  touch-action: pan-y;
  user-select: none;
}
#play-area.is-expanded, #play-area:fullscreen {
  position: fixed; z-index: 1000; inset: 0; width: 100%;
  height: 100vh; height: 100dvh; max-height: 100dvh;
  display: grid; grid-template-rows: auto minmax(0, 1fr);
  gap: 4px; margin: 0; background: #07080c;
  padding: max(4px, env(safe-area-inset-top)) max(4px, env(safe-area-inset-right))
    max(4px, env(safe-area-inset-bottom)) max(4px, env(safe-area-inset-left));
}
#play-area.is-expanded .screen-toolbar, #play-area:fullscreen .screen-toolbar {
  width: 100%; margin: 0;
}
#play-area.is-expanded .cabinet, #play-area:fullscreen .cabinet {
  width: 100%; height: 100%; min-height: 0;
  aspect-ratio: auto; border: 0; border-radius: 0;
}
#play-area.is-expanded .cabinet #game, #play-area:fullscreen .cabinet #game {
  touch-action: manipulation;
}

#rotate-tip {
  color: var(--muted); font: inherit; font-size: .78rem;
  line-height: 1.25; align-self: center; max-width: 26ch;
}
#play-area .screen-toolbar { gap: .6rem; }
@media (orientation: landscape) and (any-pointer: coarse) {
  #play-area.is-expanded, #play-area:fullscreen {
    grid-template-rows: minmax(0, 1fr);
  }
  #play-area.is-expanded .screen-toolbar, #play-area:fullscreen .screen-toolbar {
    position: absolute; z-index: 2; top: max(4px, env(safe-area-inset-top));
    left: max(6px, env(safe-area-inset-left)); width: auto;
  }
  #play-area.is-expanded #screen-toggle, #play-area:fullscreen #screen-toggle {
    background: #262a34e8; font-size: .75rem; padding: .3rem .6rem;
  }
}

#play-area .screen-toolbar { align-items: center; flex-wrap: wrap; }
#speed-toggle {
  min-height: 44px; padding: .42rem .65rem; border: 1px solid var(--line);
  border-radius: 8px; color: #f7f5f2; background: #262a34;
  font: inherit; font-size: .78rem; font-weight: 700; cursor: pointer;
}
#speed-toggle[aria-pressed="true"] { border-color: var(--accent); color: var(--accent); }
#speed-readout { font: 700 .72rem/1.2 system-ui, sans-serif; color: var(--muted); white-space: nowrap; }
@media (orientation: landscape) and (any-pointer: coarse) {
  #play-area.is-expanded .screen-toolbar, #play-area:fullscreen .screen-toolbar {
    top: max(4px, env(safe-area-inset-top));
    left: max(6px, env(safe-area-inset-left));
    right: max(54px, calc(env(safe-area-inset-right) + 42px));
    justify-content: flex-start;
  }
}

.ios-install-tip { display: none; }
@media (any-pointer: coarse) {
  .ios-install-tip { display: block; }
}
@media (display-mode: standalone) {
  .ios-install-tip { display: none; }
}
@media (orientation: landscape) and (any-pointer: coarse) {
  /* Scale only the image, not the canvas backing buffer or the touch controls.
     Cap the widening on narrow landscape screens so the image is not clipped. */
  #play-area:is(.is-expanded, :fullscreen) .ejs_canvas {
    transform: scaleX(1.18);
    transform-origin: center;
  }
  @media (max-aspect-ratio: 8/5) {
    #play-area:is(.is-expanded, :fullscreen) .ejs_canvas { transform: none; }
  }
}
