/* 有数 · 益智游戏系列共用样式。放在各游戏自己的 globals.css 之后引入，让系列的壳与色板压过游戏自带的页头。 */
/* 壳用字：各游戏自带的字体子集只含自己的文案，系列页头里其它游戏的名字会缺字，所以壳自带一份小子集（可变字重）；
   字体栈里放在最前，缺的字自然落到游戏自己的 Noto 子集，再落到系统字体，字形一致。 */
@font-face { font-family: 'YS Shell Serif'; font-style: normal; font-weight: 200 900; font-display: swap; src: url(./fonts/ys-shell-serif.woff2) format('woff2'); }
@font-face { font-family: 'YS Shell Sans'; font-style: normal; font-weight: 100 900; font-display: swap; src: url(./fonts/ys-shell-sans.woff2) format('woff2'); }
:root {
  --ys-paper: #f7f3ea;
  --ys-card: #fdfbf4;
  --ys-band: #f4efe2;
  --ys-tint: #efe8d8;
  --ys-ink: #2a2521;
  --ys-ink2: #4a4238;
  --ys-sub: #5f564b;
  --ys-faint: #6f6659;
  --ys-mute: #8c8273;
  --ys-line: #e4dbc6;
  --ys-line2: #eee6d4;
  --ys-cinnabar: #a63a2b;
  --ys-cinnabar-dark: #8c2f22;
  --ys-green: #4e7a66;
  /* 线上先用有数网站的切片字体（YS Site *，字全、和网站共用缓存），离线时退到壳子集与游戏自带子集 */
  --ys-serif: 'YS Site Serif', 'YS Shell Serif', 'Noto Serif SC', 'Songti SC', 'STSong', 'SimSun', serif;
  --ys-sans: 'YS Site Sans', 'YS Shell Sans', 'Noto Sans SC', 'PingFang SC', 'Microsoft YaHei', sans-serif;
  --ys-kai: 'YS Site Kai', 'Kaiti SC', 'KaiTi', 'STKaiti', serif;
  --ys-page-max: 1180px;
  --ys-page-pad: 20px;
}

html { background: var(--ys-paper); }
body { background: var(--ys-paper); color: var(--ys-ink); font-family: var(--ys-serif); }

/* ---------- 系列页头 ---------- */
.ys-series-head {
  position: sticky; top: 0; z-index: 50;
  background: rgba(247, 243, 234, 0.92);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--ys-line);
}
.ys-series-row {
  max-width: var(--ys-page-max); margin: 0 auto; padding: 0 var(--ys-page-pad);
  height: 54px; display: flex; align-items: center; gap: 22px;
}
.ys-series-brand {
  display: inline-flex; align-items: center; gap: 9px; text-decoration: none; color: var(--ys-ink); flex: none;
}
.ys-series-brand span { font-family: var(--ys-serif); font-size: 19px; font-weight: 900; letter-spacing: 0.16em; }
.ys-series-brand em {
  font-style: normal; font-family: var(--ys-sans); font-size: 12px; letter-spacing: 0.3em; color: var(--ys-faint);
  padding-left: 12px; border-left: 1px solid var(--ys-line);
}
.ys-series-games {
  display: flex; align-items: center; gap: 4px; flex: 1 1 auto; min-width: 0;
  overflow-x: auto; scrollbar-width: none; -ms-overflow-style: none;
}
.ys-series-games::-webkit-scrollbar { display: none; }
.ys-series-games a {
  flex: none; font-family: var(--ys-sans); font-size: 14px; color: var(--ys-sub); text-decoration: none;
  padding: 6px 11px; border-radius: 2px; border-bottom: 2px solid transparent; transition: color .2s, border-color .2s;
}
.ys-series-games a:hover { color: var(--ys-ink); }
.ys-series-games a[aria-current='page'] { color: var(--ys-cinnabar); font-weight: 700; border-bottom-color: var(--ys-cinnabar); }
.ys-series-back {
  flex: none; font-family: var(--ys-sans); font-size: 13px; color: var(--ys-faint); text-decoration: none;
  border: 1px solid var(--ys-line); padding: 5px 12px; border-radius: 2px; transition: color .2s, border-color .2s;
}
.ys-series-back:hover { color: var(--ys-cinnabar); border-color: var(--ys-cinnabar); }

