:root {
  color-scheme: dark;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  background: #05080c;
}

* { box-sizing: border-box; }

html,
body {
  width: 100%;
  min-height: 100%;
  margin: 0;
}

body {
  display: grid;
  place-items: center;
  overflow: hidden;
  color: #f2f4da;
  background:
    radial-gradient(circle at 50% 0%, #172936 0, #081018 40%, #030507 78%),
    #030507;
}

.arcade-shell {
  width: min(100vw, 1200px, calc((100vh - 102px) * 16 / 9));
  border: 2px solid #c5a53b;
  background: #080d12;
  box-shadow: 0 0 0 5px #18232a, 0 24px 80px #000;
}

.marquee {
  height: 42px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 14px;
  border-bottom: 2px solid #263943;
  letter-spacing: .08em;
}

.marquee__title {
  color: #f4ca48;
  font-size: 13px;
  font-weight: 900;
  text-shadow: 2px 2px #5a361c;
}

.marquee__mode {
  color: #7f9da7;
  font-size: 10px;
}

.screen {
  position: relative;
  display: grid;
  place-items: center;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #000;
}

.quality-toggle {
  display: none;
  position: absolute;
  top: max(9px, env(safe-area-inset-top));
  right: max(10px, env(safe-area-inset-right));
  z-index: 6;
  min-width: 76px;
  min-height: 28px;
  border: 1px solid #6c9daf;
  border-radius: 14px;
  color: #e8f6ee;
  background: #07141bdd;
  box-shadow: inset 0 1px 0 #ffffff24, 0 2px 8px #0008;
  font: 700 11px "PingFang SC", "Hiragino Sans GB", system-ui, sans-serif;
  letter-spacing: .04em;
  -webkit-tap-highlight-color: transparent;
}

.quality-toggle:active { filter: brightness(1.35); }
.quality-toggle[hidden] { display: none !important; }

.stage {
  position: relative;
  line-height: 0;
}

#game {
  display: block;
  width: 100%;
  height: 100%;
  image-rendering: crisp-edges;
  image-rendering: pixelated;
  outline: none;
}

#ui {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  image-rendering: auto;
}

.instructions {
  min-height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 17px;
  padding: 8px 12px;
  border-top: 2px solid #263943;
  color: #9db3b6;
  font-size: 11px;
}

kbd {
  min-width: 20px;
  display: inline-block;
  margin-right: 3px;
  padding: 2px 4px;
  border: 1px solid #526d77;
  border-radius: 2px;
  color: #f1f4dc;
  background: #172a33;
  text-align: center;
  font: inherit;
}

.touch-controls {
  --pad: max(14px, env(safe-area-inset-left));
  --pad-right: max(14px, env(safe-area-inset-right));
  --pad-bottom: max(12px, env(safe-area-inset-bottom));
  position: absolute;
  inset: auto var(--pad-right) var(--pad-bottom) var(--pad);
  z-index: 3;
  display: none;
  align-items: end;
  justify-content: space-between;
  pointer-events: none;
}

.touch-guide {
  display: none;
  position: absolute;
  left: 50%;
  bottom: max(6px, env(safe-area-inset-bottom));
  z-index: 2;
  width: max-content;
  max-width: 70%;
  margin: 0;
  padding: 3px 8px;
  transform: translateX(-50%);
  border: 1px solid #60869466;
  border-radius: 10px;
  color: #d5e7ea;
  background: #07131bcc;
  font-size: 9px;
  line-height: 1.2;
  text-align: center;
  text-shadow: 1px 1px #000;
  pointer-events: none;
}

