:root {
  --night: #081019;
  --night-deep: #050b11;
  --panel: rgba(9, 18, 25, 0.91);
  --panel-soft: rgba(13, 25, 33, 0.84);
  --line: rgba(185, 208, 208, 0.28);
  --line-strong: rgba(228, 238, 236, 0.5);
  --text: #f4f5f2;
  --muted: #adb9b8;
  --teal: #58bed0;
  --teal-soft: #9bd4d9;
  --orange: #f28d19;
  --orange-bright: #ffad3c;
  --green: #6fc436;
  --danger: #e7674b;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--night-deep);
}

html {
  overscroll-behavior: none;
}

body {
  color: var(--text);
  font-family: "Microsoft YaHei", "PingFang SC", "Noto Sans CJK SC", system-ui, sans-serif;
  background-color: #0b151d;
  overflow-x: hidden;
}

body.is-playing,
body.is-playing .game-page {
  overscroll-behavior: none;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
}

button,
a {
  font: inherit;
}

button {
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
a:focus-visible,
[tabindex]:focus-visible {
  outline: 3px solid #fff1c9;
  outline-offset: 3px;
}

.game-page {
  width: min(100%, 1700px);
  min-height: 100vh;
  margin: 0 auto;
  background: var(--night);
}

.site-bar {
  position: relative;
  z-index: 50;
  height: 62px;
  padding: 8px clamp(14px, 2.1vw, 34px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  background: rgba(6, 13, 22, 0.98);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.2);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  min-width: 0;
  color: #fff;
  text-decoration: none;
}

.brand img {
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  border-radius: 9px;
}

.brand span {
  display: flex;
  flex-direction: column;
  min-width: 0;
  line-height: 1.08;
}

.brand strong {
  font-family: "STKaiti", "KaiTi", "Microsoft YaHei", sans-serif;
  font-size: 21px;
  font-weight: 700;
  letter-spacing: 0.08em;
}

.brand small {
  margin-top: 3px;
  color: #9ba8b4;
  font-size: 9px;
  letter-spacing: 0.12em;
}

.site-actions {
  display: flex;
  align-items: center;
  gap: 9px;
}

.site-actions a,
.site-actions button {
  min-height: 36px;
  padding: 7px 15px;
  color: #d7dddf;
  background: rgba(255, 255, 255, 0.035);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 7px;
  text-decoration: none;
  cursor: pointer;
  transition: border-color 160ms ease, background-color 160ms ease, color 160ms ease;
}

.site-actions a:hover,
.site-actions button:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 173, 60, 0.65);
}

.game-frame {
  position: relative;
  width: min(100%, calc((100svh - 62px) * 16 / 9));
  aspect-ratio: 16 / 9;
  min-height: 0;
  margin: 0 auto;
  overflow: hidden;
  overflow: clip;
  isolation: isolate;
  background-color: #243a3c;
  background-image: url("/games/helicopter/assets/alpine-valley.png");
  background-position: center;
  background-size: cover;
  box-shadow: 0 26px 72px rgba(0, 0, 0, 0.45);
}

#gameCanvas {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  outline: none;
  touch-action: none;
}

.flight-hud {
  position: absolute;
  z-index: 5;
  top: clamp(16px, 1.8vw, 24px);
  left: clamp(16px, 1.8vw, 24px);
  display: grid;
  grid-template-columns: 0.78fr 1.02fr 0.92fr 1.8fr 1.14fr;
  align-items: stretch;
  width: min(57%, 660px);
  min-height: 72px;
  padding: 9px 11px;
  color: var(--text);
  background: var(--panel);
  border: 1px solid rgba(240, 166, 62, 0.38);
  border-radius: 9px;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.34);
  backdrop-filter: blur(9px);
  pointer-events: none;
}

.hud-metric {
  min-width: 0;
  padding: 2px clamp(7px, 1.05vw, 16px);
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  border-right: 1px solid rgba(222, 204, 171, 0.25);
}

.hud-metric:last-child {
  border-right: 0;
}

