:root {
  color-scheme: dark;
  --ink: #f7f1e3;
  --muted: #a8a294;
  --red: #e6402f;
  --red-deep: #9a1d18;
  --gold: #f2c14e;
  --panel: #0b0f16;
  --line: rgba(247, 241, 227, 0.14);
  --font: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
    "Noto Sans CJK SC", "Microsoft YaHei", sans-serif;
  --display: "Arial Black", "Avenir Next Heavy", "PingFang SC", var(--font);
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: #05070b;
  color: var(--ink);
  font-family: var(--font);
  overscroll-behavior: none;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

#game,
#game canvas {
  touch-action: none;
}

button {
  font-family: inherit;
  color: inherit;
}

#game {
  position: fixed;
  inset: 0;
  background: radial-gradient(circle at 50% 42%, #131a28 0, #070a10 58%, #030407 100%);
}

/* ---------- boot ---------- */

#boot {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 24px 20px calc(120px + env(safe-area-inset-bottom));
  pointer-events: none;
  text-align: center;
  background:
    radial-gradient(circle at 50% 36%, rgba(230, 64, 47, 0.16), transparent 38%),
    radial-gradient(circle at 50% 110%, rgba(242, 193, 78, 0.08), transparent 45%),
    #070a10;
  transition: opacity 0.5s ease, visibility 0.5s ease;
}

#boot::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image: repeating-linear-gradient(
    to bottom,
    rgba(255, 255, 255, 0.035) 0 1px,
    transparent 1px 3px
  );
  opacity: 0.5;
  pointer-events: none;
}

#boot::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 50% 50%, transparent 45%, rgba(0, 0, 0, 0.62) 100%);
  pointer-events: none;
}

#boot.is-hidden {
  opacity: 0;
  visibility: hidden;
}

.boot-frame {
  position: relative;
  z-index: 1;
  display: grid;
  justify-items: center;
  gap: 10px;
  max-width: 680px;
}

.eyebrow {
  margin: 0;
  color: var(--gold);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.34em;
  text-transform: uppercase;
}

.logo {
  margin: 4px 0 0;
  font-family: var(--display);
  font-size: clamp(64px, 15vw, 150px);
  font-weight: 900;
  line-height: 0.94;
  letter-spacing: 0.06em;
  background: linear-gradient(180deg, #fff6df 4%, #f6cf83 42%, #ec7a3f 68%, #c62c1e 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  transform: skewX(-5deg);
  filter: drop-shadow(0 6px 0 rgba(122, 20, 16, 0.85)) drop-shadow(0 18px 40px rgba(230, 64, 47, 0.38));
}

.logo-en {
  margin: -2px 0 0;
  padding-left: 0.62em;
  color: var(--red);
  font-size: clamp(11px, 1.7vw, 15px);
  font-weight: 800;
  letter-spacing: 0.62em;
}

.boot-sub {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: clamp(12px, 2.4vw, 14px);
  letter-spacing: 0.16em;
}

.boot-chips {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin-top: 8px;
}

.boot-chips span {
  padding: 6px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--ink);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
}

.boot-chips span em {
  color: var(--gold);
  font-style: normal;
}

.boot-load {
  display: grid;
  gap: 10px;
  width: min(420px, 72vw);
  margin-top: 18px;
}

.boot-track {
  position: relative;
  height: 8px;
  border-radius: 999px;
  background: rgba(247, 241, 227, 0.12);
  box-shadow: inset 0 0 0 1px rgba(247, 241, 227, 0.08);
  overflow: hidden;
}

.boot-fill {
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #f2c14e, #ec7a3f 55%, #e6402f);
  box-shadow: 0 0 18px rgba(236, 122, 63, 0.55);
  transition: width 0.18s linear;
}

.boot-track.is-waiting .boot-fill {
  width: 32% !important;
  animation: boot-slide 1.1s ease-in-out infinite;
}

.boot-load-meta {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-align: left;
}

.boot-load-meta b {
  color: var(--gold);
  font-variant-numeric: tabular-nums;
}

#boot.is-loading .boot-sub {
  color: var(--gold);
  animation: boot-blink 1.15s ease-in-out infinite;
}

@keyframes boot-blink {
  0%, 100% { opacity: 0.45; }
  50% { opacity: 1; }
}

@keyframes boot-slide {
  0% { transform: translateX(-110%); }
  100% { transform: translateX(320%); }
}

