/* 海拉鲁象棋 · 旷野之息明亮主题 */
:root {
  --bg-0: #e8f8ff;
  --bg-1: #d6f1ff;
  --bg-2: #eaf9e3;
  --panel: #fffdf7;
  --panel-2: #fff7e6;
  --panel-3: #fdf0d4;
  --line: rgba(176, 124, 38, .28);
  --line-soft: rgba(176, 124, 38, .15);
  --gold: #e4a93e;
  --gold-bright: #ffd36e;
  --gold-deep: #a96f1c;
  --cyan: #2d9db8;
  --cyan-soft: rgba(45, 157, 184, .14);
  --ink: #263a38;
  --ink-soft: #4b625d;
  --muted: #7d918b;
  --red: #d94a5a;
  --red-deep: #a3303e;
  --black-side: #6f63c9;
  --green: #5aa566;
  --danger: #d9544b;
  --paper: #fffaf0;
  --paper-ink: #40321c;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 10px 26px rgba(88, 110, 66, .16);
  --font: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", system-ui, -apple-system, sans-serif;
  --serif: "Songti SC", "STSong", "Noto Serif SC", Georgia, serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100dvh;
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg-0);
  overflow-x: hidden;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
button, input, select { font: inherit; }
button { color: inherit; cursor: pointer; }
button:focus-visible, input:focus-visible, select:focus-visible {
  outline: 3px solid var(--cyan);
  outline-offset: 2px;
}
.pixel { image-rendering: pixelated; image-rendering: crisp-edges; vertical-align: middle; flex: none; }
.muted { color: var(--muted); font-size: 13px; line-height: 1.6; }
[hidden] { display: none !important; }

