/* ==========================================================================
   找一找 · 不一样  ——  儿童训练小游戏样式
   设计原则：大触控区、低刺激配色、清晰对比、无闪烁、可减少动画
   ========================================================================== */

:root {
  --bg1: #eef4ff;
  --bg2: #f7f1ff;
  --bg3: #eafaf3;

  --ink: #2f3b52;
  --ink-soft: #6b7a94;
  --line: #e4e9f4;

  --card: #ffffff;
  --primary: #5b8def;
  --primary-dark: #3f6fd8;
  --ok: #37c98b;
  --warn: #ffb547;
  --bad: #f0857f;

  --radius-lg: 26px;
  --radius: 20px;
  --radius-sm: 14px;

  --shadow: 0 12px 30px rgba(72, 96, 148, .14);
  --shadow-sm: 0 4px 14px rgba(72, 96, 148, .12);

  --font: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
          "Microsoft YaHei", "Noto Sans SC", system-ui, sans-serif;
  --font-emoji: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji",
                "EmojiOne Color", "Android Emoji", sans-serif;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background: linear-gradient(160deg, var(--bg1) 0%, var(--bg2) 52%, var(--bg3) 100%);
  background-attachment: fixed;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  overscroll-behavior: none;
  touch-action: manipulation;
  line-height: 1.45;
}

button { font-family: inherit; color: inherit; }

/* ------------------------------ 屏幕容器 ------------------------------ */

.screen {
  display: none;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
  padding: env(safe-area-inset-top) env(safe-area-inset-right)
           env(safe-area-inset-bottom) env(safe-area-inset-left);
}

.screen.is-active { display: flex; }

/* ------------------------------ 通用按钮 ------------------------------ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink);
  border-radius: var(--radius-sm);
  padding: 14px 22px;
  font-size: 18px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: transform .12s ease, box-shadow .18s ease, background .18s ease;
  min-height: 56px;
}

.btn:active { transform: scale(.97); }
.btn:focus-visible { outline: 3px solid rgba(91, 141, 239, .45); outline-offset: 2px; }

.btn-primary {
  background: linear-gradient(180deg, #6d9bf2, var(--primary-dark));
  border-color: transparent;
  color: #fff;
  box-shadow: 0 10px 22px rgba(63, 111, 216, .35);
}

.btn-xl { font-size: 21px; min-height: 64px; border-radius: 18px; width: 100%; }

.btn-ghost {
  background: rgba(255, 255, 255, .7);
  border-color: transparent;
  color: var(--ink-soft);
  box-shadow: none;
}

.btn-tiny {
  min-height: 36px;
  padding: 4px 14px;
  font-size: 14px;
  border-radius: 12px;
  font-weight: 500;
  color: var(--ink-soft);
  box-shadow: none;
}

.btn-danger { color: var(--bad); }

.icon-btn {
  border: none;
  background: rgba(255, 255, 255, .8);
  border-radius: 14px;
  width: 46px;
  height: 46px;
  font-size: 20px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  flex: 0 0 auto;
  transition: transform .12s ease;
}
.icon-btn:active { transform: scale(.94); }

/* ------------------------------ 首页 ------------------------------ */

.home-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 30px;
  padding: 32px 22px 40px;
  max-width: 560px;
  margin: 0 auto;
  width: 100%;
}

.brand { text-align: center; }

.brand h1 {
  margin: 20px 0 8px;
  font-size: clamp(28px, 7.5vw, 42px);
  letter-spacing: 1px;
}

.brand-sub {
  margin: 0;
  color: var(--ink-soft);
  font-size: clamp(14px, 3.8vw, 17px);
}

