:root {
  --bg-deep: #060a12;
  --bg-panel: rgba(8, 18, 32, 0.92);
  --cyan: #00e5ff;
  --cyan-dim: rgba(0, 229, 255, 0.35);
  --text: #c8e8ff;
  --tile-w: 68px;
  --tile-h: 82px;
  --radius: 6px;
  /* 麻将牌深灰底 */
  --tile-bg-top: #525860;
  --tile-bg: #3d4249;
  --tile-bg-bottom: #2c3036;
  --tile-border: #6a717c;
  --tile-edge: #1a1d22;
  /* 牌桌深灰底 */
  --board-bg-top: #3a4049;
  --board-bg: #2c3139;
  --board-bg-bottom: #22262d;
  --board-border: #525a68;

  /* 五行霓虹 */
  --wx-wood: #3dff9a;
  --wx-wood-glow: rgba(61, 255, 154, 0.65);
  --wx-fire: #ff3d5c;
  --wx-fire-glow: rgba(255, 61, 92, 0.7);
  --wx-earth: #9a6b45;
  --wx-earth-glow: rgba(180, 140, 100, 0.55);
  --tile-earth-bg-top: #6d4d35;
  --tile-earth-bg: #523a28;
  --tile-earth-bg-bottom: #3d2a1e;
  --tile-earth-edge: #2a1c14;
  --wx-earth-char: #f8f4ee;
  --wx-metal: #ffe566;
  --wx-metal-glow: rgba(255, 229, 102, 0.7);
  --wx-water: #00d4ff;
  --wx-water-glow: rgba(0, 212, 255, 0.7);
  --wx-relation: #c77dff;
  --wx-relation-glow: rgba(199, 125, 255, 0.6);
  --gold: #ffbe3d;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: "PingFang SC", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  background: var(--bg-deep);
  min-height: 100dvh;
  color: var(--text);
  overflow-x: hidden;
  overscroll-behavior: none;
  touch-action: manipulation;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse 80% 50% at 50% 0%, rgba(0, 100, 140, 0.18), transparent 55%),
    radial-gradient(ellipse 60% 40% at 80% 100%, rgba(120, 0, 180, 0.12), transparent 50%),
    linear-gradient(180deg, #060a12 0%, #0a1420 50%, #060a12 100%);
  pointer-events: none;
  z-index: 0;
}

body::after {
  content: "";
  position: fixed;
  inset: 0;
  opacity: 0.12;
  background-image:
    linear-gradient(var(--cyan-dim) 1px, transparent 1px),
    linear-gradient(90deg, var(--cyan-dim) 1px, transparent 1px);
  background-size: 28px 28px;
  pointer-events: none;
  z-index: 0;
}

body:not(.in-game):not(.in-rules-page) {
  height: 100dvh;
  max-height: 100dvh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

body:not(.in-game):not(.in-rules-page) #app {
  height: auto;
  max-height: 100dvh;
  min-height: 0;
  flex: 0 1 auto;
  overflow: hidden;
}

#app {
  position: relative;
  z-index: 1;
  max-width: 520px;
  margin: 0 auto;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding-left: env(safe-area-inset-left, 0);
  padding-right: env(safe-area-inset-right, 0);
  padding-bottom: env(safe-area-inset-bottom, 0);
}

.top-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  background: rgba(0, 20, 40, 0.75);
  border-bottom: 1px solid var(--cyan-dim);
  box-shadow: 0 0 20px rgba(0, 229, 255, 0.08);
}

.top-bar h1 {
  font-size: 1.4rem;
  font-weight: 800;
  letter-spacing: 0.28em;
  flex: 1;
  color: var(--cyan);
  text-shadow:
    0 0 8px rgba(0, 229, 255, 0.9),
    0 0 24px rgba(0, 229, 255, 0.4);
}

.level-label {
  font-size: 1.5rem;
  line-height: 1.25;
  color: var(--cyan);
  opacity: 0.85;
  text-shadow: 0 0 6px var(--cyan-dim);
}

.icon-btn {
  width: 36px;
  height: 36px;
  border: 1px solid var(--cyan-dim);
  border-radius: 4px;
  background: rgba(0, 229, 255, 0.08);
  color: var(--cyan);
  font-size: 1.1rem;
  cursor: pointer;
  box-shadow: 0 0 10px rgba(0, 229, 255, 0.15);
}

.screen {
  display: none;
  flex: 1;
  flex-direction: column;
  padding: 0 12px 16px;
}

.screen.active {
  display: flex;
}

.screen[hidden] {
  display: none !important;
}

/* —— 首页：Logo + 开始按钮 —— */
body:not(.in-game):not(.in-rules-page) .top-bar-game {
  display: none;
}

body.in-rules-page .top-bar-game {
  display: flex;
}

#screen-menu {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: 14px 12px;
  padding-top: max(14px, env(safe-area-inset-top, 0));
  padding-bottom: max(6px, env(safe-area-inset-bottom, 0));
  width: 100%;
  max-width: 520px;
  margin: 0 auto;
  min-height: 0;
  overflow: hidden;
}

#screen-menu::before,
#screen-menu::after {
  display: none;
}

.home-hero {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 10px;
  flex-shrink: 0;
}

.home-actions {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  flex-shrink: 0;
}

body:not(.in-game) .home-logo {
  width: min(96vw, 400px);
  max-width: 100%;
  height: auto;
  display: block;
  filter: drop-shadow(0 10px 32px rgba(0, 0, 0, 0.55));
}

.home-credit-link {
  display: inline-block;
  margin-top: 10px;
  padding: 4px 2px;
  font-size: 1.05rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  color: #3dff9a;
  text-decoration: underline;
  text-underline-offset: 4px;
  text-decoration-thickness: 2px;
  cursor: pointer;
  transition: color 0.2s ease, text-shadow 0.2s ease;
}

.home-credit-link:hover {
  color: #7dffb8;
  text-shadow: 0 0 12px rgba(61, 255, 154, 0.55);
}

.home-credit-link:active {
  color: #2ee87a;
}

.home-knowledge {
  margin-top: 12px;
  text-align: center;
}

.home-knowledge-link {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  text-decoration: none;
  padding: 8px 16px;
  border-radius: 8px;
  border: 1px solid var(--cyan-dim);
  background: rgba(0, 229, 255, 0.06);
  transition: background 0.2s ease, box-shadow 0.2s ease;
}

.home-knowledge-link:hover {
  background: rgba(0, 229, 255, 0.12);
  box-shadow: 0 0 16px rgba(0, 229, 255, 0.2);
}

.home-knowledge-domain {
  font-size: 1rem;
  font-weight: 700;
  color: var(--cyan);
  letter-spacing: 0.04em;
}

.home-knowledge-cta {
  font-size: 0.88rem;
  color: var(--text);
  opacity: 0.85;
}

.home-menu-center {
  flex: 1;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 0;
}

.home-mix-actions {
  width: min(92vw, 380px);
  max-width: 100%;
  margin: 0 auto;
}

.daily-progress {
  width: 100%;
  margin-bottom: 10px;
  padding: 8px 12px;
  border-radius: 10px;
  background: rgba(255, 190, 61, 0.1);
  border: 1px solid rgba(255, 190, 61, 0.28);
}

.daily-progress-line {
  margin: 0;
  font-size: 0.82rem;
  line-height: 1.45;
  text-align: center;
  color: var(--text-muted, rgba(220, 240, 255, 0.9));
}

.daily-progress-line.daily-done {
  color: var(--gold, #ffbe3d);
  font-weight: 700;
}

.daily-dot {
  display: inline-block;
  width: 9px;
  height: 9px;
  margin: 0 3px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.25);
  vertical-align: middle;
}

