:root {
  --bg-ink: #081119;
  --bg-deep: #101d2e;
  --arcade-red: #ff5c43;
  --arcade-gold: #ffd36c;
  --arcade-cyan: #69f3d1;
  --arcade-paper: rgba(10, 16, 27, 0.78);
  --arcade-line: rgba(255, 255, 255, 0.12);
  --arcade-shadow: rgba(0, 0, 0, 0.4);
  --text-main: #f8f3e4;
  --text-soft: rgba(248, 243, 228, 0.78);
}

* {
  box-sizing: border-box;
}

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

body {
  position: relative;
  overflow-x: hidden;
  color: var(--text-main);
  font-family: "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
  overscroll-behavior: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  background:
    radial-gradient(circle at top, rgba(255, 102, 79, 0.18), transparent 30%),
    radial-gradient(circle at 20% 20%, rgba(105, 243, 209, 0.18), transparent 26%),
    radial-gradient(circle at 80% 10%, rgba(126, 140, 255, 0.12), transparent 24%),
    linear-gradient(180deg, #11223a 0%, #0a1018 58%, #05070c 100%);
}

.page-noise {
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.22;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.04) 1px, transparent 1px);
  background-size: 100% 4px, 4px 100%;
  mix-blend-mode: soft-light;
}

.cabinet {
  position: relative;
  max-width: 1480px;
  margin: 0 auto;
  padding: 28px 24px 40px;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(320px, 0.9fr);
  gap: 22px;
  align-items: stretch;
  margin-bottom: 22px;
}

.hero-copy,
.hero-panel,
.brief-card,
.stage-shell {
  position: relative;
  border: 1px solid var(--arcade-line);
  background:
    linear-gradient(180deg, rgba(19, 32, 48, 0.9), rgba(9, 14, 22, 0.92));
  box-shadow:
    0 24px 60px var(--arcade-shadow),
    inset 0 1px 0 rgba(255, 255, 255, 0.06);
  backdrop-filter: blur(12px);
}

.hero-copy,
.hero-panel {
  border-radius: 28px;
  padding: 28px 30px;
}

.hero-copy::after,
.hero-panel::after,
.brief-card::after,
.stage-shell::after {
  content: "";
  position: absolute;
  inset: 10px;
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: inherit;
  pointer-events: none;
}

.eyebrow {
  margin: 0 0 16px;
  color: var(--arcade-cyan);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.24em;
  text-transform: uppercase;
}

h1,
h2,
.home-title,
.leaderboard-head h3,
.mission-chip,
.control-bar span,
button {
  font-family: "Courier New", "Monaco", monospace;
}

h1 {
  margin: 0;
  max-width: 14ch;
  color: var(--arcade-paper);
  text-shadow:
    0 0 18px rgba(255, 211, 108, 0.36),
    0 0 34px rgba(255, 92, 67, 0.26);
  -webkit-text-stroke: 1px rgba(255, 210, 108, 0.32);
  color: #fff5d2;
  font-size: clamp(38px, 6vw, 72px);
  line-height: 1.03;
}

.dek {
  margin: 18px 0 0;
  max-width: 52ch;
  color: var(--text-soft);
  font-size: 17px;
  line-height: 1.8;
}

.hero-panel {
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  gap: 18px;
  background:
    radial-gradient(circle at top, rgba(255, 211, 108, 0.14), transparent 34%),
    linear-gradient(180deg, rgba(39, 18, 18, 0.92), rgba(12, 14, 25, 0.94));
}

.mission-chip {
  display: inline-flex;
  align-self: flex-start;
  padding: 10px 14px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.08);
  color: var(--arcade-gold);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.08em;
}

.action-row {
  display: grid;
  gap: 12px;
}

.home-logo {
  display: grid;
  gap: 8px;
}

.home-kicker {
  margin: 0;
  color: #69f3d1;
  font-family: "Courier New", "Monaco", monospace;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.2em;
  text-transform: uppercase;
}