/* 游戏内子页导航（对局 / 学习 / 练习 / 教学 / 打印） */
.ys-game-tabs {
  max-width: var(--ys-page-max); margin: 0 auto; padding: 0 var(--ys-page-pad);
  display: flex; gap: 22px; height: 40px; align-items: stretch; overflow-x: auto; scrollbar-width: none;
}
.ys-game-tabs::-webkit-scrollbar { display: none; }
.ys-game-tabs a {
  flex: none; display: inline-flex; align-items: center; font-family: var(--ys-serif); font-size: 14.5px; letter-spacing: 0.06em;
  color: var(--ys-sub); text-decoration: none; border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.ys-game-tabs a:hover { color: var(--ys-ink); }
.ys-game-tabs a[aria-current='page'] { color: var(--ys-ink); font-weight: 700; border-bottom-color: var(--ys-ink); }

/* ---------- 页面容器与页脚 ---------- */
.ys-game-main { max-width: var(--ys-page-max); margin: 0 auto; padding: 22px var(--ys-page-pad) 56px; }
.ys-series-foot {
  max-width: var(--ys-page-max); margin: 0 auto; padding: 18px var(--ys-page-pad) 34px;
  border-top: 1px solid var(--ys-line); display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px;
  font-family: var(--ys-sans); font-size: 12px; color: var(--ys-faint); line-height: 1.9;
}
.ys-series-foot a { color: var(--ys-faint); text-decoration: none; border-bottom: 1px solid var(--ys-line); }
.ys-series-foot a:hover { color: var(--ys-cinnabar); border-bottom-color: var(--ys-cinnabar); }

/* ---------- 游戏页通用节奏（各游戏把自己的标题区改成这套类） ---------- */
.ys-game-title { display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap; margin: 0 0 6px; }
.ys-game-title h1 { margin: 0; font-family: var(--ys-serif); font-size: 26px; font-weight: 700; letter-spacing: 0.04em; color: var(--ys-ink); }
.ys-game-title .ys-tagline { font-family: var(--ys-serif); font-size: 15px; letter-spacing: 0.04em; color: var(--ys-sub); }
.ys-game-subtitle { font-family: var(--ys-sans); font-size: 12.5px; color: var(--ys-faint); letter-spacing: 0.06em; margin: 0 0 18px; }

@media (max-width: 720px) {
  /* 手机：只留标志 + 五个游戏名，一行放得下（390px 宽实测 ~360px），放不下时可横向滑动且当前项自动居中 */
  .ys-series-row { gap: 8px; height: 50px; padding: 0 12px; }
  .ys-series-brand { gap: 6px; }
  .ys-series-brand span { font-size: 17px; letter-spacing: 0.1em; }
  .ys-series-brand em { display: none; }
  .ys-series-back { display: none; }
  .ys-series-games { gap: 0; }
  .ys-series-games a { font-size: 13px; padding: 6px 7px; letter-spacing: 0; }
  .ys-game-tabs { padding: 0 12px; gap: 18px; }
  .ys-game-main { padding: 16px 14px 44px; }
  .ys-game-title h1 { font-size: 22px; }
}
@media print {
  .ys-series-head, .ys-series-foot { display: none !important; }
}

/* ======================================================================
   v3「纸上棋局」界面套件（GameKit.tsx 用，类名 ysg-）
   三层：游戏首页 → 选择页 → 对局；设置、规则、暂停、通关都在弹层里。
   ====================================================================== */
:root {
  --ysg-ease: cubic-bezier(0.2, 0.7, 0.2, 1);
  --ysg-r: 8px;           /* 卡片、按钮圆角 */
  --ysg-r-lg: 12px;       /* 弹层圆角 */
  --ysg-top: 60px;        /* 顶栏高 */
  --ysg-board-max: min(620px, calc(100svh - 230px));
  --ysg-shadow: 0 1px 2px rgba(42, 37, 33, 0.05), 0 14px 30px -22px rgba(42, 37, 33, 0.45);
}
.ysg-home, .ysg-screen, .ysg-play { min-height: 100svh; display: flex; flex-direction: column; background: var(--ys-paper); color: var(--ys-ink); font-family: var(--ys-sans); }
.ysg-home :where(button, a), .ysg-screen :where(button, a), .ysg-play :where(button, a), .ysg-sheet :where(button, a) { -webkit-tap-highlight-color: transparent; }
:where(.ysg-home, .ysg-screen, .ysg-play, .ysg-sheet) :where(button, a, [role='radio'], [role='switch']):focus-visible { outline: 2px solid var(--ys-cinnabar); outline-offset: 2px; }
@keyframes ysg-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.ysg-home-main, .ysg-screen-main, .ysg-play-main { animation: ysg-in 0.35s var(--ysg-ease) both; }

/* ---- 顶栏 ---- */
.ysg-top {
  position: sticky; top: 0; z-index: 30; height: var(--ysg-top); flex: none;
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 12px; padding: 0 16px;
  background: rgba(247, 243, 234, 0.94); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--ys-line);
}
.ysg-top-l { display: flex; align-items: center; min-width: 0; }
.ysg-top-c { text-align: center; min-width: 0; }
.ysg-top-title { font: 700 17px/1.2 var(--ys-serif); letter-spacing: 0.08em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ysg-top-sub { margin-top: 2px; font: 400 11.5px/1.2 var(--ys-sans); color: var(--ys-faint); letter-spacing: 0.06em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ysg-top-r { display: flex; align-items: center; justify-content: flex-end; gap: 8px; min-width: 0; }
.ysg-back { display: inline-flex; align-items: center; gap: 2px; padding: 8px 10px 8px 2px; border: 0; background: none; color: var(--ys-ink2); font: 400 14px/1 var(--ys-sans); letter-spacing: 0.06em; cursor: pointer; border-radius: 6px; }
.ysg-back:hover { color: var(--ys-ink); }
.ysg-ibtn {
  position: relative; flex: none; width: 40px; height: 40px; display: inline-grid; place-items: center; padding: 0;
  border: 1px solid var(--ys-line); border-radius: 50%; background: var(--ys-card); color: var(--ys-ink2); cursor: pointer;
  transition: border-color 0.2s, color 0.2s, background 0.2s;
}
.ysg-ibtn:hover { border-color: var(--ys-ink2); color: var(--ys-ink); }
.ysg-ibtn.on { border-color: var(--ys-cinnabar); color: var(--ys-cinnabar); background: rgba(166, 58, 43, 0.06); }
.ysg-ibtn:disabled { opacity: 0.45; cursor: default; }
.ysg-badge {
  position: absolute; top: -5px; right: -5px; min-width: 18px; height: 18px; padding: 0 4px; box-sizing: border-box;
  display: inline-grid; place-items: center; border-radius: 999px; border: 1.5px solid var(--ys-paper);
  background: var(--ys-cinnabar); color: #fbf8f1; font: 600 10.5px/1 var(--ys-sans);
}
.ysg-clock { font: 500 15px/1 var(--ys-sans); font-variant-numeric: tabular-nums; letter-spacing: 0.04em; color: var(--ys-ink2); padding: 0 4px; }
.ysg-clock.paused { opacity: 0.45; }

/* ---- 按钮 ---- */
.ysg-primary {
  width: 100%; min-height: 58px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  padding: 10px 18px; border: 0; border-radius: var(--ysg-r); background: var(--ys-cinnabar); color: #fbf8f1; cursor: pointer;
  font: 700 18px/1.2 var(--ys-serif); letter-spacing: 0.12em; box-shadow: 0 12px 22px -16px rgba(140, 47, 34, 0.85);
  transition: background 0.2s, transform 0.15s, box-shadow 0.2s;
}
.ysg-primary small { font: 400 12.5px/1.2 var(--ys-sans); letter-spacing: 0.06em; opacity: 0.86; }
.ysg-primary:hover { background: var(--ys-cinnabar-dark); }
.ysg-primary:active { transform: translateY(1px); box-shadow: 0 6px 14px -12px rgba(140, 47, 34, 0.9); }
.ysg-primary:disabled { opacity: 0.5; cursor: default; box-shadow: none; transform: none; }
.ysg-primary:disabled:hover { background: var(--ys-cinnabar); }
.ysg-secondary:disabled { opacity: 0.45; cursor: default; }
.ysg-secondary {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 42px; padding: 0 16px;
  border: 1px solid var(--ys-line); border-radius: var(--ysg-r); background: var(--ys-card); color: var(--ys-ink2); cursor: pointer;
  font: 400 14px/1 var(--ys-sans); letter-spacing: 0.04em; transition: border-color 0.2s, color 0.2s;
}
.ysg-secondary:hover { border-color: var(--ys-ink2); color: var(--ys-ink); }

/* ---- 游戏首页 ---- */
.ysg-home { background: radial-gradient(ellipse 60% 44% at 50% 0%, rgba(255, 255, 255, 0.7), rgba(255, 255, 255, 0) 70%), var(--ys-paper); }
.ysg-home-top { width: 100%; max-width: 1080px; margin: 0 auto; box-sizing: border-box; display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; }
.ysg-brand { display: inline-flex; align-items: center; gap: 8px; color: var(--ys-ink); text-decoration: none; }
.ysg-brand-n { font: 900 19px/1 var(--ys-serif); letter-spacing: 0.16em; }
.ysg-brand-s { padding-left: 10px; border-left: 1px solid var(--ys-line); font: 400 12px/1 var(--ys-sans); letter-spacing: 0.26em; color: var(--ys-faint); }
.ysg-home-main { flex: 1; width: min(100% - 40px, 440px); margin: 0 auto; display: flex; flex-direction: column; align-items: center; text-align: center; padding: 4px 0 36px; }
.ysg-home-art { width: 168px; height: 168px; margin-top: 8px; display: grid; place-items: center; }
.ysg-home-art img { width: 100%; height: 100%; object-fit: contain; }
.ysg-home-title { margin: 14px 0 0; font: 900 clamp(46px, 11vw, 62px)/1.1 var(--ys-serif); letter-spacing: 0.16em; text-indent: 0.16em; }
.ysg-home-tag { margin: 12px 0 0; font: 400 17px/1.6 var(--ys-kai); letter-spacing: 0.14em; color: var(--ys-ink2); }
.ysg-home-orn { position: relative; display: block; width: 132px; height: 1px; margin: 22px auto 26px; background: linear-gradient(90deg, transparent, var(--ys-line) 25%, var(--ys-line) 75%, transparent); }
.ysg-home-orn i { position: absolute; left: 50%; top: 50%; width: 7px; height: 7px; border: 1px solid var(--ys-cinnabar); background: var(--ys-paper); transform: translate(-50%, -50%) rotate(45deg); }
.ysg-tiles { width: 100%; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-top: 16px; }
.ysg-tile {
  position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 7px; min-height: 96px; padding: 14px 6px 12px;
  border: 1px solid var(--ys-line); border-radius: var(--ysg-r); background: var(--ys-card); color: var(--ys-ink2); cursor: pointer; text-decoration: none;
  font: 400 13.5px/1.2 var(--ys-sans); letter-spacing: 0.06em; transition: border-color 0.2s, transform 0.2s var(--ysg-ease), box-shadow 0.2s;
}
.ysg-tile:hover { border-color: var(--ys-ink2); color: var(--ys-ink); transform: translateY(-2px); box-shadow: var(--ysg-shadow); }
.ysg-tile-s { font-size: 11px; color: var(--ys-faint); letter-spacing: 0.02em; }
.ysg-tile-l, .ysg-link-l, .ysg-link-i { color: inherit; } /* 挡住游戏旧模板里 nav span 之类的全局规则 */
.ysg-tile .ysg-badge { top: 8px; right: 8px; }
.ysg-home-foot { width: 100%; margin-top: 30px; display: flex; flex-direction: column; align-items: center; gap: 14px; }
.ysg-home-stats { margin: 0; font: 400 13px/1.6 var(--ys-sans); letter-spacing: 0.08em; color: var(--ys-faint); }
/* 小圆图标按个数排成均匀、居中的行：≤5 个一行，更多时每行 ⌈n/2⌉ 个（6 个桌面一行）；--ysg-links 由 GameHome 写入 */
.ysg-home-links { display: flex; flex-wrap: wrap; justify-content: center; gap: 14px 8px; width: 100%; max-width: calc(var(--ysg-links, 5) * 76px + (var(--ysg-links, 5) - 1) * 8px); }
.ysg-home-links[data-n='6'] { --ysg-links: 3; }
.ysg-link-l { max-width: 100%; }
.ysg-link { flex: 0 0 calc((100% - (var(--ysg-links, 5) - 1) * 8px) / var(--ysg-links, 5) - 0.5px); max-width: 76px; min-width: 0; display: inline-flex; flex-direction: column; align-items: center; gap: 6px; padding: 0; border: 0; background: none; color: var(--ys-ink2); cursor: pointer; text-decoration: none; font: 400 12px/1.2 var(--ys-sans); letter-spacing: 0.04em; }
.ysg-link-i { width: 42px; height: 42px; display: grid; place-items: center; border: 1px solid var(--ys-line); border-radius: 50%; background: var(--ys-card); transition: border-color 0.2s, color 0.2s; }
.ysg-link:hover { color: var(--ys-cinnabar); }
.ysg-link:hover .ysg-link-i { border-color: var(--ys-cinnabar); }
.ysg-home-note, .ysg-series-note { margin: 22px 0 0; font: 400 12px/1.8 var(--ys-sans); color: var(--ys-faint); letter-spacing: 0.04em; text-align: center; }
.ysg-series-note a { color: var(--ys-ink2); text-decoration: none; border-bottom: 1px solid var(--ys-line); }

/* 系列菜单 */
.ysg-menu { display: flex; flex-direction: column; gap: 4px; }
.ysg-menu-g { display: flex; align-items: center; gap: 14px; padding: 10px 10px; border-radius: var(--ysg-r); color: var(--ys-ink); text-decoration: none; transition: background 0.15s; }
.ysg-menu-g:hover { background: var(--ys-card); }
.ysg-menu-g[aria-current='page'] { background: var(--ys-card); box-shadow: inset 3px 0 0 var(--ys-cinnabar); }
.ysg-menu-g img { flex: none; width: 44px; height: 44px; object-fit: contain; }
.ysg-menu-g b { display: block; font: 700 16px/1.3 var(--ys-serif); letter-spacing: 0.1em; }
.ysg-menu-g small { display: block; margin-top: 2px; font: 400 12.5px/1.5 var(--ys-kai); color: var(--ys-sub); letter-spacing: 0.06em; }
.ysg-menu-foot { display: flex; gap: 18px; margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--ys-line); }
.ysg-menu-foot a { font: 400 13.5px/1 var(--ys-sans); color: var(--ys-ink2); text-decoration: none; }
.ysg-menu-foot a:hover { color: var(--ys-cinnabar); }
.ysg-menu-note { margin: 14px 0 0; font: 400 12px/1.6 var(--ys-sans); color: var(--ys-faint); }

/* ---- 选择页 ---- */
.ysg-screen-main { flex: 1; width: min(100% - 32px, 600px); margin: 0 auto; padding: 26px 0 48px; box-sizing: border-box; }
.ysg-screen-main.wide { width: min(100% - 32px, 900px); }
.ysg-choices { display: flex; flex-direction: column; gap: 12px; }
.ysg-choice {
  position: relative; display: flex; align-items: center; gap: 16px; width: 100%; box-sizing: border-box; padding: 16px 46px 16px 16px; text-align: left;
  border: 1px solid var(--ys-line); border-radius: var(--ysg-r); background: var(--ys-card); color: var(--ys-ink); cursor: pointer;
  transition: border-color 0.2s, transform 0.2s var(--ysg-ease), box-shadow 0.2s;
}
.ysg-choice:hover { border-color: var(--ys-ink2); transform: translateY(-1px); box-shadow: var(--ysg-shadow); }
.ysg-choice.on { border-color: var(--ys-cinnabar); background: linear-gradient(rgba(166, 58, 43, 0.045), rgba(166, 58, 43, 0.045)), var(--ys-card); box-shadow: inset 0 0 0 1px var(--ys-cinnabar); }
.ysg-choice:disabled { opacity: 0.5; cursor: default; transform: none; box-shadow: none; }
.ysg-choice-thumb { flex: none; width: 58px; height: 58px; display: grid; place-items: center; border: 1px solid var(--ys-line2); border-radius: 6px; background: var(--ys-paper); color: var(--ys-ink2); }
.ysg-choice-body { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.ysg-choice-h { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.ysg-choice-h b { font: 700 18px/1.3 var(--ys-serif); letter-spacing: 0.08em; }
.ysg-choice-h em { font: 400 13px/1 var(--ys-sans); font-style: normal; color: var(--ys-faint); letter-spacing: 0.04em; }
.ysg-choice-d { margin-top: 4px; font: 400 12.5px/1.6 var(--ys-sans); color: var(--ys-sub); }
.ysg-progress { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 10px; margin-top: 10px; }
.ysg-progress::before { content: ''; grid-column: 1; grid-row: 1; height: 4px; border-radius: 2px; background: var(--ys-line2); }
.ysg-progress i { grid-column: 1; grid-row: 1; justify-self: start; height: 4px; border-radius: 2px; background: var(--ys-ink2); transition: width 0.4s var(--ysg-ease); }
.ysg-choice.on .ysg-progress i { background: var(--ys-cinnabar); }
.ysg-progress small { font: 400 12px/1 var(--ys-sans); font-variant-numeric: tabular-nums; color: var(--ys-faint); }
.ysg-ribbon { position: absolute; top: 12px; right: -1px; padding: 3px 10px 3px 12px; border-radius: 3px 0 0 3px; background: var(--ys-cinnabar); color: #fbf8f1; font: 500 11px/1.4 var(--ys-sans); letter-spacing: 0.14em; }
.ysg-choice-go { position: absolute; right: 16px; top: 50%; transform: translateY(-50%); color: var(--ys-faint); transition: color 0.2s, transform 0.2s; }
.ysg-choice:hover .ysg-choice-go { color: var(--ys-ink); transform: translate(3px, -50%); }
.ysg-choice:has(.ysg-ribbon) .ysg-choice-go { top: auto; bottom: 16px; transform: none; }

.ysg-section { margin-top: 30px; }
.ysg-section:first-child { margin-top: 0; }
.ysg-section-h { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.ysg-section-h h2 { margin: 0; font: 700 16px/1.3 var(--ys-serif); letter-spacing: 0.1em; }
.ysg-section-h span { font: 400 12px/1.4 var(--ys-sans); color: var(--ys-faint); }

.ysg-levels { display: grid; grid-template-columns: repeat(auto-fill, minmax(var(--ysg-lv, 64px), 1fr)); gap: 10px; }
.ysg-level {
  position: relative; aspect-ratio: 1; display: grid; place-items: center; padding: 0; border: 1px solid var(--ys-line); border-radius: var(--ysg-r);
  background: var(--ys-card); color: var(--ys-ink); cursor: pointer; font: 600 18px/1 var(--ys-serif); transition: border-color 0.2s, transform 0.2s var(--ysg-ease), box-shadow 0.2s;
}
.ysg-level:hover { border-color: var(--ys-ink2); transform: translateY(-1px); box-shadow: var(--ysg-shadow); }
.ysg-level.done { background: rgba(78, 122, 102, 0.05); border-color: rgba(78, 122, 102, 0.35); }
.ysg-level.current { border-color: var(--ys-cinnabar); box-shadow: inset 0 0 0 1px var(--ys-cinnabar); color: var(--ys-cinnabar); }
.ysg-level.locked { background: transparent; color: var(--ys-mute); cursor: default; }
.ysg-level.locked:hover { transform: none; box-shadow: none; border-color: var(--ys-line); }
.ysg-level-ok { position: absolute; right: 5px; bottom: 5px; width: 16px; height: 16px; display: grid; place-items: center; border-radius: 50%; background: var(--ys-green); color: #fbf8f1; }
.ysg-level-stars { position: absolute; left: 0; right: 0; bottom: 6px; display: flex; justify-content: center; gap: 1px; color: var(--ys-line); }
.ysg-level-stars .lit, .ysg-result-stars .lit { color: var(--ys-cinnabar); }

/* ---- 对局页 ---- */
.ysg-play-main { flex: 1; width: 100%; max-width: 1180px; margin: 0 auto; box-sizing: border-box; display: flex; flex-direction: column; align-items: center; gap: 18px; padding: 16px 14px 28px; }
.ysg-play-stage { width: 100%; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.ysg-board { width: 100%; max-width: var(--ysg-board-max); }
.ysg-status { min-height: 20px; font: 400 13px/1.6 var(--ys-sans); color: var(--ys-sub); text-align: center; letter-spacing: 0.04em; }
.ysg-play-side { width: 100%; max-width: 560px; display: flex; flex-direction: column; gap: 16px; }
.ysg-controls { display: flex; flex-direction: column; gap: 14px; }
.ysg-aside { font: 400 13px/1.8 var(--ys-sans); color: var(--ys-sub); }
.ysg-tools { display: flex; justify-content: space-around; gap: 6px; }
.ysg-tool { display: inline-flex; flex-direction: column; align-items: center; gap: 6px; min-width: 60px; padding: 0; border: 0; background: none; color: var(--ys-ink2); cursor: pointer; font: 400 12.5px/1.2 var(--ys-sans); letter-spacing: 0.06em; }
.ysg-tool-i { position: relative; width: 52px; height: 52px; display: grid; place-items: center; border: 1px solid var(--ys-line); border-radius: 50%; background: var(--ys-card); transition: border-color 0.2s, color 0.2s, background 0.2s, transform 0.15s; }
.ysg-tool:hover .ysg-tool-i { border-color: var(--ys-ink2); color: var(--ys-ink); }
.ysg-tool:active .ysg-tool-i { transform: scale(0.96); }
.ysg-tool.on { color: var(--ys-cinnabar); }
.ysg-tool.on .ysg-tool-i { border-color: var(--ys-cinnabar); background: rgba(166, 58, 43, 0.06); }
.ysg-tool:disabled { opacity: 0.4; cursor: default; }
.ysg-keys { display: grid; grid-template-columns: repeat(var(--ysg-keys, 9), minmax(0, 1fr)); gap: 6px; }
.ysg-key {
  min-height: 52px; padding: 0; border: 1px solid var(--ys-line); border-radius: 6px; background: var(--ys-card); color: var(--ys-ink); cursor: pointer;
  font: 500 24px/1 var(--ys-serif); font-variant-numeric: tabular-nums; transition: border-color 0.15s, background 0.15s, color 0.15s, transform 0.1s;
}
.ysg-key:hover { border-color: var(--ys-ink2); }
.ysg-key:active { transform: scale(0.97); }
.ysg-key.on { background: var(--ys-cinnabar); border-color: var(--ys-cinnabar); color: #fbf8f1; }
.ysg-key.done { opacity: 0.35; }
.ysg-key:disabled { opacity: 0.3; cursor: default; }

/* ---- 弹层 ---- */
@keyframes ysg-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes ysg-pop { from { opacity: 0; transform: translateY(10px) scale(0.98); } to { opacity: 1; transform: none; } }
@keyframes ysg-up { from { transform: translateY(100%); } to { transform: none; } }
@keyframes ysg-left { from { transform: translateX(100%); } to { transform: none; } }
.ysg-sheet-wrap { position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center; padding: 16px; }
.ysg-sheet-wrap.bottom { align-items: flex-end; padding: 0; }
.ysg-sheet-wrap.right { align-items: stretch; justify-content: flex-end; padding: 0; }
.ysg-sheet-bg { position: absolute; inset: 0; background: rgba(42, 37, 33, 0.38); -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px); animation: ysg-fade 0.2s ease both; }
.ysg-sheet {
  position: relative; width: min(100%, 520px); max-height: min(88svh, 760px); display: flex; flex-direction: column; box-sizing: border-box; outline: none;
  background: var(--ys-paper); border: 1px solid var(--ys-line); border-radius: var(--ysg-r-lg); box-shadow: 0 30px 70px -30px rgba(42, 37, 33, 0.55);
  animation: ysg-pop 0.24s var(--ysg-ease) both; color: var(--ys-ink); font-family: var(--ys-sans);
}
.ysg-sheet.sm { width: min(100%, 380px); }
.ysg-sheet.lg { width: min(100%, 760px); }
.ysg-sheet.bottom { width: 100%; max-width: 640px; border-radius: 16px 16px 0 0; border-bottom: 0; animation: ysg-up 0.28s var(--ysg-ease) both; padding-bottom: env(safe-area-inset-bottom); }
.ysg-sheet.right { width: min(88vw, 380px); max-height: none; height: 100%; border-radius: 0; border-top: 0; border-bottom: 0; border-right: 0; animation: ysg-left 0.28s var(--ysg-ease) both; }
.ysg-sheet-h { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 18px 10px 22px; }
.ysg-sheet-h h2 { margin: 0; font: 700 19px/1.3 var(--ys-serif); letter-spacing: 0.08em; }
.ysg-sheet-x { width: 40px; height: 40px; display: grid; place-items: center; border: 0; border-radius: 50%; background: none; color: var(--ys-faint); cursor: pointer; }
.ysg-sheet-x:hover { background: var(--ys-card); color: var(--ys-ink); }
.ysg-sheet-body { padding: 4px 22px 22px; overflow: auto; font: 400 14px/1.8 var(--ys-sans); color: var(--ys-ink2); }
.ysg-sheet-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 22px; border-top: 1px solid var(--ys-line); }

.ysg-pause { display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 30px 24px 24px; text-align: center; }
.ysg-pause-i { width: 62px; height: 62px; display: grid; place-items: center; border: 1px solid var(--ys-line); border-radius: 50%; background: var(--ys-card); color: var(--ys-ink2); }
.ysg-pause h2 { margin: 4px 0 0; font: 700 22px/1.3 var(--ys-serif); letter-spacing: 0.14em; }
.ysg-pause-info { margin: 0; font: 400 13px/1.7 var(--ys-sans); color: var(--ys-faint); }
.ysg-pause .ysg-primary { margin-top: 8px; min-height: 52px; }
.ysg-pause-row { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; width: 100%; }
.ysg-pause-row .ysg-secondary { flex: 1 1 0; min-width: 96px; }

.ysg-result { display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 32px 24px 24px; text-align: center; }
.ysg-result-mark { width: 68px; height: 68px; display: grid; place-items: center; border-radius: 50%; border: 1px solid rgba(78, 122, 102, 0.4); background: rgba(78, 122, 102, 0.08); color: var(--ys-green); }
.ysg-result-t { margin: 2px 0 0; font: 900 28px/1.2 var(--ys-serif); letter-spacing: 0.16em; text-indent: 0.16em; }
.ysg-result-sub { margin: 0; font: 400 16px/1.7 var(--ys-kai); color: var(--ys-ink2); letter-spacing: 0.08em; }
.ysg-result-stars { display: flex; gap: 6px; color: var(--ys-line); }
.ysg-result-stats { width: 100%; display: flex; margin: 6px 0 4px; border: 1px solid var(--ys-line); border-radius: var(--ysg-r); background: var(--ys-card); }
.ysg-result-stats > div { flex: 1 1 0; padding: 12px 6px; border-left: 1px solid var(--ys-line2); }
.ysg-result-stats > div:first-child { border-left: 0; }
.ysg-result-stats dt { font: 400 12px/1.2 var(--ys-sans); color: var(--ys-faint); letter-spacing: 0.08em; }
.ysg-result-stats dd { margin: 6px 0 0; font: 700 20px/1.1 var(--ys-serif); font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ysg-result .ysg-primary { margin-top: 6px; min-height: 52px; }

/* ---- 设置控件 ---- */
.ysg-set { padding: 14px 0; border-bottom: 1px solid var(--ys-line2); }
.ysg-set:last-child { border-bottom: 0; }
.ysg-set-h { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.ysg-set-h h3 { margin: 0; font: 700 15px/1.4 var(--ys-serif); letter-spacing: 0.08em; color: var(--ys-ink); }
.ysg-set-h span { font: 400 12px/1.4 var(--ys-sans); color: var(--ys-faint); }
.ysg-seg { display: grid; grid-template-columns: repeat(var(--ysg-seg, 2), minmax(0, 1fr)); gap: 8px; }
.ysg-seg-o { display: flex; flex-direction: column; gap: 3px; padding: 10px 12px; text-align: left; border: 1px solid var(--ys-line); border-radius: var(--ysg-r); background: var(--ys-card); color: var(--ys-ink2); cursor: pointer; transition: border-color 0.2s, background 0.2s; }
.ysg-seg-o b { font: 500 14px/1.3 var(--ys-sans); letter-spacing: 0.04em; }
.ysg-seg-o small { font: 400 11.5px/1.5 var(--ys-sans); color: var(--ys-faint); }
.ysg-seg-o:hover { border-color: var(--ys-ink2); }
.ysg-seg-o.on { border-color: var(--ys-cinnabar); background: rgba(166, 58, 43, 0.05); box-shadow: inset 0 0 0 1px var(--ys-cinnabar); }
.ysg-seg-o.on b { color: var(--ys-cinnabar); }
.ysg-toggle { width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 10px 0; border: 0; background: none; text-align: left; cursor: pointer; color: var(--ys-ink); }
.ysg-toggle-t { display: flex; flex-direction: column; gap: 2px; }
.ysg-toggle-t b { font: 500 14px/1.4 var(--ys-sans); }
.ysg-toggle-t small { font: 400 12px/1.5 var(--ys-sans); color: var(--ys-faint); }
.ysg-switch { position: relative; flex: none; width: 42px; height: 24px; border-radius: 999px; background: var(--ys-line2); border: 1px solid var(--ys-line); transition: background 0.2s, border-color 0.2s; }
.ysg-switch i { position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(42, 37, 33, 0.3); transition: transform 0.2s var(--ysg-ease); }
.ysg-toggle.on .ysg-switch { background: var(--ys-cinnabar); border-color: var(--ys-cinnabar); }
.ysg-toggle.on .ysg-switch i { transform: translateX(18px); }
.ysg-seg-o:disabled, .ysg-toggle:disabled { opacity: 0.45; cursor: default; }
.ysg-seg-o:disabled:hover { border-color: var(--ys-line); }
.ysg-seg-o.on:disabled:hover { border-color: var(--ys-cinnabar); }

/* ---- 自绘图标（传 SVG 节点给 ToolButton / IconButton / 首页入口）统一尺寸；首页大图取不到时的宋体大字 ---- */
.ysg-tool-i > svg { width: 22px; height: 22px; }
.ysg-ibtn > svg { width: 19px; height: 19px; }
.ysg-tile > svg { width: 24px; height: 24px; }
.ysg-link-i > svg { width: 18px; height: 18px; }
.ysg-secondary > svg { width: 17px; height: 17px; }
.ysg-home-glyph { width: 78%; aspect-ratio: 1; display: grid; place-items: center; border: 1px solid var(--ys-line); border-radius: 50%; background: var(--ys-card); font: 900 72px/1 var(--ys-serif); color: var(--ys-ink); }

/* ---- 桌面：对局页左棋盘右工具，首页更舒展 ---- */
@media (min-width: 1024px) {
  .ysg-play-main { flex-direction: row; align-items: flex-start; justify-content: center; gap: 44px; padding: 30px 32px 40px; }
  .ysg-play-stage { width: auto; flex: 0 1 auto; }
  .ysg-board { width: min(640px, calc(100svh - 140px), calc(100vw - 460px)); max-width: none; } /* 1024–1100 宽时别把右栏挤出页边 */
  .ysg-play-side { width: 320px; flex: none; position: sticky; top: calc(var(--ysg-top) + 24px); }
  .ysg-keys { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
  .ysg-key { min-height: 64px; font-size: 26px; }
  .ysg-home-main { width: 460px; padding-top: 12px; }
  .ysg-home-art { width: 196px; height: 196px; }
  .ysg-home-links[data-n='6'] { --ysg-links: 6; }
}
/* ---- 手机 ---- */
/* 窄屏：左右两侧按内容宽度，标题在中间一栏里居中、放不下就省略（三个按钮 + 计时时不会压到标题） */
@media (max-width: 640px) {
  .ysg-top { grid-template-columns: auto minmax(0, 1fr) auto; }
  .ysg-top-l { min-width: 40px; }
}
@media (max-width: 480px) {
  .ysg-top { padding: 0 10px; gap: 6px; }
  .ysg-back-t { display: none; }
  .ysg-ibtn { width: 40px; height: 40px; }
  .ysg-tiles { gap: 8px; }
  .ysg-tile { min-height: 88px; font-size: 12.5px; }
  .ysg-tool { min-width: 54px; font-size: 11.5px; }
  .ysg-tool-i { width: 48px; height: 48px; }
  .ysg-key { min-height: 46px; font-size: 21px; }
  .ysg-sheet-body { padding: 4px 18px 18px; }
  .ysg-result-stats > div { padding: 12px 4px; }
  .ysg-result-stats dd { font-size: 17px; }
}
@media (prefers-reduced-motion: reduce) {
  .ysg-home-main, .ysg-screen-main, .ysg-play-main, .ysg-sheet, .ysg-sheet-bg { animation: none !important; }
}
@media print {
  .ysg-top, .ysg-home-top, .ysg-sheet-wrap { display: none !important; }
}