.dpad,
.action-pad,
.start-btn {
  pointer-events: auto;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.touch-controls button {
  margin: 0;
  padding: 0;
  appearance: none;
  display: grid;
  place-items: center;
  font: inherit;
  cursor: pointer;
}

.dpad {
  position: relative;
  width: 148px;
  height: 148px;
  border-radius: 50%;
  background:
    radial-gradient(circle at 50% 32%, #3a3f4466, #12141799 62%, #070809aa);
  box-shadow:
    inset 0 1px 0 #ffffff22,
    inset 0 -6px 12px #00000088,
    0 4px 16px #00000066;
}

.dpad__plus {
  position: absolute;
  inset: 16px;
}

.dpad__arm {
  position: absolute;
  display: grid;
  place-items: center;
  color: #8b939a;
  background: linear-gradient(180deg, #3a4046cc, #1b1f24cc);
  box-shadow: inset 0 1px 0 #ffffff2a, inset 0 -2px 3px #00000088;
}

.dpad__up,
.dpad__down {
  left: 31%;
  width: 38%;
  height: 46%;
  border-radius: 7px;
}

.dpad__left,
.dpad__right {
  top: 31%;
  width: 46%;
  height: 38%;
  border-radius: 7px;
}

.dpad__up { top: 4%; }
.dpad__down { bottom: 4%; }
.dpad__left { left: 4%; }
.dpad__right { right: 4%; }

.dpad__arm i {
  font-style: normal;
  font-size: 11px;
  line-height: 1;
  text-shadow: 0 1px 0 #000;
}

.dpad__nub {
  position: absolute;
  inset: 32%;
  border-radius: 50%;
  background: radial-gradient(circle at 40% 32%, #4a5158, #1c2024);
  box-shadow: inset 0 1px 0 #ffffff22, 0 0 0 1px #0006;
}

.dpad.is-up .dpad__up,
.dpad.is-down .dpad__down,
.dpad.is-left .dpad__left,
.dpad.is-right .dpad__right {
  color: #f4f4e4;
  background: linear-gradient(180deg, #6a727a, #2c3238);
  filter: brightness(1.25);
}

.action-pad {
  display: grid;
  width: 168px;
  height: 168px;
  grid-template-columns: 52px 52px 52px;
  grid-template-rows: 52px 52px 52px;
  grid-template-areas:
    ". tri ."
    "sq . cir"
    ". cro .";
  gap: 6px;
  justify-content: center;
  align-content: center;
}

.face {
  width: 52px;
  height: 52px;
  border: 1px solid #2c3036cc;
  border-radius: 50%;
  background:
    radial-gradient(circle at 38% 28%, #2c3138cc, #101214e6 68%);
  box-shadow:
    inset 0 1px 0 #ffffff24,
    0 3px 8px #00000088;
  color: #d0d4d8;
}

.face--triangle { grid-area: tri; color: #5ce1b0; }
.face--circle { grid-area: cir; color: #ff5a6a; }
.face--cross { grid-area: cro; color: #7eb3ff; }
.face--square { grid-area: sq; color: #f0a0e0; }

.face__glyph {
  font-size: 22px;
  line-height: 1;
  text-shadow: 0 1px 0 #0008;
}

.start-btn {
  position: absolute;
  left: 50%;
  right: auto;
  bottom: 4px;
  width: 44px;
  height: 18px;
  transform: translateX(-50%);
  border: 1px solid #3d444acc;
  border-radius: 9px;
  color: #9aa4aa;
  background: #161a1ecc;
  box-shadow: inset 0 1px 0 #ffffff18;
  font: 700 11px inherit;
  letter-spacing: .04em;
}

.face:active,
.face.is-active,
.start-btn:active,
.start-btn.is-active {
  filter: brightness(1.45);
  box-shadow: inset 0 2px 6px #00000088, 0 0 10px currentColor;
}

@media (pointer: coarse), (any-pointer: coarse) {
  .arcade-shell {
    width: 100vw;
    height: 100dvh;
    display: flex;
    flex-direction: column;
    border-inline: 0;
  }
  .marquee { height: 36px; padding-inline: 10px; flex: none; }
  .marquee__title { font-size: 11px; }
  .marquee__mode { font-size: 8px; }
  .instructions { display: none; }
  .touch-controls { display: flex; }
  .touch-guide { display: block; }
  .quality-toggle { display: grid; place-items: center; }
  .screen {
    flex: 1;
    aspect-ratio: auto;
    min-height: 0;
  }
}

@media (pointer: coarse) and (orientation: landscape),
       (any-pointer: coarse) and (orientation: landscape) {
  html,
  body {
    height: 100%;
    min-height: 100dvh;
    overflow: hidden;
    touch-action: none;
  }

  body { display: block; }

  .arcade-shell {
    width: 100vw;
    height: 100dvh;
    border: 0;
    box-shadow: none;
  }

  .marquee,
  .instructions,
  .touch-guide { display: none; }

  .screen {
    width: 100%;
    height: 100dvh;
    aspect-ratio: auto;
  }

  .touch-controls {
    --pad: max(20px, env(safe-area-inset-left));
    --pad-right: max(20px, env(safe-area-inset-right));
    --pad-bottom: max(16px, env(safe-area-inset-bottom));
  }

  .dpad { width: 160px; height: 160px; }
  .action-pad {
    width: 184px;
    height: 184px;
    grid-template-columns: 56px 56px 56px;
    grid-template-rows: 56px 56px 56px;
  }
  .face { width: 56px; height: 56px; }
  .start-btn { bottom: 6px; }
}