.home-title {
  margin: 0;
  color: #fff1bf;
  font-size: clamp(30px, 4.2vw, 46px);
  line-height: 1;
  text-shadow:
    0 0 18px rgba(255, 211, 108, 0.32),
    0 0 30px rgba(255, 92, 67, 0.2);
}

.home-subtitle {
  margin: 0;
  color: rgba(248, 243, 228, 0.76);
  font-size: 14px;
  line-height: 1.7;
}

.player-lock-chip {
  display: inline-flex;
  align-self: flex-start;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: 999px;
  border: 1px solid rgba(105, 243, 209, 0.22);
  background: rgba(14, 24, 38, 0.74);
  color: #cffff2;
  font-family: "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.2;
}

.player-lock-chip::before {
  content: "";
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #69f3d1;
  box-shadow: 0 0 16px rgba(105, 243, 209, 0.45);
}

.player-lock-chip[hidden] {
  display: none;
}

.player-setup {
  display: grid;
  gap: 10px;
  padding: 14px;
  border-radius: 20px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.04);
}

.player-name-field {
  display: grid;
  gap: 8px;
}

.player-name-field span {
  color: #fff0bf;
  font-family: "Courier New", "Monaco", monospace;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.player-name-field input {
  width: 100%;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 14px;
  padding: 14px 16px;
  color: #fff8e0;
  background: rgba(6, 10, 18, 0.68);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
  font-size: 16px;
  font-family: "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
}

.player-name-field input:focus {
  outline: 2px solid rgba(255, 211, 108, 0.36);
  outline-offset: 2px;
}

.player-name-tip {
  margin: 0;
  color: rgba(248, 243, 228, 0.68);
  font-size: 13px;
  line-height: 1.65;
}

body.name-locked .player-setup {
  display: none;
}

.leaderboard-card {
  display: grid;
  gap: 12px;
  padding: 16px;
  border-radius: 22px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background:
    linear-gradient(180deg, rgba(14, 24, 38, 0.78), rgba(8, 11, 19, 0.84));
}

.leaderboard-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.leaderboard-head h3 {
  margin: 0;
  color: #fff1bf;
  font-size: 20px;
}

.leaderboard-head span {
  color: rgba(248, 243, 228, 0.62);
  font-size: 12px;
  letter-spacing: 0.06em;
}

.leaderboard-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 8px;
  max-height: 280px;
  overflow: auto;
  padding-right: 4px;
}

.leaderboard-row,
.leaderboard-empty {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.04);
}

.leaderboard-empty {
  grid-template-columns: 1fr;
  color: rgba(248, 243, 228, 0.7);
  font-size: 13px;
}

.leaderboard-rank {
  color: #ffd36c;
  font-family: "Courier New", "Monaco", monospace;
  font-size: 15px;
  font-weight: 700;
}

.leaderboard-player {
  display: grid;
  gap: 2px;
}

.leaderboard-name {
  color: #fff6db;
  font-size: 14px;
  font-weight: 700;
}

.leaderboard-stage {
  color: rgba(248, 243, 228, 0.58);
  font-size: 12px;
}

.leaderboard-score {
  color: #69f3d1;
  font-family: "Courier New", "Monaco", monospace;
  font-size: 14px;
  font-weight: 700;
}

button {
  appearance: none;
  border: 0;
  border-radius: 16px;
  padding: 14px 18px;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: #0d1420;
  background:
    linear-gradient(180deg, #ffe2a1 0%, #ff9d57 52%, #ff6844 100%);
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, 0.34),
    0 10px 24px rgba(255, 104, 68, 0.28);
  transition: transform 140ms ease, box-shadow 140ms ease, filter 140ms ease;
}

button:hover {
  transform: translateY(-1px);
  filter: saturate(1.08);
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, 0.4),
    0 14px 28px rgba(255, 104, 68, 0.36);
}

button:active {
  transform: translateY(1px);
}