.hud-metric > span {
  color: #aeb8b8;
  font-size: clamp(9px, 0.85vw, 12px);
  font-weight: 600;
  letter-spacing: 0.14em;
  white-space: nowrap;
}

.hud-metric strong {
  color: var(--text);
  font-family: "Consolas", "SFMono-Regular", monospace;
  font-size: clamp(15px, 1.52vw, 23px);
  font-weight: 700;
  line-height: 1;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.altitude-metric strong {
  color: #75d23c;
}

.speed-metric strong {
  color: #68cbe0;
}

.hud-metric b {
  float: right;
  color: #e8edeb;
  font-family: "Consolas", "SFMono-Regular", monospace;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0;
}

.meter-track {
  width: 100%;
  height: 7px;
  overflow: hidden;
  background: rgba(211, 220, 217, 0.18);
  border-radius: 2px;
}

.meter-track i {
  display: block;
  width: 0;
  height: 100%;
  background: var(--orange);
  transition: width 180ms ease, background-color 180ms ease;
}

.fuel-track i {
  width: 100%;
  background: var(--green);
}

.status-hud {
  position: absolute;
  z-index: 5;
  top: clamp(16px, 1.8vw, 24px);
  right: clamp(16px, 1.8vw, 24px);
  width: clamp(144px, 14.6vw, 188px);
  min-height: 72px;
  padding: 9px 10px;
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-rows: auto auto;
  align-items: center;
  gap: 4px 10px;
  color: var(--text);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 9px;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.34);
  backdrop-filter: blur(9px);
}

.status-hud > div {
  min-width: 0;
}

.status-hud span {
  display: block;
  color: #9ba9aa;
  font-size: 9px;
  letter-spacing: 0.12em;
}

.status-hud strong {
  display: block;
  margin-top: 3px;
  overflow: hidden;
  color: var(--orange-bright);
  font-size: clamp(11px, 0.9vw, 13px);
  text-overflow: ellipsis;
  white-space: nowrap;
}

#timerValue {
  color: #f5f3eb;
  font-family: "Consolas", "SFMono-Regular", monospace;
  font-size: clamp(15px, 1.4vw, 21px);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

#pauseButton {
  grid-column: 1 / -1;
  min-height: 25px;
  padding: 3px 9px;
  color: #d5dcdd;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 5px;
  font-size: 10px;
  cursor: pointer;
}

#pauseButton:hover {
  color: #fff;
  border-color: rgba(255, 173, 60, 0.65);
}

