:root {
  --ink: #060907;
  --ink-2: #0b110d;
  --bone: #ece6d6;
  --muted: #77856f;
  --lime: #cdf45c;
  --gold: #f5c96a;
  --rust: #e2563f;
  --mono: "Space Mono", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  --display: "Fraunces", "Times New Roman", Georgia, serif;
  --serif-cn: "Songti SC", "Noto Serif SC", "STSong", serif;
  --sans-cn: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", system-ui, sans-serif;
}

*,
*::before,
*::after { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(14px, 3.2vh, 34px) clamp(16px, 4vw, 56px);
  overflow-x: hidden;
  position: relative;
  background: var(--ink);
  color: var(--bone);
  font-family: var(--mono);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

/* atmosphere */
body::before {
  content: "";
  position: fixed;
  inset: -20%;
  pointer-events: none;
  background:
    radial-gradient(46% 38% at 50% 60%, rgba(205, 244, 92, 0.085), transparent 70%),
    radial-gradient(32% 28% at 84% 10%, rgba(226, 86, 63, 0.075), transparent 72%),
    radial-gradient(40% 42% at 10% 90%, rgba(140, 205, 165, 0.05), transparent 70%);
  animation: drift 24s ease-in-out infinite alternate;
}

@keyframes drift {
  from { transform: translate3d(-1.4%, 1%, 0) scale(1); }
  to   { transform: translate3d(1.4%, -1.6%, 0) scale(1.06); }
}

.grain {
  position: fixed;
  inset: 0;
  z-index: 50;
  pointer-events: none;
  opacity: 0.05;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='180' height='180' filter='url(%23n)'/%3E%3C/svg%3E");
  background-size: 180px 180px;
}

.vignette {
  position: fixed;
  inset: 0;
  z-index: 40;
  pointer-events: none;
  background: radial-gradient(120% 100% at 50% 45%, transparent 42%, rgba(0, 0, 0, 0.7) 100%);
}

/* stage */
.stage {
  --board: min(580px, 82vw, calc(100dvh - 220px));
  position: relative;
  z-index: 10;
  width: min(100%, 940px);
  display: flex;
  flex-direction: column;
  gap: clamp(12px, 2vh, 20px);
}

.masthead {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  font-size: 11px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--muted);
  animation: rise 0.8s cubic-bezier(0.2, 0.7, 0.2, 1) both;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--bone);
  min-width: 0;
}

.brand-dot {
  width: 7px;
  height: 7px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--gold);
  box-shadow: 0 0 12px rgba(245, 201, 106, 0.9);
  animation: dotPulse 2.4s ease-in-out infinite;
}

@keyframes dotPulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.45; transform: scale(0.8); }
}

.brand-name { font-weight: 700; letter-spacing: 0.34em; }
.brand-divider { color: rgba(236, 230, 214, 0.26); }
.brand-cn {
  font-family: var(--serif-cn);
  font-size: 12px;
  letter-spacing: 0.34em;
}
.brand-no {
  font-size: 9px;
  letter-spacing: 0.2em;
  color: rgba(236, 230, 214, 0.32);
  padding-left: 4px;
}

.best { display: flex; align-items: baseline; gap: 10px; white-space: nowrap; }
.best-label { font-size: 9.5px; color: var(--muted); }
.best-value {
  font-size: 15px;
  font-weight: 700;
  color: var(--bone);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.06em;
}

/* playfield + rails */
.playfield {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(14px, 2.4vw, 34px);
  animation: rise 0.9s 0.06s cubic-bezier(0.2, 0.7, 0.2, 1) both;
}

.rail {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  font-size: 9px;
  letter-spacing: 0.32em;
  text-transform: uppercase;
  color: rgba(236, 230, 214, 0.28);
}

.rail-text { writing-mode: vertical-rl; text-orientation: mixed; }
.rail-line {
  width: 1px;
  height: clamp(60px, 12vh, 130px);
  background: linear-gradient(to bottom, transparent, rgba(236, 230, 214, 0.22), transparent);
}
.rail-num { font-size: 10px; letter-spacing: 0.18em; color: rgba(245, 201, 106, 0.65); }