.briefing {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
  margin-bottom: 22px;
}

.brief-card {
  min-height: 188px;
  border-radius: 24px;
  padding: 24px 24px 22px;
}

.brief-tag {
  display: inline-block;
  margin-bottom: 14px;
  color: var(--arcade-cyan);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.22em;
  text-transform: uppercase;
}

h2 {
  margin: 0 0 12px;
  color: #fff0be;
  font-size: 25px;
  line-height: 1.24;
}

.brief-card p {
  margin: 0;
  color: var(--text-soft);
  font-size: 15px;
  line-height: 1.75;
}

.stage-shell {
  --touch-stick-size: clamp(86px, 10vw, 112px);
  --touch-action-size: clamp(74px, 8vw, 96px);
  --touch-side-space: calc(var(--touch-stick-size) + 40px);
  --touch-top-space: 46px;
  border-radius: 34px;
  padding: 18px;
  overflow: hidden;
  background:
    linear-gradient(180deg, rgba(13, 20, 33, 0.96), rgba(5, 8, 14, 0.98));
}

.world-strip {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 10px;
  margin: 0 0 22px;
}

.world-strip span {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 62px;
  padding: 10px 12px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 18px;
  background:
    linear-gradient(180deg, rgba(18, 28, 43, 0.92), rgba(8, 12, 22, 0.92));
  box-shadow:
    0 12px 32px rgba(0, 0, 0, 0.25),
    inset 0 1px 0 rgba(255, 255, 255, 0.05);
  color: #fff0c0;
  font-family: "Courier New", "Monaco", monospace;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-align: center;
}

.world-strip span.active {
  border-color: rgba(255, 211, 108, 0.45);
  background:
    linear-gradient(180deg, rgba(88, 49, 24, 0.94), rgba(26, 14, 15, 0.94));
  box-shadow:
    0 16px 36px rgba(255, 118, 72, 0.22),
    inset 0 0 0 1px rgba(255, 211, 108, 0.1);
  color: #fff6d8;
}

canvas {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 22px;
  border: 3px solid rgba(255, 255, 255, 0.08);
  background: #0f1624;
  box-shadow:
    inset 0 0 0 2px rgba(255, 255, 255, 0.04),
    0 24px 70px rgba(0, 0, 0, 0.42),
    0 0 60px rgba(105, 243, 209, 0.08);
  touch-action: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

.game-frame {
  position: relative;
  width: 100%;
  max-width: 1280px;
  margin: 0 auto;
  z-index: 1;
}

.control-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
}

.control-bar span {
  padding: 9px 12px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.06);
  color: #fff0bf;
  font-size: 12px;
  letter-spacing: 0.05em;
}

.mobile-hint,
.touch-overlay {
  display: none;
}

.mobile-hint {
  margin-bottom: 12px;
  padding: 10px 14px;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.06);
  color: #fff0bf;
  font-family: "Courier New", "Monaco", monospace;
  font-size: 12px;
  letter-spacing: 0.04em;
}

.touch-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 3;
}

.touch-top-actions {
  position: absolute;
  top: 104px;
  right: 16px;
  display: flex;
  gap: 10px;
  pointer-events: auto;
  opacity: 0.46;
}

.touch-action-btn {
  appearance: none;
  border: 1px solid rgba(182, 238, 255, 0.16);
  border-radius: 999px;
  width: var(--touch-action-size);
  height: var(--touch-action-size);
  min-width: 0;
  min-height: 0;
  padding: 0;
  color: #fff6da;
  background:
    radial-gradient(circle at 35% 28%, rgba(255, 255, 255, 0.14), transparent 34%),
    radial-gradient(circle at 70% 76%, rgba(105, 243, 209, 0.08), transparent 34%),
    linear-gradient(180deg, rgba(22, 42, 62, 0.42), rgba(7, 14, 24, 0.56));
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.05),
    0 10px 22px rgba(0, 0, 0, 0.12);
  backdrop-filter: blur(10px);
  pointer-events: auto;
  touch-action: none;
  opacity: 0.74;
}

