:root {
  color-scheme: dark;
  font-family: "Hiragino Sans", "Yu Gothic", system-ui, sans-serif;
  background: #030914;
  color: #f8fbff;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  overscroll-behavior: none;
  background:
    radial-gradient(circle at 50% -20%, #17345e 0, transparent 48%),
    #030914;
}

body {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 12px;
}

.game-shell {
  width: min(100%, 1040px);
  display: grid;
  justify-items: center;
  gap: 10px;
}

.canvas-viewport {
  width: 100%;
  display: flex;
  justify-content: center;
  overflow: visible;
}

canvas {
  display: block;
  width: min(100%, 960px);
  height: auto;
  max-height: calc(100dvh - 145px);
  aspect-ratio: 16 / 10;
  border: 1px solid rgba(124, 200, 255, .35);
  border-radius: 22px;
  background: #071426;
  box-shadow: 0 24px 70px rgba(0, 0, 0, .5), inset 0 0 0 1px rgba(255,255,255,.05);
  image-rendering: pixelated;
  touch-action: none;
}

.fps-page canvas {
  image-rendering: auto;
  border-color: rgba(131, 221, 255, .48);
  box-shadow: 0 28px 90px rgba(0, 0, 0, .62), 0 0 42px rgba(42, 147, 210, .12), inset 0 0 0 1px rgba(255,255,255,.07);
}

.fps-page .safety-note strong { color: #f6c63b; }

.mobile-controls {
  width: min(100%, 620px);
  display: none;
  align-items: center;
  justify-content: space-between;
  padding: 0 8px;
  user-select: none;
}

.mobile-readout {
  display: none;
}

.mobile-controls button {
  appearance: none;
  border: 1px solid rgba(255,255,255,.28);
  color: white;
  background: rgba(22, 48, 79, .92);
  box-shadow: 0 7px 0 #07111f;
  font: 700 18px/1 inherit;
  touch-action: none;
}

.mobile-controls button:active,
.mobile-controls button.active {
  transform: translateY(4px);
  box-shadow: 0 3px 0 #07111f;
  background: #1b72a7;
}

.dpad {
  width: 132px;
  height: 90px;
  display: grid;
  grid-template: repeat(2, 42px) / repeat(3, 42px);
  gap: 5px;
}

.dpad button { border-radius: 12px; }
.dpad .up { grid-area: 1 / 2; }
.dpad .left { grid-area: 2 / 1; }
.dpad .down { grid-area: 2 / 2; }
.dpad .right { grid-area: 2 / 3; }

.action {
  width: 92px;
  height: 72px;
  border-radius: 50% !important;
  background: #e5a61a !important;
  color: #211500 !important;
}

.safety-note {
  margin: 0;
  color: #9dafc4;
  font-size: 12px;
  text-align: center;
}

.operator-info {
  width: min(100%, 760px);
  display: grid;
  justify-items: center;
  gap: 7px;
  margin-top: 2px;
  padding: 14px 18px;
  border: 1px solid rgba(131, 221, 255, .22);
  border-radius: 16px;
  background: rgba(7, 20, 38, .72);
  color: #c5d6e3;
  font-size: 13px;
  line-height: 1.55;
  text-align: center;
}

.operator-info p { margin: 0; }

.operator-info strong { color: #fff; }

.operator-info nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px 18px;
}

.operator-info a {
  min-height: 32px;
  display: inline-flex;
  align-items: center;
  color: #83ddff;
  font-weight: 800;
  text-underline-offset: 3px;
}

.operator-info a:focus-visible {
  outline: 3px solid #f6c63b;
  outline-offset: 3px;
  border-radius: 4px;
}

@media (max-width: 820px) {
  html, body {
    overscroll-behavior-y: auto;
    overflow-x: hidden;
  }

  body {
    display: block;
    padding: max(6px, env(safe-area-inset-top)) 0 max(16px, env(safe-area-inset-bottom));
  }

  .game-shell {
    width: 100%;
    gap: 12px;
  }

  .mobile-readout {
    position: sticky;
    top: 0;
    z-index: 5;
    display: grid;
    width: calc(100% - 16px);
    gap: 5px;
    padding: 12px 14px;
    border: 1px solid rgba(131, 221, 255, .34);
    border-radius: 16px;
    background: rgba(4, 15, 29, .96);
    box-shadow: 0 10px 30px rgba(0, 0, 0, .38);
    backdrop-filter: blur(14px);
  }

  .mobile-readout__label,
  .mobile-readout h1,
  .mobile-readout p {
    margin: 0;
  }

  .mobile-readout__label {
    color: #83ddff;
    font-size: 15px;
    font-weight: 900;
    letter-spacing: .06em;
  }

  .mobile-readout h1 {
    color: #fff;
    font-size: clamp(22px, 6.2vw, 28px);
    line-height: 1.25;
  }

  .mobile-readout > p:last-of-type {
    color: #c5d6e3;
    font-size: 16px;
    line-height: 1.45;
  }

  .mobile-readout button {
    appearance: none;
    justify-self: start;
    min-height: 42px;
    margin-top: 3px;
    padding: 0 15px;
    border: 1px solid rgba(246, 198, 59, .5);
    border-radius: 999px;
    color: #211500;
    background: #f6c63b;
    font: 900 15px/1 inherit;
  }

  .canvas-viewport {
    width: 100vw;
    justify-content: flex-start;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 0 8px 10px;
    scroll-behavior: smooth;
    scrollbar-color: #4b84a9 #071426;
    -webkit-overflow-scrolling: touch;
  }

  canvas {
    width: 720px;
    min-width: 720px;
    max-width: none;
    max-height: none;
    border-radius: 16px;
  }

  .mobile-controls {
    display: flex;
    width: 100%;
    padding: 2px 18px 10px;
  }

  .mobile-controls button {
    font-size: 22px;
  }

  .dpad {
    width: 170px;
    height: 116px;
    grid-template: repeat(2, 52px) / repeat(3, 52px);
    gap: 8px;
  }

  .dpad button { border-radius: 15px; }

  .action {
    width: 114px;
    height: 92px;
    font-size: 21px !important;
  }

  .safety-note {
    width: calc(100% - 24px);
    font-size: 13px;
    line-height: 1.55;
  }

  .operator-info {
    width: calc(100% - 24px);
    padding: 15px 14px;
    font-size: 14px;
  }
}

@media (max-height: 620px) and (orientation: landscape) {
  body { padding: 4px; }
  .game-shell { grid-template-columns: 1fr 170px; gap: 8px; }
  .mobile-readout { display: none; }
  .canvas-viewport { width: 100%; padding: 0; overflow: hidden; }
  canvas { width: auto; min-width: 0; max-width: 100%; max-height: calc(100dvh - 8px); }
  .mobile-controls { display: flex; width: 170px; flex-direction: column; gap: 18px; }
  .safety-note, .operator-info { display: none; }
}