/* 自动启动：EJS 自带的开始按钮与加载文字不再需要，进度由页面统一显示 */

body .ejs_start_button,
body .ejs_loading_text {
  display: none !important;
}

/* ---------- top bar ---------- */

.topbar {
  position: fixed;
  z-index: 70;
  top: calc(10px + env(safe-area-inset-top));
  left: calc(12px + env(safe-area-inset-left));
  display: flex;
  align-items: center;
  gap: 8px;
}

#help-toggle {
  height: 34px;
  padding: 0 14px;
  border: 1px solid rgba(247, 241, 227, 0.28);
  border-radius: 999px;
  background: rgba(8, 11, 18, 0.68);
  color: var(--ink);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.12em;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  cursor: pointer;
}

.lang-select {
  height: 34px;
  padding: 0 24px 0 11px;
  border: 1px solid rgba(247, 241, 227, 0.22);
  border-radius: 999px;
  background-color: rgba(8, 11, 18, 0.68);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%23a8a294' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 9px center;
  color: var(--ink);
  font-family: inherit;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  appearance: none;
  -webkit-appearance: none;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  cursor: pointer;
}

.lang-select:focus-visible {
  outline: 2px solid rgba(120, 245, 255, 0.9);
  outline-offset: 2px;
}

.lang-select option {
  background: #0b1119;
  color: var(--ink);
}

#help-toggle:hover {
  border-color: rgba(242, 193, 78, 0.7);
  color: var(--gold);
}

#badges {
  position: fixed;
  z-index: 60;
  top: calc(10px + env(safe-area-inset-top));
  right: calc(12px + env(safe-area-inset-right));
  display: flex;
  gap: 7px;
  pointer-events: none;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 34px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(8, 11, 18, 0.68);
  color: var(--ink);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  white-space: nowrap;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.badge i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--gold);
  box-shadow: 0 0 10px rgba(242, 193, 78, 0.8);
}

.badge-fire i {
  background: var(--red);
  box-shadow: 0 0 10px rgba(230, 64, 47, 0.85);
}

.badge-fire.is-hot {
  border-color: rgba(230, 64, 47, 0.8);
  color: #ffe6dd;
}

.badge-fire.is-hot i {
  animation: fire-pulse 0.42s ease-in-out infinite;
}

@keyframes fire-pulse {
  0%, 100% { opacity: 0.35; transform: scale(0.8); }
  50% { opacity: 1; transform: scale(1.25); }
}

/* ---------- help ---------- */

.help {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: grid;
  place-items: center;
  padding: max(14px, env(safe-area-inset-top)) 14px max(14px, env(safe-area-inset-bottom));
  background: rgba(3, 5, 8, 0.78);
  backdrop-filter: blur(7px);
  -webkit-backdrop-filter: blur(7px);
}

.help[hidden] {
  display: none;
}

.help-card {
  width: min(560px, 100%);
  max-height: min(88vh, 780px);
  overflow: auto;
  padding: clamp(18px, 3.4vw, 28px);
  border: 1px solid rgba(247, 241, 227, 0.16);
  border-radius: 20px;
  background:
    linear-gradient(180deg, rgba(242, 193, 78, 0.06), transparent 30%),
    linear-gradient(180deg, #0d141f 0%, #080b11 100%);
  box-shadow: 0 34px 90px rgba(0, 0, 0, 0.7);
  touch-action: pan-y;
  overscroll-behavior: contain;
}

.help-card::-webkit-scrollbar {
  width: 6px;
}

.help-card::-webkit-scrollbar-thumb {
  border-radius: 99px;
  background: rgba(247, 241, 227, 0.22);
}

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

.help-head h2 {
  margin: 4px 0 0;
  font-size: clamp(20px, 4vw, 24px);
  letter-spacing: 0.06em;
}

.icon-btn {
  flex: none;
  width: 36px;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.04);
  color: var(--muted);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}

.icon-btn:hover {
  color: var(--ink);
  border-color: rgba(247, 241, 227, 0.4);
}

.help-lead {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.7;
}

.cheat-note {
  display: flex;
  gap: 12px;
  margin: 16px 0 4px;
  padding: 13px 15px;
  border-left: 3px solid var(--red);
  border-radius: 4px 12px 12px 4px;
  background: rgba(230, 64, 47, 0.09);
}