.touch-action-btn.is-active {
  transform: scale(0.97);
  border-color: rgba(150, 236, 255, 0.42);
  background:
    radial-gradient(circle at 35% 28%, rgba(255, 255, 255, 0.18), transparent 34%),
    radial-gradient(circle at 68% 72%, rgba(105, 243, 209, 0.14), transparent 34%),
    linear-gradient(180deg, rgba(34, 74, 106, 0.82), rgba(9, 22, 36, 0.9));
}

.touch-stick {
  --stick-x: 0px;
  --stick-y: 0px;
  position: absolute;
  bottom: 16px;
  width: var(--touch-stick-size);
  height: var(--touch-stick-size);
  pointer-events: auto;
  touch-action: none;
  user-select: none;
  opacity: 0.58;
  transition: opacity 120ms ease;
}

.touch-stick-move {
  left: 12px;
}

.touch-stick-ring,
.touch-stick-guide,
.touch-stick-knob {
  position: absolute;
  border-radius: 50%;
}

.touch-stick-ring {
  inset: 0;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background:
    radial-gradient(circle at 35% 28%, rgba(255, 255, 255, 0.08), transparent 34%),
    radial-gradient(circle at 50% 50%, rgba(120, 188, 255, 0.08), rgba(8, 12, 20, 0.12) 58%, rgba(3, 5, 12, 0.28) 100%);
  box-shadow:
    inset 0 0 0 8px rgba(255, 255, 255, 0.02),
    inset 0 0 16px rgba(105, 243, 209, 0.06),
    0 12px 20px rgba(0, 0, 0, 0.12);
  backdrop-filter: blur(8px);
}

.touch-stick-guide {
  inset: 14px;
  border: 1px dashed rgba(255, 255, 255, 0.11);
  opacity: 0.58;
}

.touch-stick-guide::before,
.touch-stick-guide::after {
  content: "";
  position: absolute;
  background: rgba(255, 255, 255, 0.12);
}

.touch-stick-guide::before {
  top: 50%;
  left: 10px;
  right: 10px;
  height: 1px;
  transform: translateY(-50%);
}

.touch-stick-guide::after {
  top: 10px;
  bottom: 10px;
  left: 50%;
  width: 1px;
  transform: translateX(-50%);
}

.touch-stick-knob {
  left: 50%;
  top: 50%;
  width: 44px;
  height: 44px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background:
    radial-gradient(circle at 35% 30%, rgba(255, 255, 255, 0.18), rgba(255, 255, 255, 0.04) 36%, rgba(10, 16, 30, 0.7) 100%);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.12),
    0 8px 14px rgba(0, 0, 0, 0.18);
  transform: translate(calc(-50% + var(--stick-x)), calc(-50% + var(--stick-y)));
}

.touch-action-cluster {
  position: absolute;
  right: 12px;
  bottom: 18px;
  width: calc(var(--touch-action-size) * 2.45);
  height: calc(var(--touch-action-size) * 2.1);
  pointer-events: auto;
}

.touch-action-cluster .touch-action-btn {
  position: absolute;
}

.touch-action-btn-utility {
  width: 56px;
  height: 56px;
  border-color: rgba(154, 232, 255, 0.18);
}

.touch-action-btn-jump {
  right: calc(var(--touch-action-size) * 0.42);
  bottom: calc(var(--touch-action-size) * 0.92);
  width: calc(var(--touch-action-size) * 0.96);
  height: calc(var(--touch-action-size) * 0.96);
}

.touch-action-btn-fire {
  right: 0;
  bottom: 0;
  width: calc(var(--touch-action-size) * 1.14);
  height: calc(var(--touch-action-size) * 1.14);
  border-color: rgba(154, 232, 255, 0.22);
}

.touch-action-btn-fire.is-active {
  border-color: rgba(150, 236, 255, 0.44);
}