/* board */
.board {
  position: relative;
  width: var(--board);
  max-width: 100%;
  background:
    linear-gradient(175deg, rgba(23, 34, 26, 0.94), rgba(8, 12, 10, 0.97) 55%, rgba(5, 8, 6, 0.99));
  border: 1px solid rgba(236, 230, 214, 0.13);
  box-shadow:
    0 0 0 1px rgba(0, 0, 0, 0.55),
    0 40px 90px -40px #000,
    inset 0 1px 0 rgba(236, 230, 214, 0.06);
}

.corner {
  position: absolute;
  width: 9px;
  height: 9px;
  border: 1px solid rgba(245, 201, 106, 0.75);
  pointer-events: none;
  z-index: 4;
}
.corner--tl { top: -6px; left: -6px; border-right: 0; border-bottom: 0; }
.corner--tr { top: -6px; right: -6px; border-left: 0; border-bottom: 0; }
.corner--bl { bottom: -6px; left: -6px; border-right: 0; border-top: 0; }
.corner--br { bottom: -6px; right: -6px; border-left: 0; border-top: 0; }

/* hud */
.hud {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px 9px;
  border-bottom: 1px solid rgba(236, 230, 214, 0.1);
  background: linear-gradient(180deg, rgba(236, 230, 214, 0.035), transparent);
}

.hud-cell { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.hud-cell--right { align-items: flex-end; }
.hud-label {
  font-size: 8px;
  letter-spacing: 0.26em;
  color: rgba(119, 133, 111, 0.95);
  white-space: nowrap;
}
.hud-value {
  font-size: clamp(19px, 4vmin, 25px);
  line-height: 1;
  font-weight: 700;
  letter-spacing: 0.05em;
  font-variant-numeric: tabular-nums;
  color: var(--bone);
}

.hud-mid { flex: 1; display: flex; justify-content: center; padding-bottom: 2px; }

.combo {
  font-size: 9.5px;
  letter-spacing: 0.22em;
  color: var(--gold);
  opacity: 0;
  transform: translateY(5px);
  transition: opacity 0.28s ease, transform 0.28s ease;
  white-space: nowrap;
}
.combo.is-on { opacity: 1; transform: none; }
.combo.pop { animation: comboPop 0.34s cubic-bezier(0.2, 0.8, 0.2, 1); }

@keyframes comboPop {
  0% { transform: scale(1.35); color: #fffaf0; }
  100% { transform: scale(1); }
}

/* canvas */
.canvas-wrap {
  position: relative;
  aspect-ratio: 1 / 1;
  overflow: hidden;
  cursor: crosshair;
}

#game { display: block; width: 100%; height: 100%; }

/* overlays */
.screen {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: clamp(20px, 5vmin, 44px);
  text-align: center;
  background: radial-gradient(120% 90% at 50% 40%, rgba(9, 13, 10, 0.72), rgba(4, 7, 5, 0.95));
  transition: opacity 0.5s ease, visibility 0.5s ease;
}

.screen.is-hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.screen-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: clamp(7px, 1.5vmin, 13px);
  max-width: 420px;
  animation: screenIn 1s cubic-bezier(0.2, 0.7, 0.2, 1) both;
}

@keyframes screenIn {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: none; }
}

.eyebrow {
  margin: 0;
  font-size: 8.5px;
  letter-spacing: 0.36em;
  text-transform: uppercase;
  color: rgba(119, 133, 111, 0.95);
}

.title { margin: 0; display: flex; flex-direction: column; align-items: center; }

.title-en {
  font-family: var(--display);
  font-style: italic;
  font-weight: 500;
  font-variation-settings: "opsz" 144, "SOFT" 60, "WONK" 1;
  font-size: clamp(58px, 13vmin, 96px);
  line-height: 0.82;
  letter-spacing: -0.045em;
  color: var(--bone);
  text-shadow: 0 0 70px rgba(245, 201, 106, 0.18);
}

.title-cn {
  font-family: var(--serif-cn);
  font-size: clamp(12px, 2.1vmin, 15px);
  letter-spacing: 0.78em;
  margin: 12px 0 0 0.78em;
  color: var(--gold);
}