.cheat-dot {
  flex: none;
  width: 8px;
  height: 8px;
  margin-top: 6px;
  border-radius: 50%;
  background: var(--red);
  box-shadow: 0 0 12px rgba(230, 64, 47, 0.9);
}

.cheat-note strong {
  font-size: 14px;
  letter-spacing: 0.04em;
}

.cheat-note p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.6;
}

.help-card h3 {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 22px 0 10px;
  color: var(--gold);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.26em;
  text-transform: uppercase;
}

.help-card h3::after {
  content: "";
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, rgba(242, 193, 78, 0.32), transparent);
}

.key-list,
.tips {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.key-list li {
  display: flex;
  align-items: baseline;
  gap: 12px;
  font-size: 13px;
  line-height: 1.5;
}

.key-list li b {
  flex: none;
  width: 96px;
  color: var(--ink);
  font-weight: 700;
}

.key-list li span {
  color: var(--muted);
}

.tips {
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.65;
}

.tips li {
  position: relative;
  padding-left: 16px;
}

.tips li::before {
  content: "";
  position: absolute;
  top: 0.62em;
  left: 2px;
  width: 5px;
  height: 5px;
  border-radius: 1px;
  background: var(--red);
  transform: rotate(45deg);
}

.help-actions {
  position: sticky;
  bottom: calc(-1 * clamp(18px, 3.4vw, 28px));
  display: grid;
  grid-template-columns: 1fr 1.6fr;
  gap: 10px;
  margin-top: 22px;
  padding: 18px 0 clamp(18px, 3.4vw, 28px);
  background: #080b11;
  box-shadow: 0 -14px 22px #080b11;
}

.ghost-btn,
.primary-btn {
  height: 48px;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.08em;
  cursor: pointer;
}

.ghost-btn {
  border: 1px solid rgba(247, 241, 227, 0.24);
  background: rgba(255, 255, 255, 0.04);
  color: var(--ink);
}

.ghost-btn:hover {
  border-color: rgba(247, 241, 227, 0.5);
}

.primary-btn {
  border: 0;
  background: linear-gradient(180deg, #f26a4b, #ce3323);
  color: #fff9ec;
  box-shadow: 0 10px 26px rgba(230, 64, 47, 0.28);
}

.primary-btn:hover {
  filter: brightness(1.06);
}

.legal {
  margin: 18px 0 0;
  color: rgba(168, 162, 148, 0.66);
  font-size: 11px;
  line-height: 1.6;
}

/* ---------- fatal / noscript ---------- */

#fatal {
  position: fixed;
  inset: 0;
  z-index: 120;
  display: grid;
  place-items: center;
  padding: 28px;
  background: #06080d;
  color: #ffe9e3;
  font: 13px/1.7 ui-monospace, SFMono-Regular, Menlo, monospace;
  white-space: pre-wrap;
  text-align: center;
}

#fatal[hidden] {
  display: none;
}

.noscript {
  position: fixed;
  inset: 0;
  z-index: 130;
  display: grid;
  place-items: center;
  padding: 24px;
  background: #06080d;
  color: var(--ink);
  font-size: 14px;
  text-align: center;
}

/* ---------- EmulatorJS overrides (runtime CSS loads after this file) ---------- */

body .ejs_parent {
  background: #05070b;
}

/* 手机触控由页面自己的摇杆接管，EJS 自带虚拟手柄全部隐藏。 */
body .ejs_virtualGamepad_parent {
  display: none !important;
}

body .ejs_menu_bar {
  background: linear-gradient(180deg, rgba(9, 13, 20, 0.4), rgba(9, 13, 20, 0.92));
}

body .ejs_settings_parent,
body .ejs_popup_parent {
  --ejs-primary-color: 230, 64, 47;
}

/* ---------- mobile touch controls ---------- */

.safe-probe {
  position: fixed;
  inset: 0;
  padding: env(safe-area-inset-top) env(safe-area-inset-right)
    env(safe-area-inset-bottom) env(safe-area-inset-left);
  visibility: hidden;
  pointer-events: none;
}

#touch-ui {
  position: fixed;
  inset: 0;
  z-index: 45;
  pointer-events: none;
  touch-action: none;
}

#touch-ui[hidden] {
  display: none !important;
}