.daily-dot.done {
  background: var(--cyan, #00e5ff);
  box-shadow: 0 0 6px rgba(0, 229, 255, 0.5);
}

.daily-progress-num {
  margin-left: 4px;
  font-weight: 700;
}

.btn-daily-leaderboard {
  margin-top: 4px;
  margin-bottom: 10px;
  padding: 10px 14px;
  width: 100%;
  border: 1px solid rgba(255, 190, 61, 0.45);
  border-radius: 12px;
  background: rgba(255, 190, 61, 0.12);
  color: var(--gold, #ffbe3d);
  font-size: 0.92rem;
  font-weight: 700;
  cursor: pointer;
}

.btn-daily-leaderboard:active {
  transform: scale(0.98);
}

.btn-mix-plate.level-done {
  opacity: 0.55;
  border-color: rgba(0, 229, 255, 0.35);
}

.btn-mix-plate.level-locked {
  opacity: 0.45;
}

.modal-nickname-card,
.modal-leaderboard-card {
  max-width: 360px;
}

.modal-nickname-title,
.modal-leaderboard-title {
  margin: 0 0 8px;
  font-size: 1.15rem;
}

.modal-nickname-hint,
.leaderboard-day {
  margin: 0 0 6px;
  font-size: 0.85rem;
  opacity: 0.85;
}

.leaderboard-sort-hint {
  margin: 0 0 12px;
  font-size: 0.78rem;
  opacity: 0.72;
  line-height: 1.4;
}

.nickname-input {
  width: 100%;
  box-sizing: border-box;
  padding: 10px 12px;
  margin-bottom: 8px;
  border: 1px solid var(--cyan-dim, rgba(0, 229, 255, 0.35));
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.25);
  color: inherit;
  font-size: 1rem;
}

.nickname-error {
  min-height: 1.2em;
  margin: 0 0 10px;
  font-size: 0.82rem;
  color: #ff6b6b;
}

.leaderboard-list {
  max-height: 50vh;
  overflow-y: auto;
  margin-bottom: 12px;
}

.leaderboard-ol {
  list-style: none;
  margin: 0;
  padding: 0;
}

.leaderboard-row {
  display: grid;
  grid-template-columns: 2rem 1fr auto auto;
  gap: 8px;
  align-items: center;
  padding: 8px 4px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 0.88rem;
}

.lb-rank {
  font-weight: 800;
  color: var(--gold, #ffbe3d);
}

.lb-pts {
  color: var(--cyan, #00e5ff);
  font-weight: 700;
}

.lb-time {
  font-size: 0.78rem;
  opacity: 0.7;
}

.leaderboard-empty,
.leaderboard-loading {
  text-align: center;
  opacity: 0.8;
  padding: 16px 0;
}

.btn-mix-plate {
  display: block;
  width: 100%;
  margin: 0 0 10px;
  padding: 12px 10px;
  min-height: 50px;
  font-size: 1.42rem;
  line-height: 1.28;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-align: center;
  color: #f0e8ff;
  background: linear-gradient(180deg, #5a6a8a 0%, #3d4a62 100%);
  border: 1px solid rgba(0, 229, 255, 0.25);
  border-radius: 10px;
  cursor: pointer;
  box-shadow: 0 0 16px rgba(0, 229, 255, 0.15);
}

.btn-mix-plate-all {
  color: #1a1028;
  background: linear-gradient(180deg, #c77dff 0%, #9b5de5 100%);
  border: none;
  box-shadow: 0 0 24px var(--wx-relation-glow);
}

.btn-mix-plate:active {
  transform: scale(0.98);
}

.home-mix-actions .promotion-hint {
  margin-top: 8px;
  font-size: 0.78rem;
  line-height: 1.45;
  text-align: center;
  opacity: 0.88;
}

.home-footer-qr {
  margin-top: auto;
  width: 100%;
  display: flex;
  justify-content: center;
  padding: 10px 0 max(8px, env(safe-area-inset-bottom, 0));
  flex-shrink: 0;
}

.home-wechat-qr {
  width: 72px;
  height: 72px;
  display: block;
  object-fit: contain;
  background: #fff;
  border-radius: 10px;
  padding: 4px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.28);
}

.home-stats {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px 18px;
  margin: 14px 0 4px;
  padding: 10px 14px;
  border: 1px solid rgba(0, 229, 255, 0.22);
  border-radius: 12px;
  background: rgba(0, 229, 255, 0.06);
  font-size: 0.82rem;
  color: var(--text-muted, rgba(220, 240, 255, 0.85));
}

.home-stats-item,
.home-stat-item {
  display: inline-flex;
  align-items: baseline;
  gap: 4px;
}

.home-stats-item strong,
.home-stat-item strong {
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--cyan);
  font-variant-numeric: tabular-nums;
}

.home-stats-label {
  opacity: 0.9;
}

.home-stats-line {
  margin: 0;
  width: 100%;
  text-align: center;
  line-height: 1.5;
}

.home-stat-sep {
  margin: 0 2px;
  opacity: 0.55;
}

.home-stats-offline {
  opacity: 0.65;
}

/* —— 首页 · 对照表入口图标 —— */
.home-rules-icon {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-top: 16px;
  padding: 12px 18px;
  border: 1px solid var(--cyan-dim);
  border-radius: 14px;
  background: rgba(0, 229, 255, 0.08);
  color: var(--cyan);
  cursor: pointer;
  box-shadow: 0 0 18px rgba(0, 229, 255, 0.15);
  transition: background 0.2s ease, transform 0.12s ease;
}

.home-rules-icon:active {
  transform: scale(0.97);
}

.home-rules-icon-svg {
  display: block;
  filter: drop-shadow(0 0 8px rgba(0, 229, 255, 0.35));
}

.home-rules-icon-text {
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.2em;
}

/* —— 对照表独立页 —— */
#screen-rules {
  padding: 8px 10px 20px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.rules-page-head {
  text-align: center;
  margin-bottom: 10px;
}

.rules-page-title {
  font-size: 1.2rem;
  font-weight: 800;
  color: var(--cyan);
  letter-spacing: 0.12em;
  margin-bottom: 6px;
  text-shadow: 0 0 12px var(--cyan-dim);
}

.rules-table-count {
  margin: 4px 0;
  text-align: center;
  font-size: 0.75rem;
  opacity: 0.7;
}

.rules-table-hint {
  font-size: 0.72rem;
  text-align: center;
  opacity: 0.65;
  margin-bottom: 8px;
}

.rules-table-wrap {
  overflow: auto;
  border: 1px solid var(--cyan-dim);
  border-radius: 10px;
  background: rgba(4, 12, 24, 0.92);
  -webkit-overflow-scrolling: touch;
  box-shadow: inset 0 0 24px rgba(0, 229, 255, 0.04);
}

.rules-table-wrap-page {
  max-height: none;
  flex: 1;
  min-height: min(72dvh, 640px);
}

.rules-sheet-footer {
  padding: 14px 10px 20px;
  padding-bottom: max(20px, env(safe-area-inset-bottom, 0));
}

.btn-rules-ok {
  display: block;
  width: 100%;
  max-width: 280px;
  margin: 0 auto;
  padding: 14px 24px;
  border: 2px solid #e6a800;
  border-radius: 12px;
  background: linear-gradient(180deg, #ffe566 0%, #ffd028 50%, #f5c400 100%);
  color: #c62828;
  font-size: 1.35rem;
  font-weight: 900;
  letter-spacing: 0.35em;
  text-indent: 0.35em;
  cursor: pointer;
  touch-action: manipulation;
  box-shadow: 0 3px 0 #c9a000, 0 4px 14px rgba(0, 0, 0, 0.35);
}

.btn-rules-ok:active {
  transform: translateY(2px) scale(0.99);
  box-shadow: 0 1px 0 #c9a000;
}

.rules-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.78rem;
}

.rules-table thead {
  position: sticky;
  top: 0;
  z-index: 2;
  background: #0a1828;
  box-shadow: 0 2px 0 var(--cyan-dim);
}

.rules-table th {
  padding: 8px 6px;
  font-weight: 700;
  color: var(--cyan);
  text-align: left;
  white-space: nowrap;
  letter-spacing: 0.08em;
}

.rules-table td {
  padding: 7px 6px;
  border-top: 1px solid rgba(0, 229, 255, 0.08);
  vertical-align: middle;
}

.rules-section-row td {
  padding: 10px 8px;
  font-weight: 800;
  font-size: 0.82rem;
  letter-spacing: 0.1em;
  border-top: 2px solid rgba(0, 229, 255, 0.25);
}

.rules-section-count {
  font-weight: 600;
  font-size: 0.68rem;
  opacity: 0.75;
  margin-left: 6px;
}

.rules-data-row {
  cursor: pointer;
  transition: background 0.15s ease;
}

.rules-data-row:hover,
.rules-data-row:focus {
  background: rgba(0, 229, 255, 0.1);
  outline: none;
}

.rules-data-row:active {
  background: rgba(0, 229, 255, 0.16);
}

.rules-row-study-only .col-note::after {
  content: ' · 仅学习';
  font-size: 0.62rem;
  opacity: 0.55;
}

.col-els b {
  font-size: 0.92rem;
  letter-spacing: 0.15em;
}

.col-tf {
  color: var(--gold);
  font-weight: 700;
  white-space: nowrap;
}

.col-note {
  font-size: 0.7rem;
  opacity: 0.85;
  line-height: 1.35;
}

.tone-he .rules-section-row td {
  color: #7ee8ff;
}

.tone-he.rules-data-row .col-type {
  color: #9ef0ff;
}

.tone-xing .rules-section-row td,
.tone-chong .rules-section-row td {
  color: #ff9eb5;
}

.tone-xing.rules-data-row .col-type,
.tone-chong.rules-data-row .col-type {
  color: #ff7a96;
}

.tone-sha .rules-section-row td {
  color: #ffb86a;
}

.tone-sha.rules-data-row .col-type {
  color: #ffbe3d;
}

.rules-sheet-defs {
  margin-bottom: 10px;
  padding: 10px 12px;
  border: 1px solid rgba(255, 190, 61, 0.35);
  border-radius: 10px;
  background: rgba(40, 28, 8, 0.45);
}

.rules-def-item {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  margin-bottom: 8px;
  line-height: 1.45;
}

.rules-def-item:last-child {
  margin-bottom: 0;
}

.rules-def-title {
  flex-shrink: 0;
  min-width: 1.6em;
  font-weight: 900;
  color: #ffbe3d;
  letter-spacing: 0.12em;
}

.rules-def-text {
  flex: 1;
  color: rgba(230, 235, 245, 0.88);
  font-size: 0.82rem;
}

/* 对局内打开的本盘口诀表（整体略小） */
body.in-rules-page.in-game .rules-page-title {
  font-size: 1.5rem;
}

body.in-rules-page.in-game .rules-table-count {
  font-size: 0.95rem;
}

body.in-rules-page.in-game .rules-table-hint {
  display: none;
}

body.in-rules-page.in-game .rules-def-text {
  font-size: 0.78rem;
}

body.in-rules-page.in-game .rules-table {
  font-size: 1rem;
}

body.in-rules-page.in-game .rules-table th,
body.in-rules-page.in-game .rules-table td {
  padding: 7px 6px;
}

body.in-rules-page.in-game .rules-section-row td {
  font-size: 1.05rem;
  padding: 8px 6px;
}

body.in-rules-page.in-game .rules-section-count {
  font-size: 0.82rem;
}

body.in-rules-page.in-game .col-els b {
  font-size: 1.12rem;
}

body.in-rules-page.in-game .col-type,
body.in-rules-page.in-game .col-rel {
  font-size: 0.95rem;
}

body.in-rules-page.in-game.modal-open .rule-detail-cat {
  font-size: 1.31rem;
}

body.in-rules-page.in-game.modal-open .rule-detail-rel {
  font-size: 2.4rem;
}

body.in-rules-page.in-game.modal-open .rule-detail-transform,
body.in-rules-page.in-game.modal-open .rule-detail-mnemonic {
  font-size: 1.2rem;
}

body.in-rules-page.in-game.modal-open .rule-detail-note {
  font-size: 1.02rem;
}

body.in-rules-page.in-game.modal-open .rule-char {
  min-width: 64px;
  min-height: 72px;
  font-size: 1.76rem;
}

body.in-rules-page.in-game.modal-open .rule-char small {
  font-size: 0.8rem;
}

body.in-rules-page.in-game.modal-open .modal-rule-card {
  max-width: min(92vw, 420px);
}

/* 规则学习弹窗 */
.modal-rule .modal-rule-card {
  max-width: 360px;
  text-align: center;
}

.rule-detail-cat {
  font-size: 0.82rem;
  color: var(--cyan);
  letter-spacing: 0.2em;
  margin-bottom: 4px;
}

.rule-detail-rel {
  font-size: 1.5rem;
  font-weight: 900;
  color: #fff;
  letter-spacing: 0.25em;
  margin-bottom: 12px;
  text-shadow: 0 0 16px var(--wx-relation-glow);
}

.rule-detail-chars {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  margin-bottom: 12px;
}

.rule-char {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-width: 52px;
  min-height: 58px;
  padding: 6px 10px;
  border-radius: 10px;
  font-size: 1.75rem;
  font-weight: 900;
  border: 2px solid var(--tile-border);
  background: linear-gradient(165deg, var(--tile-bg-top), var(--tile-bg-bottom));
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

.rule-char small {
  font-size: 0.62rem;
  font-weight: 700;
  margin-top: 4px;
  opacity: 0.9;
}

.rule-char.wx-wood { color: var(--wx-wood); border-color: var(--wx-wood); }
.rule-char.wx-fire { color: var(--wx-fire); border-color: var(--wx-fire); }
.rule-char.wx-earth {
  color: var(--wx-earth-char);
  border-color: #b07a4f;
  background: linear-gradient(165deg, var(--tile-earth-bg-top), var(--tile-earth-bg-bottom));
  text-shadow: 0 0 8px rgba(0, 0, 0, 0.5);
}
.rule-char.wx-metal { color: var(--wx-metal); border-color: var(--wx-metal); }
.rule-char.wx-water { color: var(--wx-water); border-color: var(--wx-water); }

.rule-detail-transform {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--gold);
  margin-bottom: 8px;
  text-shadow: 0 0 12px rgba(255, 190, 61, 0.45);
}

.rule-detail-mnemonic {
  font-size: 1rem;
  margin-bottom: 10px;
  opacity: 0.9;
}

.rule-detail-note {
  font-size: 0.75rem;
  opacity: 0.65;
  line-height: 1.5;
  margin-bottom: 16px;
}

.rule-detail-note.study-only {
  color: #ffb86a;
  opacity: 0.9;
}

.btn-rule-close {
  width: 100%;
  min-height: 48px;
}

body.modal-open {
  overflow: hidden;
}

/* —— 难度层选择 —— */
#screen-tier {
  flex: 1;
  flex-direction: column;
  justify-content: center;
  padding: 12px 10px 20px;
  overflow: hidden;
  min-height: 0;
}

.tier-plate-title {
  text-align: center;
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--cyan);
  letter-spacing: 0.08em;
  margin-bottom: 6px;
  text-shadow: 0 0 12px var(--cyan-dim);
}

.tier-plate-hint {
  text-align: center;
  font-size: 0.82rem;
  opacity: 0.7;
  margin-bottom: 14px;
}

.tier-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-bottom: 16px;
}