.toast {
  position: absolute;
  z-index: 20;
  top: 20%;
  left: 50%;
  width: max-content;
  max-width: min(76%, 520px);
  padding: 10px 17px;
  color: #fff;
  background: rgba(7, 15, 21, 0.92);
  border: 1px solid rgba(255, 173, 60, 0.58);
  border-radius: 7px;
  box-shadow: 0 9px 28px rgba(0, 0, 0, 0.38);
  font-size: clamp(11px, 1vw, 14px);
  text-align: center;
  transform: translate(-50%, -10px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease, transform 180ms ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

.overlay {
  position: absolute;
  z-index: 15;
  inset: 0;
  display: grid;
  place-items: center;
  padding: clamp(18px, 3vw, 42px);
  background: rgba(3, 10, 14, 0.46);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 220ms ease, visibility 220ms ease;
}

.overlay.is-visible {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.start-overlay {
  background: rgba(3, 10, 14, 0.24);
}

.mission-intro {
  position: absolute;
  top: clamp(118px, 15.5%, 152px);
  left: clamp(24px, 3.2vw, 50px);
  max-width: 34%;
  text-shadow: 0 3px 16px rgba(0, 0, 0, 0.92);
}

.mission-intro h1 {
  width: max-content;
  max-width: 100%;
  margin: 0;
  padding: 0 0 13px;
  color: #f4f2eb;
  border-bottom: 3px solid var(--orange);
  font-size: clamp(38px, 4.7vw, 74px);
  font-weight: 800;
  line-height: 1;
  letter-spacing: 0.08em;
}

.mission-intro p {
  margin: 16px 0 0;
  color: #f3f2ed;
  font-size: clamp(13px, 1.48vw, 22px);
  font-weight: 700;
  letter-spacing: 0.1em;
  white-space: nowrap;
}

.start-panel,
.pause-panel,
.result-panel,
.orientation-panel {
  width: min(92%, 470px);
  padding: clamp(24px, 3vw, 38px) clamp(23px, 3.4vw, 44px);
  color: var(--text);
  background: rgba(8, 17, 24, 0.96);
  border: 1px solid rgba(225, 193, 142, 0.42);
  border-radius: 12px;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.58), inset 0 0 34px rgba(100, 160, 164, 0.035);
  text-align: center;
}

.start-panel {
  transform: translateX(3%);
}

.flight-mark {
  width: 94px;
  margin: -4px auto 11px;
  color: #d8dedc;
}

.flight-mark svg {
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;
}

.flight-mark path:not(.mountain-mark) {
  fill: currentColor;
}

.flight-mark circle,
.flight-mark .mountain-mark {
  fill: rgba(8, 17, 24, 0.92);
  stroke: currentColor;
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.panel-kicker {
  margin: 0 0 8px;
  color: var(--orange-bright);
  font-size: clamp(9px, 0.78vw, 12px);
  font-weight: 700;
  letter-spacing: 0.2em;
}

.start-panel h2,
.pause-panel h2,
.result-panel h2,
.orientation-panel h2 {
  margin: 0;
  color: #f5f4ef;
  font-size: clamp(27px, 2.7vw, 40px);
  line-height: 1.18;
  letter-spacing: 0.08em;
}

.panel-copy {
  max-width: 390px;
  margin: 15px auto 20px;
  color: #bcc6c5;
  font-size: clamp(11px, 0.98vw, 14px);
  line-height: 1.75;
}

.control-guide {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 11px 18px;
  margin: 0 0 24px;
  text-align: left;
}

.control-guide > div {
  display: flex;
  align-items: center;
  min-width: 0;
  gap: 6px;
}

.control-guide span {
  margin-left: auto;
  color: #c9d0cf;
  font-size: clamp(10px, 0.88vw, 13px);
  white-space: nowrap;
}

.touch-guide {
  display: none;
}

kbd {
  min-width: 39px;
  padding: 7px 9px;
  color: #ecf0ee;
  background: #19242c;
  border: 1px solid rgba(225, 232, 230, 0.36);
  border-bottom-width: 2px;
  border-radius: 6px;
  box-shadow: 0 3px 0 rgba(0, 0, 0, 0.26);
  font-family: "Consolas", "SFMono-Regular", monospace;
  font-size: clamp(11px, 1vw, 14px);
  font-weight: 700;
  text-align: center;
  white-space: nowrap;
}

.primary-action,
.secondary-action {
  display: block;
  width: min(100%, 270px);
  min-height: 49px;
  margin: 10px auto 0;
  padding: 11px 22px;
  border-radius: 7px;
  font-weight: 800;
  letter-spacing: 0.08em;
  cursor: pointer;
  transition: transform 150ms ease, filter 150ms ease, border-color 150ms ease;
}

.primary-action {
  color: #24170a;
  background: var(--orange-bright);
  border: 1px solid #ffc66f;
  box-shadow: 0 9px 24px rgba(222, 117, 16, 0.32);
}

.primary-action:hover {
  filter: brightness(1.08);
  transform: translateY(-1px);
}

.secondary-action {
  color: #d6dddd;
  background: #18232b;
  border: 1px solid rgba(220, 230, 229, 0.32);
}

.secondary-action:hover {
  color: #fff;
  border-color: rgba(255, 173, 60, 0.62);
}

.start-panel > small {
  display: block;
  margin-top: 13px;
  color: #7f8d8e;
  font-size: clamp(9px, 0.78vw, 11px);
  line-height: 1.5;
}

.pause-panel,
.result-panel {
  width: min(92%, 430px);
}

.pause-panel .panel-copy,
.result-panel .panel-copy {
  margin-bottom: 23px;
}

.result-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin: 21px 0;
}

.result-stats div {
  padding: 13px 10px;
  background: rgba(255, 255, 255, 0.035);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 7px;
}

.result-stats span {
  display: block;
  color: #8f9c9e;
  font-size: 10px;
  letter-spacing: 0.12em;
}

.result-stats strong {
  display: block;
  margin-top: 6px;
  color: #f4f3ec;
  font-family: "Consolas", "SFMono-Regular", monospace;
  font-size: 23px;
  font-variant-numeric: tabular-nums;
}

.secondary-link {
  display: inline-block;
  margin-top: 15px;
  color: #aab7b8;
  font-size: 12px;
}

.secondary-link:hover {
  color: #fff;
}

.orientation-overlay {
  display: none;
}

.orientation-panel {
  width: min(88%, 420px);
}

.mobile-controls {
  position: absolute;
  z-index: 10;
  inset: auto 0 clamp(13px, 2.4vw, 30px);
  display: flex;
  align-items: end;
  justify-content: space-between;
  padding: 0 clamp(16px, 3vw, 38px);
  opacity: 0.78;
  pointer-events: none;
}

.joystick {
  position: relative;
  width: clamp(94px, 13vw, 132px);
  height: clamp(94px, 13vw, 132px);
  flex: 0 0 auto;
  color: #dce4e3;
  background: rgba(13, 23, 28, 0.68);
  border: 2px solid rgba(232, 238, 236, 0.58);
  border-radius: 50%;
  box-shadow: inset 0 0 0 8px rgba(0, 0, 0, 0.18), 0 9px 28px rgba(0, 0, 0, 0.36);
  pointer-events: auto;
  touch-action: none;
}

.joystick-knob {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 49%;
  height: 49%;
  background: rgba(81, 95, 99, 0.92);
  border: 2px solid rgba(235, 240, 238, 0.58);
  border-radius: 50%;
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.38), inset 0 0 0 3px rgba(255, 255, 255, 0.035);
  transform: translate(-50%, -50%);
  transition: transform 60ms linear;
}

.joystick small {
  position: absolute;
  left: 50%;
  bottom: 8px;
  width: max-content;
  color: rgba(230, 237, 235, 0.73);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.12em;
  transform: translateX(-50%);
}

.altitude-controls {
  display: grid;
  gap: 8px;
  pointer-events: auto;
}

.altitude-controls button {
  width: clamp(68px, 8.3vw, 88px);
  height: clamp(68px, 8.3vw, 88px);
  padding: 0;
  color: #f0f3f1;
  background: rgba(16, 27, 32, 0.8);
  border: 2px solid rgba(232, 238, 236, 0.62);
  border-radius: 50%;
  box-shadow: inset 0 0 0 5px rgba(0, 0, 0, 0.16), 0 8px 22px rgba(0, 0, 0, 0.34);
  font-size: clamp(18px, 2vw, 25px);
  font-weight: 800;
  cursor: pointer;
  touch-action: none;
}

.altitude-controls button.is-active,
.altitude-controls button.is-pressed,
.altitude-controls button:active {
  color: #2b1904;
  background: var(--orange-bright);
  border-color: #ffe0a3;
  transform: scale(0.95);
}

.game-notes {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1px;
  background: rgba(255, 255, 255, 0.08);
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.game-notes div {
  min-height: 80px;
  padding: 18px clamp(16px, 2.5vw, 28px);
  background: #09121b;
}

.game-notes span {
  display: block;
  margin-bottom: 6px;
  color: #708184;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.16em;
}

.game-notes strong {
  color: #bac5c5;
  font-size: 12px;
  font-weight: 500;
  line-height: 1.65;
}

@media (hover: none), (pointer: coarse), (max-width: 900px) {
  .mobile-controls {
    display: flex;
    opacity: 1;
  }

  .desktop-guide {
    display: none;
  }

  .touch-guide {
    display: grid;
  }

  .site-actions a {
    display: none;
  }

  .start-panel {
    transform: none;
  }
}

@media (max-width: 760px) {
  .site-bar {
    height: 54px;
    padding: 7px 10px;
  }

  .brand {
    gap: 8px;
  }

  .brand img {
    width: 34px;
    height: 34px;
  }

  .brand strong {
    font-size: 17px;
  }

  .brand small {
    font-size: 8px;
  }

  .site-actions {
    gap: 5px;
  }

  .site-actions button {
    min-height: 32px;
    padding: 5px 8px;
    font-size: 11px;
  }

  .game-frame {
    width: min(100%, calc((100svh - 54px) * 16 / 9));
  }

  .flight-hud {
    top: 8px;
    left: 8px;
    width: calc(100% - 122px);
    min-height: 50px;
    padding: 5px;
    border-radius: 6px;
  }

  .hud-metric {
    padding: 1px 5px;
    gap: 3px;
  }

  .hud-metric > span {
    font-size: 7px;
  }

  .hud-metric strong {
    font-size: 11px;
  }

  .hud-metric b {
    display: none;
  }

  .meter-track {
    height: 5px;
  }

  .status-hud {
    top: 8px;
    right: 8px;
    width: 106px;
    min-height: 50px;
    padding: 5px 6px;
    gap: 2px 4px;
    border-radius: 6px;
  }

  .status-hud span {
    font-size: 6px;
  }

  .status-hud strong {
    font-size: 8px;
  }

  #timerValue {
    font-size: 11px;
  }

  #pauseButton {
    min-height: 18px;
    padding: 1px 5px;
    font-size: 7px;
  }

  .mission-intro {
    display: none;
  }

  .game-notes {
    grid-template-columns: 1fr;
  }

  .game-notes div:not(:first-child) {
    display: none;
  }
}