.touch-stick,
.touch-btn {
  position: absolute;
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  color: var(--ink);
  font-family: inherit;
  pointer-events: auto;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

.touch-stick {
  border-radius: 50%;
}

.touch-stick-visual,
.touch-knob {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
}

.touch-stick-visual {
  width: var(--stick-d, 120px);
  height: var(--stick-d, 120px);
  filter: drop-shadow(0 10px 22px rgba(0, 0, 0, 0.45));
  transition: filter 0.16s ease;
}

.touch-stick-visual svg {
  display: block;
  width: 100%;
  height: 100%;
}

.touch-knob {
  width: calc(var(--stick-d, 120px) * 0.235);
  height: calc(var(--stick-d, 120px) * 0.235);
  border: 2px solid rgba(89, 235, 250, 0.38);
  border-radius: 50%;
  background: radial-gradient(circle at 50% 38%, rgba(16, 92, 108, 0.9), rgba(4, 32, 40, 0.86));
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.45), 0 0 0 1px rgba(0, 0, 0, 0.25) inset;
  transition: border-color 0.12s ease, box-shadow 0.12s ease;
}

.touch-knob span {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 20%;
  height: 20%;
  border-radius: 50%;
  background: rgba(89, 235, 250, 0.38);
  transform: translate(-50%, -50%);
}

.touch-stick.is-active .touch-stick-visual {
  filter: drop-shadow(0 0 14px rgba(89, 235, 250, 0.34));
}

.touch-stick.is-active .touch-knob {
  border-color: rgba(89, 235, 250, 0.92);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.45), 0 0 14px rgba(89, 235, 250, 0.4);
}

.touch-face {
  display: grid;
  place-items: center;
  border: 2px solid rgba(89, 235, 250, 0.4);
  border-radius: 50%;
  background:
    radial-gradient(circle at 50% 34%, rgba(20, 96, 112, 0.55), rgba(4, 26, 34, 0.9) 72%);
  color: rgba(224, 249, 252, 0.9);
  font-size: var(--face-font, 22px);
  font-weight: 800;
  letter-spacing: 0.02em;
  box-shadow:
    0 10px 22px rgba(0, 0, 0, 0.42),
    0 0 0 1px rgba(0, 0, 0, 0.3) inset;
  transition: transform 0.09s ease, border-color 0.09s ease, background 0.09s ease;
}

.touch-face.is-down {
  transform: scale(0.94);
  border-color: rgba(120, 245, 255, 0.95);
  background:
    radial-gradient(circle at 50% 34%, rgba(52, 176, 198, 0.75), rgba(8, 46, 58, 0.92) 74%);
  color: #fff;
  box-shadow: 0 0 18px rgba(89, 235, 250, 0.36);
}

.touch-face.is-b::after {
  content: var(--fire-tag, "连");
  position: absolute;
  right: -3px;
  bottom: -3px;
  width: auto;
  min-width: 18px;
  padding: 0 3px;
  height: 18px;
  border-radius: 9px;
  background: var(--red);
  color: #fff;
  font-size: 9px;
  font-weight: 800;
  line-height: 18px;
  text-align: center;
  box-shadow: 0 0 10px rgba(230, 64, 47, 0.7);
}

.touch-pill {
  display: grid;
  place-items: center;
  height: 26px;
  padding: 0 10px;
  border: 1px solid rgba(89, 235, 250, 0.32);
  border-radius: 999px;
  background: rgba(5, 22, 29, 0.72);
  color: rgba(216, 246, 250, 0.86);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  white-space: nowrap;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.touch-pill.is-down {
  border-color: rgba(120, 245, 255, 0.9);
  background: rgba(18, 74, 88, 0.86);
  color: #fff;
}

.touch-face:focus-visible,
.touch-pill:focus-visible {
  outline: 2px solid rgba(120, 245, 255, 0.9);
  outline-offset: 3px;
}

/* ---------- rotate to landscape ---------- */

#rotate {
  position: fixed;
  inset: 0;
  z-index: 65;
  display: grid;
  place-items: center;
  padding: 24px 20px calc(24px + env(safe-area-inset-bottom));
  background:
    radial-gradient(circle at 50% 34%, rgba(230, 64, 47, 0.16), transparent 42%),
    radial-gradient(circle at 50% 108%, rgba(89, 235, 250, 0.1), transparent 46%),
    rgba(5, 8, 13, 0.94);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

#rotate[hidden] {
  display: none !important;
}

