:root {
  --night-blue: #0b3448;
  --night-cyan: #55e1d5;
  --night-red: #ff5c48;
  --night-lime: #ffe56f;
  --night-ink: #071e2c;
}

.game2-view {
  min-height: 100svh;
  padding: 0;
  overflow: hidden;
  background: var(--night-blue);
}

.night-run,
.night-run * {
  box-sizing: border-box;
}

.night-run {
  position: relative;
  width: 100%;
  min-height: 100svh;
  overflow: hidden;
  color: #f3fbff;
  background: #0f7884;
  font-family: "Press Start 2P", "Courier New", monospace;
  touch-action: none;
  user-select: none;
}

.night-run-canvas {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
  outline: 0;
  touch-action: none;
}

.night-run-vignette,
.night-run-speed-lines {
  position: absolute;
  inset: 0;
  z-index: 4;
  pointer-events: none;
}

.night-run-vignette {
  background:
    repeating-linear-gradient(0deg, rgba(255, 229, 111, 0.018) 0 1px, transparent 1px 5px),
    linear-gradient(180deg, rgba(4, 61, 78, 0.08) 0%, transparent 34%, transparent 68%, rgba(7, 30, 44, 0.26) 100%),
    radial-gradient(ellipse at center, transparent 54%, rgba(7, 30, 44, 0.38) 118%);
}