.btn-tier {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 56px;
  padding: 10px 8px;
  border-radius: 10px;
  border: 1px solid rgba(0, 229, 255, 0.3);
  background: linear-gradient(180deg, #4a5568 0%, #343d4d 100%);
  color: #eef6ff;
  cursor: pointer;
  box-shadow: 0 0 12px rgba(0, 229, 255, 0.12);
}

.btn-tier:active {
  transform: scale(0.98);
}

.btn-tier .tier-num {
  font-size: 1.05rem;
  font-weight: 800;
  letter-spacing: 0.06em;
}

.btn-tier .tier-meta {
  margin-top: 4px;
  font-size: 0.88rem;
  color: var(--gold);
  opacity: 0.95;
}

.btn-tier .tier-status {
  margin-top: 3px;
  font-size: 0.72rem;
  opacity: 0.75;
}

.btn-tier-cleared {
  border-color: rgba(199, 125, 255, 0.45);
  box-shadow: 0 0 14px rgba(199, 125, 255, 0.2);
}

.btn-tier-cleared .tier-status {
  color: #c9a0ff;
}

.btn-tier-locked {
  opacity: 0.42;
  cursor: not-allowed;
  filter: grayscale(0.35);
}

.btn-tier-locked .tier-status {
  color: #8899aa;
}

.menu-progress {
  color: var(--cyan);
  opacity: 0.85;
}

.btn-tier-back {
  display: block;
  width: 100%;
  padding: 14px;
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 10px;
  cursor: pointer;
}

.home-actions .btn-start-game {
  display: block;
  width: 100%;
  margin: 0 0 14px;
  padding: 22px 18px;
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: 0.32em;
  color: #060a12;
  background: linear-gradient(180deg, var(--cyan) 0%, #00a8c8 100%);
  border: none;
  border-radius: 12px;
  cursor: pointer;
  box-shadow: 0 0 32px rgba(0, 229, 255, 0.5);
}

.home-actions .btn-promotion-game {
  display: block;
  width: 100%;
  margin-bottom: 12px;
  padding: 20px 18px;
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: 0.2em;
}

.home-actions .promotion-hint {
  font-size: 0.9rem;
  text-align: center;
  opacity: 0.65;
  line-height: 1.5;
  margin: 0;
  padding: 0 4px;
}

body.in-game .top-bar-game {
  display: flex;
}

.subtitle {
  text-align: center;
  font-size: 0.9rem;
  color: var(--cyan);
  text-shadow: 0 0 10px var(--cyan-dim);
  margin-bottom: 4px;
}

.tagline {
  text-align: center;
  font-size: 0.72rem;
  opacity: 0.55;
  margin-bottom: 22px;
  letter-spacing: 0.05em;
}

.btn-start-game {
  display: block;
  width: 100%;
  margin: 24px 0;
  padding: 18px;
  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: 0.35em;
  color: #060a12;
  background: linear-gradient(180deg, var(--cyan) 0%, #00a8c8 100%);
  border: none;
  border-radius: 10px;
  cursor: pointer;
  box-shadow: 0 0 28px rgba(0, 229, 255, 0.45);
}

.btn-start-game:active {
  transform: scale(0.98);
}

.btn-promotion-game {
  display: block;
  width: 100%;
  margin-bottom: 8px;
  padding: 16px;
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.2em;
  color: #f0e8ff;
  background: linear-gradient(180deg, #7a5cad 0%, #5c4590 100%);
  border: none;
  border-radius: 10px;
  cursor: pointer;
  box-shadow: 0 0 20px var(--wx-relation-glow);
}

.btn-promotion-game.needs-pass:active,
.btn-promotion-game:active {
  transform: scale(0.98);
}

.btn-promotion-game.unlocked {
  color: #1a1028;
  background: linear-gradient(180deg, #c77dff 0%, #9b5de5 100%);
  box-shadow: 0 0 24px var(--wx-relation-glow);
}

.pass-modal .pass-modal-desc {
  font-size: 0.88rem;
  opacity: 0.85;
  margin-bottom: 8px;
  line-height: 1.5;
}

.pass-input {
  width: 100%;
  padding: 12px 14px;
  margin-bottom: 8px;
  font-size: 1rem;
  border-radius: 8px;
  border: 1px solid var(--cyan-dim);
  background: rgba(4, 12, 28, 0.9);
  color: var(--text);
}

.pass-error {
  color: var(--wx-fire);
  font-size: 0.82rem;
  margin-bottom: 10px;
}

.promotion-hint {
  font-size: 0.68rem;
  text-align: center;
  opacity: 0.55;
  margin-bottom: 16px;
  padding: 0 10px;
}

.campaign-phases {
  font-size: 0.62rem;
  line-height: 1.5;
  opacity: 0.55;
  margin-bottom: 12px;
  text-align: center;
  padding: 0 8px;
}

#screen-game:not(.active) {
  display: none !important;
  visibility: hidden;
  height: 0;
  overflow: hidden;
  padding: 0;
  margin: 0;
}

.game-knowledge {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 4px;
  flex-shrink: 0;
  padding: 6px 8px 4px;
  background: linear-gradient(180deg, rgba(0, 32, 56, 0.92), rgba(0, 20, 40, 0.75));
  border-bottom: 1px solid rgba(0, 229, 255, 0.22);
}

.btn-plate-knowledge {
  width: 100%;
  margin: 0;
  padding: 10px 12px;
  border: 2px solid #e6a800;
  border-radius: 10px;
  background: linear-gradient(180deg, #ffe566 0%, #ffd028 50%, #f5c400 100%);
  color: #c62828;
  font-size: 1rem;
  font-weight: 900;
  letter-spacing: 0.2em;
  cursor: pointer;
  touch-action: manipulation;
  text-align: center;
  box-shadow: 0 3px 0 #c9a000, 0 4px 12px rgba(0, 0, 0, 0.35);
}

.btn-plate-knowledge:active {
  transform: translateY(2px) scale(0.99);
  box-shadow: 0 1px 0 #c9a000, 0 2px 6px rgba(0, 0, 0, 0.3);
  background: linear-gradient(180deg, #ffd84a 0%, #f5bc00 100%);
}

.btn-plate-knowledge-text {
  display: block;
  width: 100%;
  text-align: center;
  font-size: inherit;
  font-weight: inherit;
  letter-spacing: inherit;
  color: inherit;
}

.game-knowledge-hint {
  text-align: center;
  font-size: 0.68rem;
  color: rgba(180, 210, 230, 0.65);
  letter-spacing: 0.06em;
}

.game-hud {
  flex-shrink: 0;
  padding: 6px 8px 3px;
  background: rgba(0, 20, 40, 0.75);
  border-bottom: 1px solid var(--cyan-dim);
}

.hud-top-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;
}

.hud-top-row .hud-score-wrap {
  flex: 1;
  min-width: 0;
  margin-bottom: 0;
}

.btn-hint {
  flex-shrink: 0;
  border: 2px solid var(--cyan);
  background: linear-gradient(165deg, rgba(0, 80, 100, 0.9), rgba(0, 40, 70, 0.95));
  color: var(--cyan);
  font-size: 0.78rem;
  font-weight: 800;
  padding: 8px 12px;
  border-radius: 10px;
  cursor: pointer;
  touch-action: manipulation;
  box-shadow: 0 0 12px var(--cyan-dim);
  letter-spacing: 0.06em;
}

.btn-hint .hud-hints-num {
  display: inline-block;
  min-width: 1.1em;
  margin-left: 2px;
  color: var(--gold);
}

.btn-hint:disabled,
.btn-hint.btn-hint-empty {
  opacity: 0.45;
  cursor: not-allowed;
  border-color: #4a5568;
  color: #8a9aaa;
  box-shadow: none;
}

.btn-hint:not(:disabled):active {
  transform: scale(0.96);
}

.btn-hint-shake {
  animation: btnHintShake 0.4s ease;
}

@keyframes btnHintShake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-4px); }
  75% { transform: translateX(4px); }
}

.hud-score-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;
}

#hud-score {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--gold, #ffbe3d);
  flex-shrink: 0;
}