.rotate-card {
  display: grid;
  justify-items: center;
  gap: 10px;
  width: min(420px, 100%);
  padding: 26px 22px 22px;
  border: 1px solid rgba(247, 241, 227, 0.14);
  border-radius: 20px;
  background: linear-gradient(180deg, rgba(16, 23, 34, 0.96), rgba(8, 12, 19, 0.98));
  box-shadow: 0 28px 70px rgba(0, 0, 0, 0.55);
  text-align: center;
}

.rotate-card h2 {
  margin: 2px 0 0;
  font-size: 21px;
  letter-spacing: 0.06em;
}

.rotate-lead {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.7;
}

.rotate-phone {
  position: relative;
  width: 92px;
  height: 52px;
  margin: 4px 0 26px;
  border: 2px solid rgba(242, 193, 78, 0.85);
  border-radius: 10px;
  background: rgba(6, 14, 20, 0.9);
  box-shadow: 0 0 22px rgba(242, 193, 78, 0.22);
  animation: rotate-hint 2.6s ease-in-out infinite;
}

.rotate-screen {
  position: absolute;
  inset: 4px 12px 4px 4px;
  border-radius: 4px;
  background:
    linear-gradient(135deg, rgba(89, 235, 250, 0.55), rgba(230, 64, 47, 0.5)),
    rgba(4, 12, 18, 0.9);
  opacity: 0.85;
}

.rotate-home {
  position: absolute;
  right: 5px;
  top: 50%;
  width: 5px;
  height: 5px;
  margin-top: -2.5px;
  border-radius: 50%;
  background: rgba(242, 193, 78, 0.8);
}

@keyframes rotate-hint {
  0%, 12% { transform: rotate(-90deg); }
  46%, 82% { transform: rotate(0deg); }
  100% { transform: rotate(-90deg); }
}

.rotate-actions {
  display: grid;
  gap: 10px;
  width: 100%;
  margin-top: 8px;
}

.rotate-actions .primary-btn,
.rotate-actions .ghost-btn {
  width: 100%;
}

.rotate-note {
  margin: 4px 0 0;
  color: var(--gold);
  font-size: 11px;
  letter-spacing: 0.06em;
}

.rotate-note[hidden] {
  display: none;
}

body.rotate-prompt .topbar,
body.rotate-prompt #badges {
  display: none;
}

/* ---------- language switch ---------- */

.lang-row {
  display: flex;
  gap: 4px;
  margin: 14px 0 2px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.03);
}

.lang-btn {
  flex: 1;
  height: 30px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-family: inherit;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  cursor: pointer;
}

.lang-btn:hover {
  color: var(--ink);
}

.lang-btn.is-active {
  background: rgba(89, 235, 250, 0.14);
  color: #a8f4ff;
}

.lang-btn:focus-visible {
  outline: 2px solid rgba(120, 245, 255, 0.9);
  outline-offset: 1px;
}

/* ---------- iOS Safari fullscreen guide ---------- */

#ios-guide {
  position: fixed;
  inset: 0;
  z-index: 72;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 20px 18px calc(20px + env(safe-area-inset-bottom));
  background: rgba(5, 8, 13, 0.96);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  overflow: auto;
  touch-action: pan-y;
  overscroll-behavior: contain;
}

#ios-guide[hidden] {
  display: none !important;
}

.ios-card {
  position: relative;
  width: min(440px, 100%);
  margin: auto 0;
  padding: 24px 20px 20px;
  border: 1px solid rgba(247, 241, 227, 0.14);
  border-radius: 20px;
  background: linear-gradient(180deg, rgba(16, 23, 34, 0.97), rgba(8, 12, 19, 0.99));
  box-shadow: 0 28px 70px rgba(0, 0, 0, 0.6);
}

.ios-card h2 {
  margin: 4px 0 0;
  font-size: 20px;
  letter-spacing: 0.04em;
}

.ios-close {
  position: absolute;
  top: 12px;
  right: 12px;
}

.ios-lead {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.7;
}

.ios-steps {
  display: grid;
  gap: 12px;
  margin: 16px 0 0;
  padding: 0;
  list-style: none;
}

.ios-steps li {
  display: grid;
  grid-template-columns: 34px 1fr;
  gap: 10px;
  align-items: start;
  padding: 10px 12px;
  border: 1px solid rgba(89, 235, 250, 0.14);
  border-radius: 12px;
  background: rgba(6, 14, 20, 0.6);
  text-align: left;
}

