:root {
  color-scheme: light;
  background: #fff4d9;
  color: #32251f;
  font-family: system-ui, sans-serif;
  --mono: "Courier New", ui-monospace, monospace;
  --muted: #6c5140;
  --score-color: #a13c29;
  --rule: #b2825b6b;
  --photo-aspect: 2;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  min-width: 280px;
  min-height: 100vh;
  background:
    radial-gradient(ellipse at 52% 10%, #fffdf2 0%, #fff4dc 54%, #f5dfb7 100%);
}

.arcade {
  width: min(calc(100% - 32px), 1720px);
  margin-inline: auto;
  padding-bottom: 16px;
}

.marquee {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .9rem;
  padding: 9px 1px 11px;
}

.wordmark {
  display: inline-flex;
  align-items: center;
  gap: .22em;
  padding: .23em .47em .2em .38em;
  border-radius: 3px;
  background: #ffcc00;
  color: #b60925;
  font-size: clamp(1.45rem, 2.8vw, 2rem);
  font-weight: 950;
  font-style: italic;
  letter-spacing: -.07em;
  line-height: 1;
}

.brand-mark {
  width: .59em;
  height: .39em;
  transform: skewX(-21deg);
  background: repeating-linear-gradient(0deg, currentColor 0 19%, transparent 19% 40%);
}

.brand-express {
  margin-left: .23em;
  font-size: .44em;
  font-weight: 850;
  letter-spacing: .035em;
  text-transform: uppercase;
}

.route-hud {
  display: flex;
  gap: 8px 14px;
  align-items: center;
  margin: 0;
  padding: .48rem .72rem;
  border: 1px solid #c7a66e8f;
  border-radius: 4px;
  background: #fff7e1;
  font-family: var(--mono);
}

.route-hud div { display: flex; align-items: baseline; gap: .35em; }
.route-hud dt { color: var(--muted); font-size: .74rem; font-weight: 700; text-transform: uppercase; }
.route-hud dd { margin: 0; color: #1c6163; font-size: .95rem; font-weight: 800; font-variant-numeric: tabular-nums; }

.studio-credit {
  color: var(--muted);
  font-size: .875rem;
  text-align: right;
}

.room {
  position: relative;
  isolation: isolate;
  aspect-ratio: var(--photo-aspect);
  overflow: hidden;
  outline: 1px solid var(--rule);
  border-radius: 5px;
  background: #352319;
  box-shadow: 0 18px 44px #88512d24, 0 4px 12px #794c2f30;
  --screen-x: 21.88%;
  --screen-y: 21.37%;
  --screen-width: 25.91%;
  --screen-height: 37.37%;
  --stick-x: 69.79%;
  --stick-y: 55.02%;
  --stick-width: 7.43%;
  --stick-height: 13.82%;
  --fire-x: 70.51%;
  --fire-y: 66.15%;
}

.tv-window, .hardware-window, .scene-coordinate {
  position: absolute;
  inset: 0;
}

.room-image {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  user-select: none;
  pointer-events: none;
}

.hardware-window { pointer-events: none; }
.hardware-image { display: none; }

.tube {
  position: absolute;
  isolation: isolate;
  container-type: inline-size;
  left: var(--screen-x);
  top: var(--screen-y);
  width: var(--screen-width);
  height: var(--screen-height);
  overflow: hidden;
  border-radius: 10% / 12%;
  clip-path: polygon(8% 2.7%, 22% .65%, 45% 0, 70% .55%, 90% 2.55%, 95% 4.8%, 97.7% 9%, 99.3% 18%, 100% 43%, 99.5% 72%, 98.3% 89%, 96.3% 94.4%, 91% 97.6%, 77% 99.2%, 50% 100%, 23% 99.1%, 9% 97.6%, 4.1% 94.6%, 2% 89%, .55% 72%, 0% 47%, .5% 24%, 1.7% 13%, 3.6% 7%, 5.7% 4.5%);
  background: #171929;
  box-shadow: 0 0 9px #b87e4354, 0 0 1px 1px #493011;
}

#game {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  image-rendering: pixelated;
  touch-action: none;
}

.tube::before, .tube::after {
  position: absolute;
  z-index: 3;
  inset: 0;
  pointer-events: none;
  content: "";
}

.tube::before {
  background:
    linear-gradient(127deg, #ffdfab15 0%, transparent 47%),
    radial-gradient(ellipse, transparent 43%, #152f4370 100%);
  box-shadow: inset 0 0 8px 2px #10232c70;
}

.tube::after {
  background: repeating-linear-gradient(0deg, #0d0b191d 0 1px, transparent 1px 3px);
}

.screen-overlay {
  position: absolute;
  z-index: 2;
  inset: 0;
  display: flex;
  align-items: center;
  padding: 8%;
  background: linear-gradient(90deg, #183548f4, #254151e9 34%, #26455482 58%, transparent 87%);
  color: #ffe9be;
}

.overlay-content { width: min(76%, 22rem); }

.screen-brand {
  display: inline-block;
  margin-bottom: clamp(7px, 2.4cqi, 18px);
  padding: .25em .48em;
  background: #ffce12;
  color: #9a0522;
  font: italic 950 clamp(.72rem, 3.2cqi, 1.1rem)/1 system-ui, sans-serif;
  text-transform: uppercase;
  white-space: nowrap;
}

#overlay-title {
  margin: 0;
  color: #ffd775;
  font: 950 clamp(1.5rem, 10.45cqi, 4.95rem)/.86 "Arial Black", Impact, system-ui, sans-serif;
  text-transform: uppercase;
  letter-spacing: -.065em;
  text-wrap: balance;
  text-shadow: 1px 1px #f8ac56, 3px 3px #a95136, 4px 5px #452736;
}

#overlay-title span { color: #ffc078; }

#overlay-subtitle {
  max-width: 25ch;
  margin: clamp(7px, 3.2cqi, 20px) 0 clamp(9px, 3.8cqi, 23px);
  color: #ffedcb;
  font: 700 clamp(.75rem, 3.5cqi, 1.12rem)/1.38 var(--mono);
}

button { font: inherit; color: inherit; cursor: pointer; }

button:focus-visible {
  outline: 2px solid #1c6b76;
  outline-offset: 3px;
}

.start-button {
  min-height: 40px;
  padding: .62em 1.15em;
  border: 1px solid #ffdb86;
  border-bottom-color: #b57638;
  border-radius: 3px;
  background: linear-gradient(#ffdc8a, #e7a24c 95%);
  box-shadow: 0 3px #6f4727, 0 5px 8px #0009;
  color: #291b14;
  font: 900 clamp(.72rem, 3.4cqi, 1rem)/1.2 var(--mono);
  text-transform: uppercase;
  letter-spacing: .02em;
}

.start-button:hover { background: #ffe0a1; }
.start-button:focus-visible { outline-color: #ffda87; }
.start-button:active { transform: translateY(2px); }

.route-actions { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }

.secondary-button {
  min-height: 37px;
  padding: .45em .65em;
  border: 1px solid #f6ddaa97;
  border-radius: 3px;
  background: #183548;
  color: #ffe9be;
  font: 700 clamp(.68rem, 3.2cqi, .94rem)/1.2 var(--mono);
  white-space: nowrap;
}

.secondary-button:hover { background: #2d5360; }
.secondary-button:focus-visible { outline-color: #ffda87; }
.secondary-button:active { transform: translateY(2px); }

#joystick, #fire {
  position: absolute;
  display: block;
  padding: 0;
  border: 0;
  border-radius: 30%;
  background: transparent;
  pointer-events: auto;
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
}

#joystick {
  --shaft-angle: 4deg;
  --shaft-depth: 1;
  left: var(--stick-x);
  top: var(--stick-y);
  width: var(--stick-width);
  height: var(--stick-height);
  cursor: grab;
}

#joystick:active { cursor: grabbing; }
#joystick[data-direction="up"] { --shaft-depth: .76; }
#joystick[data-direction="down"] { --shaft-depth: 1.12; }
#joystick[data-direction="left"] { --shaft-angle: -19deg; }
#joystick[data-direction="right"] { --shaft-angle: 24deg; }

.joystick-shaft {
  position: absolute;
  left: 50.75%;
  bottom: 23%;
  width: 17%;
  height: 70%;
  border: 1px solid #120f0d;
  border-radius: 45% 45% 29% 29% / 5% 5% 3% 3%;
  background: linear-gradient(90deg, #231d18, #44382d 19%, #736151 29%, #383029 45%, #1c1916 75%, #110e0d);
  box-shadow: 1px 2px 2px #1d120f91;
  pointer-events: none;
  transform: translateX(-50%) rotate(var(--shaft-angle)) scaleY(var(--shaft-depth));
  transform-origin: 50% 98%;
  transition: transform 95ms ease-out;
}

.joystick-shaft::before {
  position: absolute;
  inset: 0 1% auto;
  height: 7%;
  border-radius: 50%;
  background: linear-gradient(160deg, #9a8878, #584a3e 59%, #211b15);
  content: "";
}

#fire {
  left: var(--fire-x);
  top: var(--fire-y);
  width: 1.28%;
  height: 1.35%;
  transform: translate(-50%, -50%);
  border-radius: 50%;
}

#fire::before {
  position: absolute;
  inset: -10px;
  border-radius: 50%;
  content: "";
}

.fire-cap {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: linear-gradient(#ff9d54, #e54e1c 76%);
  box-shadow: 0 2px 0 #992f15, 0 3px 3px #281810a0, inset 0 1px 1px #ffc391;
  transform: translateY(0);
  transition: transform 85ms ease-out, box-shadow 85ms ease-out;
  pointer-events: none;
}

#fire:active .fire-cap, #fire[data-pressed] .fire-cap {
  transform: translateY(2px) scale(.94);
  box-shadow: inset 0 2px 2px #9a361c;
}

.control-bar {
  position: relative;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding-top: 12px;
}

.readouts {
  display: flex;
  align-items: center;
  margin: 0;
  font-family: var(--mono);
}

.readouts div {
  min-width: 4rem;
  padding: 0 clamp(9px, 1.4vw, 20px);
  border-left: 1px solid var(--rule);
}

.readouts div:first-child {
  padding-left: 0;
  border-left: 0;
}

.readouts dt {
  color: var(--muted);
  font-size: .75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .055em;
}

.readouts dd {
  margin: .1rem 0 0;
  color: var(--score-color);
  font-size: 1.35rem;
  font-weight: 700;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.controls, .dpad, .switches {
  display: flex;
  align-items: center;
}

.controls { gap: clamp(10px, 1.65vw, 22px); }
.dpad, .switches { gap: 5px; }

.controls-hint {
  margin: 0;
  color: var(--muted);
  font-size: .875rem;
  text-align: right;
}

kbd {
  color: #6d3925;
  font: 700 .9em/1 var(--mono);
  letter-spacing: .025em;
}

.dpad button, .switches button {
  display: inline-grid;
  min-width: 34px;
  min-height: 36px;
  place-items: center;
  padding: .42rem .56rem;
  border: 1px solid #9c775363;
  border-radius: 4px;
  background: linear-gradient(#fff9e9, #f5e6c6);
  box-shadow: 0 2px 0 #b88b614f;
  color: #503b31;
  font-size: .8125rem;
  font-weight: 650;
  white-space: nowrap;
  transition: transform 85ms ease-out, box-shadow 85ms ease-out;
}

.switches button { min-width: 4.6rem; }
.switches button[aria-pressed="true"] { border-color: #689b9d; color: #185663; }
.dpad button:hover, .switches button:hover:not(:disabled) { background: #ffedbd; }
.dpad button:active, .dpad button[data-pressed], .switches button:active:not(:disabled) {
  transform: translateY(2px);
  border-color: #367b87;
  background: #256876;
  color: #fff9e8;
  box-shadow: inset 0 2px 4px #163d4660;
}
.switches button:disabled { cursor: default; opacity: .5; }

.dpad i {
  display: block;
  box-sizing: content-box;
  width: 5px;
  height: 5px;
  border: solid currentColor;
  border-width: 1px 1px 0 0;
}

[data-move="left"] i { transform: rotate(-135deg); }
[data-move="up"] i { transform: rotate(-45deg); }
[data-move="down"] i { transform: rotate(135deg); }
[data-move="right"] i { transform: rotate(45deg); }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

@media (max-width: 850px) {
  .control-bar {
    gap: 8px;
    padding-top: 10px;
  }

  .controls-hint { max-width: 11rem; }
}

@media (min-width: 661px) and (max-width: 760px) {
  .controls { gap: 8px; }
  .controls-hint { display: none; }
}

@media (max-width: 660px) {
  .arcade { width: min(100% - 24px, 480px); }
  .marquee { flex-wrap: wrap; gap: .55rem; padding-block: 10px; }
  .route-hud { order: 3; flex-basis: 100%; }
  .studio-credit { font-size: .75rem; }
  .room { aspect-ratio: auto; border-radius: 4px; }

  .tv-window, .hardware-window {
    position: relative;
    overflow: hidden;
    aspect-ratio: calc(var(--photo-aspect) * var(--crop-width) / var(--crop-height));
    background: #23180f;
  }

  .tv-window {
    --crop-width: .395;
    --crop-height: .700;
    --crop-x: .176;
    --crop-y: .047;
  }

  .hardware-window {
    --crop-width: .420;
    --crop-height: .727;
    --crop-x: .558;
    --crop-y: .020;
    border-top: 1px solid #93633a66;
  }

  .hardware-image { display: block; }

  #fire::before { inset: -15px; }

  .scene-coordinate {
    inset: auto;
    top: calc(-100% * var(--crop-y) / var(--crop-height));
    left: calc(-100% * var(--crop-x) / var(--crop-width));
    width: calc(100% / var(--crop-width));
    height: calc(100% / var(--crop-height));
  }

  .control-bar { align-items: center; }
  .controls { flex-wrap: wrap; justify-content: flex-end; gap: 5px 8px; }
  .readouts { margin-right: auto; }
  .readouts div { min-width: 0; padding-inline: 7px; }
  .readouts dt { font-size: .625rem; }
  .readouts dd { font-size: 1.17rem; }
  .controls-hint { display: none; }
  .dpad button, .switches button { min-height: 44px; }
  .dpad button { min-width: 44px; }
}

@media (max-width: 440px) {
  .control-bar { flex-wrap: wrap; }
  .controls { width: 100%; justify-content: space-between; }
  .controls-hint {
    display: block;
    order: 3;
    flex-basis: 100%;
    max-width: none;
    margin-top: 4px;
    text-align: left;
  }
}

@media (max-width: 374px) {
  .dpad button { min-width: 36px; }
  .switches button { min-width: 4rem; }
  .overlay-content { width: 83%; }
  .start-button, .secondary-button { min-height: 34px; }
}

@media (prefers-reduced-motion: reduce) {
  .joystick-shaft, .fire-cap, .dpad button, .switches button { transition: none; }
}
