/* 墨攻棋阵 —— 秦时明月主题（深浅色自适应，仿水墨设计稿） */

/* 马善政毛笔楷体子集（墨攻棋阵破和局），SIL OFL 协议，见 fonts/OFL.txt */
@font-face {
  font-family: "MoBrush";
  src: url("fonts/MaShanZheng-subset.woff2") format("woff2");
  font-display: swap;
}

:root {
  color-scheme: dark light;

  /* 深色（默认）：夜色水墨 */
  --page-bg-base: #131316;
  --page-glow-top: radial-gradient(1100px 700px at 50% -8%, #1f2027 0%, transparent 60%);
  --page-glow-bottom: radial-gradient(900px 600px at 50% 112%, #1c1913 0%, transparent 55%);
  --text: #d8d3c4;
  --text-dim: #8d8878;
  --accent: #c9a86a;
  --accent-strong: #e6c88a;
  --accent-line: rgba(201, 168, 106, 0.35);
  --turn-glow: #f2d58f;
  --turn-glow-soft: rgba(230, 200, 138, 0.55);
  --title-grad: linear-gradient(172deg, #f2dda6 8%, #c9a86a 46%, #8a744a 90%);
  --panel-bg: #1d1f24;
  --panel-shadow: 0 6px 18px rgba(0, 0, 0, 0.45);
  --frame-bg: linear-gradient(168deg, #1d1e22 0%, #17181c 60%, #1b1c20 100%);
  --frame-border: rgba(201, 168, 106, 0.5);
  --frame-shadow: 0 20px 55px rgba(0, 0, 0, 0.6), inset 0 0 26px rgba(0, 0, 0, 0.5);
  --board-image: url("assets/board-dark.webp");
  --board-inset: 11.6%;
  --board-desktop-size: 640px;
  --board-desktop-inset: 74.24px;
  --board-bg: radial-gradient(circle at 50% 42%, #2a2c31 0%, #232529 62%, #1f2125 100%);
  --grid-line: rgba(201, 168, 106, 0.38);
  --hint-dot: rgba(230, 200, 138, 0.85);
  --black-rim: rgba(201, 168, 106, 0.5);
  --white-rim: rgba(90, 72, 40, 0.5);
  --piece-shadow: 0 3px 7px rgba(0, 0, 0, 0.65);
  --overlay-bg: rgba(8, 9, 11, 0.86);
  --toast-bg: rgba(24, 25, 30, 0.96);
  --btn-primary-text: #16130c;
  --serif: "STKaiti", "KaiTi", "Kaiti SC", "Noto Serif SC", "Songti SC", "SimSun", serif;
}

@media (prefers-color-scheme: light) {
  :root {
    /* 浅色：宣纸墨韵 */
    --page-bg-base: #efe8d8;
    --page-glow-top: radial-gradient(1100px 700px at 50% -8%, #f9f4e6 0%, transparent 60%);
    --page-glow-bottom: radial-gradient(900px 600px at 50% 112%, #e3d6b9 0%, transparent 55%);
    --text: #3b3527;
    --text-dim: #8a8069;
    --accent: #8a6a34;
    --accent-strong: #7a5c28;
    --accent-line: rgba(122, 92, 40, 0.4);
    --turn-glow: #a87322;
    --turn-glow-soft: rgba(138, 106, 52, 0.42);
    --title-grad: linear-gradient(172deg, #55452a 8%, #2f2a1e 50%, #6b5732 92%);
    --panel-bg: #faf5e8;
    --panel-shadow: 0 5px 16px rgba(122, 92, 40, 0.18);
    --frame-bg: linear-gradient(168deg, #fbf6ea 0%, #f4edda 60%, #f8f2e2 100%);
    --frame-border: rgba(138, 106, 52, 0.55);
    --frame-shadow: 0 16px 44px rgba(122, 92, 40, 0.26), inset 0 0 20px rgba(150, 120, 70, 0.12);
    --board-image: url("assets/board-light.webp");
    --board-inset: 10.8%;
    --board-desktop-size: 625px;
    --board-desktop-inset: 67.5px;
    --board-bg: radial-gradient(circle at 50% 42%, #f8f2e2 0%, #f3ebd6 62%, #eee4cb 100%);
    --grid-line: rgba(138, 106, 52, 0.5);
    --hint-dot: rgba(138, 106, 52, 0.65);
    --black-rim: rgba(60, 48, 26, 0.6);
    --white-rim: rgba(122, 92, 40, 0.55);
    --piece-shadow: 0 3px 7px rgba(90, 70, 40, 0.4);
    --overlay-bg: rgba(243, 236, 220, 0.9);
    --toast-bg: rgba(255, 252, 243, 0.96);
    --btn-primary-text: #fffdf6;
  }
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html {
  height: 100%;
  background: var(--page-bg-base); /* Safari 回弹区域同色，保证沉浸感 */
}

body {
  font-family: var(--serif);
  color: var(--text);
  background:
    var(--page-glow-top),
    var(--page-glow-bottom),
    var(--page-bg-base);
  display: flex;
  justify-content: center;
  min-height: 100vh;
  min-height: 100svh;
}

.stage {
  position: relative;
  width: min(94vw, 620px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  /* 刘海屏 / 底部横条安全区 */
  padding-top: calc(18px + env(safe-area-inset-top, 0px));
  padding-bottom: calc(24px + env(safe-area-inset-bottom, 0px));
  padding-left: env(safe-area-inset-left, 0px);
  padding-right: env(safe-area-inset-right, 0px);
}

/* ---------- 规则 / 音效悬钮 ---------- */

.help-btn,
.sound-btn {
  position: absolute;
  top: calc(14px + env(safe-area-inset-top, 0px));
  width: 38px;
  height: 38px;
  border-radius: 50%;
  font-family: var(--serif);
  font-size: 17px;
  color: var(--accent);
  background: var(--panel-bg);
  border: 1px solid var(--accent-line);
  box-shadow: var(--panel-shadow);
  cursor: pointer;
  transition: color 0.25s, border-color 0.25s, box-shadow 0.25s, transform 0.1s;
  z-index: 5;
}

.help-btn { right: 2px; }
.sound-btn { left: 2px; }

.sound-btn.muted { color: var(--text-dim); opacity: 0.75; }

.help-btn:hover,
.sound-btn:hover {
  color: var(--accent-strong);
  border-color: var(--accent);
  box-shadow: 0 0 12px var(--accent-line);
}

/* ---------- 标题 ---------- */

.masthead { text-align: center; margin-bottom: 16px; }

.masthead h1 {
  position: relative;
  font-family: "MoBrush", var(--serif);
  font-size: clamp(44px, 10.5vw, 66px);
  font-weight: 400;
  letter-spacing: 0.06em;
  margin-left: 0.06em;
  background: var(--title-grad);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.35));
}

.masthead .motto {
  margin-top: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  font-size: 15px;
  letter-spacing: 0.28em;
  text-indent: 0.28em;
  color: var(--text-dim);
}

.masthead .motto::before,
.masthead .motto::after {
  content: "";
  width: 44px;
  height: 1px;
  flex: none;
}

.masthead .motto::before {
  background: linear-gradient(to left, var(--accent), transparent);
}

.masthead .motto::after {
  background: linear-gradient(to right, var(--accent), transparent);
}

/* ---------- 记分区 ---------- */

.hud {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
}

.side {
  position: relative;
  display: flex;
  align-items: center;
  width: max-content;
  gap: 12px;
}

/* 翻子增量飘字 */
.side .delta {
  position: absolute;
  top: -6px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 16px;
  letter-spacing: 0.05em;
  color: var(--accent-strong);
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
  pointer-events: none;
  animation: delta-float 1s ease-out forwards;
}

@keyframes delta-float {
  0%   { opacity: 0; transform: translateX(-50%) translateY(6px); }
  18%  { opacity: 1; }
  100% { opacity: 0; transform: translateX(-50%) translateY(-20px); }
}

/* 子数跳动 */
.side-count.bump { animation: count-bump 0.4s ease-out; }

@keyframes count-bump {
  0%   { transform: scale(1); }
  35%  { transform: scale(1.35); color: var(--accent-strong); }
  100% { transform: scale(1); }
}

.side-right { justify-content: flex-end; }

.side-count {
  font-size: 28px;
  line-height: 1;
  color: var(--text);
}

.disc-badge {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  flex: none;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.35);
  will-change: transform, box-shadow;
}

.side.active .disc-badge {
  animation: turn-breathe 1.8s ease-in-out infinite;
}

@keyframes turn-breathe {
  0%, 100% {
    transform: scale(1);
    box-shadow:
      0 2px 5px rgba(0, 0, 0, 0.35),
      0 0 0 1px var(--turn-glow),
      0 0 8px var(--turn-glow-soft);
  }
  50% {
    transform: scale(1.06);
    box-shadow:
      0 3px 7px rgba(0, 0, 0, 0.4),
      0 0 0 2px var(--turn-glow),
      0 0 19px var(--turn-glow-soft);
  }
}

@media (prefers-reduced-motion: reduce) {
  .side.active .disc-badge {
    animation: none;
    box-shadow:
      0 2px 5px rgba(0, 0, 0, 0.35),
      0 0 0 2px var(--turn-glow),
      0 0 12px var(--turn-glow-soft);
  }
}

.badge-black {
  background: radial-gradient(circle at 35% 30%, #4a4a52, #17171c 62%, #050507);
  border: 1px solid var(--black-rim);
}

.badge-white {
  background: radial-gradient(circle at 35% 30%, #fdfaf1, #d9d0ba 65%, #a99d80);
  border: 1px solid var(--white-rim);
}

.turn-status {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ---------- 局势墨条 ---------- */

.balance {
  width: 100%;
  height: 7px;
  display: flex;
  margin-bottom: 14px;
  border: 1px solid var(--accent-line);
  border-radius: 999px;
  overflow: hidden;
  box-shadow: var(--panel-shadow);
}

.balance-black,
.balance-white {
  height: 100%;
  transition: width 0.7s cubic-bezier(0.22, 1, 0.36, 1);
}

.balance-black {
  width: 50%;
  background: linear-gradient(90deg, #17130d, #322a1c);
}

.balance-white {
  width: 50%;
  background: linear-gradient(90deg, #ddd3ba, #f8f4e8);
}

/* ---------- 棋盘 ---------- */

.board-frame {
  position: relative;
  width: 100%;
  padding: var(--board-inset);
  border-radius: 18px;
  overflow: hidden;
  background: var(--board-image) center / 100% 100% no-repeat;
  border: 0;
}

/* 两套底座按各自外框比例使用独立桌面尺寸；保持正方形，避免网格与图片变形。 */
@media (min-width: 700px) {
  .board-frame {
    --board-inset: var(--board-desktop-inset);
    width: var(--board-desktop-size);
    align-self: center;
    flex: none;
  }
}

/* 四角回纹 */
.corner {
  display: none;
}

.c-tl { top: 5px; left: 5px; border-top: 1px solid var(--accent); border-left: 1px solid var(--accent); }
.c-tr { top: 5px; right: 5px; border-top: 1px solid var(--accent); border-right: 1px solid var(--accent); }
.c-bl { bottom: 5px; left: 5px; border-bottom: 1px solid var(--accent); border-left: 1px solid var(--accent); }
.c-br { bottom: 5px; right: 5px; border-bottom: 1px solid var(--accent); border-right: 1px solid var(--accent); }

/* 底部山纹 */
.board-frame::after {
  content: none;
}

/* 线格棋盘：细线 + 星位 */
.board {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  aspect-ratio: 1;
  border: 1px solid var(--grid-line);
  border-radius: 4px;
  background-image:
    radial-gradient(circle at 25% 25%, var(--grid-line) 0 2px, transparent 2.6px),
    radial-gradient(circle at 75% 25%, var(--grid-line) 0 2px, transparent 2.6px),
    radial-gradient(circle at 25% 75%, var(--grid-line) 0 2px, transparent 2.6px),
    radial-gradient(circle at 75% 75%, var(--grid-line) 0 2px, transparent 2.6px),
    radial-gradient(circle at 50% 50%, var(--grid-line) 0 2px, transparent 2.6px),
    repeating-linear-gradient(to right, var(--grid-line) 0 1px, transparent 1px calc(100% / 8)),
    repeating-linear-gradient(to bottom, var(--grid-line) 0 1px, transparent 1px calc(100% / 8));
}

.cell { position: relative; }

/* 落点提示 */
.cell .hint-dot {
  display: none;
  position: absolute;
  inset: 41%;
  border-radius: 50%;
  background: var(--hint-dot);
  box-shadow: 0 0 6px var(--accent-line);
  transition: transform 0.2s;
}

.cell.hint { cursor: pointer; }
.cell.hint .hint-dot { display: block; }
.cell.hint:hover .hint-dot { transform: scale(1.5); }

/* 悬停预判：将被夹翻的棋子亮出虚环 */
.cell.preview::after {
  content: "";
  position: absolute;
  inset: 6%;
  border-radius: 50%;
  border: 2px dashed var(--accent-strong);
  opacity: 0.8;
  z-index: 3;
  pointer-events: none;
}

@media (hover: none) {
  .cell.preview::after { display: none; }
}

/* 大量翻子时的微震 */
.board-frame.shake { animation: board-shake 0.32s ease-out; }

@keyframes board-shake {
  0%, 100% { transform: none; }
  25% { transform: translate(1.6px, -1px); }
  50% { transform: translate(-1.5px, 1.2px); }
  75% { transform: translate(1px, 1.4px); }
}

/* 最近一手标记 */
.cell.last::before {
  content: "";
  position: absolute;
  top: 8%;
  right: 8%;
  width: 11%;
  height: 11%;
  border-radius: 50%;
  background: var(--accent-strong);
  box-shadow: 0 0 6px var(--accent-line);
  z-index: 3;
}

/* ---------- 翻转连线 ---------- */

.chains {
  position: absolute;
  inset: var(--board-inset); /* 与底座图片的中央可落子区域一致 */
  width: calc(100% - var(--board-inset) - var(--board-inset));
  height: calc(100% - var(--board-inset) - var(--board-inset));
  pointer-events: none;
  overflow: visible;
  z-index: 1; /* 压在棋子之下，墨痕如影子从子底淌过 */
}

/* ---------- 棋子（双面翻转） ---------- */

.piece-wrap {
  position: absolute;
  inset: 8%;
  perspective: 260px;
  -webkit-perspective: 260px;
  display: none;
  z-index: 2; /* 高于墨痕层 */
}

.piece-wrap.on { display: block; }

.piece-wrap.rise { animation: rise 0.4s ease-out; }

@keyframes rise {
  0%   { transform: scale(0.2); opacity: 0; }
  60%  { transform: scale(1.1); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}

.piece {
  position: relative;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  -webkit-transform-style: preserve-3d;
  transition: transform 0.55s ease;
}

.piece.no-anim { transition: none; }

.piece.white { transform: rotateY(180deg); }

.face {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}

.face.black {
  background: radial-gradient(circle at 35% 30%, #4a4a52, #17171c 62%, #050507);
  border: 1px solid var(--black-rim);
  box-shadow: var(--piece-shadow), inset 0 -2px 5px rgba(0, 0, 0, 0.7);
}

.face.white {
  background: radial-gradient(circle at 35% 30%, #fdfaf1, #d9d0ba 65%, #a99d80);
  border: 1px solid var(--white-rim);
  box-shadow: var(--piece-shadow), inset 0 -2px 5px rgba(120, 105, 75, 0.55);
  transform: rotateY(180deg);
}

/* ---------- 终局遮罩 ---------- */

.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--overlay-bg);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  border-radius: 12px;
  z-index: 10;
  opacity: 1;
  transition: opacity 0.4s;
}

.overlay.hidden { opacity: 0; pointer-events: none; }

.overlay-inner { text-align: center; }

.verdict {
  font-family: "MoBrush", var(--serif);
  font-size: clamp(58px, 13vw, 92px);
  letter-spacing: 0.2em;
  margin-left: 0.2em; /* 抵消字间距造成的偏移 */
  background: var(--title-grad);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 0 22px var(--accent-line));
}

.verdict-sub {
  margin-top: 8px;
  font-size: 15px;
  letter-spacing: 0.2em;
  text-indent: 0.2em;
  color: var(--text-dim);
}

.final-score {
  margin: 16px 0 22px;
  font-size: 20px;
  color: var(--text);
  letter-spacing: 0.1em;
}

/* ---------- 操作区 ---------- */

.controls {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: 18px;
  flex-wrap: wrap;
  justify-content: center;
}

/* 难度胶囊与按钮统一为 46px 高的药丸 */
.level-label,
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 46px;
  padding: 0 22px;
  font-family: var(--serif);
  font-size: 15px;
  letter-spacing: 0.1em;
  color: var(--text);
  background: var(--panel-bg);
  border: 1px solid var(--accent-line);
  border-radius: 999px;
  box-shadow: var(--panel-shadow);
}

.level-label { gap: 6px; cursor: pointer; }

.level-caption {
  font-size: 13px;
  letter-spacing: 0.1em;
  color: var(--text-dim);
  white-space: nowrap;
}

select {
  font-family: var(--serif);
  font-size: 15px;
  letter-spacing: 0.1em;
  color: var(--text);
  background: transparent;
  border: none;
  outline: none;
  cursor: pointer;
  text-align: center;
}

.btn { cursor: pointer; transition: border-color 0.25s, box-shadow 0.25s, color 0.25s, transform 0.1s; }

/* 按压反馈（移动端无 hover 时的主要触感） */
.btn:active,
.help-btn:active,
.sound-btn:active { transform: scale(0.94); }

.btn:hover {
  border-color: var(--accent);
  color: var(--accent-strong);
  box-shadow: var(--panel-shadow), 0 0 10px var(--accent-line);
}

.btn.primary {
  padding: 0 28px;
  color: var(--btn-primary-text);
  background: linear-gradient(165deg, var(--accent-strong), var(--accent) 70%);
  border-color: var(--accent);
}

.btn.primary:hover {
  color: var(--btn-primary-text);
  box-shadow: var(--panel-shadow), 0 0 18px var(--accent-line);
}

.pill-new::before {
  content: "⟳";
  margin-right: 8px;
  font-weight: 700;
}

/* ---------- 铭文 ---------- */

.inscription {
  margin-top: 18px;
  width: min(100%, 500px);
  text-align: center;
  font-size: 13px;
  line-height: 2;
  letter-spacing: 0.32em;
  text-indent: 0.32em;
  color: var(--text-dim);
}

/* ---------- 提示浮层 ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(7vh + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%) translateY(10px);
  padding: 9px 22px;
  font-family: var(--serif);
  font-size: 14px;
  letter-spacing: 0.15em;
  color: var(--accent-strong);
  background: var(--toast-bg);
  border: 1px solid var(--accent-line);
  border-radius: 999px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s, transform 0.3s;
  z-index: 50;
}

.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- 规则弹层 ---------- */

.rules-modal {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: var(--overlay-bg);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  opacity: 1;
  transition: opacity 0.3s;
}

.rules-modal.hidden { opacity: 0; pointer-events: none; }

.rules-panel {
  max-width: 420px;
  width: 100%;
  max-height: 80vh;
  overflow-y: auto;
  padding: 26px 28px 24px;
  background: var(--panel-bg);
  border: 1px solid var(--accent-line);
  border-radius: 14px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.4);
  text-align: center;
}

.rules-panel h2 {
  font-size: 22px;
  font-weight: 600;
  letter-spacing: 0.25em;
  margin-left: 0.25em;
  color: var(--accent-strong);
  margin-bottom: 16px;
}

.rules-panel ol {
  text-align: left;
  margin: 0 0 20px;
  padding-left: 1.4em;
  font-size: 15px;
  line-height: 1.9;
  color: var(--text);
}

.rules-panel li { margin-bottom: 4px; }

.rules-panel li::marker { color: var(--accent); }

/* 在线对战弹层 */
.online-tip {
  font-size: 14px;
  line-height: 1.9;
  letter-spacing: 0.08em;
  color: var(--text-dim);
  margin-bottom: 14px;
}

.join-row {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin: 16px 0 20px;
}

.join-row input {
  width: 130px;
  height: 46px;
  padding: 0 14px;
  font-family: var(--serif);
  font-size: 18px;
  letter-spacing: 0.3em;
  text-align: center;
  text-transform: uppercase;
  color: var(--text);
  background: transparent;
  border: 1px solid var(--accent-line);
  border-radius: 999px;
  outline: none;
}

.join-row input:focus { border-color: var(--accent); }

.room-code {
  font-size: 40px;
  letter-spacing: 0.3em;
  margin-left: 0.3em;
  color: var(--accent-strong);
  margin: 8px 0 10px;
}

#onlineHome .btn.primary { margin-top: 4px; }

#onlineCloseBtn { margin-top: 6px; }

.hidden-block { display: none; }

/* ---------- 响应式 ---------- */

@media (max-width: 480px) {
  .masthead { margin-bottom: 10px; }

  .hud {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    margin-bottom: 10px;
  }

  .side {
    width: max-content;
    min-width: 0;
    gap: 8px;
  }

  .side-right { justify-self: end; }

  .side-count { font-size: 23px; }
  .disc-badge { width: 26px; height: 26px; }

  .balance { margin-bottom: 10px; }

  .controls {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px 8px;
    margin-top: 14px;
  }

  .controls .level-label {
    width: 100%;
    min-width: 0;
    height: 42px;
    padding: 0 10px;
  }

  .controls .level-caption {
    font-size: 11px;
    letter-spacing: 0.04em;
  }

  .controls select {
    min-width: 0;
    font-size: 13px;
    letter-spacing: 0.04em;
  }

  .controls .pill-new {
    grid-column: 1 / -1;
    justify-self: center;
    height: 42px;
  }

  .controls:has(#levelWrap[style*="display: none"]) .level-label:first-child {
    grid-column: 1 / -1;
    justify-self: center;
    width: min(100%, 180px);
  }

  .inscription {
    margin-top: 14px;
    font-size: clamp(11px, 3.2vw, 13px);
    line-height: 1.9;
    letter-spacing: 0.12em;
    text-indent: 0.12em;
  }

  .inscription p { white-space: nowrap; }

  .help-btn,
  .sound-btn { width: 32px; height: 32px; font-size: 15px; }
}

@media (max-width: 360px) {
  .stage { width: 96vw; }
  .masthead h1 { font-size: 40px; }
  .masthead .motto { gap: 8px; font-size: 13px; }
  .masthead .motto::before,
  .masthead .motto::after { width: 24px; }

  .side { gap: 5px; }
  .side-count { font-size: 19px; }
  .disc-badge { width: 22px; height: 22px; }

  .controls .level-label { padding-inline: 7px; }
  .controls .level-caption { font-size: 10px; }
  .controls select { font-size: 12px; }
}

/* 矮屏：隐藏铭文，保证棋盘完整显示 */
@media (max-height: 700px) {
  .inscription { display: none; }
  .masthead { margin-bottom: 8px; }
  .masthead .motto { display: none; }
}