.ios-step-icon {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 9px;
  background: rgba(89, 235, 250, 0.12);
  color: #a8f4ff;
  font-size: 16px;
  font-weight: 700;
}

.ios-step-icon svg {
  width: 19px;
  height: 19px;
}

.ios-steps b {
  display: block;
  font-size: 13px;
  letter-spacing: 0.02em;
}

.ios-steps span:not(.ios-step-icon) {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.6;
}

.ios-note {
  margin: 14px 0 0;
  color: var(--gold);
  font-size: 11px;
  line-height: 1.6;
}

.ios-card .primary-btn {
  width: 100%;
  margin-top: 16px;
}

body.ios-guide-open #touch-ui,
body.ios-guide-open #touch-fullscreen {
  visibility: hidden;
}

/* 已经以主屏幕独立窗口打开时不需要全屏按钮。 */
body.is-standalone #touch-fullscreen {
  display: none !important;
}

.zoom-reset {
  position: fixed;
  left: 50%;
  bottom: calc(14px + env(safe-area-inset-bottom));
  z-index: 80;
  transform: translateX(-50%);
  padding: 9px 16px;
  border: 1px solid rgba(242, 193, 78, 0.6);
  border-radius: 999px;
  background: rgba(9, 14, 20, 0.92);
  color: var(--gold);
  font-size: 12px;
  letter-spacing: 0.04em;
  pointer-events: auto;
}

.zoom-reset[hidden] {
  display: none !important;
}

@media (max-height: 480px) {
  /* 矮横屏里说明面板本身要滚动，底部按钮改成随内容排列，避免盖住文字。 */
  .help-actions {
    position: static;
    padding-bottom: 0;
    background: none;
    box-shadow: none;
  }

  #ios-guide {
    padding: 10px 14px;
  }

  .ios-card {
    padding: 16px 16px 14px;
  }

  .ios-card h2 {
    font-size: 17px;
  }

  .ios-lead {
    display: none;
  }

  .ios-steps {
    gap: 7px;
    margin-top: 10px;
  }

  .ios-steps li {
    grid-template-columns: 28px 1fr;
    gap: 8px;
    padding: 7px 10px;
  }

  .ios-step-icon {
    width: 26px;
    height: 26px;
    font-size: 14px;
  }

  .ios-steps b {
    font-size: 12px;
  }

  .ios-steps span:not(.ios-step-icon) {
    margin-top: 1px;
    font-size: 10px;
    line-height: 1.45;
  }

  .ios-note {
    display: none;
  }

  .ios-card .primary-btn {
    margin-top: 10px;
    padding: 10px;
  }
}

/* ---------- responsive ---------- */

@media (pointer: coarse) {
  #badges {
    top: calc(46px + env(safe-area-inset-top));
  }
}

/* 横屏时两侧黑边要留给摇杆和按键，提示徽章不再压在画面右上角。 */
@media (pointer: coarse) and (orientation: landscape) {
  #badges {
    display: none;
  }
}

/* 横屏黑边只有几十到一百多像素，语言下拉收进说明面板，避免压到画面。 */
@media (pointer: coarse) and (orientation: landscape) {
  .lang-select {
    display: none;
  }
}

/* Portrait phones letterbox the 4:3 canvas at the top; lift it into the
   empty space between the top bar and the touch controls. */
@media (orientation: portrait) {
  body.is-running .ejs_canvas {
    transform: translateY(calc((100vh - 75vw) / 2));
    will-change: transform;
  }
}

@media (max-width: 575px) {
  #help-toggle {
    height: 32px;
    padding: 0 12px;
    font-size: 11px;
  }

  .badge {
    height: 30px;
    padding: 0 10px;
    font-size: 10px;
  }

  .boot-frame {
    gap: 8px;
  }

  .boot-hint {
    margin-top: 10px;
  }

  .key-list li b {
    width: 84px;
  }
}

@media (max-height: 520px) and (orientation: landscape) {
  #boot {
    padding-bottom: calc(84px + env(safe-area-inset-bottom));
  }

  .logo {
    font-size: clamp(44px, 10vh, 76px);
  }

  .boot-hint,
  .boot-chips {
    display: none;
  }
}

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