.hud-score-bar {
  flex: 1;
  height: 8px;
  background: rgba(0, 0, 0, 0.35);
  border-radius: 4px;
  overflow: hidden;
}

.hud-score-wrap.danger .hud-score-fill {
  background: linear-gradient(90deg, var(--wx-fire), #ff6b8a);
}

.hud-score-wrap.danger #hud-score {
  color: var(--wx-fire);
}

.slot.slot-penalty {
  animation: slotPenalty 0.4s ease;
}

@keyframes slotPenalty {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-4px); }
  40% { transform: translateX(4px); }
  60% { transform: translateX(-3px); }
  80% { transform: translateX(3px); }
}

.hud-score-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #00e5ff, #3dff9a);
  transition: width 0.35s ease;
}

.hud-progress {
  font-size: 1.05rem;
  line-height: 1.3;
  font-weight: 700;
  color: var(--cyan);
  margin-bottom: 2px;
}

.hud-accuracy {
  font-size: 0.68rem;
  opacity: 0.75;
}

.hud-accuracy.warn {
  color: var(--wx-fire);
  opacity: 1;
}

.chapter-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.chapter-list li button {
  width: 100%;
  padding: 16px 18px;
  border: 1px solid var(--cyan-dim);
  border-radius: var(--radius);
  background: var(--bg-panel);
  color: var(--text);
  font-size: 1rem;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s;
  box-shadow:
    inset 0 0 20px rgba(0, 229, 255, 0.04),
    0 0 12px rgba(0, 0, 0, 0.4);
}

.chapter-list li button:hover,
.chapter-list li button:active {
  border-color: var(--cyan);
  box-shadow:
    0 0 16px rgba(0, 229, 255, 0.25),
    inset 0 0 24px rgba(0, 229, 255, 0.06);
}

.chapter-list li button .ch-title {
  font-weight: 700;
  display: block;
  margin-bottom: 4px;
  color: #fff;
}

.chapter-list li button .ch-desc {
  font-size: 0.72rem;
  opacity: 0.55;
}

.hint-foot {
  margin-top: auto;
  padding-top: 24px;
  text-align: center;
  font-size: 0.68rem;
  opacity: 0.4;
  letter-spacing: 0.08em;
}

body.in-game {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  overflow-x: hidden;
  overflow-y: auto;
  height: 100dvh;
  max-height: 100dvh;
  position: fixed;
  inset: 0;
  width: 100%;
}

body.in-game #app {
  flex: 0 0 auto;
  height: auto;
  max-height: 100dvh;
  min-height: 0;
  width: 100%;
  max-width: 520px;
  overflow-x: hidden;
  overflow-y: auto;
}

body.in-game .top-bar {
  flex-shrink: 0;
  padding: 8px 12px;
  padding-top: max(8px, env(safe-area-inset-top, 0));
}

body.in-game .top-bar h1 {
  font-size: 1.15rem;
}

body.in-game .level-label {
  font-size: 1.05rem;
}

#screen-game {
  padding: 0 4px 6px;
  min-height: 0;
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  overflow: visible;
  justify-content: flex-start;
}

body.in-game #game-knowledge,
body.in-game #game-hud {
  flex-shrink: 0;
}

.game-layout {
  display: flex;
  flex: 0 0 auto;
  gap: 4px;
  min-height: 0;
  justify-content: flex-start;
  margin-top: 0;
  width: 100%;
}

.game-main {
  flex: 0 0 auto;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  width: 100%;
}

.matched-log {
  flex-shrink: 0;
  padding: 5px 10px 7px;
  text-align: left;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--gold, #ffbe3d);
  line-height: 1.35;
  letter-spacing: 0.04em;
  word-break: break-all;
  border-top: 1px solid rgba(0, 229, 255, 0.12);
  background: rgba(34, 38, 45, 0.55);
}

.matched-log.matched-log-pop {
  animation: matched-log-pop 0.32s ease-out;
}

@keyframes matched-log-pop {
  0% {
    color: #fff;
    background: rgba(0, 229, 255, 0.22);
  }
  100% {
    color: var(--gold, #ffbe3d);
    background: rgba(34, 38, 45, 0.55);
  }
}

.matched-panel {
  width: 108px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--cyan-dim);
  border-radius: var(--radius);
  background: rgba(4, 10, 22, 0.92);
  overflow: hidden;
  box-shadow: inset 0 0 24px rgba(0, 229, 255, 0.05);
}

.panel-hd {
  font-size: 0.65rem;
  text-align: center;
  padding: 8px 4px;
  color: var(--cyan);
  letter-spacing: 0.2em;
  border-bottom: 1px solid var(--cyan-dim);
  flex-shrink: 0;
}

.panel-hd-sub {
  display: inline-block;
  margin-left: 4px;
  padding: 0 4px;
  font-size: 0.58rem;
  color: var(--gold);
  border: 1px solid rgba(255, 190, 61, 0.45);
  border-radius: 3px;
  letter-spacing: 0.05em;
}