.lede {
  margin: 8px 0 0;
  font-family: var(--sans-cn);
  font-size: 11.5px;
  line-height: 2.05;
  letter-spacing: 0.09em;
  color: rgba(236, 230, 214, 0.6);
}

.prompt {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 12px 0 0;
  font-size: 10px;
  letter-spacing: 0.2em;
  color: rgba(236, 230, 214, 0.72);
  animation: breathe 2.3s ease-in-out infinite;
}

.prompt-text { font-family: var(--sans-cn); letter-spacing: 0.22em; }

@keyframes breathe {
  0%, 100% { opacity: 0.45; }
  50% { opacity: 1; }
}

.screen-foot {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 14px;
  margin: 0;
  font-size: 8px;
  letter-spacing: 0.3em;
  color: rgba(236, 230, 214, 0.26);
}

/* game over */
.over-title {
  margin: 2px 0 0;
  font-family: var(--serif-cn);
  font-weight: 400;
  font-size: clamp(32px, 6.6vmin, 50px);
  letter-spacing: 0.24em;
  margin-left: 0.24em;
  color: var(--bone);
}

.final-stats {
  display: flex;
  gap: clamp(18px, 4.6vmin, 34px);
  margin: 8px 0 0;
}

.final-cell { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.final-cell span {
  font-size: 7.5px;
  letter-spacing: 0.3em;
  color: rgba(119, 133, 111, 0.95);
}
.final-cell strong {
  font-size: clamp(17px, 3.4vmin, 23px);
  font-weight: 700;
  letter-spacing: 0.07em;
  font-variant-numeric: tabular-nums;
  color: var(--bone);
}

.new-best {
  margin: 4px 0 0;
  padding: 5px 10px;
  font-size: 8.5px;
  font-weight: 700;
  letter-spacing: 0.28em;
  color: #11170c;
  background: var(--gold);
}
.new-best[hidden] { display: none; }

/* keycaps + controls */
.keycap {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  border: 1px solid rgba(236, 230, 214, 0.22);
  border-radius: 4px;
  background: rgba(236, 230, 214, 0.05);
  box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.45), 0 1px 0 rgba(236, 230, 214, 0.05);
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: rgba(236, 230, 214, 0.86);
}

.controls {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: clamp(12px, 2vw, 22px);
  font-size: 10px;
  letter-spacing: 0.18em;
  color: var(--muted);
  animation: rise 0.9s 0.14s cubic-bezier(0.2, 0.7, 0.2, 1) both;
}

.ctrl { display: flex; align-items: center; gap: 6px; }
.ctrl-label {
  font-family: var(--sans-cn);
  font-size: 10px;
  letter-spacing: 0.16em;
}
.ctrl-sep { width: 1px; height: 12px; background: rgba(236, 230, 214, 0.15); }
.ctrl.is-muted .keycap {
  color: rgba(226, 86, 63, 0.95);
  border-color: rgba(226, 86, 63, 0.45);
}
.ctrl.is-muted .ctrl-label { color: rgba(226, 86, 63, 0.8); }

@keyframes rise {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: none; }
}

/* hud loadout info */
.hud-sub {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 2px;
}

.hud-char {
  font-family: var(--serif-cn);
  font-size: 10px;
  letter-spacing: 0.18em;
  color: var(--lime);
  white-space: nowrap;
}

.pips { display: inline-flex; gap: 4px; }
.pip {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  border: 1px solid rgba(236, 230, 214, 0.28);
}
.pip.is-on {
  background: var(--lime);
  border-color: var(--lime);
  box-shadow: 0 0 8px rgba(205, 244, 92, 0.6);
}

/* buttons */
.screen-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 18px;
}

.btn {
  appearance: none;
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  padding: 10px 18px;
  border: 1px solid transparent;
  border-radius: 2px;
  cursor: pointer;
  color: var(--bone);
  transition: background 0.2s, border-color 0.2s, color 0.2s, box-shadow 0.2s, transform 0.12s;
}

.btn:active { transform: translateY(1px); }