@media (orientation: portrait) and (max-width: 900px) {
  .orientation-overlay {
    position: fixed;
    z-index: 100;
    inset: 0;
    display: grid;
    place-items: center;
    padding: 22px;
    background-color: #071019;
  }
}

@media (orientation: landscape) and (max-height: 600px) {
  html,
  body,
  .game-page {
    width: 100%;
    height: 100svh;
    min-height: 0;
    overflow: hidden;
  }

  body,
  .game-page {
    display: grid;
    place-items: center;
  }

  .site-bar,
  .game-notes {
    display: none;
  }

  .game-frame {
    width: min(100vw, calc(100svh * 16 / 9));
    height: min(100svh, calc(100vw * 9 / 16));
    aspect-ratio: 16 / 9;
    box-shadow: none;
  }

  .overlay {
    padding: 10px;
  }

  .start-panel,
  .pause-panel,
  .result-panel {
    width: min(64%, 420px);
    max-height: calc(100svh - 18px);
    padding: 13px 22px;
    overflow-y: auto;
  }

  .panel-kicker {
    margin-bottom: 3px;
    font-size: 8px;
  }

  .start-panel h2,
  .pause-panel h2,
  .result-panel h2 {
    font-size: 23px;
  }

  .panel-copy {
    margin: 7px auto 9px;
    font-size: 9px;
    line-height: 1.45;
  }

  .control-guide {
    gap: 6px 12px;
    margin-bottom: 8px;
  }

  .control-guide span {
    font-size: 8px;
  }

  kbd {
    min-width: 30px;
    padding: 4px 6px;
    font-size: 9px;
  }

  .primary-action,
  .secondary-action {
    min-height: 36px;
    margin-top: 6px;
    padding: 7px 16px;
    font-size: 11px;
  }

  .start-panel > small {
    margin-top: 6px;
    font-size: 7px;
  }

  .result-stats {
    margin: 9px 0;
  }

  .result-stats div {
    padding: 7px;
  }

  .result-stats strong {
    font-size: 17px;
  }

  .secondary-link {
    margin-top: 7px;
    font-size: 9px;
  }

  .mobile-controls {
    bottom: 10px;
    padding: 0 14px;
  }

  .joystick {
    width: clamp(86px, 25vh, 116px);
    height: clamp(86px, 25vh, 116px);
  }

  .altitude-controls {
    gap: 5px;
  }

  .altitude-controls button {
    width: clamp(58px, 17vh, 76px);
    height: clamp(58px, 17vh, 76px);
    font-size: 18px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