/* ---------- 海拉鲁天空与草地 ---------- */
.world-bg {
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  pointer-events: none;
  background:
    radial-gradient(ellipse 64% 26% at 8% 100%, #a8da74 0 72%, transparent 74%),
    radial-gradient(ellipse 74% 32% at 92% 100%, #8fcb5b 0 72%, transparent 74%),
    radial-gradient(ellipse 130% 46% at 50% 114%, #7cbe4b 0 60%, transparent 62%),
    linear-gradient(180deg, #66bfea 0%, #96d8f5 30%, #d2f0ff 52%, #edf9e2 64%, #d4eda9 100%);
}
/* 太阳（明亮的金色日轮） */
.world-bg::before {
  content: "";
  position: absolute;
  top: 4%;
  right: 8%;
  width: clamp(90px, 12vw, 160px);
  height: clamp(90px, 12vw, 160px);
  border-radius: 50%;
  background: radial-gradient(circle, #fffbe0 0 36%, #ffe883 46%, #ffd06b 62%, rgba(255, 208, 107, .35) 74%, transparent 78%);
  filter: blur(1px);
  opacity: .95;
  box-shadow: 0 0 40px rgba(255, 214, 120, .35);
}
/* 漂浮白云 */
.world-bg::after {
  content: "";
  position: absolute;
  top: 12%;
  left: -6%;
  width: 26vw;
  height: 5vw;
  min-height: 26px;
  border-radius: 999px;
  background: rgba(255, 255, 255, .82);
  box-shadow:
    9vw -4vh 0 -6px rgba(255, 255, 255, .68),
    17vw 3vh 0 -2px rgba(255, 255, 255, .58),
    32vw -2vh 0 -8px rgba(255, 255, 255, .52);
  filter: blur(10px);
  opacity: .85;
  animation: cloudDrift 90s linear infinite;
}
@keyframes cloudDrift {
  from { transform: translateX(0); }
  to { transform: translateX(42vw); }
}
.bg-glow {
  position: absolute;
  border-radius: 50%;
  filter: blur(26px);
  background: rgba(255, 255, 255, .85);
  opacity: .6;
  animation: glowDrift 26s ease-in-out infinite alternate;
}
.bg-glow.g1 { width: 30vw; height: 9vw; min-height: 42px; left: -8vw; top: 26vh; }
.bg-glow.g2 { width: 24vw; height: 8vw; min-height: 36px; right: -4vw; top: 40vh; opacity: .45; animation-delay: -8s; }
.bg-glow.g3 { width: 34vw; height: 10vw; min-height: 48px; left: 30vw; top: 12vh; opacity: .4; animation-delay: -15s; }
@keyframes glowDrift {
  from { transform: translate3d(0, 0, 0) scale(1); }
  to { transform: translate3d(2vw, 1vh, 0) scale(1.06); }
}
/* 远处高山剪影（多层，远近不同深浅） */
.mountain {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 34vh;
  background: transparent;
  pointer-events: none;
  z-index: 0;
}
.mountain layer {
  display: block;
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 100%;
  clip-path: polygon(0% 100%, 6% 94%, 14% 98%, 22% 90%, 30% 96%, 38% 86%, 46% 94%, 54% 84%, 62% 90%, 70% 80%, 78% 92%, 86% 82%, 94% 90%, 100% 78%, 100% 100%);
}
.mountain.layer-near { background: #5aa566; opacity: .9; transform: scaleY(.78); }
.mountain.layer-mid { background: #478652; opacity: .72; transform: scaleY(.62); left: -4vw; width: 108%; animation: mountainDrift 70s linear infinite; }
.mountain.layer-far { background: #3c6b48; opacity: .5; transform: scaleY(.48); left: -8vw; width: 116%; animation: mountainDrift 110s linear infinite reverse; }
@keyframes mountainDrift {
  from { transform: scaleY(var(--sy, .5)) translateX(0); }
  to { transform: scaleY(var(--sy, .5)) translateX(8vw); }
}
/* 森林树线（树冠剪影） */
.forest-line {
  position: absolute;
  bottom: 10%;
  left: 0;
  width: 100%;
  height: 16vh;
  pointer-events: none;
  z-index: 0;
  background: transparent;
}
.tree {
  position: absolute;
  bottom: 0;
  border-radius: 50% 50% 0 0;
  background: #4a8c50;
  opacity: .85;
}
.tree.t1 { left: 4vw; width: 14vw; height: 10vw; transform: scaleY(.85); }
.tree.t2 { left: 18vw; width: 10vw; height: 8vw; transform: scaleY(.72); opacity: .7; }
.tree.t3 { left: 30vw; width: 16vw; height: 11vw; transform: scaleY(.92); }
.tree.t4 { left: 44vw; width: 9vw; height: 7vw; transform: scaleY(.68); opacity: .62; }
.tree.t5 { left: 58vw; width: 13vw; height: 9vw; transform: scaleY(.8); }
.tree.t6 { left: 72vw; width: 11vw; height: 8.5vw; transform: scaleY(.75); opacity: .75; }
.tree.t7 { left: 84vw; width: 15vw; height: 10vw; transform: scaleY(.88); }
.tree.t8 { left: 96vw; width: 8vw; height: 6vw; transform: scaleY(.6); opacity: .55; }
/* 红月（血红色大圆月，右上方，带微弱光晕） */
.red-moon {
  position: absolute;
  top: 6%;
  right: 10%;
  width: clamp(70px, 9vw, 120px);
  height: clamp(70px, 9vw, 120px);
  border-radius: 50%;
  background: radial-gradient(circle at 38% 34%, #ff9a78 0 24%, #e8453a 48%, #b32222 70%, #7d1111 84%, rgba(125, 17, 17, 0) 89%);
  box-shadow: 0 0 46px rgba(190, 35, 35, .38), 0 0 92px rgba(190, 35, 35, .18);
  opacity: .9;
  animation: moonPulse 5s ease-in-out infinite alternate;
  z-index: 1;
}
@keyframes moonPulse {
  from { opacity: .8; transform: scale(1); }
  to { opacity: .98; transform: scale(1.03); }
}
/* 大桥（石拱桥，横跨下方草地与河流） */
.bridge {
  position: absolute;
  bottom: 8%;
  left: 6%;
  width: 88%;
  height: 14vh;
  pointer-events: none;
  z-index: 0;
  background: transparent;
}
.bridge-arch {
  position: absolute;
  inset: 0;
  border-bottom: 10px solid #d2b48c;
  border-radius: 50% / 60%;
  box-shadow: 0 8px 0 #b8956a;
}
.bridge-deck {
  position: absolute;
  bottom: 30%;
  left: 0;
  width: 100%;
  height: 12px;
  background: #c7b28a;
  border-top: 2px solid #a88b5e;
}
/* 海拉鲁城堡（石塔 + 蓝色尖顶，右侧远方） */
.castle {
  position: absolute;
  bottom: 5%;
  right: 3%;
  width: clamp(150px, 20vw, 260px);
  height: clamp(150px, 20vw, 260px);
  pointer-events: none;
  z-index: 1;
  filter: drop-shadow(0 12px 18px rgba(88, 110, 66, .16));
}
.castle-tower {
  position: absolute;
  bottom: 0;
  width: 22%;
  height: 64%;
  background: linear-gradient(180deg, #fffef9 0%, #f4efe2 55%, #e2d9c4 100%);
  border: 2px solid #bdb49f;
  border-top: none;
  border-radius: 2px 2px 5px 5px;
  box-shadow: inset -4px 0 10px rgba(120, 110, 90, .12);
}
.castle-tower::before {
  content: "";
  position: absolute;
  top: -20px;
  left: -16%;
  width: 132%;
  height: 28px;
  background: linear-gradient(180deg, #93b9d0, #5d87a3);
  clip-path: polygon(50% 0, 100% 100%, 0 100%);
  filter: drop-shadow(0 2px 0 rgba(70, 100, 120, .22));
}
.castle-tower::after {
  content: "";
  position: absolute;
  top: 11px;
  left: 50%;
  transform: translateX(-50%);
  width: 7px;
  height: 14px;
  border-radius: 50% 50% 2px 2px;
  background: #7d9aae;
  box-shadow: inset 0 0 3px rgba(40, 60, 80, .5);
}
.castle-tower.c1 { left: 2%; height: 56%; }
.castle-tower.c2 { left: 39%; width: 24%; height: 78%; }
.castle-tower.c3 { right: 2%; height: 50%; }
.castle-main {
  position: absolute;
  bottom: 0;
  left: 20%;
  width: 60%;
  height: 38%;
  background: linear-gradient(180deg, #fffef9, #efe8d8);
  border: 2px solid #bdb49f;
  border-top: none;
  border-radius: 0 0 6px 6px;
  box-shadow: inset -6px 0 12px rgba(120, 110, 90, .1);
}
.castle-main::before {
  content: "";
  position: absolute;
  top: -24px;
  left: 14%;
  width: 72%;
  height: 30px;
  background: linear-gradient(180deg, #93b9d0, #5d87a3);
  clip-path: polygon(50% 0, 100% 100%, 0 100%);
}
.castle-main::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 26%;
  transform: translateX(-50%);
  width: 18px;
  height: 24px;
  border-radius: 9px 9px 2px 2px;
  background: #8aa6b8;
  box-shadow: -28px 0 0 -3px #8aa6b8, 28px 0 0 -3px #8aa6b8;
}
.castle-glow {
  position: absolute;
  bottom: 4%;
  left: 50%;
  transform: translateX(-50%);
  width: 15px;
  height: 21px;
  border-radius: 50% 50% 2px 2px;
  background: #ffdf7a;
  box-shadow: 0 0 16px rgba(255, 215, 110, .85);
  animation: castleGlow 3s ease-in-out infinite alternate;
}
@keyframes castleGlow {
  from { opacity: .75; }
  to { opacity: 1; box-shadow: 0 0 26px rgba(255, 224, 102, .95); }
}
.mote {
  position: absolute;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #fff3b8;
  box-shadow: 0 0 10px rgba(255, 232, 140, .95);
  opacity: .85;
  animation: moteFloat 16s ease-in-out infinite;
}
.mote.m1 { left: 12%; top: 70%; animation-delay: 0s; }
.mote.m2 { left: 32%; top: 42%; animation-delay: -3s; width: 3px; height: 3px; }
.mote.m3 { left: 58%; top: 78%; animation-delay: -6s; }
.mote.m4 { left: 76%; top: 34%; animation-delay: -9s; width: 4px; height: 4px; }
.mote.m5 { left: 90%; top: 62%; animation-delay: -12s; width: 3px; height: 3px; }
@keyframes moteFloat {
  0%, 100% { transform: translate3d(0, 0, 0); opacity: .25; }
  50% { transform: translate3d(14px, -28px, 0); opacity: .95; }
}
.vignette {
  position: absolute;
  inset: 0;
  background: radial-gradient(120% 95% at 50% 42%, transparent 62%, rgba(106, 160, 180, .13) 100%);
}

/* ---------- 顶栏 ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px clamp(12px, 3vw, 30px);
  background: linear-gradient(180deg, rgba(255, 255, 255, .78), rgba(255, 255, 255, .3) 70%, transparent);
  backdrop-filter: blur(8px);
}
body[data-screen="game"] .topbar,
body[data-screen="result"] .topbar { display: none; }
.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 4px 6px;
  border: none;
  background: none;
  text-align: left;
}
.brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: linear-gradient(160deg, #fffdf4, #ffedc4);
  border: 1px solid rgba(176, 124, 38, .4);
  box-shadow: 0 3px 0 rgba(169, 111, 28, .16), inset 0 0 10px rgba(45, 157, 184, .12);
}
.brand-text {
  display: flex;
  flex-direction: column;
  font-family: var(--serif);
  font-weight: 800;
  font-size: 18px;
  letter-spacing: .06em;
  color: #1f5d6d;
  line-height: 1.1;
}
.brand-text small {
  font-family: var(--font);
  font-size: 10px;
  letter-spacing: .32em;
  color: var(--muted);
  font-weight: 600;
  margin-top: 3px;
}
.top-actions { display: flex; align-items: center; gap: 8px; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid rgba(176, 124, 38, .3);
  background: rgba(255, 253, 247, .9);
  color: var(--ink-soft);
  font-size: 13px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  box-shadow: 0 2px 0 rgba(169, 111, 28, .08);
}
.chip.small { padding: 5px 10px; font-size: 12px; }
.chip.warn { border-color: rgba(217, 84, 75, .6); color: #a8322c; background: #fff1ee; box-shadow: 0 0 0 3px rgba(217, 84, 75, .12); }
.icon-btn {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 1px solid rgba(176, 124, 38, .3);
  background: rgba(255, 253, 247, .9);
  color: var(--gold-deep);
  font-size: 16px;
  box-shadow: 0 2px 0 rgba(169, 111, 28, .08);
  transition: transform .15s, opacity .15s, background .15s;
}
.icon-btn:hover { transform: translateY(-1px); background: #fff8e6; }
.icon-btn.off { color: var(--muted); opacity: .55; }

/* ---------- 屏幕 ---------- */
.screen {
  display: none;
  max-width: 1240px;
  margin: 0 auto;
  padding: 10px clamp(12px, 3vw, 26px) 104px;
}
.screen.active { display: block; animation: screenIn .22s ease-out; }
@keyframes screenIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}
#screen-result { padding-top: 20px; }

.kicker {
  margin: 0 0 6px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .3em;
  color: #2d8fa8;
  text-transform: uppercase;
}

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 42px;
  padding: 9px 18px;
  border-radius: 12px;
  border: 1px solid rgba(176, 124, 38, .38);
  background: linear-gradient(180deg, #fffdf7, #fff4dc);
  color: var(--ink);
  font-size: 14px;
  font-weight: 800;
  letter-spacing: .02em;
  box-shadow: 0 3px 0 rgba(169, 111, 28, .22), inset 0 1px 0 #fff;
  transition: transform .12s, box-shadow .12s, background .12s, opacity .12s;
}
.btn:hover { transform: translateY(-1px); box-shadow: 0 5px 0 rgba(169, 111, 28, .2), inset 0 1px 0 #fff; background: #fffaf0; }
.btn:active { transform: translateY(2px); box-shadow: 0 1px 0 rgba(169, 111, 28, .22); }
.btn.primary {
  border-color: rgba(169, 111, 28, .55);
  background: linear-gradient(180deg, #ffe6a0, #ffcd63 55%, #f2b445);
  color: #5c3c08;
  text-shadow: 0 1px 0 rgba(255, 255, 255, .5);
}
.btn.primary:hover { background: linear-gradient(180deg, #ffedb8, #ffd679 55%, #f7bf58); }
.btn.ghost { background: transparent; box-shadow: none; border-color: rgba(176, 124, 38, .28); }
.btn.small { min-height: 34px; padding: 6px 12px; font-size: 12.5px; border-radius: 10px; }
.btn.big { min-height: 50px; padding: 12px 24px; font-size: 16px; border-radius: 14px; }
.btn.danger { border-color: rgba(217, 84, 75, .45); background: linear-gradient(180deg, #ff8a80, #e56055); color: #fff; text-shadow: 0 1px 0 rgba(120, 20, 15, .3); }
.btn:disabled { opacity: .42; cursor: not-allowed; transform: none; box-shadow: none; }
.btn b { font-size: .92em; opacity: .8; }
.link-btn {
  border: none;
  background: none;
  color: #1f7f96;
  font-weight: 800;
  padding: 0 2px;
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* ---------- 通用面板 ---------- */
.panel {
  position: relative;
  border-radius: var(--radius);
  border: 1px solid rgba(176, 124, 38, .24);
  background:
    radial-gradient(120% 120% at 0% 0%, rgba(255, 255, 255, .9), transparent 55%),
    linear-gradient(180deg, #fffdf7, #fff7e7);
  box-shadow: var(--shadow), inset 0 1px 0 #fff;
  padding: 16px;
}
.panel::after {
  content: "";
  position: absolute;
  inset: 5px;
  border-radius: calc(var(--radius) - 5px);
  border: 1px solid rgba(176, 124, 38, .11);
  pointer-events: none;
}
.panel-kicker {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .24em;
  color: var(--gold-deep);
  margin-bottom: 8px;
}
.panel h3 { margin: 0 0 10px; font-size: 16px; font-family: var(--serif); letter-spacing: .04em; color: var(--gold-deep); }

/* ---------- 首页 ---------- */
.home-hero {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 20px;
  padding: clamp(18px, 4vw, 40px);
  border-radius: 26px;
  border: 1px solid rgba(176, 124, 38, .26);
  overflow: hidden;
  background:
    radial-gradient(620px 380px at 86% 8%, rgba(144, 214, 240, .38), transparent 62%),
    radial-gradient(520px 300px at 6% 100%, rgba(255, 226, 150, .4), transparent 66%),
    linear-gradient(180deg, #fffef9 0%, #fff8e8 100%);
  box-shadow: var(--shadow);
  margin-bottom: 18px;
}
.home-hero::before {
  content: "";
  position: absolute;
  inset: 8px;
  border-radius: 20px;
  border: 1px solid rgba(176, 124, 38, .16);
  pointer-events: none;
}
.hero-copy h1 {
  margin: 0 0 10px;
  font-family: var(--serif);
  font-size: clamp(34px, 6vw, 62px);
  line-height: 1.02;
  letter-spacing: .06em;
  background: linear-gradient(180deg, #ffd97a 8%, #eab044 52%, #b87818 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 2px 0 rgba(255, 255, 255, .65));
}
.hero-sub { margin: 0 0 20px; color: var(--ink-soft); font-size: clamp(13px, 1.6vw, 16px); max-width: 46ch; line-height: 1.7; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.hero-note { margin: 14px 0 0; color: #9a6818; font-size: 13px; }
.hero-mascots {
  display: flex;
  align-items: flex-end;
  gap: clamp(4px, 1.4vw, 16px);
  padding-right: 4px;
}
.mascot {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  animation: mascotBob 5.6s ease-in-out infinite;
}
.mascot.link { animation-delay: -1.2s; }
.mascot.ganon { animation-delay: -2.4s; }
.mascot:nth-child(2) { transform: translateY(-12px); }
@keyframes mascotBob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}
.mascot-ring {
  display: grid;
  place-items: center;
  width: clamp(62px, 8vw, 104px);
  height: clamp(62px, 8vw, 104px);
  border-radius: 50%;
  background: radial-gradient(circle at 35% 25%, #ffffff, #fff2d2);
  border: 1px solid rgba(176, 124, 38, .35);
  box-shadow: 0 6px 0 rgba(169, 111, 28, .13), inset 0 0 16px rgba(255, 220, 140, .35);
}
.mascot.ganon .mascot-ring { box-shadow: 0 6px 0 rgba(120, 80, 150, .13), inset 0 0 16px rgba(190, 160, 255, .3); }
.mascot b { font-size: 11px; color: var(--ink-soft); white-space: nowrap; }
.mascot i { font-size: 9.5px; color: var(--muted); font-style: normal; letter-spacing: .08em; }

.home-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(280px, .8fr);
  gap: 16px;
  align-items: start;
}
.mode-panel { display: grid; gap: 10px; }
.mode-card {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid rgba(176, 124, 38, .17);
  background: linear-gradient(180deg, #fffefb, #fff8ea);
  text-align: left;
  transition: transform .14s, border-color .14s, background .14s;
}
.mode-card:hover { transform: translateX(3px); border-color: rgba(176, 124, 38, .4); background: #fffdf6; }
.mode-icon {
  display: grid;
  place-items: center;
  width: 54px;
  height: 54px;
  border-radius: 13px;
  background: #fff8e8;
  border: 1px solid rgba(176, 124, 38, .18);
}
.mode-copy { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.mode-copy b { font-size: 16px; font-family: var(--serif); letter-spacing: .04em; color: var(--gold-deep); }
.mode-copy i { font-style: normal; font-size: 12.5px; color: var(--muted); line-height: 1.5; }
.mode-tag {
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 10.5px;
  font-weight: 800;
  letter-spacing: .1em;
  color: #1f7f96;
  border: 1px solid rgba(45, 157, 184, .32);
  background: rgba(45, 157, 184, .1);
  white-space: nowrap;
}
.home-side { display: grid; gap: 16px; }
.coach-card {
  background:
    radial-gradient(140% 100% at 100% 0%, rgba(186, 224, 140, .3), transparent 62%),
    linear-gradient(180deg, #fffdf7, #f7fbe9);
}
.coach-line { margin: 0 0 12px; font-size: 13.5px; line-height: 1.75; color: var(--ink-soft); }
.progress-panel .progress-row { display: flex; justify-content: space-between; align-items: baseline; font-size: 12.5px; color: var(--muted); margin-bottom: 8px; }
.progress-panel .progress-row b { color: var(--gold-deep); font-size: 15px; }
.bar { height: 9px; border-radius: 999px; background: #f1e6cf; border: 1px solid rgba(176, 124, 38, .16); overflow: hidden; margin-bottom: 14px; }
.bar i { display: block; height: 100%; border-radius: 999px; background: linear-gradient(90deg, #f3c25d, #e4a93e); box-shadow: 0 0 12px rgba(228, 169, 62, .5); }
.mini-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; text-align: center; }
.mini-stats div { padding: 8px 4px; border-radius: 10px; background: #fff9ec; border: 1px solid rgba(176, 124, 38, .14); }
.mini-stats b { display: block; font-size: 17px; color: var(--gold-deep); font-variant-numeric: tabular-nums; }
.mini-stats span { font-size: 10.5px; color: var(--muted); }

/* ---------- 页头 ---------- */
.page-head {
  display: flex;
  align-items: center;
  gap: 16px;
  margin: 6px 0 18px;
}
.page-head > div { flex: 1; min-width: 0; }
.page-head h2 { margin: 0; font-family: var(--serif); font-size: clamp(22px, 3vw, 30px); letter-spacing: .06em; color: #1f5d6d; }
.page-sub { margin: 5px 0 0; color: var(--muted); font-size: 12.5px; line-height: 1.5; }
.stars-total {
  padding: 7px 13px;
  border-radius: 999px;
  border: 1px solid rgba(176, 124, 38, .3);
  background: rgba(255, 253, 247, .9);
  color: var(--gold-deep);
  font-size: 13px;
  font-weight: 800;
  white-space: nowrap;
  box-shadow: 0 2px 0 rgba(169, 111, 28, .1);
}

/* ---------- 冒险地图 ---------- */
.level-map {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(258px, 1fr));
  gap: 14px;
}
.level-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-height: 168px;
  padding: 16px 16px 14px;
  border-radius: var(--radius);
  border: 1px solid rgba(176, 124, 38, .22);
  background:
    radial-gradient(260px 170px at 88% 0%, var(--biome, rgba(144, 214, 240, .35)), transparent 72%),
    linear-gradient(180deg, #fffefb, #fff7e8);
  text-align: left;
  overflow: hidden;
  box-shadow: 0 4px 0 rgba(169, 111, 28, .1), 0 10px 22px rgba(88, 110, 66, .1);
  transition: transform .15s, border-color .15s, box-shadow .15s;
}
.level-card::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(176, 124, 38, .05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(176, 124, 38, .05) 1px, transparent 1px);
  background-size: 22px 22px;
  opacity: .7;
  pointer-events: none;
}
.level-card:hover { transform: translateY(-3px); border-color: rgba(176, 124, 38, .5); box-shadow: 0 8px 0 rgba(169, 111, 28, .1), 0 16px 28px rgba(88, 110, 66, .14); }
.level-card.locked { cursor: not-allowed; filter: grayscale(.55); opacity: .6; }
.level-card.locked:hover { transform: none; }
.biome-plateau { --biome: rgba(148, 214, 120, .42); }
.biome-hills { --biome: rgba(238, 200, 110, .42); }
.biome-village { --biome: rgba(255, 214, 130, .42); }
.biome-zora { --biome: rgba(130, 210, 245, .45); }
.biome-goron { --biome: rgba(245, 145, 105, .38); }
.biome-rito { --biome: rgba(165, 205, 255, .42); }
.biome-gerudo { --biome: rgba(250, 180, 110, .4); }
.biome-castle { --biome: rgba(232, 196, 106, .45); }
.biome-lab { --biome: rgba(130, 220, 235, .4); }
.biome-calamity { --biome: rgba(240, 130, 140, .38); }
.lv-num {
  position: absolute;
  right: 14px;
  top: 10px;
  font-family: var(--serif);
  font-size: 34px;
  font-weight: 800;
  color: rgba(169, 111, 28, .16);
  line-height: 1;
}
.lv-kicker { font-size: 10px; letter-spacing: .22em; color: #2d8fa8; font-weight: 800; text-transform: uppercase; }
.lv-name { font-family: var(--serif); font-size: 21px; letter-spacing: .06em; color: #1f5d6d; }
.lv-theme { font-size: 12.5px; color: var(--ink-soft); font-weight: 700; }
.lv-desc { font-size: 12px; color: var(--muted); line-height: 1.55; }
.lv-stars { display: flex; align-items: center; gap: 3px; margin-top: auto; padding-top: 10px; }
.star { display: inline-flex; opacity: .22; filter: grayscale(1); }
.star.on { opacity: 1; filter: none; }
.lock { font-style: normal; color: var(--muted); font-size: 16px; }

/* ---------- 图鉴 ---------- */
.collection-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; }
.piece-card {
  border-radius: var(--radius);
  border: 1px solid rgba(176, 124, 38, .22);
  background: linear-gradient(180deg, #fffefb, #fff7e8);
  padding: 14px;
  box-shadow: var(--shadow);
}
.pc-head { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 8px; }
.pc-side { display: flex; align-items: center; gap: 7px; min-width: 0; }
.pc-side.black { flex-direction: row-reverse; text-align: right; }
.pc-side span { display: grid; place-items: center; width: 46px; height: 46px; border-radius: 12px; background: #fff8e8; border: 1px solid rgba(176, 124, 38, .18); }
.pc-side.red span { box-shadow: inset 0 0 14px rgba(217, 74, 90, .12); }
.pc-side.black span { box-shadow: inset 0 0 14px rgba(111, 99, 201, .12); }
.pc-side b { font-size: 12px; color: var(--ink-soft); line-height: 1.3; }
.pc-mid { text-align: center; padding: 0 4px; }
.pc-char { display: block; font-family: var(--serif); font-size: 22px; color: var(--gold-deep); letter-spacing: .08em; white-space: nowrap; }
.pc-mid small { font-size: 10px; color: var(--muted); letter-spacing: .18em; }
.pc-move { margin: 12px 0 6px; font-size: 12.5px; color: var(--ink-soft); line-height: 1.6; }
.pc-tip { margin: 0; font-size: 11.5px; color: var(--muted); line-height: 1.6; border-top: 1px dashed rgba(176, 124, 38, .2); padding-top: 8px; }

/* ---------- 成就 ---------- */
.badge-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 12px; }
.badge-card {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(176, 124, 38, .16);
  background: rgba(255, 253, 247, .8);
  opacity: .64;
}
.badge-card.earned { opacity: 1; border-color: rgba(228, 169, 62, .55); background: linear-gradient(180deg, #fffdf5, #fff3d8); box-shadow: 0 0 20px rgba(228, 169, 62, .18); }
.badge-icon { display: grid; place-items: center; width: 42px; height: 42px; border-radius: 12px; border: 1px solid rgba(176, 124, 38, .25); background: #fff8e8; color: var(--gold-deep); font-size: 20px; flex: none; }
.badge-card.earned .badge-icon { color: #b87818; box-shadow: 0 0 16px rgba(228, 169, 62, .3); }
.badge-card b { font-size: 14px; color: var(--ink); }
.badge-card p { margin: 3px 0 4px; font-size: 11.5px; color: var(--muted); line-height: 1.5; }
.badge-card small { font-size: 10px; color: var(--gold-deep); letter-spacing: .06em; }

/* ---------- 家长设置 ---------- */
.parent-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; align-items: start; }
.parent-panel h3 { margin-bottom: 12px; }
.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  border-top: 1px dashed rgba(176, 124, 38, .18);
}
.setting-row:first-of-type { border-top: none; }
.setting-row.column { flex-direction: column; align-items: stretch; gap: 8px; }
.setting-row > div:first-child { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.setting-row b { font-size: 13.5px; color: var(--ink); }
.setting-row span { font-size: 11px; color: var(--muted); line-height: 1.4; }
.switch {
  position: relative;
  width: 50px;
  height: 28px;
  flex: none;
  border-radius: 999px;
  border: 1px solid rgba(176, 124, 38, .3);
  background: #f0e8d7;
  transition: background .16s, border-color .16s;
}
.switch i {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(80, 60, 20, .25);
  transition: transform .18s, background .18s;
}
.switch.on { background: rgba(90, 165, 102, .3); border-color: rgba(90, 165, 102, .6); }
.switch.on i { transform: translateX(22px); background: #5aa566; box-shadow: 0 0 10px rgba(90, 165, 102, .5); }
.seg-row { display: flex; flex-wrap: wrap; gap: 6px; }
.seg {
  padding: 6px 12px;
  border-radius: 9px;
  border: 1px solid rgba(176, 124, 38, .2);
  background: #fffaf0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}
.seg.active { border-color: rgba(228, 169, 62, .7); background: #ffefc8; color: #8c5c12; }
.danger-zone { border-color: rgba(217, 84, 75, .35); }

/* ---------- 对局 ---------- */
body[data-screen="game"] { overflow: hidden; }
#screen-game {
  position: fixed;
  inset: 0;
  z-index: 20;
  width: 100%;
  max-width: none;
  height: 100dvh;
  margin: 0;
  padding: 0;
  overflow: hidden;
}
#screen-game.active { display: block; animation: none; }

/* 顶部悬浮工具（不占用棋盘空间） */
.game-hud {
  position: absolute;
  top: calc(6px + env(safe-area-inset-top));
  left: calc(10px + env(safe-area-inset-left));
  right: calc(10px + env(safe-area-inset-right));
  z-index: 40;
  display: flex;
  align-items: flex-start;
  justify-content: flex-start;
  gap: 10px;
  pointer-events: none;
}
.game-hud > * { pointer-events: auto; }
.game-hud .btn,
.game-hud .chip {
  background: rgba(255, 253, 247, .9);
  backdrop-filter: blur(6px);
  box-shadow: 0 3px 12px rgba(88, 110, 66, .14);
}
.game-title {
  flex: 0 1 auto;
  min-width: 0;
  max-width: 30vw;
  margin-left: 2px;
  padding: 3px 14px;
  border-radius: 999px;
  border: 1px solid rgba(176, 124, 38, .18);
  background: rgba(255, 253, 247, .82);
  backdrop-filter: blur(6px);
  font-family: var(--serif);
  font-size: 12.5px;
  letter-spacing: .1em;
  color: #1f5d6d;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  box-shadow: 0 2px 10px rgba(88, 110, 66, .1);
}
.game-top-actions { display: flex; align-items: center; gap: 6px; margin-left: auto; }

.game-layout {
  display: grid;
  grid-template-columns: minmax(140px, 1fr) auto minmax(140px, 1fr);
  gap: clamp(10px, 1.6vw, 22px);
  align-items: center;
  justify-items: center;
  width: 100%;
  height: 100dvh;
  padding: 0 calc(10px + env(safe-area-inset-right)) 0 calc(10px + env(safe-area-inset-left));
}
.game-side {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: min(100%, 236px);
  min-width: 0;
}
.game-side.left { justify-self: end; }
.game-side.right { justify-self: start; }

.player-panel {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px;
  border-radius: var(--radius);
  border: 1px solid rgba(176, 124, 38, .2);
  background: linear-gradient(180deg, #fffefb, #fff7e8);
  box-shadow: 0 4px 0 rgba(169, 111, 28, .08), 0 10px 20px rgba(88, 110, 66, .1);
  transition: border-color .18s, box-shadow .18s;
}
.player-panel.red { border-color: rgba(217, 74, 90, .26); }
.player-panel.black { border-color: rgba(111, 99, 201, .24); }
.player-panel.active.red { border-color: rgba(217, 74, 90, .7); box-shadow: 0 0 0 3px rgba(217, 74, 90, .12), 0 10px 20px rgba(88, 110, 66, .12); }
.player-panel.active.black { border-color: rgba(111, 99, 201, .66); box-shadow: 0 0 0 3px rgba(111, 99, 201, .12), 0 10px 20px rgba(88, 110, 66, .12); }
.pp-head { display: flex; align-items: center; gap: 8px; position: relative; }
.pp-avatar { display: grid; place-items: center; width: 46px; height: 46px; border-radius: 12px; background: #fff8e8; border: 1px solid rgba(176, 124, 38, .18); flex: none; }
.pp-name { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.pp-name b { font-size: 12.5px; font-family: var(--serif); letter-spacing: .04em; color: #1f5d6d; }
.pp-name i { font-style: normal; font-size: 9.5px; color: var(--muted); line-height: 1.3; }
.check-badge {
  position: absolute;
  right: 0;
  top: -2px;
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--red);
  color: #fff;
  font-size: 9.5px;
  font-weight: 800;
  animation: checkBlink 1s steps(2) infinite;
}
@keyframes checkBlink { 50% { opacity: .45; } }
.pp-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.pp-stats div { padding: 6px 4px; text-align: center; border-radius: 9px; background: #fff9ec; border: 1px solid rgba(176, 124, 38, .14); }
.pp-stats b { display: block; font-size: 15px; color: var(--ink); font-variant-numeric: tabular-nums; }
.pp-stats span { font-size: 9.5px; color: var(--muted); }
.pp-captured { display: flex; flex-wrap: wrap; gap: 3px; min-height: 24px; align-items: center; }
.pp-captured .cap-token { display: inline-flex; line-height: 0; }
.pp-captured .empty { font-style: normal; font-size: 10px; color: var(--muted); }

.board-stage {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  height: 100%;
}
.turn-banner {
  position: absolute;
  top: -27px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 12;
  padding: 4px 16px;
  border-radius: 999px;
  border: 1px solid rgba(176, 124, 38, .3);
  background: rgba(255, 253, 247, .94);
  backdrop-filter: blur(5px);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .06em;
  color: var(--ink-soft);
  white-space: nowrap;
  box-shadow: 0 3px 10px rgba(88, 110, 66, .14);
}
.turn-banner.red { border-color: rgba(217, 74, 90, .5); color: #a8323f; background: #fff1f2; }
.turn-banner.black { border-color: rgba(111, 99, 201, .45); color: #5647a8; background: #f5f2ff; }
.turn-banner.thinking { animation: thinkPulse 1.1s ease-in-out infinite; }
@keyframes thinkPulse { 50% { opacity: .55; } }

.board-wrap {
  position: relative;
  width: min(calc((100dvh - 56px) * 8 / 9), calc(100vw - 410px));
  margin: 0 auto;
  aspect-ratio: 8 / 9;
}
.board-frame {
  position: relative;
  height: 100%;
}
  padding: 5px;
  border-radius: 14px;
  background: linear-gradient(160deg, #e9c987, #c79a4d 45%, #dfb970);
  box-shadow: 0 14px 34px rgba(88, 110, 66, .28), 0 4px 0 rgba(126, 88, 28, .2), inset 0 0 0 1px rgba(255, 248, 220, .8);
}
.board-frame::before {
  content: "";
  position: absolute;
  inset: 2px;
  border-radius: 12px;
  border: 1px solid rgba(126, 88, 28, .35);
  pointer-events: none;
  z-index: 2;
}
.board {
  position: relative;
  width: 100%;
  aspect-ratio: 8 / 9;
  border-radius: 10px;
  overflow: hidden;
  background:
    radial-gradient(120% 90% at 50% 0%, rgba(255, 255, 255, .55), transparent 55%),
    linear-gradient(180deg, #fdf0d1, #f8e5ba 48%, #f4dcae 52%, #efd19a);
  box-shadow: inset 0 0 34px rgba(160, 116, 44, .22);
  touch-action: manipulation;
}
.board-lines, .hint-layer { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.board-lines .grid-line { stroke: rgba(139, 96, 35, .45); stroke-width: 1; fill: none; }
.board-lines .grid-line.strong { stroke: rgba(126, 84, 26, .7); stroke-width: 1.6; }
.board-lines .palace-line { stroke: rgba(139, 96, 35, .4); stroke-width: 1; fill: none; }
.river {
  position: absolute;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 4%;
  pointer-events: none;
  color: rgba(74, 105, 112, .62);
  font-family: var(--serif);
  font-size: clamp(10px, 1.5vw, 15px);
  letter-spacing: .34em;
  font-weight: 700;
  white-space: nowrap;
  background: linear-gradient(90deg, rgba(144, 206, 230, .28), rgba(170, 224, 244, .46), rgba(144, 206, 230, .28));
  border-top: 1px dashed rgba(90, 150, 175, .35);
  border-bottom: 1px dashed rgba(90, 150, 175, .35);
}
.river-mark { color: rgba(74, 140, 165, .38); font-size: .7em; letter-spacing: 0; }

.cell {
  position: absolute;
  width: 10.4%;
  aspect-ratio: 1;
  transform: translate(-50%, -50%);
  border: none;
  background: transparent;
  padding: 0;
  border-radius: 50%;
  z-index: 3;
  transition: filter .12s;
}
.cell::before {
  content: "";
  position: absolute;
  inset: 12%;
  border-radius: 50%;
  border: 1.5px solid transparent;
  transition: border-color .14s, background .14s, box-shadow .14s, transform .14s;
}
.cell.can-move::before {
  border-color: rgba(45, 157, 184, .75);
  background: rgba(45, 157, 184, .18);
  box-shadow: 0 0 13px rgba(45, 157, 184, .35), inset 0 0 8px rgba(45, 157, 184, .22);
  transform: scale(.72);
  animation: moveDot 1.6s ease-in-out infinite;
}
@keyframes moveDot { 50% { transform: scale(.62); opacity: .75; } }
.cell.can-capture::before {
  border-color: rgba(217, 74, 90, .85);
  border-width: 2.5px;
  box-shadow: 0 0 16px rgba(217, 74, 90, .4), inset 0 0 10px rgba(217, 74, 90, .25);
}
.cell.sel::before {
  border-color: #d99b28;
  border-width: 2.5px;
  box-shadow: 0 0 18px rgba(228, 169, 62, .55), inset 0 0 10px rgba(255, 220, 140, .35);
}
.cell.last-from::before { background: rgba(45, 157, 184, .12); }
.cell.last-to::before { background: rgba(228, 169, 62, .18); border-color: rgba(169, 111, 28, .3); }
.cell.hint-from::before { border-color: #2d9db8; box-shadow: 0 0 18px rgba(45, 157, 184, .55); animation: hintPulse 1s ease-in-out infinite; }
.cell.hint-to::before { border-color: #2d9db8; border-width: 2.5px; background: rgba(45, 157, 184, .2); box-shadow: 0 0 20px rgba(45, 157, 184, .55); }
@keyframes hintPulse { 50% { box-shadow: 0 0 28px rgba(45, 157, 184, .85), inset 0 0 12px rgba(45, 157, 184, .35); } }
.hint-arrow {
  stroke: #2d9db8;
  stroke-width: 2.4;
  stroke-linecap: round;
  stroke-dasharray: 3 2.4;
  filter: drop-shadow(0 1px 2px rgba(20, 100, 120, .5));
  animation: dashFlow 1s linear infinite;
}
@keyframes dashFlow { to { stroke-dashoffset: -10.8; } }

.piece {
  position: absolute;
  inset: 4%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0;
  border-radius: 50%;
  line-height: 1;
  pointer-events: none;
  box-shadow: 0 5px 9px rgba(120, 84, 28, .3), inset 0 -3px 0 rgba(120, 84, 28, .13), inset 0 2px 0 rgba(255, 255, 255, .6);
  will-change: transform;
}
.piece.red {
  background: radial-gradient(circle at 34% 26%, #ffffff, #fff4d8 46%, #f2dcac 100%);
  border: 1.5px solid #c09344;
  color: #b32d40;
}
.piece.black {
  background: radial-gradient(circle at 34% 26%, #dfe6f7, #b9c4e0 48%, #95a2c4 100%);
  border: 1.5px solid #6e7ca3;
  color: #2e3550;
  box-shadow: 0 5px 9px rgba(70, 80, 120, .3), inset 0 -3px 0 rgba(60, 70, 100, .16), inset 0 2px 0 rgba(255, 255, 255, .5);
}
.piece.red::after, .piece.black::after {
  content: "";
  position: absolute;
  inset: 7%;
  border-radius: 50%;
  border: 1px solid rgba(192, 147, 68, .4);
  pointer-events: none;
}
.piece.black::after { border-color: rgba(110, 124, 163, .4); }
.piece-art { display: block; height: 46%; }
.piece-art .pixel { width: 100%; height: 100%; }
.piece-char {
  font-family: var(--serif);
  font-weight: 800;
  font-size: clamp(9px, 1.55vw, 15px);
  line-height: 1;
  margin-top: 1px;
  text-shadow: 0 1px 0 rgba(255, 255, 255, .5);
}
.piece.black .piece-char {
  text-shadow: 0 1px 0 rgba(255, 255, 255, .35);
  /* 上方的黑方棋子朝向对面玩家，文字旋转 180° */
  transform: rotate(180deg);
}
.piece.in-check { animation: pieceShake .5s cubic-bezier(.36, .07, .19, .97) infinite; box-shadow: 0 0 0 3px rgba(217, 74, 90, .8), 0 0 22px rgba(217, 74, 90, .7); }
.piece.shake { animation: pieceShake .5s cubic-bezier(.36, .07, .19, .97) 2; }
@keyframes pieceShake {
  10%, 90% { transform: translateX(-1.5px); }
  20%, 80% { transform: translateX(2.5px); }
  30%, 50%, 70% { transform: translateX(-3px); }
  40%, 60% { transform: translateX(3px); }
}
.piece.just-moved { z-index: 6; }
.fx-layer { position: absolute; inset: 0; pointer-events: none; z-index: 8; }
.spark {
  position: absolute;
  width: 6px;
  height: 6px;
  margin: -3px 0 0 -3px;
  border-radius: 2px;
  background: var(--c, var(--gold));
  box-shadow: 0 0 8px var(--c, var(--gold));
  z-index: 8;
  animation: sparkFly .7s ease-out forwards;
}
@keyframes sparkFly {
  0% { transform: translate(0, 0) scale(1); opacity: 1; }
  100% { transform: translate(var(--dx), var(--dy)) scale(.2); opacity: 0; }
}

.coach-strip {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  width: 100%;
  padding: 10px 11px;
  border-radius: 14px;
  border: 1px solid rgba(176, 124, 38, .24);
  background:
    radial-gradient(140% 130% at 100% 0%, rgba(190, 226, 150, .35), transparent 60%),
    linear-gradient(180deg, #fffef9, #f7fbe9);
  box-shadow: 0 3px 0 rgba(169, 111, 28, .08), 0 8px 18px rgba(88, 110, 66, .1);
  transition: opacity .2s;
}
.coach-strip.muted { opacity: .5; }
.coach-strip.pulse { animation: coachPop .4s ease-out; }
@keyframes coachPop {
  0% { transform: scale(.985); box-shadow: 0 0 0 0 rgba(45, 157, 184, .35); }
  60% { transform: scale(1.005); box-shadow: 0 0 0 8px rgba(45, 157, 184, 0); }
  100% { transform: scale(1); }
}
.coach-avatar { display: grid; place-items: center; width: 36px; height: 36px; flex: none; border-radius: 50%; background: #fff8e8; border: 1px solid rgba(176, 124, 38, .22); }
.coach-panel { min-width: 0; }
.coach-name { display: block; font-size: 9.5px; font-weight: 800; letter-spacing: .18em; color: var(--gold-deep); margin-bottom: 2px; }
.coach-panel p { margin: 0; font-size: 12.5px; line-height: 1.55; color: var(--ink-soft); }

.game-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  width: 100%;
  padding: 0;
}
.game-actions .btn { min-width: 0; width: 100%; padding: 8px 6px; font-size: 11.5px; }
.game-actions .off { opacity: .62; }

/* ---------- 结算 ---------- */
.result-wrap { max-width: 980px; margin: 0 auto; }
.result-hero {
  display: flex;
  align-items: center;
  gap: clamp(14px, 3vw, 28px);
  padding: clamp(18px, 4vw, 34px);
  border-radius: 24px;
  border: 1px solid rgba(176, 124, 38, .28);
  background:
    radial-gradient(520px 300px at 82% 8%, var(--mood, rgba(255, 214, 130, .4)), transparent 65%),
    linear-gradient(180deg, #fffefb, #fff7e6);
  box-shadow: var(--shadow);
  margin-bottom: 16px;
}
.result-hero.win { --mood: rgba(255, 210, 110, .55); border-color: rgba(228, 169, 62, .55); }
.result-hero.draw { --mood: rgba(144, 214, 240, .45); border-color: rgba(45, 157, 184, .4); }
.result-hero.lose { --mood: rgba(240, 160, 160, .4); border-color: rgba(217, 74, 90, .35); }
.result-badge {
  display: grid;
  place-items: center;
  width: clamp(76px, 10vw, 108px);
  height: clamp(76px, 10vw, 108px);
  flex: none;
  border-radius: 50%;
  border: 1px solid rgba(176, 124, 38, .3);
  background: radial-gradient(circle at 34% 26%, #ffffff, #fff1cf);
  box-shadow: 0 6px 0 rgba(169, 111, 28, .12), 0 0 34px var(--mood, rgba(255, 210, 110, .4));
}
.result-copy h1 { margin: 0 0 8px; font-family: var(--serif); font-size: clamp(23px, 3.4vw, 36px); letter-spacing: .05em; color: #1f5d6d; }
.result-copy > p:not(.kicker) { margin: 0; color: var(--ink-soft); font-size: 13px; line-height: 1.7; max-width: 60ch; }
.result-stars { display: flex; align-items: center; gap: 6px; margin-top: 12px; flex-wrap: wrap; }
.result-stars .star { transform: scale(1.15); transform-origin: left center; }
.result-reason {
  margin-left: 10px;
  padding: 3px 10px;
  border-radius: 999px;
  border: 1px solid rgba(176, 124, 38, .28);
  background: #fff9ec;
  font-size: 11px;
  color: var(--gold-deep);
  font-weight: 700;
}
.result-grid { display: grid; grid-template-columns: minmax(0, .85fr) minmax(0, 1.15fr); gap: 16px; margin-bottom: 16px; }
.rs-row { display: flex; justify-content: space-between; gap: 10px; padding: 8px 0; border-top: 1px dashed rgba(176, 124, 38, .16); font-size: 12.5px; color: var(--muted); }
.rs-row:first-of-type { border-top: none; }
.rs-row b { color: var(--ink); font-variant-numeric: tabular-nums; }
.review-item { display: flex; gap: 9px; padding: 8px 0; border-top: 1px dashed rgba(176, 124, 38, .16); }
.review-item:first-of-type { border-top: none; }
.q-tag {
  flex: none;
  padding: 3px 8px;
  height: fit-content;
  border-radius: 7px;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .06em;
  border: 1px solid currentColor;
}
.q-brilliant .q-tag { color: #a96f1c; background: rgba(228, 169, 62, .14); }
.q-good .q-tag { color: #3f8a4e; background: rgba(90, 165, 102, .12); }
.q-normal .q-tag { color: var(--muted); background: rgba(125, 145, 139, .08); }
.q-mistake .q-tag { color: #b8701f; background: rgba(230, 160, 70, .12); }
.q-blunder .q-tag { color: #b83a34; background: rgba(217, 84, 75, .1); }
.q-missed .q-tag { color: #1f7f96; background: rgba(45, 157, 184, .1); }
.q-body { min-width: 0; }
.q-body b { font-size: 12.5px; color: var(--ink-soft); }
.q-body p { margin: 2px 0 0; font-size: 11.5px; color: var(--muted); line-height: 1.5; }
.result-badges { margin-bottom: 16px; border-color: rgba(228, 169, 62, .45); }
.new-badges { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 10px; }
.new-badge { display: flex; align-items: center; gap: 10px; padding: 9px; border-radius: 11px; background: #fff6df; border: 1px solid rgba(176, 124, 38, .18); }
.new-badge > span { display: grid; place-items: center; width: 38px; height: 38px; flex: none; border-radius: 10px; background: #fffdf6; color: #b87818; font-size: 18px; }
.new-badge b { font-size: 12.5px; }
.new-badge p { margin: 2px 0 0; font-size: 10.5px; color: var(--muted); }
.result-actions { display: flex; justify-content: center; flex-wrap: wrap; gap: 10px; padding-bottom: 10px; }

/* ---------- 底部导航 ---------- */
.bottom-nav {
  position: fixed;
  left: 50%;
  bottom: 10px;
  transform: translateX(-50%);
  z-index: 40;
  display: flex;
  gap: 3px;
  padding: 5px;
  border-radius: 16px;
  border: 1px solid rgba(176, 124, 38, .28);
  background: rgba(255, 253, 247, .92);
  box-shadow: 0 10px 26px rgba(70, 100, 80, .2);
  backdrop-filter: blur(8px);
}
.bottom-nav button {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  min-width: 56px;
  padding: 6px 9px;
  border: none;
  border-radius: 11px;
  background: transparent;
  color: var(--muted);
  transition: color .15s, background .15s;
}
.bottom-nav button span { font-size: 17px; line-height: 1; }
.bottom-nav button i { font-style: normal; font-size: 9.5px; font-weight: 700; letter-spacing: .08em; }
.bottom-nav button:hover { color: var(--ink-soft); }
.bottom-nav button.active { color: #8c5c12; background: #ffedc4; box-shadow: inset 0 0 0 1px rgba(228, 169, 62, .45); }
body[data-screen="game"] .bottom-nav,
body[data-screen="result"] .bottom-nav { display: none; }

/* ---------- 弹窗 ---------- */
.modal-layer {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(60, 92, 92, .3);
  backdrop-filter: blur(5px);
  animation: fadeIn .15s ease-out;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal {
  position: relative;
  width: min(560px, 100%);
  max-height: calc(100dvh - 40px);
  overflow-y: auto;
  padding: 22px;
  border-radius: 20px;
  border: 1px solid rgba(176, 124, 38, .32);
  background:
    radial-gradient(420px 240px at 100% 0%, rgba(144, 214, 240, .25), transparent 65%),
    linear-gradient(180deg, #fffefb, #fff6e3);
  box-shadow: 0 24px 60px rgba(60, 90, 80, .28), inset 0 1px 0 #fff;
  animation: modalIn .2s ease-out;
  color: var(--ink);
}
@keyframes modalIn { from { opacity: 0; transform: translateY(10px) scale(.98); } to { opacity: 1; transform: none; } }
.modal h3 {
  margin: 0 0 10px;
  padding-right: 34px;
  font-family: var(--serif);
  font-size: 21px;
  letter-spacing: .05em;
  color: #1f5d6d;
}
.modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid rgba(176, 124, 38, .24);
  background: #fff9ec;
  color: var(--muted);
  font-size: 18px;
  line-height: 1;
}
.modal-body { font-size: 13.5px; line-height: 1.7; color: var(--ink-soft); }
.modal-body p { margin: 0 0 9px; }
.modal-body ul { margin: 0 0 10px; padding-left: 20px; }
.modal-body li { margin-bottom: 5px; }
.modal-actions { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 8px; margin-top: 18px; }

.difficulty-list { display: grid; gap: 8px; margin-top: 12px; }
.difficulty-card {
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid rgba(176, 124, 38, .2);
  background: #fffaf0;
  text-align: left;
  transition: border-color .15s, background .15s, transform .15s;
}
.difficulty-card:hover { border-color: rgba(228, 169, 62, .6); background: #fff5dd; transform: translateX(2px); }
.difficulty-card > span { display: grid; place-items: center; width: 46px; height: 46px; flex: none; border-radius: 11px; background: #fffdf6; border: 1px solid rgba(176, 124, 38, .18); }
.difficulty-card > div { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.difficulty-card b { font-size: 14px; color: #8c5c12; }
.difficulty-card i { font-style: normal; font-size: 11px; color: var(--muted); }
.difficulty-card em { font-style: normal; font-size: 10px; font-weight: 800; color: #1f7f96; letter-spacing: .08em; }
.chapter-theme { font-family: var(--serif); font-size: 16px; color: #1f5d6d; letter-spacing: .04em; }
.lesson-list { padding-left: 20px; }
.tip-line { padding: 9px 12px; border-radius: 10px; border: 1px dashed rgba(228, 169, 62, .55); background: #fff7e2; color: #8c5c12; font-size: 12.5px; }
.rules-body p { margin: 0 0 7px; }
.rules-body b { color: #8c5c12; }

/* ---------- 休息 ---------- */
.rest-body { text-align: center; }
.rest-avatar { display: inline-grid; place-items: center; width: 74px; height: 74px; margin-bottom: 8px; border-radius: 50%; border: 1px solid rgba(176, 124, 38, .3); background: #fff8e8; box-shadow: 0 0 26px rgba(228, 169, 62, .25); }
.rest-clock {
  margin: 12px auto;
  font-family: var(--serif);
  font-size: 44px;
  font-weight: 800;
  letter-spacing: .08em;
  color: #1f7f96;
  text-shadow: 0 2px 0 #fff;
  font-variant-numeric: tabular-nums;
}

/* ---------- Toast ---------- */
.toast-layer {
  position: fixed;
  left: 50%;
  bottom: 78px;
  transform: translateX(-50%);
  z-index: 70;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  pointer-events: none;
  width: min(92vw, 440px);
}
body[data-screen="game"] .toast-layer,
body[data-screen="result"] .toast-layer { bottom: 20px; }
.toast {
  padding: 9px 16px;
  border-radius: 999px;
  border: 1px solid rgba(176, 124, 38, .28);
  background: rgba(255, 253, 247, .97);
  color: var(--ink-soft);
  font-size: 12px;
  font-weight: 700;
  box-shadow: 0 10px 26px rgba(70, 100, 80, .22);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity .2s, transform .2s;
  max-width: 100%;
  text-align: center;
}
.toast.in { opacity: 1; transform: none; }
.toast-error { border-color: rgba(217, 84, 75, .55); color: #a8322c; background: #fff2ef; }
.toast-badge { border-color: rgba(228, 169, 62, .65); color: #8c5c12; background: #fff6df; }
.toast-clock { border-color: rgba(45, 157, 184, .45); color: #1f7f96; background: #f1fbff; }

/* ---------- 响应式 ---------- */
@media (max-height: 760px) and (min-width: 981px) {
  .board-wrap { width: min(calc((100dvh - 56px) * 8 / 9), calc(100vw - 400px)); }
  .coach-strip { padding: 8px 10px; }
  .coach-panel p { font-size: 11.5px; }
  .player-panel { padding: 10px; }
  .pp-avatar { width: 38px; height: 38px; }
  .game-actions { gap: 6px; }
}

@media (max-width: 1080px) {
  .game-layout { grid-template-columns: minmax(110px, 1fr) auto minmax(110px, 1fr); gap: 10px; }
  .game-side { width: min(100%, 196px); }
  .board-wrap { width: min(calc((100dvh - 56px) * 8 / 9), calc(100vw - 352px)); }
  .pp-name i { display: none; }
  .pp-avatar { width: 38px; height: 38px; }
  .coach-strip { padding: 8px 10px; }
  .coach-panel p { font-size: 11.5px; }
  .game-actions .btn { font-size: 11px; padding: 7px 5px; }
}

@media (max-width: 980px) {
  .home-grid { grid-template-columns: 1fr; }
  .home-hero { grid-template-columns: 1fr; justify-items: start; }
  .hero-mascots { justify-content: flex-start; flex-wrap: wrap; }
  .result-grid { grid-template-columns: 1fr; }
}

/* 竖屏 / 窄屏：上下堆叠，棋盘横向占满 */
@media (max-width: 980px) and (orientation: portrait) {
  #screen-game { position: fixed; overflow: hidden; }
  body[data-screen="game"] { overflow: hidden; }
  #screen-game.active { display: flex; flex-direction: column; }
  .game-title { font-size: 11.5px; padding: 2px 10px; max-width: 42vw; }
  .game-layout {
    flex: 1;
    height: auto;
    min-height: 0;
    display: grid;
    grid-template-columns: 1fr;
    grid-template-rows: auto auto minmax(0, 1fr) auto auto;
    grid-template-areas: "black" "coach" "board" "red" "actions";
    gap: 6px;
    align-items: center;
    justify-items: center;
    padding: calc(40px + env(safe-area-inset-top)) 8px calc(8px + env(safe-area-inset-bottom));
  }
  .game-side { display: contents; }
  .player-panel { width: 100%; flex-direction: row; align-items: center; gap: 8px; padding: 6px 9px; }
  .player-panel.black { grid-area: black; }
  .player-panel.red { grid-area: red; }
  .coach-strip { grid-area: coach; width: 100%; padding: 7px 10px; }
  .board-stage { grid-area: board; width: 100%; height: 100%; }
  .board-wrap { width: min(100%, calc((100dvh - 300px) * 8 / 9)); max-width: none; }
  .game-actions { grid-area: actions; grid-template-columns: repeat(4, 1fr); width: 100%; gap: 6px; }
  .pp-head { flex: 0 1 auto; }
  .pp-avatar { width: 34px; height: 34px; }
  .pp-name b { font-size: 12px; }
  .pp-name i { display: none; }
  .pp-stats { display: flex; gap: 5px; margin-left: auto; min-width: 0; }
  .pp-stats div { padding: 4px 9px; }
  .pp-stats b { font-size: 13px; }
  .pp-stats span { font-size: 9px; }
  .pp-captured { display: none; }
  .coach-panel p { font-size: 11.5px; line-height: 1.45; }
  .coach-avatar { width: 30px; height: 30px; }
}


@media (max-width: 720px) {
  .screen { padding-left: 10px; padding-right: 10px; }
  .topbar { padding: 8px 10px; }
  .brand-mark { width: 36px; height: 36px; }
  .brand-text { font-size: 15px; }
  .brand-text small { letter-spacing: .2em; }
  .chip { padding: 6px 9px; font-size: 11px; }
  .icon-btn { width: 34px; height: 34px; }
  .page-head { gap: 10px; flex-wrap: wrap; }
  .page-head .btn { order: 0; }
  .stars-total { margin-left: auto; }
  .mode-card { grid-template-columns: auto minmax(0, 1fr); }
  .mode-tag { display: none; }
  .level-map { grid-template-columns: 1fr 1fr; gap: 10px; }
  .level-card { min-height: 148px; padding: 12px; }
  .lv-num { font-size: 26px; right: 10px; }
  .lv-name { font-size: 17px; }
  .lv-desc { display: none; }
  .collection-grid { grid-template-columns: 1fr; }
  .badge-grid { grid-template-columns: 1fr; }
  .parent-grid { grid-template-columns: 1fr; }
  .bottom-nav button { min-width: 48px; padding: 6px 7px; }
  .bottom-nav button i { font-size: 9px; }
  .modal { padding: 18px; }
  .result-hero { flex-direction: column; text-align: center; align-items: center; }
  .result-stars { justify-content: center; }
  .result-actions .btn { flex: 1 1 44%; }
}

@media (max-width: 620px) {
  .game-top-actions .chip { display: none; }
  .game-actions { gap: 6px; }
  .game-actions .btn { min-width: 0; padding: 8px 5px; font-size: 10.5px; }
  .coach-panel p { font-size: 11.5px; }
  .coach-strip { padding: 7px 9px; }
  .piece-char { font-size: clamp(8px, 2vw, 12px); }
  .turn-banner { font-size: 11px; padding: 3px 11px; top: -24px; }
  .home-hero { padding: 16px; }
  .hero-copy h1 { font-size: clamp(30px, 9vw, 44px); }
  .hero-actions .btn { flex: 1 1 100%; }
  .hero-actions .btn.big { flex: 1 1 100%; }
}

@media (max-width: 480px) {
  .level-map { grid-template-columns: 1fr; }
  .mascot { display: none; }
  .mascot:first-child { display: flex; }
  .mascot-ring { width: 70px; height: 70px; }
  .pp-stats { min-width: 0; }
  .pp-avatar { display: none; }
  .result-actions .btn { flex: 1 1 100%; }
}

@media (max-width: 380px) {
  .game-actions .btn { font-size: 10px; }
}

/* 横屏矮屏：压缩侧栏，让棋盘尽量高 */
@media (max-height: 520px) and (orientation: landscape) {
  .board-wrap { width: min(calc((100dvh - 40px) * 8 / 9), calc(100vw - 330px)); }
  .game-side { gap: 6px; }
  .coach-strip { padding: 6px 8px; }
  .coach-panel p { font-size: 10.5px; line-height: 1.35; }
  .coach-avatar { display: none; }
  .player-panel { padding: 7px; gap: 6px; }
  .pp-avatar { width: 34px; height: 34px; }
  .pp-stats div { padding: 4px 2px; }
  .turn-banner { top: -19px; font-size: 10.5px; padding: 3px 10px; }
  .game-actions { gap: 5px; }
  .game-actions .btn { padding: 6px 4px; font-size: 10px; }
}

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

/* ---------- 全屏按钮 ---------- */
[data-fullscreen] { touch-action: manipulation; }
[data-fullscreen] .fs-enter,
[data-fullscreen] .fs-exit {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
  pointer-events: none;
}
[data-fullscreen] .fs-exit { display: none; }
[data-fullscreen].is-fs .fs-enter { display: none; }
[data-fullscreen].is-fs .fs-exit { display: block; }