.matched-list {
  flex: 1;
  overflow-y: auto;
  padding: 6px 4px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.matched-entry {
  padding: 6px 5px;
  border-radius: 4px;
  background: rgba(0, 229, 255, 0.06);
  border-left: 2px solid var(--cyan);
  text-align: left;
}

.entry-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 4px;
}

.entry-transform {
  flex-shrink: 0;
  font-size: 0.72rem;
  font-weight: 800;
  color: var(--gold);
  text-shadow: 0 0 8px rgba(255, 190, 61, 0.45);
  letter-spacing: 0.05em;
  line-height: 1.3;
}

.entry-transform-none {
  opacity: 0.35;
  font-weight: 600;
}

.matched-entry.pop-in {
  animation: popIn 0.35s ease;
}

@keyframes popIn {
  from {
    opacity: 0;
    transform: translateX(12px) scale(0.9);
  }
  to {
    opacity: 1;
    transform: translateX(0) scale(1);
  }
}

.entry-line {
  display: block;
  flex: 1;
  min-width: 0;
  font-size: 0.78rem;
  color: #fff;
  line-height: 1.3;
}

.entry-line b {
  font-size: 0.9rem;
  letter-spacing: 0.12em;
  color: var(--cyan);
}

.entry-mnemonic {
  display: block;
  font-size: 0.5rem;
  opacity: 0.55;
  margin-top: 2px;
  line-height: 1.2;
}

.rel-popup {
  position: fixed;
  z-index: 150;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  transform: translate(-50%, -50%);
  transition:
    left 0.55s cubic-bezier(0.22, 0.68, 0.2, 1),
    top 0.55s cubic-bezier(0.22, 0.68, 0.2, 1),
    transform 0.55s ease,
    opacity 0.45s ease;
}

.rel-popup[hidden] {
  display: none !important;
}

/* —— 成局特效：飞牌 → 大字说明合成了什么 —— */
.fuse-overlay {
  position: fixed;
  inset: 0;
  z-index: 400;
  pointer-events: auto;
  cursor: pointer;
  background: radial-gradient(ellipse at center, rgba(0, 40, 70, 0.62), rgba(6, 10, 18, 0.88));
  transition: opacity 0.4s ease;
}

.fuse-overlay[hidden] {
  display: none !important;
  pointer-events: none;
}

.fuse-overlay.fuse-out {
  opacity: 0;
}

.fuse-stage {
  position: absolute;
  inset: 0;
}

.fuse-flight-tile {
  position: fixed;
  z-index: 2;
  margin: 0;
  box-shadow:
    0 8px 0 rgba(0, 0, 0, 0.5),
    0 12px 28px rgba(0, 0, 0, 0.45),
    0 0 24px var(--cyan-dim);
}

.fuse-result {
  position: fixed;
  left: 50%;
  top: 50%;
  z-index: 5;
  transform: translate(-50%, -42%) scale(0.75);
  opacity: 0;
  width: min(94vw, 380px);
  pointer-events: auto;
  cursor: pointer;
}

.fuse-result.fuse-result-show {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
  transition: none;
  animation: fuseResultIn 0.16s cubic-bezier(0.2, 1.12, 0.35, 1);
}

@keyframes fuseResultIn {
  from {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.88);
  }
  to {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
  }
}

.fuse-result.fuse-result-vanish {
  opacity: 0;
  transform: translate(-50%, -48%) scale(1.06);
  transition: opacity 0.38s ease, transform 0.38s ease;
}

.fuse-result-card {
  text-align: center;
  padding: 18px 16px 16px;
  border-radius: 16px;
  background: rgba(8, 16, 32, 0.96);
  border: 3px solid var(--cyan);
  box-shadow:
    0 0 0 1px rgba(0, 229, 255, 0.25),
    0 12px 40px rgba(0, 0, 0, 0.55),
    0 0 32px rgba(0, 229, 255, 0.2);
}

.fuse-result-card.tone-he {
  border-color: var(--wx-wood);
  box-shadow: 0 0 28px rgba(61, 255, 154, 0.25), 0 12px 40px rgba(0, 0, 0, 0.5);
}

.fuse-result-card.tone-chong {
  border-color: var(--wx-fire);
  box-shadow: 0 0 28px rgba(255, 61, 92, 0.25), 0 12px 40px rgba(0, 0, 0, 0.5);
}

.fuse-result-card.tone-sha,
.fuse-result-card.tone-xing {
  border-color: var(--wx-relation);
  box-shadow: 0 0 28px var(--wx-relation-glow), 0 12px 40px rgba(0, 0, 0, 0.5);
}

.fuse-result-title {
  font-size: clamp(1.2rem, 4.8vw, 1.5rem);
  font-weight: 900;
  color: #fff;
  letter-spacing: 0.18em;
  margin-bottom: 12px;
}

.fuse-result-top {
  padding: 8px 4px 4px;
}

.fuse-result-top-label {
  font-size: 0.68rem;
  opacity: 0.7;
  letter-spacing: 0.2em;
  margin-bottom: 10px;
}

.fuse-result-chars {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: center;
  gap: 14px;
  width: 100%;
  padding: 4px 8px;
}

.fuse-result-char {
  position: relative !important;
  left: auto !important;
  top: auto !important;
  width: clamp(56px, 15vw, 80px);
  height: clamp(68px, 18vw, 94px);
  flex: 0 0 auto;
  margin: 0;
}

.fuse-result-char .char {
  font-size: clamp(1.75rem, 6.5vw, 2.4rem);
}

.fuse-result-plus {
  flex: 0 0 auto;
  font-size: clamp(1.5rem, 5.5vw, 2rem);
  font-weight: 900;
  color: var(--gold);
  line-height: 1;
  padding: 0 2px;
  align-self: center;
}

.fuse-result-divider {
  margin: 14px 0 10px;
  height: 1px;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255, 255, 255, 0.35),
    transparent
  );
  position: relative;
}

.fuse-result-divider-arrow {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  font-size: 1.25rem;
  font-weight: 900;
  color: var(--gold);
  background: rgba(8, 16, 32, 0.96);
  padding: 0 10px;
  line-height: 1;
}

.fuse-result-bottom {
  padding: 12px 8px 6px;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.28);
  margin-top: 4px;
}

.fuse-result-bottom-hint {
  font-size: 0.72rem;
  letter-spacing: 0.28em;
  opacity: 0.85;
  margin-bottom: 6px;
}

.fuse-result-attr-hero {
  font-size: clamp(4rem, 24vw, 6.5rem);
  font-weight: 900;
  line-height: 1;
  letter-spacing: 0.05em;
  margin: 4px 0 2px;
}

.fuse-result-attr-line {
  font-size: clamp(1.15rem, 4.8vw, 1.55rem);
  font-weight: 800;
  letter-spacing: 0.2em;
  margin-bottom: 6px;
}

.fuse-result-rel-note {
  font-size: 0.72rem;
  opacity: 0.72;
  letter-spacing: 0.1em;
}

.fuse-dismiss-hint {
  margin-top: 12px;
  font-size: 0.78rem;
  opacity: 0.65;
  letter-spacing: 0.08em;
}

