/* ============================================================
   TETRIS · 竖屏移动端
   ============================================================ */

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

:root {
  --bg: #05070d;
  --ink: #eaf2ff;
  --muted: #8494af;
  --dim: #5a6780;
  --stroke: rgba(148, 163, 184, 0.14);
  --cyan: #22d3ee;
  --cyan-soft: #a5f3fc;
  --violet: #a78bfa;
  --pink: #f472b6;
  --amber: #fbbf24;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  --font: "SF Pro Display", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", system-ui, sans-serif;
}

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
  -webkit-text-size-adjust: 100%;
  text-rendering: optimizeLegibility;
  -webkit-touch-callout: none;
}

button {
  font-family: inherit;
  color: inherit;
  -webkit-appearance: none;
  appearance: none;
}

button:focus-visible {
  outline: 2px solid rgba(103, 232, 249, 0.8);
  outline-offset: 2px;
}

/* ---------- 背景 ---------- */
.bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  background:
    radial-gradient(120% 80% at 50% -10%, #101c33 0%, #070c16 45%, #04060c 100%);
}

.bg-grid {
  position: absolute;
  inset: -10%;
  background-image:
    linear-gradient(rgba(148, 163, 184, 0.055) 1px, transparent 1px),
    linear-gradient(90deg, rgba(148, 163, 184, 0.055) 1px, transparent 1px);
  background-size: 44px 44px;
  mask-image: radial-gradient(70% 60% at 50% 42%, #000 15%, transparent 80%);
  -webkit-mask-image: radial-gradient(70% 60% at 50% 42%, #000 15%, transparent 80%);
  opacity: 0.7;
}

.orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(70px);
  opacity: 0.5;
  will-change: transform;
}
.orb-a {
  width: 70vw; height: 70vw; max-width: 430px; max-height: 430px;
  background: rgba(8, 145, 178, 0.5);
  top: -18%; left: -24%;
  animation: drift-a 22s ease-in-out infinite alternate;
}
.orb-b {
  width: 82vw; height: 82vw; max-width: 500px; max-height: 500px;
  background: rgba(109, 40, 217, 0.42);
  bottom: -24%; right: -30%;
  animation: drift-b 26s ease-in-out infinite alternate;
}
.orb-c {
  width: 42vw; height: 42vw; max-width: 250px; max-height: 250px;
  background: rgba(190, 24, 93, 0.24);
  top: 40%; right: -18%;
  animation: drift-a 18s ease-in-out infinite alternate-reverse;
}
@keyframes drift-a {
  from { transform: translate3d(0, 0, 0) scale(1); }
  to   { transform: translate3d(8%, 6%, 0) scale(1.12); }
}
@keyframes drift-b {
  from { transform: translate3d(0, 0, 0) scale(1.05); }
  to   { transform: translate3d(-7%, -5%, 0) scale(1); }
}

/* ---------- 应用布局 ---------- */
#app {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 100vh;
  height: var(--app-h, 100dvh);
  max-width: 600px;
  margin: 0 auto;
  z-index: 1;
  display: flex;
  flex-direction: column;
  gap: clamp(6px, 1.4vh, 12px);
  padding: calc(var(--safe-t) + 8px)
           calc(var(--safe-r) + 10px)
           calc(var(--safe-b) + 8px)
           calc(var(--safe-l) + 10px);
  overflow: hidden;
}

/* ---------- 顶部 HUD ---------- */
.hud {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 46px;
}

.score-wrap {
  flex: 0 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
  line-height: 1;
}

.kicker {
  font-size: 8px;
  font-weight: 800;
  letter-spacing: 0.22em;
  color: var(--dim);
  line-height: 1.2;
}