.touch-action-btn-jump::before,
.touch-action-btn-fire::before {
  content: "";
  position: absolute;
  inset: 7px;
  border-radius: inherit;
  pointer-events: none;
}

.touch-action-btn-jump::before {
  border: 1px solid rgba(202, 246, 255, 0.14);
}

.touch-action-btn-fire::before {
  border: 1px solid rgba(202, 246, 255, 0.14);
}

.touch-action-icon {
  position: relative;
  display: block;
  width: 100%;
  height: 100%;
}

.touch-action-icon::before,
.touch-action-icon::after {
  content: "";
  position: absolute;
}

.touch-action-icon-jump::before {
  left: 50%;
  top: 48%;
  width: 16px;
  height: 16px;
  border-top: 4px solid rgba(244, 252, 255, 0.96);
  border-left: 4px solid rgba(244, 252, 255, 0.96);
  transform: translate(-50%, -42%) rotate(45deg);
}

.touch-action-icon-jump::after {
  left: 50%;
  top: 54%;
  width: 24px;
  height: 10px;
  border-radius: 999px;
  border: 3px solid rgba(244, 252, 255, 0.86);
  border-top: 0;
  background: transparent;
  box-sizing: border-box;
  transform: translateX(-50%);
}

.touch-action-btn-jump .touch-action-icon::after {
  box-shadow:
    -16px -18px 0 -2px rgba(180, 238, 255, 0.76),
    16px -14px 0 -2px rgba(180, 238, 255, 0.62);
}

.touch-action-btn-jump .touch-action-icon::before {
  filter: drop-shadow(0 0 10px rgba(140, 224, 255, 0.18));
}

.touch-action-icon-fire::before {
  left: 50%;
  top: 50%;
  width: 22px;
  height: 22px;
  border: 4px solid rgba(255, 241, 219, 0.94);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  box-shadow: 0 0 20px rgba(255, 147, 92, 0.18);
}

.touch-action-icon-fire::after {
  left: 50%;
  top: 50%;
  width: 8px;
  height: 8px;
  background: rgba(255, 241, 219, 0.98);
  border-radius: 50%;
  transform: translate(-50%, -50%);
}

.touch-action-icon-swap::before {
  left: 50%;
  top: 18px;
  width: 22px;
  height: 8px;
  background: rgba(236, 248, 255, 0.9);
  border-radius: 4px 6px 6px 4px;
  box-shadow:
    8px 0 0 -2px rgba(236, 248, 255, 0.9),
    0 9px 0 -2px rgba(105, 243, 209, 0.7);
  transform: translateX(-50%);
}

.touch-action-icon-swap::after {
  left: 50%;
  top: 31px;
  width: 18px;
  height: 12px;
  border: 3px solid rgba(236, 248, 255, 0.88);
  border-top: 0;
  border-right: 0;
  border-radius: 0 0 0 10px;
  transform: translateX(-50%) rotate(-12deg);
}

.touch-stick.is-active {
  opacity: 0.9;
}

.touch-stick.is-active .touch-stick-ring {
  border-color: rgba(255, 211, 108, 0.35);
  box-shadow:
    inset 0 0 0 8px rgba(255, 255, 255, 0.03),
    inset 0 0 20px rgba(105, 243, 209, 0.12),
    0 14px 24px rgba(255, 111, 76, 0.16);
}

@media (max-width: 1100px) {
  .hero {
    grid-template-columns: 1fr;
  }

  .briefing {
    grid-template-columns: 1fr;
  }

  .world-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 720px) {
  .cabinet {
    padding: 18px 14px 28px;
  }

  .hero-copy,
  .hero-panel,
  .brief-card,
  .stage-shell {
    border-radius: 22px;
  }

  .hero-copy,
  .hero-panel {
    padding: 22px 20px;
  }

  .brief-card {
    min-height: auto;
    padding: 20px;
  }

  .stage-shell {
    padding: 12px;
  }

  .world-strip {
    grid-template-columns: 1fr;
  }

  .mobile-hint {
    display: block;
  }

  .control-bar {
    gap: 8px;
  }

  .control-bar span {
    font-size: 11px;
  }

  .touch-overlay {
    display: block;
  }

  .touch-stick {
    --touch-stick-size: 92px;
    bottom: 12px;
  }

  .touch-stick-move {
    left: 12px;
  }

    .touch-action-cluster {
      right: 12px;
    }
  }