.btn-fuse-close {
  display: block;
  width: 100%;
  margin-top: 14px;
  padding: 12px 16px;
  font-size: 1rem;
  font-weight: 800;
  letter-spacing: 0.2em;
  color: #060a12;
  background: linear-gradient(180deg, var(--cyan) 0%, #00a8c8 100%);
  border: none;
  border-radius: 10px;
  cursor: pointer;
  box-shadow: 0 0 20px rgba(0, 229, 255, 0.35);
}

.btn-fuse-close:active {
  transform: scale(0.98);
}

.fuse-result-bottom.wx-metal .fuse-result-attr-hero,
.fuse-result-bottom.wx-metal .fuse-result-attr-line {
  color: var(--wx-metal);
  text-shadow: 0 0 20px var(--wx-metal-glow), 0 0 40px var(--wx-metal-glow);
}

.fuse-result-bottom.wx-wood .fuse-result-attr-hero,
.fuse-result-bottom.wx-wood .fuse-result-attr-line {
  color: var(--wx-wood);
  text-shadow: 0 0 20px var(--wx-wood-glow), 0 0 40px var(--wx-wood-glow);
}

.fuse-result-bottom.wx-water .fuse-result-attr-hero,
.fuse-result-bottom.wx-water .fuse-result-attr-line {
  color: var(--wx-water);
  text-shadow: 0 0 20px var(--wx-water-glow), 0 0 40px var(--wx-water-glow);
}

.fuse-result-bottom.wx-fire .fuse-result-attr-hero,
.fuse-result-bottom.wx-fire .fuse-result-attr-line {
  color: var(--wx-fire);
  text-shadow: 0 0 20px var(--wx-fire-glow), 0 0 40px var(--wx-fire-glow);
}

.fuse-result-bottom.wx-earth .fuse-result-attr-hero,
.fuse-result-bottom.wx-earth .fuse-result-attr-line {
  color: var(--wx-earth);
  text-shadow: 0 0 20px var(--wx-earth-glow), 0 0 40px var(--wx-earth-glow);
}

.fuse-result-bottom.wx-relation .fuse-result-attr-hero {
  font-size: clamp(2rem, 11vw, 3.2rem);
  letter-spacing: 0.08em;
  color: #fff;
  text-shadow: 0 0 16px var(--wx-relation-glow);
}

.fuse-result-bottom.wx-relation .fuse-result-attr-line {
  font-size: clamp(0.95rem, 4vw, 1.2rem);
  color: var(--gold);
  text-shadow: 0 0 10px rgba(255, 190, 61, 0.45);
}

.rel-popup-tag {
  font-size: 1.75rem;
  font-weight: 900;
  color: #fff;
  padding: 10px 20px;
  border: 2px solid var(--wx-relation);
  border-radius: 6px;
  background: rgba(12, 8, 32, 0.95);
  box-shadow:
    0 0 30px var(--wx-relation-glow),
    0 0 60px rgba(199, 125, 255, 0.25);
  text-shadow: 0 0 16px var(--wx-relation-glow);
  letter-spacing: 0.25em;
  animation: stampPop 0.28s ease;
}

.rel-popup-chars {
  font-size: 1rem;
  color: var(--cyan);
  text-shadow: 0 0 10px var(--cyan-dim);
  letter-spacing: 0.3em;
}

.rel-popup-transform {
  font-size: 0.95rem;
  font-weight: 800;
  color: var(--gold);
  text-shadow: 0 0 10px rgba(255, 190, 61, 0.5);
  letter-spacing: 0.12em;
}

@keyframes stampPop {
  0% {
    transform: scale(0.3);
    opacity: 0;
  }
  70% {
    transform: scale(1.08);
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

body.in-game .board-wrap.board-flat {
  flex: 0 0 auto;
  height: auto;
  width: 100%;
  margin: 2px 0 4px;
  overflow: hidden;
}

body.in-game .board-wrap.board-flat .board {
  min-height: 0;
  height: auto;
  position: relative;
  width: 100%;
}

body.in-game .board-wrap.board-flat .board.board-grid {
  display: grid;
  grid-template-columns: repeat(6, var(--tile-w, 48px));
  grid-template-rows: repeat(6, var(--tile-h, 52px));
  column-gap: var(--board-tile-gap, 2px);
  row-gap: var(--board-tile-gap, 2px);
  padding: var(--board-row-pad, 12px) 10px;
  height: var(--board-frame-h, auto);
  min-height: var(--board-frame-h, auto);
  justify-content: center;
  justify-items: stretch;
  align-content: start;
  box-sizing: border-box;
}

body.in-game .board-wrap.board-flat .board.board-grid .tile {
  position: relative !important;
  left: auto !important;
  top: auto !important;
  margin: 0;
  width: 100% !important;
  max-width: var(--tile-w, 48px);
  justify-self: center;
}

body.in-game .board-wrap {
  flex: 0 0 auto;
  min-height: 0;
  max-height: none;
  margin: 4px 0;
  display: flex;
  flex-direction: column;
}

body.in-game .board {
  min-height: 0;
  height: 100%;
  width: 100%;
}

.board-wrap {
  flex: 1;
  position: relative;
  margin: 6px 0;
  border-radius: 14px;
  overflow: hidden;
  border: 2px solid var(--board-border);
  background:
    radial-gradient(ellipse 85% 65% at 50% 18%, rgba(0, 229, 255, 0.07), transparent 55%),
    linear-gradient(
      180deg,
      var(--board-bg-top) 0%,
      var(--board-bg) 48%,
      var(--board-bg-bottom) 100%
    );
  box-shadow:
    inset 0 2px 14px rgba(0, 0, 0, 0.4),
    inset 0 -4px 12px rgba(0, 0, 0, 0.25),
    0 4px 16px rgba(0, 0, 0, 0.45);
}

body:not(.in-game) .board-wrap {
  min-height: min(72vh, 520px);
  max-height: 75vh;
}

.board {
  position: relative;
  width: 100%;
  height: 100%;
}

body:not(.in-game) .board {
  min-height: min(68vh, 500px);
}

.board-wrap::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    radial-gradient(circle at 22% 78%, rgba(255, 255, 255, 0.04) 0%, transparent 10%),
    radial-gradient(circle at 78% 65%, rgba(0, 229, 255, 0.05) 0%, transparent 8%);
  pointer-events: none;
}

#app.screen-shake {
  animation: screenShake 0.45s cubic-bezier(0.36, 0.07, 0.19, 0.97);
}

@keyframes screenShake {
  0%, 100% { transform: translate(0, 0); }
  12% { transform: translate(-8px, 3px); }
  24% { transform: translate(8px, -3px); }
  36% { transform: translate(-7px, -4px); }
  48% { transform: translate(7px, 4px); }
  60% { transform: translate(-5px, 2px); }
  72% { transform: translate(5px, -2px); }
  84% { transform: translate(-3px, 1px); }
}

.board-wrap.board-penalty {
  animation: boardPenalty 0.45s ease;
  border-color: var(--wx-fire) !important;
  box-shadow:
    inset 0 0 24px rgba(255, 61, 92, 0.35),
    0 0 0 2px var(--wx-fire),
    0 0 20px rgba(255, 61, 92, 0.4) !important;
}

@keyframes boardPenalty {
  0%, 100% { transform: translateX(0); }
  15% { transform: translateX(-7px); }
  30% { transform: translateX(7px); }
  45% { transform: translateX(-5px); }
  60% { transform: translateX(5px); }
  75% { transform: translateX(-3px); }
}

.board-wrap.pick-full {
  border-color: var(--wx-fire);
  box-shadow:
    inset 0 2px 14px rgba(255, 61, 92, 0.15),
    0 0 0 2px var(--wx-fire),
    0 4px 16px rgba(0, 0, 0, 0.45);
}

/* 平铺盘 */
.board-wrap.board-flat {
  overflow: hidden;
}

.board-wrap.board-flat .board {
  min-height: 0;
}

.board-wrap.board-flat .tile.blocked {
  opacity: 1;
  filter: none;
  pointer-events: auto;
}

/* —— 牌：深灰底立体块 + 五行霓虹字 —— */
.tile {
  position: absolute;
  width: var(--tile-w);
  height: var(--tile-h);
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  user-select: none;
  touch-action: manipulation;
  -webkit-user-select: none;
  transition: transform 0.12s ease, filter 0.2s ease, box-shadow 0.12s ease;
  background: linear-gradient(
    165deg,
    var(--tile-bg-top) 0%,
    var(--tile-bg) 48%,
    var(--tile-bg-bottom) 100%
  );
  border: 2px solid var(--tile-border);
  border-bottom: 4px solid var(--tile-edge);
  box-shadow:
    0 4px 0 rgba(0, 0, 0, 0.45),
    0 6px 16px rgba(0, 0, 0, 0.35),
    inset 0 1px 0 rgba(255, 255, 255, 0.12);
}

.tile::before {
  content: "";
  position: absolute;
  inset: 3px;
  border-radius: 7px;
  opacity: 0.35;
  pointer-events: none;
}

.tile:not(.blocked):hover {
  transform: translateY(-2px);
  box-shadow:
    0 6px 0 rgba(0, 0, 0, 0.4),
    0 10px 20px rgba(0, 0, 0, 0.4),
    inset 0 1px 0 rgba(255, 255, 255, 0.15);
}

.tile .char {
  font-size: clamp(1.25rem, 5.2vw, 2rem);
  font-weight: 800;
  line-height: 1;
  z-index: 1;
}

.tile .sub {
  font-size: 0.68rem;
  margin-top: 5px;
  letter-spacing: 0.2em;
  opacity: 0.92;
  z-index: 1;
}

.tile.picked,
.tile.tile-picked-slot {
  pointer-events: none;
  cursor: default;
  transform: translateY(-10px) scale(1.24);
  box-shadow:
    0 0 0 3px var(--cyan),
    0 0 24px rgba(0, 229, 255, 0.65),
    0 10px 22px rgba(0, 0, 0, 0.45);
  z-index: 200 !important;
  transition: transform 0.2s cubic-bezier(0.2, 1.15, 0.35, 1), box-shadow 0.2s ease;
}

.tile.tile-pick-animate {
  animation: tilePickPop 0.22s cubic-bezier(0.2, 1.2, 0.35, 1);
}

.tile.tile-return-shrink {
  animation: tileReturnShrink 0.32s ease forwards;
  z-index: 180 !important;
}

@keyframes tileReturnShrink {
  0% {
    transform: translateY(-10px) scale(1.24);
    opacity: 1;
  }
  100% {
    transform: translateY(0) scale(0.72);
    opacity: 0.45;
  }
}

.tile.picked .char {
  font-size: clamp(1.45rem, 5.8vw, 2.35rem);
}

@keyframes tilePickPop {
  from {
    transform: translateY(0) scale(1);
  }
  to {
    transform: translateY(-10px) scale(1.24);
  }
}

.tile.blocked {
  pointer-events: none;
  cursor: not-allowed;
  filter: grayscale(0.3) brightness(0.78) saturate(0.7);
  opacity: 0.72;
  background: linear-gradient(165deg, #454a52 0%, #35393f 50%, #282b30 100%);
  border-color: #4a4f57;
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.35);
}

.tile.tile-playable {
  cursor: pointer;
}

.tile.tile-playable:not(.blocked):active {
  transform: translateY(2px) scale(0.97);
}

/* 木 */
.tile.wx-wood {
  border-color: var(--wx-wood);
  color: var(--wx-wood);
  box-shadow:
    0 4px 0 var(--tile-edge),
    0 0 12px var(--wx-wood-glow),
    inset 0 0 14px rgba(61, 255, 154, 0.18);
}
.tile.wx-wood .char {
  text-shadow: 0 0 10px var(--wx-wood-glow), 0 0 20px var(--wx-wood-glow);
}
.tile.wx-wood::before {
  background: linear-gradient(135deg, var(--wx-wood), transparent);
}

/* 火 */
.tile.wx-fire {
  border-color: var(--wx-fire);
  color: var(--wx-fire);
  box-shadow:
    0 4px 0 var(--tile-edge),
    0 0 12px var(--wx-fire-glow),
    inset 0 0 14px rgba(255, 61, 92, 0.15);
}
.tile.wx-fire .char {
  text-shadow: 0 0 10px var(--wx-fire-glow), 0 0 22px var(--wx-fire-glow);
}
.tile.wx-fire::before {
  background: linear-gradient(135deg, var(--wx-fire), transparent);
}

/* 土 · 褐底白字 */
.tile.wx-earth {
  border-color: #a87248;
  color: var(--wx-earth-char);
  background: linear-gradient(
    165deg,
    var(--tile-earth-bg-top) 0%,
    var(--tile-earth-bg) 48%,
    var(--tile-earth-bg-bottom) 100%
  );
  border-bottom-color: var(--tile-earth-edge);
  box-shadow:
    0 4px 0 var(--tile-earth-edge),
    0 0 14px rgba(80, 55, 35, 0.9),
    inset 0 1px 0 rgba(180, 140, 100, 0.15);
}
.tile.wx-earth .char {
  color: #fff;
  text-shadow:
    0 0 10px rgba(255, 255, 255, 0.35),
    0 0 18px var(--wx-earth-glow),
    0 2px 4px rgba(0, 0, 0, 0.65);
}
.tile.wx-earth .sub {
  color: rgba(255, 255, 255, 0.88);
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.55);
}
.tile.wx-earth::before {
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.08), transparent);
  opacity: 0.4;
}
.tile.wx-earth.picked,
.tile.wx-earth.tile-picked-slot {
  box-shadow:
    0 0 0 3px var(--cyan),
    0 0 22px rgba(0, 229, 255, 0.5),
    0 8px 16px rgba(0, 0, 0, 0.45),
    inset 0 1px 0 rgba(255, 255, 255, 0.12);
}