.btn--primary {
  background: var(--lime);
  border-color: var(--lime);
  color: #0c1208;
  box-shadow: 0 0 26px rgba(205, 244, 92, 0.18);
}
.btn--primary:hover {
  background: #dcff77;
  box-shadow: 0 0 34px rgba(205, 244, 92, 0.28);
}

.btn--ghost {
  background: rgba(236, 230, 214, 0.03);
  border-color: rgba(236, 230, 214, 0.22);
  color: rgba(236, 230, 214, 0.72);
}
.btn--ghost:hover {
  border-color: rgba(236, 230, 214, 0.5);
  color: var(--bone);
}

.new-unlocks {
  margin: 2px 0 0;
  padding: 5px 10px;
  font-family: var(--sans-cn);
  font-size: 9px;
  letter-spacing: 0.14em;
  color: var(--gold);
  border: 1px dashed rgba(245, 201, 106, 0.35);
  background: rgba(245, 201, 106, 0.06);
}
.new-unlocks[hidden] { display: none; }

/* loadout layer */
.menu-layer {
  position: fixed;
  inset: 0;
  z-index: 45;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: clamp(14px, 3.5vh, 40px) clamp(14px, 4vw, 48px);
  overflow-y: auto;
  background: radial-gradient(90% 80% at 50% 35%, rgba(9, 14, 11, 0.93), rgba(3, 5, 4, 0.98));
  transition: opacity 0.4s ease, visibility 0.4s ease;
}

.menu-layer.is-hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.loadout {
  width: min(980px, 100%);
  margin: auto 0;
  display: flex;
  flex-direction: column;
  gap: clamp(12px, 2vh, 20px);
  animation: rise 0.5s cubic-bezier(0.2, 0.7, 0.2, 1) both;
}

.loadout-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid rgba(236, 230, 214, 0.12);
}

.loadout-title {
  margin: 4px 0 0;
  font-family: var(--display);
  font-style: italic;
  font-weight: 500;
  font-size: clamp(28px, 4.6vmin, 44px);
  line-height: 1;
  letter-spacing: -0.02em;
}

.loadout-body {
  display: grid;
  grid-template-columns: 1.02fr 1.2fr 0.8fr;
  align-items: stretch;
  gap: clamp(10px, 1.4vw, 16px);
}

.panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: 14px;
  border: 1px solid rgba(236, 230, 214, 0.11);
  background: linear-gradient(180deg, rgba(236, 230, 214, 0.035), rgba(236, 230, 214, 0));
}

.panel-label {
  margin: 0 0 10px;
  font-size: 8px;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--muted);
}

.char-list { display: flex; flex-direction: column; gap: 8px; }

.char-card {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 11px;
  text-align: left;
  font-family: inherit;
  color: var(--bone);
  background: rgba(236, 230, 214, 0.03);
  border: 1px solid rgba(236, 230, 214, 0.1);
  border-radius: 2px;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s, box-shadow 0.2s;
}
.char-card:hover:not(:disabled) { border-color: rgba(236, 230, 214, 0.28); }
.char-card.is-selected {
  border-color: rgba(205, 244, 92, 0.5);
  background: rgba(205, 244, 92, 0.06);
  box-shadow: inset 2px 0 0 var(--lime);
}
.char-card.is-locked { opacity: 0.42; cursor: not-allowed; }

.char-swatch {
  width: 9px;
  height: 9px;
  flex: 0 0 auto;
  border-radius: 50%;
  box-shadow: 0 0 10px currentColor;
}

.char-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.char-name { font-family: var(--serif-cn); font-size: 14px; letter-spacing: 0.12em; }
.char-en {
  font-size: 8.5px;
  letter-spacing: 0.26em;
  text-transform: uppercase;
  color: var(--muted);
}
.char-lock {
  margin-left: auto;
  font-size: 8.5px;
  letter-spacing: 0.12em;
  color: var(--gold);
  white-space: nowrap;
}

.char-note {
  margin: 12px 0 0;
  font-family: var(--sans-cn);
  font-size: 10px;
  line-height: 1.9;
  letter-spacing: 0.08em;
  color: rgba(236, 230, 214, 0.5);
}

.slot-tabs { display: flex; gap: 6px; margin-bottom: 10px; }