.score {
  font-size: clamp(19px, 5.8vw, 25px);
  font-weight: 800;
  letter-spacing: 0.02em;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
  white-space: nowrap;
  background: linear-gradient(180deg, #ffffff, #b7c6df);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 0 12px rgba(120, 180, 255, 0.15));
}
.score.bump { animation: score-bump 0.24s ease; }
@keyframes score-bump {
  0% { transform: scale(1); }
  35% { transform: scale(1.09); filter: drop-shadow(0 0 14px rgba(34, 211, 238, 0.6)); }
  100% { transform: scale(1); }
}

.xp-line {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-top: 3px;
  min-width: 0;
}
.xp-level {
  font-size: 8px;
  font-weight: 800;
  letter-spacing: 0.1em;
  color: var(--cyan-soft);
  white-space: nowrap;
  line-height: 1;
}
.xp-level b {
  font-size: 9.5px;
  color: #ffffff;
  font-variant-numeric: tabular-nums;
}
.xp-track {
  position: relative;
  flex: 1 1 42px;
  min-width: 26px;
  height: 4px;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.16);
  overflow: hidden;
}
.xp-fill {
  display: block;
  width: 0%;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #22d3ee, #818cf8, #a78bfa);
  box-shadow: 0 0 8px rgba(34, 211, 238, 0.55);
  transition: width 0.35s cubic-bezier(0.2, 0.8, 0.3, 1);
}
.xp-num {
  font-size: 8px;
  letter-spacing: 0.02em;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  line-height: 1;
}
.xp-line.gain .xp-fill { animation: xp-gain 0.45s ease; }
@keyframes xp-gain {
  0% { filter: brightness(1); }
  40% { filter: brightness(1.8); box-shadow: 0 0 12px rgba(34, 211, 238, 0.9); }
  100% { filter: brightness(1); }
}

/* ---------- 卡牌道具栏 ---------- */
.item-dock {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}
.item-dock .panel-title { margin-bottom: 1px; }
.item-btn {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 2px;
  border-radius: 12px;
  border: 1px solid rgba(148, 163, 184, 0.16);
  background: linear-gradient(180deg, rgba(34, 211, 238, 0.11), rgba(34, 211, 238, 0.02));
  color: var(--cyan-soft);
  cursor: pointer;
  touch-action: none;
  transition: transform 0.08s ease, opacity 0.2s ease, border-color 0.15s ease, background 0.15s ease;
}
.item-btn svg { width: clamp(16px, 4.4vw, 20px); height: clamp(16px, 4.4vw, 20px); pointer-events: none; }
.item-name {
  font-size: clamp(7px, 2.1vw, 9px);
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--muted);
  white-space: nowrap;
  pointer-events: none;
}
.item-count {
  position: absolute;
  top: 2px;
  right: 2px;
  min-width: 13px;
  height: 13px;
  padding: 0 3px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: rgba(251, 191, 36, 0.92);
  color: #1a1203;
  font-size: 8px;
  font-weight: 900;
  line-height: 1;
  box-shadow: 0 1px 6px rgba(251, 191, 36, 0.35);
  pointer-events: none;
}
.item-btn:not(.has-items) .item-count { display: none; }
.item-btn:not(.has-items) {
  opacity: 0.38;
  filter: grayscale(0.4);
}
.item-btn.is-ready {
  border-color: rgba(34, 211, 238, 0.36);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08), 0 0 14px rgba(34, 211, 238, 0.1);
}
.item-btn:active { transform: scale(0.92); }
.item-btn:disabled { cursor: default; }
.item-btn.pulse { animation: item-pulse 0.4s ease; }
@keyframes item-pulse {
  0% { transform: scale(1); }
  35% { transform: scale(1.12); border-color: rgba(251, 191, 36, 0.7); }
  100% { transform: scale(1); }
}