.brand-dots {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  width: 118px;
  margin: 0 auto;
}
.brand-dots .dot {
  width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: 50%;
  display: block;
  animation: floatIn .6s cubic-bezier(.2, .8, .3, 1.2) backwards;
}
.brand-dots .d1 { background: #e8554d; animation-delay: .00s; }
.brand-dots .d2 { background: #f5b942; border-radius: 12px; animation-delay: .06s; }
.brand-dots .d3 { background: #4a86e8; clip-path: polygon(50% 4%, 100% 96%, 0 96%); animation-delay: .12s; }
.brand-dots .d4 { background: #3fb46b; animation-delay: .18s; }
.brand-dots .d5 { background: #9068d6; border-radius: 12px; clip-path: polygon(50% 4%, 100% 96%, 0 96%); animation-delay: .24s; }
.brand-dots .d6 { background: #f08a3c; animation-delay: .30s; }

.home-actions {
  display: flex;
  flex-direction: column;
  gap: 14px;
  width: 100%;
}

.home-foot {
  margin: 0;
  color: var(--ink-soft);
  font-size: 15px;
  text-align: center;
}

/* ------------------------------ 顶栏 ------------------------------ */

.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px 8px;
  flex: 0 0 auto;
}

.topbar-title {
  flex: 1;
  margin: 0;
  font-size: 19px;
  font-weight: 700;
  text-align: center;
}

.game-head {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 0;
}

.game-title {
  font-size: 17px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.game-chapter {
  font-size: 12px;
  color: var(--ink-soft);
}

.game-tools {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
}

/* ------------------------------ 分段控件 ------------------------------ */

.seg {
  display: inline-flex;
  background: rgba(255, 255, 255, .85);
  border-radius: 14px;
  padding: 4px;
  gap: 4px;
  box-shadow: var(--shadow-sm);
}

.seg-btn {
  border: none;
  background: transparent;
  border-radius: 11px;
  padding: 8px 12px;
  font-size: 14px;
  font-weight: 600;
  color: var(--ink-soft);
  cursor: pointer;
  min-height: 36px;
  transition: background .16s ease, color .16s ease;
}

.seg-btn.is-on {
  background: var(--primary);
  color: #fff;
}

.seg-sm .seg-btn { padding: 6px 9px; font-size: 13px; min-height: 32px; }

/* ------------------------------ 关卡列表 ------------------------------ */

.levels-scroll {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 8px 16px 40px;
  max-width: 720px;
  width: 100%;
  margin: 0 auto;
}

.chapter { margin-bottom: 26px; }

.chapter-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.chapter-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex: 0 0 auto;
}

.chapter-head h3 {
  margin: 0;
  font-size: 17px;
  flex: 1;
}

.chapter-count {
  font-size: 13px;
  color: var(--ink-soft);
  background: rgba(255, 255, 255, .8);
  padding: 2px 10px;
  border-radius: 10px;
}

.level-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(86px, 1fr));
  gap: 12px;
}

.level-btn {
  border: 1px solid var(--line);
  background: var(--card);
  border-radius: var(--radius-sm);
  padding: 12px 6px 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: transform .12s ease;
  min-height: 76px;
}
.level-btn:active { transform: scale(.95); }

.level-num { font-size: 20px; font-weight: 700; }

.level-stars {
  font-size: 12px;
  letter-spacing: 1px;
  color: #d9dfeb;
}

.level-btn.done .level-stars { color: var(--warn); }

.level-btn.locked {
  opacity: .5;
  cursor: not-allowed;
  box-shadow: none;
  background: rgba(255, 255, 255, .55);
}

/* ------------------------------ 游戏区 ------------------------------ */

.screen-game { position: relative; }

.round-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 16px;
  flex: 0 0 auto;
  max-width: 720px;
  width: 100%;
  margin: 0 auto;
}

.dots {
  display: flex;
  gap: 8px;
  flex: 1;
  align-items: center;
  flex-wrap: wrap;
}

.dots .pd {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: rgba(140, 160, 195, .25);
  transition: background .2s ease, transform .2s ease;
}

.dots .pd.done { background: var(--ok); }
.dots .pd.now {
  background: var(--primary);
  transform: scale(1.3);
  box-shadow: 0 0 0 4px rgba(91, 141, 239, .18);
}

.prompt {
  margin: 10px 16px 0;
  text-align: center;
  font-size: clamp(17px, 4.6vw, 22px);
  font-weight: 700;
  color: var(--ink);
  flex: 0 0 auto;
  max-width: 720px;
  width: calc(100% - 32px);
  margin-left: auto;
  margin-right: auto;
}

.grid-area {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px 14px;
  min-height: 0;
}

.grid {
  display: grid;
  gap: clamp(6px, 1.5vmin, 14px);
  width: 100%;
  max-width: min(94vw, 60vh, 600px);
}

.grid[data-size="3"] { grid-template-columns: repeat(3, 1fr); }
.grid[data-size="4"] { grid-template-columns: repeat(4, 1fr); }

.cell {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  aspect-ratio: 1 / 1;
  border: none;
  padding: 0;
  border-radius: var(--radius);
  background: linear-gradient(180deg, #ffffff, #f6f9ff);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  overflow: hidden;
  transition: transform .12s ease, box-shadow .2s ease, background .2s ease, opacity .2s ease;
}

.cell:active { transform: scale(.955); }

.grid[data-size="3"] .cell { font-size: clamp(26px, 11vmin, 70px); }
.grid[data-size="4"] .cell { font-size: clamp(20px, 8vmin, 50px); }

.cell .emoji {
  font-family: var(--font-emoji);
  font-size: 1em;
  line-height: 1;
  display: block;
  pointer-events: none;
}

.shape-svg {
  width: 64%;
  height: auto;
  aspect-ratio: 1 / 1;
  display: block;
  pointer-events: none;
  transition: transform .2s ease;
}

/* 状态 */
.cell.enter { animation: floatIn .4s cubic-bezier(.2, .8, .3, 1.2) backwards; }

.cell.correct {
  background: linear-gradient(180deg, #e9fbf2, #d5f6e5);
  box-shadow: 0 0 0 4px var(--ok), 0 10px 24px rgba(55, 201, 139, .28);
  animation: pop .55s ease;
}

.cell.wrong {
  background: #f2f4f8;
  box-shadow: none;
  opacity: .5;
  animation: shake .42s ease;
}

.cell.wrong .emoji,
.cell.wrong .shape-svg { filter: grayscale(1); }

.cell.dim { opacity: .35; }

.cell.hint {
  box-shadow: 0 0 0 4px var(--warn), 0 10px 24px rgba(255, 181, 71, .3);
  animation: breathe 1.5s ease-in-out infinite;
}

.hint-line {
  margin: 0 auto;
  padding: 0 16px 12px;
  min-height: 26px;
  text-align: center;
  font-size: clamp(14px, 3.8vw, 17px);
  color: var(--ink-soft);
  max-width: 720px;
  width: 100%;
  flex: 0 0 auto;
}

/* ------------------------------ 弹层 ------------------------------ */

.overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(47, 59, 82, .32);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  z-index: 60;
  animation: fadeIn .2s ease;
}

.overlay[hidden] { display: none !important; }

.sheet {
  background: var(--card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 26px 22px 22px;
  width: 100%;
  max-width: 420px;
  max-height: 88vh;
  overflow-y: auto;
  animation: sheetUp .3s cubic-bezier(.2, .8, .3, 1.15);
}

.sheet-title {
  margin: 0 0 18px;
  font-size: 20px;
  text-align: center;
}

.sheet .btn { width: 100%; margin-top: 10px; }

.set-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}

.set-label { font-size: 16px; font-weight: 600; }

.toggle {
  border: 1px solid var(--line);
  background: #f2f5fb;
  color: var(--ink-soft);
  border-radius: 12px;
  min-width: 68px;
  min-height: 42px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: background .18s ease, color .18s ease;
}

.toggle.is-on {
  background: var(--primary);
  border-color: transparent;
  color: #fff;
}

.set-note {
  margin: 16px 0 4px;
  font-size: 13px;
  color: var(--ink-soft);
  line-height: 1.6;
}

/* 结算 */
.sheet-result { text-align: center; }

.result-stars {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-bottom: 12px;
}

.rstar {
  font-size: 54px;
  line-height: 1;
  color: #e2e7f1;
  animation: starPop .55s cubic-bezier(.2, .8, .3, 1.4) backwards;
}

.rstar.on { color: var(--warn); text-shadow: 0 6px 16px rgba(255, 181, 71, .45); }

.result-title { margin: 6px 0 4px; font-size: 24px; }

.result-sub { margin: 0 0 18px; color: var(--ink-soft); font-size: 15px; }

.result-actions { display: flex; flex-direction: column; gap: 10px; }
.result-actions .btn { margin-top: 0; }

/* ------------------------------ 粒子特效层 ------------------------------ */

.fx-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 80;
  overflow: hidden;
}

.spark {
  position: absolute;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  animation: sparkFly .75s cubic-bezier(.2, .7, .4, 1) forwards;
}

.spark.sq { border-radius: 4px; }

.praise {
  position: fixed;
  left: 50%;
  top: 42%;
  transform: translate(-50%, -50%);
  font-size: clamp(28px, 8vw, 46px);
  font-weight: 800;
  color: #fff;
  text-shadow: 0 6px 20px rgba(63, 111, 216, .5), 0 0 2px rgba(0, 0, 0, .2);
  background: linear-gradient(180deg, #6d9bf2, #3f6fd8);
  padding: 14px 34px;
  border-radius: 999px;
  box-shadow: 0 16px 40px rgba(63, 111, 216, .4);
  pointer-events: none;
  z-index: 85;
  animation: praisePop 1.15s cubic-bezier(.2, .8, .3, 1.2) forwards;
  white-space: nowrap;
}

/* ------------------------------ 动画 ------------------------------ */

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

@keyframes floatIn {
  from { opacity: 0; transform: translateY(14px) scale(.86); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes sheetUp {
  from { opacity: 0; transform: translateY(24px) scale(.96); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes pop {
  0%   { transform: scale(1); }
  40%  { transform: scale(1.12); }
  70%  { transform: scale(.98); }
  100% { transform: scale(1.03); }
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-7px); }
  40% { transform: translateX(7px); }
  60% { transform: translateX(-5px); }
  80% { transform: translateX(4px); }
}

@keyframes breathe {
  0%, 100% { transform: scale(1); }
  50%      { transform: scale(1.045); }
}

@keyframes starPop {
  0%   { transform: scale(.3) rotate(-25deg); opacity: 0; }
  60%  { transform: scale(1.25) rotate(8deg); opacity: 1; }
  100% { transform: scale(1) rotate(0); opacity: 1; }
}

@keyframes sparkFly {
  0%   { opacity: 1; transform: translate(-50%, -50%) scale(.5); }
  100% { opacity: 0;
         transform: translate(calc(-50% + var(--tx)), calc(-50% + var(--ty))) scale(1.1); }
}

@keyframes praisePop {
  0%   { opacity: 0; transform: translate(-50%, -50%) scale(.6); }
  25%  { opacity: 1; transform: translate(-50%, -50%) scale(1.06); }
  60%  { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -90%) scale(.96); }
}

/* ------------------------------ 减少动画 ------------------------------ */

body.reduced *, body.reduced *::before, body.reduced *::after {
  animation-duration: .001s !important;
  animation-iteration-count: 1 !important;
  transition-duration: .08s !important;
}

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

/* ------------------------------ 横屏微调 ------------------------------ */

@media (orientation: landscape) and (max-height: 520px) {
  .prompt { font-size: 16px; margin-top: 4px; }
  .round-bar { padding: 0 12px; }
  .grid { max-width: min(62vw, 54vh, 520px); }
  .hint-line { min-height: 20px; padding-bottom: 6px; font-size: 13px; }
}

/* ------------------------------ 顶栏占位 ------------------------------ */

.topbar-placeholder { width: 46px; height: 46px; flex: 0 0 auto; }

/* ------------------------------ 家长看板 ------------------------------ */

.board-scroll {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 14px 16px 40px;
  max-width: 720px;
  width: 100%;
  margin: 0 auto;
}

.board-empty { text-align: center; padding: 56px 24px; color: var(--ink-soft); }
.board-empty-emoji { font-size: 54px; margin-bottom: 10px; }
.board-empty p { margin: 6px 0; font-size: 17px; }
.board-empty-sub { font-size: 14px !important; }
.board-empty .btn { margin-top: 18px; width: auto; padding-left: 28px; padding-right: 28px; }

.board-overview {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-bottom: 22px;
}

.ov-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 16px 14px;
  box-shadow: var(--shadow-sm);
  text-align: center;
}

.ov-value {
  font-size: clamp(22px, 6vw, 30px);
  font-weight: 800;
  color: var(--primary-dark);
  line-height: 1.1;
}
.ov-unit { font-size: 14px; font-weight: 600; color: var(--ink-soft); margin-left: 3px; }
.ov-label { margin-top: 6px; font-size: 14px; color: var(--ink-soft); }

.board-h3 {
  margin: 8px 2px 12px;
  font-size: 17px;
}

.board-chapters { display: flex; flex-direction: column; gap: 14px; margin-bottom: 24px; }

.chap-row { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 12px 14px; box-shadow: var(--shadow-sm); }
.chap-top { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 8px; }
.chap-name { font-size: 15px; font-weight: 700; }
.chap-meta { font-size: 13px; color: var(--ink-soft); }

.chap-bar { height: 12px; border-radius: 999px; background: rgba(140, 160, 195, .22); overflow: hidden; }
.chap-bar > span {
  display: block; height: 100%; border-radius: 999px;
  background: linear-gradient(90deg, var(--ok), #6fd8ad);
  transition: width .4s ease;
}

.board-recent { display: flex; flex-direction: column; gap: 2px; }
.recent-row {
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-areas: "title stars" "meta time";
  gap: 2px 10px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  margin-bottom: 8px;
  box-shadow: var(--shadow-sm);
}
.recent-title { grid-area: title; font-size: 15px; font-weight: 600; }
.recent-stars { grid-area: stars; color: var(--warn); letter-spacing: 1px; font-size: 14px; }
.recent-meta { grid-area: meta; font-size: 13px; color: var(--ink-soft); }
.recent-time { grid-area: time; font-size: 12px; color: var(--ink-soft); text-align: right; }

/* ------------------------------ 自定义关卡 ------------------------------ */

.maker-scroll {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 12px 16px 40px;
  max-width: 640px;
  width: 100%;
  margin: 0 auto;
}

.maker-list { display: flex; flex-direction: column; gap: 10px; margin-bottom: 6px; }
.maker-list-empty { color: var(--ink-soft); font-size: 14px; text-align: center; padding: 10px 0 4px; }

.clv {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  box-shadow: var(--shadow-sm);
}
.clv-info { display: flex; flex-direction: column; min-width: 0; }
.clv-name { font-size: 16px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.clv-meta { font-size: 13px; color: var(--ink-soft); }
.clv-actions { display: flex; gap: 6px; flex: 0 0 auto; }

.maker-divider {
  display: flex; align-items: center; gap: 12px;
  margin: 16px 0 14px; color: var(--ink-soft); font-size: 13px;
}
.maker-divider::before, .maker-divider::after {
  content: ""; flex: 1; height: 1px; background: var(--line);
}

.maker-form { display: flex; flex-direction: column; gap: 18px; }

.mf-field { display: flex; flex-direction: column; gap: 8px; }
.mf-field > label { font-size: 16px; font-weight: 700; }

.mf-input {
  border: 1px solid var(--line);
  background: var(--card);
  border-radius: var(--radius-sm);
  padding: 13px 14px;
  font-size: 17px;
  font-family: inherit;
  color: var(--ink);
  box-shadow: var(--shadow-sm);
  min-height: 52px;
}
.mf-input:focus-visible { outline: 3px solid rgba(91, 141, 239, .4); outline-offset: 1px; }

.mf-tip { margin: 0; font-size: 13px; color: var(--ink-soft); line-height: 1.55; }
.mf-tip-inline { font-size: 13px; color: var(--ink-soft); margin-left: 10px; }

.seg-wrap { flex-wrap: wrap; }
.seg-wrap .seg-btn { min-width: 64px; }

.stepper { display: inline-flex; align-items: center; gap: 14px; }
.step-btn {
  width: 46px; height: 46px; border: 1px solid var(--line); background: var(--card);
  border-radius: 14px; font-size: 24px; font-weight: 700; color: var(--primary-dark);
  cursor: pointer; box-shadow: var(--shadow-sm); line-height: 1;
}
.step-btn:active { transform: scale(.94); }
.step-val { font-size: 22px; font-weight: 800; min-width: 30px; text-align: center; }

.group-pick { display: flex; flex-direction: column; gap: 12px; }
.gp-kind { font-size: 13px; font-weight: 700; color: var(--ink-soft); }
.gp-row { display: flex; flex-wrap: wrap; gap: 8px; }
.gp-chip {
  border: 1px solid var(--line);
  background: var(--card);
  border-radius: 999px;
  padding: 9px 15px;
  font-size: 15px;
  font-weight: 600;
  color: var(--ink);
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: background .16s ease, color .16s ease, border-color .16s ease;
}
.gp-chip.is-on { background: var(--primary); border-color: transparent; color: #fff; }

.level-name { font-size: 12px; color: var(--ink-soft); max-width: 70px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ------------------------------ 游戏卡片（可打印） ------------------------------ */

#screen-cards { background: var(--bg); }

.cards-controls {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 16px 16px 6px;
  max-width: 720px;
  width: 100%;
  margin: 0 auto;
  box-sizing: border-box;
  flex: 0 0 auto;
}

.cf-field { display: flex; flex-direction: column; gap: 7px; }
.cf-field > label { font-size: 14px; font-weight: 600; color: var(--ink-soft); }

.cf-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 4px; }
.cf-actions .btn { flex: 1; min-height: 52px; min-width: 120px; }

.cf-tip { font-size: 13px; color: var(--ink-soft); margin: 2px 2px 0; line-height: 1.55; }

.cf-pages {
  font-size: 14px; font-weight: 700; color: var(--primary-dark);
  background: #eef4ff; border-radius: 10px; padding: 8px 12px; margin: 2px 0 0;
}

.cf-check { font-size: 15px; color: var(--ink); display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }
.cf-check input { width: 18px; height: 18px; }

.cards-page {
  flex: 1;
  display: grid;
  gap: 18px;
  padding: 8px 16px 30px;
  max-width: 760px;
  width: 100%;
  margin: 0 auto;
  box-sizing: border-box;
  align-content: start;
}

.cards-page.per-1 { grid-template-columns: 1fr; }
.cards-page.per-2 { grid-template-columns: 1fr; }
.cards-page.per-4 { grid-template-columns: 1fr 1fr; }

.card {
  border: 2px solid var(--line);
  border-radius: 16px;
  background: #fff;
  padding: 14px 14px 10px;
  box-sizing: border-box;
  -webkit-print-color-adjust: exact;
  print-color-adjust: exact;
}

.card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.card-no {
  font-weight: 800; color: var(--primary-dark);
  background: #eef4ff; border-radius: 8px; padding: 2px 10px; font-size: 14px;
}
.card-instr { font-size: 15px; font-weight: 700; color: var(--ink); }

.card-board {
  display: grid;
  gap: clamp(6px, 1.6vmin, 14px);
  width: 100%;
  max-width: min(98vw, 72vh, 680px);
  margin: 0 auto;
  box-sizing: border-box;
}
.card-board[data-size="3"] { grid-template-columns: repeat(3, 1fr); }
.card-board[data-size="4"] { grid-template-columns: repeat(4, 1fr); }
.card-board .cell { box-shadow: var(--shadow-sm); cursor: default; }
.card-board .cell.reveal-diff {
  box-shadow: 0 0 0 4px var(--bad), 0 10px 22px rgba(232, 85, 77, .25);
  background: linear-gradient(180deg, #ffffff, #fff3f2);
}
.card-board[data-size="3"] .cell { font-size: clamp(46px, 16vmin, 130px); }
.card-board[data-size="4"] .cell { font-size: clamp(38px, 13vmin, 104px); }
.card-board .shape-svg { width: 78%; }

.card-foot {
  margin-top: 10px; font-size: 14px; color: var(--ink-soft);
  border-top: 1px dashed var(--line); padding-top: 8px;
}

/* 打印：只保留卡片页，铺成干净的练习纸 */
@media print {
  @page { size: A4 portrait; margin: 12mm; }
  html, body { background: #fff !important; }
  .screen { display: none !important; }
  #screen-cards { display: block !important; background: #fff !important; }
  #screen-cards .topbar,
  #screen-cards .cards-controls { display: none !important; }
  .cards-page {
    display: grid !important;
    grid-template-columns: repeat(2, 1fr);
    gap: 10mm; padding: 0; max-width: none; width: 100%;
  }
  .cards-page.per-1 { grid-template-columns: 1fr; }
  .cards-page.per-4 { grid-template-columns: repeat(2, 1fr); }
  .card { break-inside: avoid; page-break-inside: avoid; border-color: #bbb; }
  .card-board { max-width: none; width: 100%; gap: clamp(5px, 1.2vmin, 10px); }
  .card-board[data-size="3"] .cell { font-size: clamp(50px, 12vw, 130px); }
  .card-board[data-size="4"] .cell { font-size: clamp(42px, 10vw, 110px); }
}