.slot-tab {
  flex: 1;
  padding: 7px 4px;
  font-family: var(--sans-cn);
  font-size: 10px;
  letter-spacing: 0.14em;
  color: var(--muted);
  background: rgba(236, 230, 214, 0.03);
  border: 1px solid rgba(236, 230, 214, 0.12);
  border-radius: 2px;
  cursor: pointer;
  transition: border-color 0.2s, color 0.2s, background 0.2s;
}
.slot-tab:hover { color: var(--bone); }
.slot-tab.is-active {
  border-color: rgba(245, 201, 106, 0.6);
  color: var(--gold);
  background: rgba(245, 201, 106, 0.07);
}

.slot-dot {
  display: inline-block;
  width: 4px;
  height: 4px;
  margin-left: 5px;
  border-radius: 50%;
  background: var(--lime);
  vertical-align: middle;
}

.equip-list {
  display: flex;
  flex-direction: column;
  gap: 7px;
  max-height: min(42vh, 340px);
  overflow-y: auto;
  padding-right: 2px;
  margin-bottom: 10px;
}

.equip-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 11px;
  text-align: left;
  font-family: inherit;
  color: var(--bone);
  background: rgba(236, 230, 214, 0.025);
  border: 1px solid rgba(236, 230, 214, 0.09);
  border-radius: 2px;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
}
.equip-item:hover:not(:disabled) { border-color: rgba(236, 230, 214, 0.26); }
.equip-item.is-equipped {
  border-color: rgba(205, 244, 92, 0.45);
  background: rgba(205, 244, 92, 0.07);
}
.equip-item.is-locked { opacity: 0.4; cursor: not-allowed; }

.equip-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.equip-name { font-family: var(--serif-cn); font-size: 12.5px; letter-spacing: 0.1em; }
.equip-name em {
  margin-left: 8px;
  font-family: var(--mono);
  font-style: normal;
  font-size: 8px;
  letter-spacing: 0.16em;
  color: var(--lime);
}
.equip-desc { font-size: 9px; letter-spacing: 0.06em; color: rgba(236, 230, 214, 0.45); }
.equip-lock { margin-left: auto; font-size: 8.5px; color: var(--gold); white-space: nowrap; }

.panel-tip {
  margin: auto 0 0;
  font-size: 8px;
  letter-spacing: 0.1em;
  color: rgba(236, 230, 214, 0.3);
}

.stat-list { display: flex; flex-direction: column; }

.stat-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  padding: 7px 0;
  font-family: var(--sans-cn);
  font-size: 9.5px;
  letter-spacing: 0.08em;
  color: var(--muted);
  border-bottom: 1px dashed rgba(236, 230, 214, 0.08);
}
.stat-row strong {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 700;
  color: var(--bone);
  font-variant-numeric: tabular-nums;
}

.unlock-hint {
  margin: 12px 0 0;
  font-family: var(--sans-cn);
  font-size: 8.5px;
  line-height: 1.8;
  letter-spacing: 0.1em;
  color: var(--gold);
}

.loadout-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
  padding-top: 12px;
  border-top: 1px solid rgba(236, 230, 214, 0.12);
}

.loadout-tip {
  margin: 0;
  font-family: var(--sans-cn);
  font-size: 8.5px;
  letter-spacing: 0.18em;
  color: rgba(236, 230, 214, 0.3);
}

/* responsive */
@media (max-width: 1040px) {
  .rail { display: none; }
}

@media (max-width: 900px) {
  .loadout-body {
    grid-template-columns: 1fr 1fr;
  }
  .loadout-body .panel:last-child {
    grid-column: 1 / -1;
  }
  .stat-list {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    column-gap: 18px;
  }
  .equip-list { max-height: min(34vh, 280px); }
}

@media (max-width: 640px) {
  .loadout-body { grid-template-columns: 1fr; }
  .equip-list { max-height: none; }
  .loadout-foot .btn { flex: 1; }
  .loadout-tip { display: none; }
  .stat-list { grid-template-columns: 1fr; }
}