@media (orientation: landscape) and (hover: none) and (pointer: coarse) {
  .stage-shell {
    padding-top: calc(max(8px, env(safe-area-inset-top)) + var(--touch-top-space));
    padding-bottom: 10px;
    padding-left: calc(max(8px, env(safe-area-inset-left)) + var(--touch-side-space));
    padding-right: calc(max(8px, env(safe-area-inset-right)) + var(--touch-side-space));
    border-radius: 20px;
  }

  .mobile-hint {
    display: block;
    margin-bottom: 6px;
    padding: 8px 12px;
    opacity: 0.82;
  }

  .touch-overlay {
    display: block;
  }

  .touch-top-actions {
    top: max(10px, env(safe-area-inset-top));
    right: max(8px, env(safe-area-inset-right));
    gap: 8px;
  }

  .touch-action-btn {
    width: var(--touch-action-size);
    height: var(--touch-action-size);
  }

  .touch-stick {
    --touch-stick-size: clamp(84px, 9vw, 102px);
    bottom:
      max(12px, env(safe-area-inset-bottom));
  }

  .touch-stick-move {
    left:
      max(8px, env(safe-area-inset-left));
  }

  .touch-action-cluster {
    right:
      max(8px, env(safe-area-inset-right));
  }

  body.mobile-game-active {
    overflow: hidden;
  }

  body.mobile-game-active .hero,
  body.mobile-game-active .briefing,
  body.mobile-game-active .world-strip,
  body.mobile-game-active .control-bar,
  body.mobile-game-active .mobile-hint {
    display: none;
  }

  body.mobile-game-active .cabinet {
    display: flex;
    max-width: none;
    min-height: 100dvh;
    padding:
      max(6px, env(safe-area-inset-top))
      max(6px, env(safe-area-inset-right))
      max(6px, env(safe-area-inset-bottom))
      max(6px, env(safe-area-inset-left));
  }

  body.mobile-game-active .stage-shell {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding-top: calc(max(8px, env(safe-area-inset-top)) + var(--touch-top-space));
    padding-bottom: max(8px, env(safe-area-inset-bottom));
  }

  body.mobile-game-active .game-frame {
    width: 100%;
    max-width: none;
  }

  body.mobile-game-active canvas {
    max-height: calc(100dvh - max(20px, env(safe-area-inset-top)) - max(20px, env(safe-area-inset-bottom)));
  }
}

@media (orientation: portrait) and (hover: none) and (pointer: coarse) {
  .cabinet {
    padding:
      max(18px, env(safe-area-inset-top))
      max(14px, env(safe-area-inset-right))
      max(28px, env(safe-area-inset-bottom))
      max(14px, env(safe-area-inset-left));
  }

  .mobile-hint::after {
    content: "，横屏效果更好";
  }
}