/* 金 */
.tile.wx-metal {
  border-color: var(--wx-metal);
  color: var(--wx-metal);
  box-shadow:
    0 4px 0 var(--tile-edge),
    0 0 12px var(--wx-metal-glow),
    inset 0 0 14px rgba(255, 229, 102, 0.15);
}
.tile.wx-metal .char {
  text-shadow: 0 0 10px var(--wx-metal-glow), 0 0 22px var(--wx-metal-glow);
}
.tile.wx-metal::before {
  background: linear-gradient(135deg, var(--wx-metal), transparent);
}

/* 水 */
.tile.wx-water {
  border-color: var(--wx-water);
  color: var(--wx-water);
  box-shadow:
    0 4px 0 var(--tile-edge),
    0 0 12px var(--wx-water-glow),
    inset 0 0 14px rgba(0, 212, 255, 0.16);
}
.tile.wx-water .char {
  text-shadow: 0 0 10px var(--wx-water-glow), 0 0 22px var(--wx-water-glow);
}
.tile.wx-water::before {
  background: linear-gradient(135deg, var(--wx-water), transparent);
}

/* 关系牌 */
.tile.wx-relation.relation {
  border-color: var(--wx-relation);
  color: #f0e0ff;
  font-size: 0.7rem;
  font-weight: 800;
  box-shadow:
    0 4px 0 var(--tile-edge),
    0 0 14px var(--wx-relation-glow),
    inset 0 0 20px rgba(199, 125, 255, 0.2);
}
.tile.wx-relation .char {
  font-size: 0.88rem;
  text-shadow: 0 0 12px var(--wx-relation-glow);
}

.tile.relation[data-rel="拱合"] .char,
.tile.relation[data-rel="暗合"] .char {
  font-size: 0.82rem;
}
.tile.wx-relation::before {
  background: linear-gradient(135deg, var(--wx-relation), var(--cyan));
}

.tile.in-slot,
.tile.in-reserve {
  position: relative;
  left: auto !important;
  top: auto !important;
  flex-shrink: 0;
}

.slot-wrap {
  padding: 6px 2px 4px;
}

.slot-label {
  font-size: 0.68rem;
  margin-bottom: 4px;
  color: #b8e8b6;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
  letter-spacing: 0.12em;
}

.slot {
  display: flex;
  gap: 8px;
  min-height: calc(var(--tile-h) + 14px);
  padding: 7px 10px;
  background: linear-gradient(180deg, #3a4038 0%, #2a3028 100%);
  border-radius: 14px;
  border: 3px solid #4a8f48;
  flex-wrap: nowrap;
  overflow-x: auto;
  box-shadow:
    inset 0 2px 10px rgba(0, 0, 0, 0.06),
    0 3px 8px rgba(0, 0, 0, 0.25);
}

.slot .tile {
  position: relative !important;
  left: auto !important;
  top: auto !important;
}

.slot.full {
  border-color: var(--wx-fire);
  animation: slotPulse 0.6s ease;
  background: linear-gradient(180deg, #453a3a 0%, #352828 100%);
}

.slot.slot-bump {
  animation: slotBump 0.2s ease;
}

@keyframes slotBump {
  50% { transform: scale(1.02); }
}

@keyframes slotPulse {
  50% { border-color: #ff6b8a; }
}

.toolbar {
  display: flex;
  gap: 8px;
  justify-content: center;
  padding: 8px 0;
}

.tool-btn {
  flex: 1;
  max-width: 110px;
  padding: 10px;
  border: 1px solid var(--cyan-dim);
  border-radius: 4px;
  background: rgba(0, 229, 255, 0.06);
  color: var(--cyan);
  font-size: 0.82rem;
  cursor: pointer;
  letter-spacing: 0.1em;
  box-shadow: 0 0 10px rgba(0, 229, 255, 0.1);
}

.tool-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.reserve {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  margin-top: 4px;
  background: rgba(4, 10, 22, 0.85);
  border: 1px solid var(--cyan-dim);
  border-radius: var(--radius);
}

.reserve-label {
  font-size: 0.68rem;
  color: var(--cyan);
  opacity: 0.7;
  flex-shrink: 0;
}

.reserve-tiles {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

.toast {
  position: fixed;
  left: 50%;
  top: 40%;
  transform: translate(-50%, -50%);
  padding: 14px 22px;
  background: rgba(4, 12, 28, 0.95);
  border: 1px solid var(--cyan);
  border-radius: 6px;
  font-size: 1rem;
  font-weight: 700;
  color: var(--cyan);
  z-index: 100;
  pointer-events: none;
  text-shadow: 0 0 12px var(--cyan-dim);
  box-shadow: 0 0 30px rgba(0, 229, 255, 0.35);
  animation: fadeIn 0.2s ease;
}

.toast[hidden] {
  display: none !important;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translate(-50%, -42%); }
  to { opacity: 1; transform: translate(-50%, -50%); }
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(2, 6, 14, 0.82);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 20px;
  backdrop-filter: blur(4px);
}

.modal[hidden] {
  display: none !important;
}

.modal-card {
  background: var(--bg-panel);
  border: 1px solid var(--cyan);
  border-radius: 8px;
  padding: 28px 24px;
  max-width: 320px;
  width: 100%;
  text-align: center;
  box-shadow: 0 0 40px rgba(0, 229, 255, 0.2);
}

.modal-card h2 {
  color: var(--cyan);
  margin-bottom: 12px;
  text-shadow: 0 0 16px var(--cyan-dim);
  letter-spacing: 0.2em;
}

.modal-card p {
  font-size: 0.88rem;
  line-height: 1.6;
  margin-bottom: 22px;
  opacity: 0.85;
}

.modal-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
}

.modal-level-picks {
  margin-bottom: 16px;
}

.modal-level-picks-title {
  margin: 0 0 10px;
  font-size: 0.88rem;
  opacity: 0.9;
}

.modal-level-picks-btns {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.btn-modal-level {
  width: 100%;
  padding: 11px 14px;
  font-size: 0.92rem;
}

.modal-actions.modal-actions-compact {
  margin-top: 4px;
}

.btn-primary {
  padding: 10px 22px;
  border-radius: 4px;
  border: 1px solid var(--cyan);
  background: rgba(0, 229, 255, 0.15);
  color: var(--cyan);
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 0 16px rgba(0, 229, 255, 0.25);
}

.btn-secondary {
  padding: 10px 22px;
  border-radius: 4px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: transparent;
  color: var(--text);
  font-size: 0.9rem;
  cursor: pointer;
}

/* —— PC / 宽屏：首页上下居中 —— */
@media (min-width: 521px) {
  html,
  body:not(.in-game):not(.in-rules-page) {
    height: 100%;
    min-height: 100dvh;
  }

  body:not(.in-game):not(.in-rules-page) {
    display: flex;
    align-items: center;
    justify-content: center;
  }

  body:not(.in-game):not(.in-rules-page) #app {
    width: 100%;
    max-width: 520px;
    height: auto;
    min-height: 0;
    flex: 0 0 auto;
    display: block;
  }

  body:not(.in-game):not(.in-rules-page) #screen-menu {
    flex: none !important;
    width: 100%;
    min-height: min(100dvh, 900px) !important;
    justify-content: flex-start !important;
    align-items: center;
    overflow-y: visible;
    padding: 24px 16px;
  }

  body:not(.in-game):not(.in-rules-page) #screen-menu::before,
  body:not(.in-game):not(.in-rules-page) #screen-menu::after {
    content: none;
    display: none;
  }

  body:not(.in-game) .home-logo {
    width: min(400px, 100%);
  }

  body:not(.in-game) .home-credit-link {
    font-size: 1.12rem;
    margin-top: 12px;
  }

  body:not(.in-game) .home-mix-actions {
    width: 380px;
  }

  body:not(.in-game) .home-wechat-qr {
    width: 80px;
    height: 80px;
  }

  body:not(.in-game) .btn-mix-plate {
    font-size: 1.48rem;
    min-height: 52px;
    padding: 13px 12px;
  }

  body:not(.in-game) .home-mix-actions .promotion-hint {
    font-size: 0.82rem;
  }
}