@media (max-width: 620px) {
  .masthead { font-size: 10px; letter-spacing: 0.16em; }
  .brand-no { display: none; }
  .stage { --board: min(92vw, calc(100dvh - 210px)); }
  .screen-foot { font-size: 7px; letter-spacing: 0.2em; }
}

@media (max-height: 640px) {
  .stage { --board: min(72vh, 82vw); }
  .lede { display: none; }
}

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

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

/* 触摸设备上的游戏区不允许滚动/缩放 */
.canvas-wrap { touch-action: none; }

/* 默认（桌面）不渲染方向键与触摸文案 */
.dpad { display: none; }
.hint--touch { display: none; }

@media (pointer: coarse) {
  .dpad {
    position: relative;
    flex: 0 0 auto;
    align-self: center;
    width: clamp(120px, 42vw, 156px);
    aspect-ratio: 1 / 1;
    display: none;
    margin: 0 auto;
    touch-action: none;
    opacity: 0.92;
    transition: opacity 0.18s ease;
  }

  /* 只在真正游戏中出现，开局前不占位 */
  .dpad.is-live { display: block; }

  .dpad.is-engaged { opacity: 1; }

  .dpad-btn {
    position: absolute;
    width: 33.33%;
    height: 33.33%;
    margin: 0;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid rgba(236, 230, 214, 0.24);
    border-radius: 12px;
    background: rgba(15, 22, 17, 0.78);
    -webkit-backdrop-filter: blur(6px);
    backdrop-filter: blur(6px);
    color: rgba(236, 230, 214, 0.8);
    font-family: var(--mono);
    font-size: 13px;
    line-height: 1;
    pointer-events: none;
    transition: background 0.1s ease, border-color 0.1s ease, color 0.1s ease;
  }

  .dpad-btn--up    { top: 0;      left: 33.33%; }
  .dpad-btn--down  { top: 66.66%; left: 33.33%; }
  .dpad-btn--left  { top: 33.33%; left: 0; }
  .dpad-btn--right { top: 33.33%; left: 66.66%; }

  .dpad-btn.is-active {
    background: rgba(205, 244, 92, 0.2);
    border-color: rgba(205, 244, 92, 0.68);
    color: rgba(233, 255, 190, 0.96);
  }

  .dpad-hub {
    position: absolute;
    top: 41.5%;
    left: 41.5%;
    width: 17%;
    height: 17%;
    border-radius: 50%;
    border: 1px solid rgba(236, 230, 214, 0.16);
    pointer-events: none;
  }

  /* 提示文案换成手势说明 */
  .hint--key { display: none; }
  .hint--touch { display: inline; }

  /* 底部操作条：隐藏键盘项，R/M 变成可点按钮 */
  .ctrl--key { display: none; }
  .controls { gap: 10px; }

  .ctrl {
    padding: 7px 15px;
    border: 1px solid rgba(236, 230, 214, 0.18);
    border-radius: 999px;
    background: rgba(236, 230, 214, 0.05);
    cursor: pointer;
    transition: background 0.12s ease, border-color 0.12s ease;
  }

  .ctrl .keycap { display: none; }

  .ctrl:active {
    background: rgba(236, 230, 214, 0.13);
    border-color: rgba(236, 230, 214, 0.34);
  }

  /* 小屏文字不要缩到看不清 */
  .screen-foot { font-size: 9px; letter-spacing: 0.14em; }
  .hud-label { font-size: 9px; }
  .loadout-tip { display: none; }
}

/* 竖屏：方向键排在棋盘下方，给棋盘让出高度 */
@media (pointer: coarse) and (orientation: portrait) {
  .stage { --board: min(92vw, calc(100dvh - 290px)); }
}

/* 横屏：屏幕高度紧张，方向键浮到右下角，棋盘按高度收缩 */
@media (pointer: coarse) and (orientation: landscape) {
  .stage {
    --board: min(62vh, 72vw);
    gap: 8px;
  }

  .dpad {
    position: fixed;
    right: max(14px, env(safe-area-inset-right));
    bottom: max(14px, env(safe-area-inset-bottom));
    width: clamp(96px, 26vh, 132px);
    margin: 0;
    z-index: 20;
  }

  .controls { gap: 8px; }
}