.night-run-speed-lines {
  opacity: 0;
  background:
    repeating-conic-gradient(from 270deg at 50% 58%, transparent 0deg 4deg, rgba(255, 224, 167, 0.2) 4.1deg 4.25deg, transparent 4.35deg 8deg);
  filter: blur(1px);
  transform: scale(1.45);
  transition: opacity 180ms ease;
  mask-image: radial-gradient(circle at 50% 55%, transparent 0 14%, #000 58%, transparent 88%);
}

.night-run.is-rushing .night-run-speed-lines {
  opacity: 1;
  animation: nightRunSpeedLines 320ms linear infinite;
}

@keyframes nightRunSpeedLines {
  to { transform: scale(1.66) rotate(0.25deg); }
}

.night-run-hud {
  position: absolute;
  top: calc(env(safe-area-inset-top, 0px) + 58px);
  right: clamp(12px, 2.6vw, 34px);
  left: clamp(12px, 2.6vw, 34px);
  z-index: 20;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  pointer-events: none;
}

.night-run-readouts {
  display: grid;
  grid-template-columns: repeat(4, minmax(78px, 116px));
  gap: 4px;
}

.night-run-readouts > div {
  position: relative;
  min-height: 64px;
  padding: 9px 10px 8px;
  overflow: hidden;
  border-top: 2px solid rgba(83, 231, 255, 0.82);
  border-bottom: 1px solid rgba(83, 231, 255, 0.3);
  background: linear-gradient(90deg, rgba(3, 9, 25, 0.82), rgba(5, 19, 38, 0.36));
  box-shadow: inset 4px 0 0 rgba(255, 49, 88, 0.76);
  backdrop-filter: blur(8px);
}

.night-run-readouts span,
.night-run-readouts small {
  display: block;
  color: rgba(196, 235, 255, 0.72);
  font-size: 7px;
  line-height: 1.35;
}

.night-run-readouts strong {
  display: inline-block;
  margin-top: 5px;
  color: #fff;
  font-size: clamp(15px, 2.2vw, 24px);
  line-height: 1;
  text-shadow: 0 0 12px rgba(83, 231, 255, 0.6);
}

.night-run-readouts small {
  display: inline-block;
  margin-left: 4px;
  color: var(--night-cyan);
  font-size: 6px;
}

.night-run-actions {
  display: flex;
  gap: 7px;
  pointer-events: auto;
}

.night-run-actions button,
.night-run-controls button,
.night-run-primary {
  border: 1px solid rgba(117, 230, 255, 0.76);
  border-radius: 0;
  background: rgba(2, 8, 23, 0.74);
  color: #effdff;
  font: inherit;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.night-run-actions button {
  width: 45px;
  height: 45px;
  padding: 0;
  font-size: 7px;
  box-shadow: 3px 3px 0 rgba(255, 49, 88, 0.52);
}

.night-run-actions button:active,
.night-run-actions button.is-muted {
  color: var(--night-red);
  transform: translate(2px, 2px);
  box-shadow: 1px 1px 0 rgba(255, 49, 88, 0.42);
}

.night-run-powerbar {
  position: absolute;
  top: calc(env(safe-area-inset-top, 0px) + 130px);
  left: clamp(12px, 2.6vw, 34px);
  z-index: 20;
  width: min(476px, calc(100vw - 24px));
  height: 12px;
  overflow: hidden;
  border: 1px solid rgba(255, 216, 74, 0.38);
  background: rgba(196, 235, 255, 0.16);
  pointer-events: none;
}

.night-run-powerbar i {
  display: block;
  width: 0;
  height: 100%;
  background: linear-gradient(90deg, #ff9f1c, #ffe45e, #fffbd1);
  box-shadow: 0 0 15px rgba(255, 216, 74, 0.9);
  transition: width 90ms linear;
}

.night-run-powerbar span {
  position: absolute;
  top: 2px;
  right: 5px;
  color: #fffbd1;
  font-size: 5px;
  letter-spacing: 0.08em;
  text-shadow: 0 0 6px #ff9f1c;
}

.night-run.is-rushing .night-run-powerbar {
  border-color: #fffbd1;
  box-shadow: 0 0 20px rgba(255, 216, 74, 0.62);
}

.night-run-callout {
  position: absolute;
  top: 33%;
  left: 50%;
  z-index: 22;
  color: #fff;
  font-size: clamp(11px, 2vw, 19px);
  letter-spacing: 0.12em;
  opacity: 0;
  text-align: center;
  text-shadow: 0 0 9px var(--night-cyan), 3px 3px 0 rgba(255, 49, 88, 0.8);
  transform: translate(-50%, 18px) scale(0.92);
  pointer-events: none;
}

.night-run-callout.is-visible {
  animation: nightRunCallout 900ms cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes nightRunCallout {
  0% { opacity: 0; transform: translate(-50%, 20px) scale(0.85); }
  18%, 68% { opacity: 1; transform: translate(-50%, 0) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -16px) scale(1.06); }
}

.night-run-panel {
  position: absolute;
  inset: 0;
  z-index: 15;
  display: grid;
  padding: 148px 24px 92px;
  place-content: center;
  justify-items: center;
  background: linear-gradient(90deg, rgba(1, 5, 18, 0.76), rgba(2, 8, 24, 0.2) 48%, rgba(1, 5, 18, 0.72));
  opacity: 0;
  visibility: hidden;
  text-align: center;
  transition: opacity 240ms ease, visibility 240ms ease;
}

.night-run-panel.is-visible {
  display: grid;
  opacity: 1;
  visibility: visible;
}

.night-run-panel:not(.is-visible) {
  display: none;
}

.night-run-panel[hidden] {
  display: none;
}

.night-run-start-panel {
  padding: 110px 24px 70px;
  gap: clamp(14px, 2.2vw, 28px);
}

.night-run-start-logo {
  display: block;
  width: min(88vw, 1180px);
  max-height: 48vh;
  object-fit: contain;
  filter: drop-shadow(0 14px 24px rgba(0, 0, 0, 0.38));
}

.night-run-start-panel .night-run-primary {
  margin-top: 0;
}

.night-run-start-panel .night-run-start-button {
  width: min(72vw, 620px);
  min-width: 0;
  min-height: 0;
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
  line-height: 0;
}

.night-run-start-button img {
  display: block;
  width: 100%;
  height: auto;
  pointer-events: none;
  filter: drop-shadow(0 12px 16px rgba(0, 0, 0, 0.38));
}

.night-run-start-panel .night-run-start-button:hover {
  background: transparent;
  box-shadow: none;
  transform: translateY(-3px) scale(1.025);
}

.night-run-start-panel .night-run-start-button:focus-visible {
  background: transparent;
  outline: 3px solid #fff;
  outline-offset: 7px;
  box-shadow: none;
  transform: translateY(-3px) scale(1.025);
}

.night-run-start-panel .night-run-start-button:active {
  transform: translateY(4px) scale(0.985);
  box-shadow: none;
}

.night-run-start-panel .night-run-drive-settings,
.night-run-start-panel .night-run-landscape-note,
.night-run-start-panel .night-run-instructions {
  display: none !important;
}

.night-run-start-panel.is-visible ~ .night-run-controls {
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
}

.night-run-panel p {
  margin: 0 0 18px;
  color: var(--night-cyan);
  font-size: clamp(7px, 1.25vw, 10px);
  letter-spacing: 0.15em;
  text-shadow: 0 0 12px rgba(83, 231, 255, 0.65);
}

.night-run-panel h1,
.night-run-panel h2 {
  margin: 0;
  max-width: 1000px;
  color: #eefbff;
  font-family: "Archivo Black", Impact, sans-serif;
  font-size: clamp(58px, 12vw, 158px);
  font-style: italic;
  font-weight: 900;
  line-height: 0.78;
  letter-spacing: -0.075em;
  text-transform: uppercase;
  text-shadow:
    5px 5px 0 var(--night-red),
    0 0 30px rgba(65, 192, 255, 0.52);
}

.night-run-panel h1 span {
  color: transparent;
  -webkit-text-stroke: 2px #eefbff;
  text-shadow: 4px 4px 0 rgba(83, 231, 255, 0.45);
}

.night-run-panel h2 {
  max-width: 850px;
  font-size: clamp(42px, 8vw, 104px);
  line-height: 0.88;
}

.night-run-panel > strong {
  margin: 24px 0 0;
  color: rgba(233, 249, 255, 0.76);
  font-size: clamp(7px, 1vw, 10px);
  line-height: 1.8;
}

.night-run-drive-settings {
  display: flex;
  margin-top: 18px;
  align-items: center;
  justify-content: center;
  gap: 7px;
  flex-wrap: wrap;
}

.night-run-drive-modes {
  display: flex;
  gap: 3px;
}

.night-run-drive-settings button,
.night-run-sensitivity {
  min-height: 30px;
  padding: 6px 9px;
  border: 1px solid rgba(83, 231, 255, 0.42);
  background: rgba(2, 8, 23, 0.72);
  color: rgba(224, 248, 255, 0.72);
  font: inherit;
  font-size: 6px;
  line-height: 1.25;
  cursor: pointer;
}

.night-run-drive-settings button[aria-pressed="true"] {
  border-color: var(--night-lime);
  background: rgba(219, 255, 84, 0.92);
  color: var(--night-ink);
  box-shadow: 3px 3px 0 rgba(255, 49, 88, 0.72);
}

.night-run-sensitivity {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: default;
}

.night-run-sensitivity input {
  width: 78px;
  height: 18px;
  accent-color: var(--night-red);
  cursor: ew-resize;
}

.night-run-recenter {
  display: none;
}

.night-run-tilt-status {
  display: none;
  min-height: 30px;
  padding: 7px 10px;
  align-items: center;
  gap: 7px;
  border: 1px solid rgba(83, 231, 255, 0.42);
  background: rgba(2, 8, 23, 0.78);
  color: rgba(224, 248, 255, 0.8);
  font-size: 6px;
  line-height: 1.25;
}

.night-run-tilt-status i {
  width: 7px;
  height: 7px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--night-cyan);
  box-shadow: 0 0 8px rgba(83, 231, 255, 0.85);
}

.night-run-tilt-status[data-status="connecting"] i {
  animation: night-run-tilt-pulse 0.7s steps(2, end) infinite;
}

.night-run-tilt-status[data-status="ready"] {
  border-color: var(--night-lime);
  color: var(--night-lime);
}

.night-run-tilt-status[data-status="ready"] i {
  background: var(--night-lime);
  box-shadow: 0 0 10px rgba(219, 255, 84, 0.9);
}

.night-run-tilt-status[data-status="insecure"],
.night-run-tilt-status[data-status="denied"],
.night-run-tilt-status[data-status="unavailable"] {
  border-color: var(--night-red);
  color: #ff8ba0;
}

.night-run-tilt-status[data-status="insecure"] i,
.night-run-tilt-status[data-status="denied"] i,
.night-run-tilt-status[data-status="unavailable"] i {
  background: var(--night-red);
  box-shadow: 0 0 9px rgba(255, 49, 88, 0.9);
}

@keyframes night-run-tilt-pulse {
  50% { opacity: 0.25; }
}

.night-run[data-control-mode="tilt"] .night-run-recenter {
  display: inline-flex;
  align-items: center;
}

.night-run[data-control-mode="tilt"] .night-run-tilt-status {
  display: inline-flex;
}

.night-run-landscape-note {
  display: none;
  margin-top: 18px;
  color: var(--night-cyan);
  font-size: 6px;
  letter-spacing: 0.08em;
}

.night-run-primary {
  min-width: 210px;
  min-height: 58px;
  margin-top: 28px;
  padding: 14px 24px;
  border: 2px solid #eaffff;
  background: var(--night-lime);
  color: var(--night-ink);
  font-size: 11px;
  box-shadow: 7px 7px 0 var(--night-red), 0 0 25px rgba(219, 255, 84, 0.25);
}

.night-run-primary:hover,
.night-run-primary:focus-visible {
  background: #fff;
  outline: 0;
  transform: translate(-2px, -2px);
  box-shadow: 9px 9px 0 var(--night-red), 0 0 30px rgba(83, 231, 255, 0.44);
}

.night-run-primary:active {
  transform: translate(5px, 5px);
  box-shadow: 2px 2px 0 var(--night-red);
}

.night-run-instructions {
  display: flex;
  margin-top: 28px;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
}

.night-run-instructions span,
.night-run-result > div span {
  padding: 8px 10px;
  border: 1px solid rgba(83, 231, 255, 0.36);
  background: rgba(2, 8, 23, 0.62);
  color: rgba(227, 248, 255, 0.68);
  font-size: 6px;
  line-height: 1.5;
}

.night-run-result > div {
  display: flex;
  margin-top: 24px;
  gap: 10px;
}

.night-run-result > div span {
  min-width: 142px;
}

.night-run-result b {
  display: block;
  margin-top: 8px;
  color: #fff;
  font-size: 13px;
}

.night-run-controls {
  position: absolute;
  right: max(16px, env(safe-area-inset-right, 0px));
  bottom: max(18px, env(safe-area-inset-bottom, 0px));
  left: max(16px, env(safe-area-inset-left, 0px));
  z-index: 24;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  pointer-events: none;
}

.night-run-controls button {
  width: clamp(88px, 12vw, 112px);
  height: clamp(88px, 12vw, 112px);
  padding: 0;
  border-width: 2px;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 42%, rgba(83, 231, 255, 0.22), rgba(3, 11, 29, 0.78) 66%);
  color: rgba(228, 250, 255, 0.86);
  font-size: clamp(7px, 1vw, 10px);
  letter-spacing: 0.08em;
  box-shadow: inset 0 0 20px rgba(83, 231, 255, 0.13), 0 0 18px rgba(0, 0, 0, 0.28);
  backdrop-filter: blur(7px);
  pointer-events: auto;
}

.night-run-controls button b,
.night-run-controls button small {
  display: block;
}

.night-run-controls button b {
  font: inherit;
  font-size: clamp(9px, 1.4vw, 13px);
  letter-spacing: 0.12em;
}

.night-run-controls button small {
  margin-top: 7px;
  color: var(--night-cyan);
  font-size: 5px;
  letter-spacing: 0.04em;
}

.night-run-controls button.is-pressed {
  background: var(--night-lime);
  color: var(--night-ink);
  transform: scale(0.9);
  box-shadow: 0 0 30px rgba(219, 255, 84, 0.65);
}

.night-run-controls button.is-pressed small {
  color: var(--night-ink);
}

.night-run-live {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

body[data-view="game"] {
  overflow: hidden;
  overscroll-behavior: none;
  background: var(--night-blue);
}

body[data-view="game"] .game2-view {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100dvh;
  min-height: 0;
  transform: none;
}

body[data-view="game"] .night-run {
  height: 100%;
  min-height: 0;
}

body[data-view="game"] .night-run-canvas {
  position: fixed;
  inset: 0;
}

body[data-view="game"] .noise {
  display: none !important;
}

@media (pointer: fine) {
  body[data-view="game"] .space-cursor {
    display: block;
    z-index: 60000;
    filter:
      drop-shadow(0 0 2px rgba(0, 0, 0, 0.95))
      drop-shadow(0 0 7px rgba(127, 255, 78, 0.95));
  }

  body[data-view="game"] .space-cursor-trails {
    display: block;
    z-index: 59999;
  }
}

body[data-view="game"] .shared-top-menu a,
body[data-view="game"] .shared-top-menu > span,
body[data-view="game"] .shared-hamburger-menu {
  color: rgba(212, 247, 255, 0.76);
  text-shadow: 0 0 9px rgba(83, 231, 255, 0.54);
}

body[data-view="game"] .shared-top-menu a[aria-current="page"],
body[data-view="game"] .shared-top-menu a:hover,
body[data-view="game"] .shared-top-menu a:focus-visible {
  color: var(--night-red);
}

@media (hover: hover) and (pointer: fine) {
  .night-run-controls {
    opacity: 0.62;
  }
}

@media (max-width: 760px) {
  .night-run-hud {
    top: calc(env(safe-area-inset-top, 0px) + 56px);
    gap: 7px;
  }

  .night-run-readouts {
    grid-template-columns: repeat(4, minmax(48px, 1fr));
    width: min(340px, calc(100vw - 128px));
  }

  .night-run-readouts > div {
    min-height: 52px;
    padding: 7px 6px;
  }

  .night-run-readouts span {
    font-size: 5px;
  }

  .night-run-readouts strong {
    font-size: clamp(11px, 3.2vw, 16px);
  }

  .night-run-readouts small {
    display: none;
  }

  .night-run-actions button {
    width: 36px;
    height: 36px;
    font-size: 6px;
  }

  .night-run-powerbar {
    top: calc(env(safe-area-inset-top, 0px) + 115px);
    width: min(340px, calc(100vw - 128px));
  }

  .night-run-panel {
    padding: 130px 18px 104px;
  }

  .night-run-panel h1 {
    font-size: clamp(55px, 17vw, 96px);
  }

  .night-run-panel > strong {
    max-width: 310px;
  }

  .night-run-drive-settings {
    max-width: 540px;
    margin-top: 13px;
    gap: 5px;
  }

  .night-run-drive-settings button,
  .night-run-sensitivity {
    min-height: 27px;
    padding: 5px 7px;
    font-size: 5px;
  }

  .night-run-sensitivity input {
    width: 64px;
  }

  .night-run-instructions {
    display: none;
  }

  .night-run-controls button {
    width: 88px;
    height: 88px;
  }
}

@media (orientation: portrait) and (max-width: 760px) {
  .night-run-panel h1 {
    font-size: clamp(62px, 21vw, 100px);
    line-height: 0.84;
  }

  .night-run-panel h1 span {
    display: block;
  }

  .night-run-panel > strong {
    margin-top: 20px;
    line-height: 1.9;
  }

  .night-run-primary {
    min-width: 190px;
    min-height: 54px;
  }

  .night-run-landscape-note {
    display: block;
  }

  .night-run-drive-settings {
    max-width: 330px;
  }

  .night-run-result > div {
    gap: 6px;
  }

  .night-run-result > div span {
    min-width: 124px;
    padding: 7px;
  }
}

@media (max-height: 560px) {
  .night-run-hud {
    top: calc(env(safe-area-inset-top, 0px) + 44px);
  }

  .night-run-readouts > div {
    min-height: 48px;
    padding-top: 6px;
  }

  .night-run-powerbar {
    top: calc(env(safe-area-inset-top, 0px) + 99px);
  }

  .night-run-panel {
    padding-top: 92px;
    padding-bottom: 74px;
  }

  .night-run-panel h1 {
    font-size: clamp(50px, 13vw, 88px);
  }

  .night-run-panel > strong,
  .night-run-instructions {
    display: none;
  }

  .night-run-drive-settings {
    margin-top: 12px;
  }

  .night-run-primary {
    min-height: 48px;
    margin-top: 14px;
  }

  .night-run-landscape-note {
    margin-top: 12px;
  }

  .night-run-controls button {
    width: 72px;
    height: 72px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .night-run-speed-lines,
  .night-run-callout,
  .night-run-primary {
    animation: none !important;
    transition: none !important;
  }
}