.hud-chips {
  margin-left: auto;
  display: flex;
  align-items: stretch;
  padding: 4px 1px;
  border: 1px solid var(--stroke);
  border-radius: 12px;
  background: rgba(15, 22, 36, 0.6);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.chip {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-width: 42px;
  padding: 0 5px;
  line-height: 1;
}
.chip + .chip { border-left: 1px solid rgba(148, 163, 184, 0.12); }
.chip b {
  font-size: clamp(12px, 3.6vw, 15px);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.hud-tools {
  flex: 0 0 auto;
  display: flex;
  gap: 6px;
}
.icon-btn {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 11px;
  border: 1px solid var(--stroke);
  background: rgba(255, 255, 255, 0.04);
  color: var(--ink);
  cursor: pointer;
  transition: transform 0.08s ease, background 0.15s ease, border-color 0.15s ease;
}
.icon-btn svg { width: 17px; height: 17px; }
.icon-btn:active { transform: scale(0.92); background: rgba(255, 255, 255, 0.08); }
.icon-btn:disabled { opacity: 0.32; pointer-events: none; }

.ico-sound-off { display: none; }
body.is-muted .ico-sound-on { display: none; }
body.is-muted .ico-sound-off { display: block; }

/* ---------- 游戏主区域 ---------- */
.field {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(5px, 1.4vw, 10px);
}

.rail {
  flex: 0 0 auto;
  width: clamp(44px, 11.5vw, 62px);
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: clamp(8px, 2vh, 16px);
}

.panel {
  position: relative;
  width: 100%;
  border-radius: 13px;
  border: 1px solid var(--stroke);
  background: linear-gradient(180deg, rgba(20, 29, 47, 0.82), rgba(9, 14, 24, 0.82));
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
  padding: 7px 5px 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  transition: opacity 0.2s ease;
}

.panel-title {
  margin: 0;
  font-size: 8px;
  font-weight: 800;
  letter-spacing: 0.2em;
  color: var(--dim);
  line-height: 1;
}

.mini-wrap {
  width: 100%;
  min-height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.mini { display: block; border-radius: 4px; }

.next-list {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.next-item {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.combo-panel { gap: 3px; }
.combo-value {
  font-size: clamp(14px, 4vw, 18px);
  font-weight: 800;
  color: var(--dim);
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
  transition: color 0.2s ease, text-shadow 0.2s ease;
}
.combo-panel.is-active .combo-value {
  color: var(--amber);
  text-shadow: 0 0 14px rgba(251, 191, 36, 0.45);
}

.hold-panel.is-used { opacity: 0.55; }
.panel.is-pulsing { animation: panel-pulse 0.32s ease; }
@keyframes panel-pulse {
  0% { transform: scale(1); }
  40% { transform: scale(1.06); border-color: rgba(34, 211, 238, 0.5); }
  100% { transform: scale(1); }
}

.board-stage {
  flex: 1 1 auto;
  min-width: 0;
  align-self: stretch;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.board-frame {
  position: relative;
  padding: 5px;
  border-radius: 16px;
  background: linear-gradient(160deg, rgba(255, 255, 255, 0.13), rgba(255, 255, 255, 0.02) 42%, rgba(255, 255, 255, 0.06));
  border: 1px solid rgba(148, 163, 184, 0.2);
  box-shadow:
    0 24px 60px rgba(0, 0, 0, 0.55),
    inset 0 1px 0 rgba(255, 255, 255, 0.12),
    0 0 34px rgba(34, 211, 238, 0.07);
  will-change: transform;
}
.board-frame::before {
  content: "";
  position: absolute;
  inset: -28px -20px;
  border-radius: 36px;
  background: radial-gradient(50% 45% at 50% 50%, rgba(34, 211, 238, 0.16), transparent 72%);
  filter: blur(12px);
  z-index: -1;
  pointer-events: none;
}
.board-frame.shake { animation: board-shake 0.2s ease; }
@keyframes board-shake {
  0%, 100% { transform: translate3d(0, 0, 0); }
  20% { transform: translate3d(-2px, 1px, 0); }
  40% { transform: translate3d(2px, -1px, 0); }
  60% { transform: translate3d(-1px, 2px, 0); }
  80% { transform: translate3d(1px, -1px, 0); }
}

#board {
  display: block;
  width: 220px;
  height: 440px;
  border-radius: 11px;
  background: #070b14;
  touch-action: none;
  cursor: grab;
}

/* ---------- 炸弹投放提示 ---------- */
.target-banner {
  position: absolute;
  top: 9px;
  left: 9px;
  right: 9px;
  z-index: 6;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 7px 8px 7px 11px;
  border-radius: 11px;
  border: 1px solid rgba(244, 114, 182, 0.42);
  background: rgba(9, 12, 22, 0.9);
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.45), 0 0 18px rgba(244, 114, 182, 0.18);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  color: #ffe4ef;
  font-size: clamp(9px, 2.6vw, 11px);
  font-weight: 700;
  letter-spacing: 0.03em;
  line-height: 1.35;
  pointer-events: auto;
}
.target-banner[hidden] { display: none !important; }
.target-cancel {
  flex: 0 0 auto;
  padding: 5px 9px;
  border-radius: 8px;
  border: 1px solid rgba(244, 114, 182, 0.35);
  background: rgba(244, 114, 182, 0.14);
  color: #fbcfe8;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.06em;
  cursor: pointer;
}
.target-cancel:active { transform: scale(0.95); }

/* ---------- 飘字 ---------- */
.toasts {
  position: absolute;
  left: 0;
  right: 0;
  top: 9%;
  z-index: 3;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  pointer-events: none;
}
.toast {
  font-size: clamp(15px, 4.6vw, 22px);
  font-weight: 900;
  letter-spacing: 0.14em;
  color: #fff;
  white-space: nowrap;
  text-shadow: 0 2px 18px rgba(0, 0, 0, 0.65);
  animation: toast-rise 0.95s cubic-bezier(0.2, 0.7, 0.3, 1) forwards;
}
.toast.tetris {
  color: var(--cyan-soft);
  text-shadow: 0 0 22px rgba(34, 211, 238, 0.85), 0 2px 8px #000;
}
.toast.tspin {
  color: #ddd6fe;
  text-shadow: 0 0 22px rgba(167, 139, 250, 0.9), 0 2px 8px #000;
}
.toast.combo {
  font-size: clamp(12px, 3.8vw, 16px);
  color: #fde68a;
  text-shadow: 0 0 20px rgba(251, 191, 36, 0.8), 0 2px 8px #000;
}
.toast.perfect {
  color: #fff;
  text-shadow: 0 0 26px rgba(255, 255, 255, 0.9), 0 0 44px rgba(34, 211, 238, 0.85);
}
.toast.levelup {
  color: #d9f99d;
  text-shadow: 0 0 20px rgba(163, 230, 53, 0.8), 0 2px 8px #000;
}
@keyframes toast-rise {
  0% { opacity: 0; transform: translateY(12px) scale(0.9); }
  16% { opacity: 1; transform: translateY(0) scale(1.04); }
  30% { transform: translateY(-2px) scale(1); }
  72% { opacity: 1; }
  100% { opacity: 0; transform: translateY(-28px) scale(0.98); }
}

/* ---------- 底部触控 ---------- */
.controls {
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: clamp(6px, 1.6vw, 10px);
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  padding-bottom: 2px;
}

.pad-btn {
  height: clamp(46px, 7.6vh, 60px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  border-radius: 15px;
  border: 1px solid rgba(148, 163, 184, 0.16);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.015));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08), 0 6px 18px rgba(0, 0, 0, 0.25);
  color: var(--ink);
  cursor: pointer;
  touch-action: none;
  user-select: none;
  transition: transform 0.07s ease, box-shadow 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}
.pad-btn svg {
  width: clamp(18px, 5vw, 22px);
  height: clamp(18px, 5vw, 22px);
  pointer-events: none;
}
.pad-label {
  font-size: clamp(8px, 2.4vw, 10px);
  font-weight: 700;
  letter-spacing: 0.14em;
  color: var(--muted);
  pointer-events: none;
}
.pad-btn.is-down {
  transform: scale(0.94);
  background: linear-gradient(180deg, rgba(34, 211, 238, 0.2), rgba(34, 211, 238, 0.06));
  border-color: rgba(34, 211, 238, 0.55);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.15), 0 0 22px rgba(34, 211, 238, 0.25);
}
.pad-btn.rotate {
  background: linear-gradient(180deg, rgba(34, 211, 238, 0.16), rgba(34, 211, 238, 0.03));
  border-color: rgba(34, 211, 238, 0.3);
}
.pad-btn.rotate svg { color: var(--cyan-soft); }
.pad-btn.hard {
  background: linear-gradient(180deg, rgba(244, 114, 182, 0.16), rgba(244, 114, 182, 0.035));
  border-color: rgba(244, 114, 182, 0.3);
}
.pad-btn.hard svg { color: #fbcfe8; }
.pad-btn.hold {
  background: linear-gradient(180deg, rgba(167, 139, 250, 0.15), rgba(167, 139, 250, 0.03));
  border-color: rgba(167, 139, 250, 0.28);
}
.pad-btn.hold svg { color: #ddd6fe; }

/* ---------- 弹层 ---------- */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: calc(var(--safe-t) + 20px) 20px calc(var(--safe-b) + 20px);
  background: rgba(3, 5, 11, 0.66);
  backdrop-filter: blur(16px) saturate(130%);
  -webkit-backdrop-filter: blur(16px) saturate(130%);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.28s ease, visibility 0.28s ease;
  overflow: hidden;
}
.overlay.is-open { opacity: 1; visibility: visible; }

.overlay-card {
  width: 100%;
  max-width: 356px;
  max-height: 100%;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: clamp(20px, 4.2vh, 30px) clamp(18px, 5vw, 26px);
  border-radius: 26px;
  text-align: center;
  background: linear-gradient(165deg, rgba(26, 36, 58, 0.94), rgba(8, 12, 22, 0.97));
  border: 1px solid rgba(148, 163, 184, 0.18);
  box-shadow: 0 34px 90px rgba(0, 0, 0, 0.65), inset 0 1px 0 rgba(255, 255, 255, 0.09);
  transform: translateY(16px) scale(0.97);
  transition: transform 0.3s cubic-bezier(0.16, 0.8, 0.3, 1.15);
  scrollbar-width: none;
}
.overlay-card::-webkit-scrollbar { display: none; }
.overlay.is-open .overlay-card { transform: none; }

.logo-wrap { position: relative; margin-bottom: 16px; }
.logo-zh {
  margin: 0 0 5px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.6em;
  text-indent: 0.6em;
  color: var(--muted);
}
.logo-en {
  margin: 0;
  font-size: clamp(42px, 15vw, 60px);
  font-weight: 900;
  line-height: 0.95;
  letter-spacing: 0.06em;
  text-indent: 0.06em;
  background: linear-gradient(180deg, #e8fdff 0%, #67e8f9 38%, #22d3ee 60%, #6366f1 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 6px 26px rgba(34, 211, 238, 0.32));
}
.tagline {
  margin: 8px 0 0;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.28em;
  text-indent: 0.28em;
  color: var(--dim);
}

.best-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 18px;
  padding: 6px 14px;
  border-radius: 999px;
  border: 1px solid rgba(251, 191, 36, 0.24);
  background: rgba(251, 191, 36, 0.07);
  color: #fcd34d;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.18em;
}
.best-chip b {
  font-size: 14px;
  color: #fef3c7;
  letter-spacing: 0.02em;
  font-variant-numeric: tabular-nums;
}
.mode-note {
  margin: -8px 0 16px;
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: 0.16em;
  color: var(--cyan-soft);
  opacity: 0.82;
}

.cta {
  width: 100%;
  height: 54px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 0;
  border-radius: 16px;
  background: linear-gradient(135deg, #22d3ee 0%, #38bdf8 45%, #818cf8 100%);
  color: #03121a;
  font-size: 15px;
  font-weight: 900;
  letter-spacing: 0.12em;
  cursor: pointer;
  box-shadow: 0 12px 32px rgba(34, 211, 238, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.5);
  transition: transform 0.08s ease, box-shadow 0.2s ease;
}
.cta svg { width: 18px; height: 18px; }
.cta:active {
  transform: scale(0.97);
  box-shadow: 0 6px 18px rgba(34, 211, 238, 0.28), inset 0 1px 0 rgba(255, 255, 255, 0.5);
}

.hints {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 20px;
  text-align: left;
}
.hint {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 12px;
  border-radius: 12px;
  border: 1px solid rgba(148, 163, 184, 0.09);
  background: rgba(255, 255, 255, 0.03);
}
.hint-icon {
  flex: 0 0 auto;
  width: 27px;
  height: 27px;
  display: grid;
  place-items: center;
  border-radius: 9px;
  background: rgba(34, 211, 238, 0.1);
  color: var(--cyan-soft);
  font-size: 13px;
  font-weight: 700;
}
.hint p {
  margin: 0;
  min-width: 0;
  display: flex;
  align-items: baseline;
  gap: 8px;
}
.hint b {
  font-size: 11.5px;
  font-weight: 700;
  color: #dbe6f7;
  white-space: nowrap;
}
.hint small {
  font-size: 10px;
  color: var(--dim);
  letter-spacing: 0.04em;
  white-space: nowrap;
}
.kbd-hint {
  margin: 14px 0 0;
  font-size: 9.5px;
  line-height: 1.7;
  letter-spacing: 0.04em;
  color: var(--dim);
}
.overlay-footer {
  margin-top: 16px;
  display: flex;
  justify-content: center;
}

.sound-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 32px;
  padding: 0 14px;
  border-radius: 999px;
  border: 1px solid var(--stroke);
  background: rgba(255, 255, 255, 0.035);
  color: var(--muted);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.12em;
  cursor: pointer;
}
.sound-pill svg { width: 14px; height: 14px; }
.sound-pill:active { transform: scale(0.97); }

.overlay-card.narrow { max-width: 330px; }
.overlay-title {
  margin: 0;
  font-size: 27px;
  font-weight: 900;
  letter-spacing: 0.04em;
}
.over-kicker {
  margin: 0 0 6px;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.34em;
  text-indent: 0.34em;
  color: var(--dim);
}
.muted-line {
  margin: 8px 0 20px;
  font-size: 11px;
  letter-spacing: 0.1em;
  color: var(--dim);
}
.btn-row {
  display: flex;
  gap: 9px;
  margin-top: 10px;
}
.btn-row .ghost-btn { flex: 1; }

/* ---------- 本局肉鸽信息 ---------- */
.run-summary {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid rgba(148, 163, 184, 0.12);
  text-align: left;
}
.run-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.14em;
  color: var(--dim);
}
.run-head b {
  color: var(--cyan-soft);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}
.run-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 9px;
}
.run-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 184, 0.14);
  background: rgba(255, 255, 255, 0.03);
  color: #c5d3e8;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.04em;
}
.run-chip .dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--rarity, var(--cyan));
  box-shadow: 0 0 6px var(--rarity, var(--cyan));
}
.run-chip.is-item { color: #fcd34d; border-color: rgba(251, 191, 36, 0.2); }
.run-effects {
  margin-top: 8px;
  font-size: 9px;
  line-height: 1.7;
  letter-spacing: 0.02em;
  color: var(--dim);
}
.run-effects:empty { display: none; }
.run-tip {
  margin: 9px 0 0;
  font-size: 8.5px;
  letter-spacing: 0.05em;
  color: rgba(148, 163, 184, 0.55);
}
.over-run {
  margin: 0 0 16px;
  font-size: 9.5px;
  letter-spacing: 0.08em;
  color: var(--cyan-soft);
  opacity: 0.8;
}
.ghost-btn {
  height: 44px;
  padding: 0 14px;
  border-radius: 13px;
  border: 1px solid var(--stroke);
  background: rgba(255, 255, 255, 0.03);
  color: #b9c6dc;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  cursor: pointer;
  transition: transform 0.08s ease, background 0.15s ease;
}
.ghost-btn:active { transform: scale(0.97); background: rgba(255, 255, 255, 0.06); }
.ghost-btn.wide { width: 100%; margin-top: 10px; }

.final-score {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin: 14px 0 6px;
}
.final-score span {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.24em;
  text-indent: 0.24em;
  color: var(--dim);
}
.final-score b {
  font-size: clamp(36px, 11vw, 48px);
  font-weight: 900;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
  background: linear-gradient(180deg, #ffffff, #8ea5c6);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.new-best {
  display: inline-block;
  margin-top: 4px;
  padding: 5px 12px;
  border-radius: 999px;
  border: 1px solid rgba(251, 191, 36, 0.3);
  background: rgba(251, 191, 36, 0.12);
  color: #fde68a;
  font-size: 9.5px;
  font-weight: 800;
  letter-spacing: 0.2em;
  text-indent: 0.2em;
  animation: best-pulse 1.4s ease-in-out infinite;
}
.new-best[hidden] { display: none; }
@keyframes best-pulse {
  0%, 100% { box-shadow: 0 0 0 rgba(251, 191, 36, 0); }
  50% { box-shadow: 0 0 22px rgba(251, 191, 36, 0.25); }
}
.summary {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin: 18px 0 20px;
}
.summary > div {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 10px 4px;
  border-radius: 12px;
  border: 1px solid rgba(148, 163, 184, 0.09);
  background: rgba(255, 255, 255, 0.03);
}
.summary span {
  font-size: 8.5px;
  font-weight: 700;
  letter-spacing: 0.16em;
  color: var(--dim);
}
.summary b {
  font-size: 16px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

/* ---------- 卡牌三选一 ---------- */
.cards-card {
  max-width: 380px;
  text-align: center;
}
.cards-card .overlay-title { font-size: clamp(22px, 6.5vw, 26px); }
.card-options {
  display: flex;
  flex-direction: column;
  gap: 9px;
  margin: 14px 0 10px;
}
.card-option {
  position: relative;
  width: 100%;
  overflow: hidden;
  padding: 12px 15px 11px 17px;
  border-radius: 16px;
  border: 1px solid var(--rarity-border);
  background: linear-gradient(135deg, var(--rarity-glow), rgba(255, 255, 255, 0.025) 58%);
  color: var(--ink);
  text-align: left;
  cursor: pointer;
  transition: transform 0.09s ease, border-color 0.15s ease, box-shadow 0.2s ease;
  animation: card-enter 0.34s cubic-bezier(0.2, 0.8, 0.3, 1.1) backwards;
}
.card-option:nth-child(2) { animation-delay: 0.055s; }
.card-option:nth-child(3) { animation-delay: 0.11s; }
.card-option::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--rarity);
  box-shadow: 0 0 12px var(--rarity);
}
.card-option::after {
  content: "";
  position: absolute;
  right: -34px;
  top: -34px;
  width: 96px;
  height: 96px;
  border-radius: 50%;
  background: var(--rarity-glow);
  filter: blur(18px);
  pointer-events: none;
}
.card-option:hover,
.card-option:focus-visible {
  border-color: var(--rarity);
  box-shadow: 0 0 0 1px var(--rarity-border), 0 10px 30px rgba(0, 0, 0, 0.35);
}
.card-option:active { transform: scale(0.975); }
.card-top {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-bottom: 5px;
}
.card-rarity {
  padding: 2px 7px;
  border-radius: 999px;
  border: 1px solid var(--rarity-border);
  background: var(--rarity-glow);
  color: var(--rarity);
  font-size: 8px;
  font-weight: 900;
  letter-spacing: 0.16em;
}
.card-kind {
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 0.16em;
  color: var(--dim);
}
.card-name {
  display: block;
  font-size: 15.5px;
  font-weight: 900;
  letter-spacing: 0.03em;
  line-height: 1.25;
}
.card-desc {
  display: block;
  margin-top: 3px;
  font-size: 10.5px;
  line-height: 1.62;
  letter-spacing: 0.01em;
  color: #a9b8d0;
}
.card-foot {
  display: block;
  margin-top: 5px;
  font-size: 8px;
  letter-spacing: 0.12em;
  color: var(--dim);
}
.card-key {
  position: absolute;
  top: 10px;
  right: 12px;
  font-size: 8px;
  color: rgba(148, 163, 184, 0.5);
  letter-spacing: 0.1em;
}
.rarity-white { --rarity: #e2e8f0; --rarity-border: rgba(226, 232, 240, 0.32); --rarity-glow: rgba(226, 232, 240, 0.08); }
.rarity-blue { --rarity: #60a5fa; --rarity-border: rgba(96, 165, 250, 0.4); --rarity-glow: rgba(96, 165, 250, 0.11); }
.rarity-gold { --rarity: #fbbf24; --rarity-border: rgba(251, 191, 36, 0.44); --rarity-glow: rgba(251, 191, 36, 0.12); }
.rarity-item { --rarity: #22d3ee; --rarity-border: rgba(34, 211, 238, 0.38); --rarity-glow: rgba(34, 211, 238, 0.1); }
.cards-owned {
  min-height: 12px;
  margin: 0 0 8px;
  font-size: 8.5px;
  line-height: 1.6;
  letter-spacing: 0.04em;
  color: var(--dim);
}
.cards-hint {
  margin: 0;
  font-size: 8px;
  letter-spacing: 0.08em;
  color: rgba(148, 163, 184, 0.52);
}
@keyframes card-enter {
  from { opacity: 0; transform: translateY(12px) scale(0.98); }
  to { opacity: 1; transform: none; }
}

/* ---------- 方块选择 ---------- */
.piece-picker-card { max-width: 340px; }
.piece-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 7px;
  margin: 2px 0 4px;
}
.piece-choice {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 7px 2px 5px;
  border-radius: 12px;
  border: 1px solid rgba(148, 163, 184, 0.16);
  background: rgba(255, 255, 255, 0.03);
  cursor: pointer;
  transition: transform 0.08s ease, border-color 0.15s ease, background 0.15s ease;
}
.piece-choice canvas {
  display: block;
  width: 44px;
  height: 30px;
}
.piece-choice span {
  font-size: 8.5px;
  font-weight: 800;
  letter-spacing: 0.08em;
  color: var(--muted);
}
.piece-choice:hover {
  border-color: var(--piece-color, rgba(148, 163, 184, 0.5));
  background: rgba(255, 255, 255, 0.055);
}
.piece-choice:active { transform: scale(0.94); }
#piece-back { margin-top: 12px; }
#piece-back[hidden] { display: none !important; }

/* ---------- 横屏提示 ---------- */
.rotate-hint {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 80;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 24px;
  text-align: center;
  background: rgba(4, 7, 13, 0.94);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}
.rotate-hint p {
  margin: 0;
  font-size: 16px;
  font-weight: 800;
  letter-spacing: 0.1em;
}
.rotate-hint small {
  font-size: 11px;
  letter-spacing: 0.14em;
  color: var(--dim);
}
.rotate-phone {
  width: 44px;
  height: 70px;
  border: 2px solid rgba(165, 243, 252, 0.65);
  border-radius: 9px;
  position: relative;
  animation: rotate-phone 2.2s ease-in-out infinite;
}
.rotate-phone::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 5px;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: rgba(165, 243, 252, 0.8);
  transform: translateX(-50%);
}
@keyframes rotate-phone {
  0%, 20% { transform: rotate(0deg); }
  60%, 100% { transform: rotate(90deg); }
}

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

/* ---------- 响应式 ---------- */
@media (pointer: coarse) {
  .kbd-hint { display: none; }
}

@media (max-height: 700px) {
  #app { gap: 6px; padding-top: calc(var(--safe-t) + 6px); padding-bottom: calc(var(--safe-b) + 6px); }
  .hud { min-height: 40px; }
  .score { font-size: 20px; }
  .pad-btn { height: 46px; }
  .hints { gap: 6px; margin-top: 16px; }
  .hint { padding: 7px 10px; }
  .overlay-card { padding-top: 20px; padding-bottom: 20px; }
  .logo-wrap { margin-bottom: 12px; }
  .item-dock { gap: 4px; }
  .item-btn { border-radius: 10px; }
  .card-option { padding: 10px 13px 9px 15px; }
  .card-options { gap: 7px; margin-top: 11px; }
}

@media (max-height: 620px) {
  .combo-panel { display: none; }
  .hint { padding: 6px 10px; }
  .hints { margin-top: 12px; }
  .cta { height: 48px; }
  .mode-note { margin-bottom: 10px; }
  .card-desc { font-size: 10px; }
  .card-foot { display: none; }
}

@media (max-width: 350px) {
  .rail { width: 44px; }
  .hud-chips { border-radius: 10px; }
  .chip { min-width: 38px; padding: 0 3px; }
  .icon-btn { width: 31px; height: 31px; }
  .pad-label { letter-spacing: 0.08em; }
  .hint b { font-size: 11px; }
  .xp-track { min-width: 20px; flex-basis: 30px; }
  .xp-num { font-size: 7.5px; }
  .item-btn svg { width: 16px; height: 16px; }
  .card-option { padding: 9px 11px 8px 13px; }
  .piece-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (orientation: landscape) and (pointer: coarse) and (max-height: 560px) {
  .rotate-hint { display: flex; }
}

@media (prefers-reduced-motion: reduce) {
  .orb { animation: none; }
  .board-frame.shake { animation: none; }
  .new-best { animation: none; }
  .rotate-phone { animation: none; transform: rotate(90deg); }
  .score.bump { animation: none; }
  .card-option { animation: none; }
  .xp-fill { transition: none; }
  .item-btn.pulse { animation: none; }
}