/* —— 手机 / 窄屏适配 —— */
@media (max-width: 520px) {
  #app {
    max-width: 100%;
  }

  .top-bar {
    padding: 10px 12px;
    padding-top: max(10px, env(safe-area-inset-top, 0));
    gap: 6px;
  }

  .top-bar h1 {
    font-size: 1.1rem;
    letter-spacing: 0.12em;
  }

  .level-label {
    font-size: 1.24rem;
    max-width: 52%;
    text-align: right;
    line-height: 1.2;
  }

  .icon-btn {
    width: 44px;
    height: 44px;
    font-size: 1.1rem;
  }

  #screen-menu {
    overflow: hidden;
    padding: 10px 10px;
    padding-top: max(10px, env(safe-area-inset-top, 0));
    padding-bottom: max(10px, env(safe-area-inset-bottom, 0));
  }

  .home-hero {
    margin-bottom: 8px;
  }

  body:not(.in-game) .home-logo {
    width: min(82vw, 320px);
  }

  .home-credit-link {
    font-size: 1.05rem;
    margin-top: 8px;
  }

  .home-mix-actions {
    width: min(90vw, 360px);
  }

  .btn-mix-plate {
    min-height: 46px;
    padding: 10px 10px;
    font-size: 1.28rem;
    line-height: 1.24;
    margin-bottom: 8px;
  }

  .home-mix-actions .promotion-hint {
    font-size: 0.72rem;
  }

  #screen-tier {
    padding: 8px 10px 12px;
  }

  .tier-plate-title {
    font-size: 1.12rem;
    margin-bottom: 4px;
  }

  .tier-plate-hint {
    font-size: 0.72rem;
    margin-bottom: 10px;
  }

  .tier-grid {
    gap: 8px;
    margin-bottom: 10px;
  }

  .btn-tier {
    min-height: 48px;
    padding: 8px 6px;
  }

  .btn-tier .tier-num {
    font-size: 0.95rem;
  }

  .btn-tier .tier-meta {
    font-size: 0.78rem;
    margin-top: 2px;
  }

  .rules-table-wrap-page {
    min-height: min(65dvh, 520px);
  }

  .rules-table {
    font-size: 0.72rem;
  }

  .home-rules-icon {
    margin-top: 12px;
    padding: 10px 14px;
  }

  .rules-table th,
  .rules-table td {
    padding: 6px 4px;
  }

  .col-els b {
    font-size: 0.85rem;
  }

  body.in-rules-page.in-game .rules-page-title {
    font-size: 1.28rem;
  }

  body.in-rules-page.in-game .rules-table {
    font-size: 0.88rem;
  }

  body.in-rules-page.in-game .rules-table-count {
    font-size: 0.82rem;
  }

  body.in-rules-page.in-game .rules-def-text {
    font-size: 0.72rem;
  }

  body.in-rules-page.in-game .rules-section-row td {
    font-size: 0.92rem;
  }

  body.in-rules-page.in-game .col-els b {
    font-size: 1rem;
  }

  body.in-rules-page.in-game .col-type,
  body.in-rules-page.in-game .col-rel {
    font-size: 0.86rem;
  }

  body.in-rules-page.in-game .rules-table th,
  body.in-rules-page.in-game .rules-table td {
    padding: 10px 8px;
  }

  .game-hud {
    padding: 4px 8px 2px;
  }

  .game-knowledge {
    padding: 4px 8px 2px;
    gap: 2px;
  }

  .btn-plate-knowledge {
    font-size: 0.92rem;
    padding: 8px 10px;
    letter-spacing: 0.12em;
  }

  .game-knowledge-hint {
    font-size: 0.58rem;
    line-height: 1.2;
  }

  #hud-score {
    font-size: 0.72rem;
  }

  .hud-top-row {
    margin-bottom: 4px;
  }

  .hud-progress {
    font-size: 0.92rem;
    margin-bottom: 1px;
  }

  .hud-accuracy {
    font-size: 0.58rem;
    line-height: 1.25;
  }

  body.in-game .board-wrap.board-flat {
    flex: 0 0 auto;
    height: auto;
    width: 100%;
    margin: 2px 0 4px;
  }

  body.in-game .board-wrap.board-flat .board.board-grid {
    padding: var(--board-row-pad, 10px) 8px;
    column-gap: var(--board-tile-gap, 2px);
    row-gap: var(--board-tile-gap, 2px);
  }

  body.in-game .board-wrap.board-flat .board {
    height: auto;
  }

  body.in-game .board-wrap {
    min-height: 0;
    max-height: none;
    flex: 0 0 auto;
    margin: 2px 0;
    border-radius: 10px;
    display: flex;
    flex-direction: column;
  }

  body.in-game .board-wrap.board-flat .board,
  body.in-game .board-wrap.board-flat .board.board-grid {
    height: auto;
  }

  body.in-game .board:not(.board-grid) {
    min-height: 0;
    height: 100%;
  }

  .matched-log {
    font-size: 0.72rem;
    padding: 4px 8px 5px;
  }

  .matched-panel {
    width: 100%;
    max-height: 26dvh;
    flex-shrink: 0;
    flex-direction: row;
    align-items: stretch;
  }

  .panel-hd {
    writing-mode: vertical-rl;
    text-orientation: mixed;
    padding: 6px 4px;
    font-size: 0.58rem;
    letter-spacing: 0.12em;
    border-bottom: none;
    border-right: 1px solid var(--cyan-dim);
    width: 1.6rem;
    flex-shrink: 0;
  }

  .matched-list {
    flex-direction: row;
    overflow-x: auto;
    overflow-y: hidden;
    flex: 1;
    gap: 6px;
    padding: 6px 8px;
    -webkit-overflow-scrolling: touch;
    scroll-snap-type: x proximity;
  }

  .matched-entry {
    flex: 0 0 auto;
    min-width: 72px;
    scroll-snap-align: start;
    padding: 6px 8px;
  }

  .entry-line {
    font-size: 0.72rem;
  }

  .entry-line b {
    font-size: 0.82rem;
  }

  .entry-transform {
    font-size: 0.68rem;
  }

  .tier-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
  }

  .btn-tier .tier-num {
    font-size: 0.95rem;
  }

  .btn-tier .tier-meta {
    font-size: 0.8rem;
  }

  .rel-popup-tag {
    font-size: 1.35rem;
    padding: 8px 14px;
    letter-spacing: 0.15em;
  }

  .rel-popup-chars {
    font-size: 0.85rem;
    letter-spacing: 0.2em;
  }

  .modal-card {
    margin: 0 12px;
    padding: 22px 18px;
    max-width: calc(100% - 24px);
  }

  .modal-actions {
    flex-direction: column;
    width: 100%;
  }

  .btn-primary,
  .btn-secondary {
    width: 100%;
    min-height: 48px;
    font-size: 1rem;
  }
}

@media (max-width: 360px) {
  .top-bar h1 {
    font-size: 1rem;
    letter-spacing: 0.08em;
  }

  body:not(.in-game) .home-logo {
    width: min(98vw, 340px);
  }

  .btn-mix-plate {
    font-size: 1.28rem;
    letter-spacing: 0.02em;
    min-height: 46px;
  }

  .home-mix-actions {
    width: min(94vw, 320px);
  }
}