@media (hover: none) and (pointer: coarse) {
  body:not(.mobile-game-active) {
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  body:not(.mobile-game-active) .hero-copy,
  body:not(.mobile-game-active) .briefing,
  body:not(.mobile-game-active) .world-strip,
  body:not(.mobile-game-active) .stage-shell {
    display: none;
  }

  body:not(.mobile-game-active) .cabinet {
    min-height: auto;
    display: block;
    padding:
      max(20px, env(safe-area-inset-top))
      max(18px, env(safe-area-inset-right))
      max(80px, env(safe-area-inset-bottom))
      max(18px, env(safe-area-inset-left));
  }

  body:not(.mobile-game-active) .hero {
    width: 100%;
    max-width: 420px;
    margin: 0 auto;
    grid-template-columns: 1fr;
  }

  body:not(.mobile-game-active) .hero-panel {
    min-height: 0;
    height: auto;
    display: flex;
    align-items: stretch;
    justify-content: flex-start;
    border-radius: 30px;
    padding: 22px 20px;
    overflow: visible;
    touch-action: auto;
  }

  body:not(.mobile-game-active) .mission-chip {
    display: none;
  }

  body:not(.mobile-game-active) .home-logo {
    gap: 4px;
  }

  body:not(.mobile-game-active) .home-subtitle {
    font-size: 13px;
    line-height: 1.45;
  }

  body:not(.mobile-game-active) .player-setup {
    gap: 8px;
    padding: 10px;
  }

  body:not(.mobile-game-active) .action-row {
    width: 100%;
    display: grid;
    gap: 10px;
  }

  body:not(.mobile-game-active) .action-row button {
    width: 100%;
    min-height: 52px;
    font-size: 17px;
  }

  body:not(.mobile-game-active) .leaderboard-card {
    max-height: none;
    overflow: visible;
    touch-action: auto;
  }

  body.mobile-game-active {
    overflow: hidden;
    background: #05070c;
  }

  body.mobile-game-active .hero,
  body.mobile-game-active .briefing,
  body.mobile-game-active .world-strip,
  body.mobile-game-active .control-bar,
  body.mobile-game-active .mobile-hint {
    display: none;
  }

  body.mobile-game-active .cabinet {
    max-width: none;
    margin: 0;
    padding: 0;
  }

  body.mobile-game-active .stage-shell {
    display: block;
    position: fixed;
    inset: 0;
    width: 100vw;
    height: 100vh;
    height: 100lvh;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: #05070c;
    z-index: 20;
  }

  body.mobile-game-active .stage-shell::after {
    display: none;
  }

  body.mobile-game-active .game-frame {
    position: absolute;
    inset: 0;
    width: 100vw;
    height: 100vh;
    height: 100lvh;
    max-width: none;
    margin: 0;
  }

  body.mobile-game-active canvas {
    width: 100vw;
    height: 100vh;
    height: 100lvh;
    max-height: none;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    background: #05070c;
  }

  body.mobile-game-active .touch-overlay {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 24;
  }

  body.mobile-game-active .touch-top-actions {
    top: max(92px, calc(env(safe-area-inset-top) + 82px));
    right: max(16px, env(safe-area-inset-right));
    gap: 8px;
    opacity: 0.48;
  }

  body.mobile-game-active .touch-action-btn {
    width: var(--touch-action-size);
    height: var(--touch-action-size);
  }

  body.mobile-game-active .touch-stick {
    --touch-stick-size: clamp(82px, 23vw, 104px);
    bottom: max(14px, env(safe-area-inset-bottom));
    opacity: 0.28;
  }

  body.mobile-game-active .touch-stick.is-active {
    opacity: 0.78;
  }

  body.mobile-game-active .touch-stick-move {
    left: max(4px, env(safe-area-inset-left));
  }

  body.mobile-game-active .touch-action-cluster {
    right: max(18px, env(safe-area-inset-right));
    bottom: max(26px, env(safe-area-inset-bottom));
  }

  body.mobile-game-active.mobile-game-portrait .stage-shell {
    overflow: hidden;
  }

  body.mobile-game-active.mobile-game-portrait .game-frame,
  body.mobile-game-active.mobile-game-portrait .touch-overlay {
    inset: auto;
    top: 50%;
    left: 50%;
    width: 100lvh;
    height: 100vw;
    transform: translate(-50%, -50%) rotate(90deg);
    transform-origin: center center;
  }

  body.mobile-game-active.mobile-game-portrait canvas {
    width: 100%;
    height: 100%;
  }
}
