/* ===== 数独小达人 · 儿童友好样式 ===== */
:root {
  --cream: #fff8ee;
  --card: #ffffff;
  --ink: #4a3b32;
  --ink-soft: #9a8577;
  --orange: #ff8a4c;
  --orange-deep: #ef6c25;
  --mint: #35c193;
  --mint-deep: #24a479;
  --sky: #4ea8f0;
  --sky-deep: #2f8bd6;
  --grape: #a98bf0;
  --grape-deep: #8a6ce0;
  --sun: #ffc94a;
  --pink: #ff7fa8;
  --line: #f0e2d0;
  --line-strong: #d9b892;
  --danger: #e8504a;
  --radius: 22px;
  --shadow: 0 6px 0 rgba(0, 0, 0, .07);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background: #ffeed6;
  color: var(--ink);
  font-family: ui-rounded, "Nunito", "Quicksand", "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", system-ui, sans-serif;
  font-size: 17px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

body {
  background:
    radial-gradient(circle at 12% 8%, #fff6e4 0%, transparent 45%),
    radial-gradient(circle at 88% 12%, #ffe9f0 0%, transparent 40%),
    radial-gradient(circle at 80% 90%, #e7f7ff 0%, transparent 45%),
    linear-gradient(180deg, #fff3e2 0%, #ffeed6 100%);
  background-attachment: fixed;
}

#app {
  max-width: 560px;
  margin: 0 auto;
  min-height: 100vh;
  padding: 12px 14px 28px;
  position: relative;
}

/* ===== 屏幕切换 ===== */
.screen { display: none; animation: fadeUp .32s ease both; }
.screen.is-active { display: block; }
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}

/* ===== 顶栏 ===== */
.top-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}
.top-title {
  flex: 1;
  margin: 0;
  text-align: center;
  font-size: 22px;
  font-weight: 800;
  letter-spacing: 1px;
}
.top-right { display: flex; gap: 6px; align-items: center; min-width: 62px; justify-content: flex-end; }

.icon-btn {
  width: 46px; height: 46px;
  border: none;
  border-radius: 16px;
  background: #fff;
  box-shadow: 0 4px 0 rgba(0, 0, 0, .08);
  font-size: 21px;
  cursor: pointer;
  transition: transform .12s, box-shadow .12s;
}
.icon-btn:active { transform: translateY(3px); box-shadow: 0 1px 0 rgba(0, 0, 0, .08); }

.chip {
  background: #fff;
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 15px;
  font-weight: 800;
  box-shadow: 0 3px 0 rgba(0, 0, 0, .06);
  white-space: nowrap;
}
.chip-star { color: #e79a1c; }

/* ===== 按钮 ===== */
.btn {
  border: none;
  cursor: pointer;
  font-family: inherit;
  font-weight: 800;
  color: #fff;
  border-radius: 20px;
  padding: 14px 22px;
  font-size: 18px;
  background: var(--orange);
  box-shadow: 0 5px 0 rgba(0, 0, 0, .12);
  transition: transform .12s, box-shadow .12s, filter .15s;
}
.btn:active { transform: translateY(4px); box-shadow: 0 1px 0 rgba(0, 0, 0, .12); }
.btn:disabled { filter: grayscale(.6) opacity(.65); cursor: not-allowed; }
.btn-xl { width: 100%; padding: 18px 22px; font-size: 22px; border-radius: 24px; }
.btn-orange { background: var(--orange); box-shadow: 0 5px 0 var(--orange-deep); }
.btn-mint { background: var(--mint); box-shadow: 0 5px 0 var(--mint-deep); }
.btn-sky { background: var(--sky); box-shadow: 0 5px 0 var(--sky-deep); }
.btn-grape { background: var(--grape); box-shadow: 0 5px 0 var(--grape-deep); }
.btn-ghost { background: #fff; color: var(--ink-soft); box-shadow: 0 5px 0 #e6d6c4; }

.link-btn {
  background: none; border: none; cursor: pointer;
  color: var(--ink-soft); font-family: inherit; font-size: 14px;
  text-decoration: underline; padding: 8px;
}

/* ===== 吉祥物 ===== */
.mascot { width: 118px; height: 118px; display: block; margin: 0 auto; }
.m-shadow { fill: rgba(120, 80, 40, .12); }
.m-body, .m-head, .m-ear, .m-tail { fill: #ff9f5e; }
.m-belly, .m-muzzle { fill: #fff4e6; }
.m-ear-in { fill: #ffd0b0; }
.m-eye { fill: #4a3b32; transform-box: fill-box; transform-origin: center; animation: blink 4.5s infinite; }
.m-eye-shine { fill: #fff; }
.m-nose { fill: #4a3b32; }
.m-mouth { fill: none; stroke: #4a3b32; stroke-width: 2.4; stroke-linecap: round; }
.m-blush { fill: #ff8fa8; opacity: .55; }
.m-sparkle text { fill: #ffc94a; font-size: 15px; animation: twinkle 1.8s infinite; }
.m-sparkle text:nth-child(2) { animation-delay: .9s; }
@keyframes blink {
  0%, 92%, 100% { transform: scaleY(1); }
  95% { transform: scaleY(.1); }
}
@keyframes twinkle {
  0%, 100% { opacity: .2; }
  50% { opacity: 1; }
}
.mascot.jump { animation: jump .8s ease; }
@keyframes jump {
  0%, 100% { transform: translateY(0); }
  30% { transform: translateY(-16px) scale(1.04); }
  60% { transform: translateY(0) scale(.98); }
}

/* ===== 首页 ===== */
.home { text-align: center; padding-top: 18px; position: relative; }
.mascot-box { margin-bottom: 4px; }
.home-title {
  margin: 0;
  font-size: 40px;
  font-weight: 900;
  letter-spacing: 3px;
  color: var(--orange-deep);
  text-shadow: 0 3px 0 #fff, 0 6px 0 rgba(239, 108, 37, .18);
}
.home-sub { margin: 6px 0 22px; color: var(--ink-soft); font-weight: 700; }
.home-btns { display: grid; gap: 14px; max-width: 320px; margin: 0 auto; }
.home-stats {
  margin: 22px auto 6px;
  display: flex; justify-content: center; gap: 10px; flex-wrap: wrap;
}
.stat-pill {
  background: #fff; border-radius: 999px; padding: 8px 16px;
  font-weight: 800; font-size: 15px; box-shadow: 0 3px 0 rgba(0, 0, 0, .06);
}

.bubble-bg { position: fixed; inset: 0; pointer-events: none; z-index: 0; overflow: hidden; }
.bubble-bg span {
  position: absolute; border-radius: 50%; opacity: .35;
  animation: floatUp linear infinite;
  background: #fff;
}
@keyframes floatUp {
  0% { transform: translateY(110vh) scale(.6); opacity: 0; }
  15% { opacity: .45; }
  100% { transform: translateY(-20vh) scale(1.1); opacity: 0; }
}

/* ===== 关卡地图 ===== */
.scroll-area { padding-bottom: 20px; }
.zone {
  background: var(--card);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}
.zone-head { display: flex; align-items: center; gap: 10px; margin-bottom: 4px; }
.zone-emoji { font-size: 30px; }
.zone-name { font-size: 20px; font-weight: 900; }
.zone-tip { color: var(--ink-soft); font-size: 14px; margin: 0 0 12px; }
.zone-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }

.level-card {
  position: relative;
  border: none;
  cursor: pointer;
  font-family: inherit;
  background: linear-gradient(180deg, #fffdf9, #fff4e4);
  border-radius: 18px;
  padding: 14px 12px;
  text-align: left;
  box-shadow: 0 4px 0 #f0dfc8;
  transition: transform .12s, box-shadow .12s;
}
.level-card:active { transform: translateY(3px); box-shadow: 0 1px 0 #f0dfc8; }
.level-card.is-locked { filter: grayscale(.85); opacity: .7; cursor: not-allowed; }
.level-card.is-done { background: linear-gradient(180deg, #f4fff9, #e2f8ee); box-shadow: 0 4px 0 #bfe9d5; }
.level-no { font-size: 13px; font-weight: 800; color: var(--ink-soft); }
.level-name { font-size: 17px; font-weight: 900; margin-top: 2px; }
.level-stars { margin-top: 6px; font-size: 19px; letter-spacing: 2px; }
.level-lock { position: absolute; right: 12px; top: 12px; font-size: 20px; }
.level-best { font-size: 12px; color: var(--ink-soft); margin-top: 2px; }

/* ===== 棋盘 ===== */
.board-wrap { display: flex; justify-content: center; margin: 6px 0 14px; }
.board {
  display: grid;
  grid-template-columns: repeat(var(--n), var(--cell));
  gap: var(--gap, 3px);
  background: var(--line-strong);
  padding: var(--gap, 3px);
  border-radius: 18px;
  box-shadow: var(--shadow);
  touch-action: manipulation;
}
.cell {
  position: relative;
  width: var(--cell);
  height: var(--cell);
  background: #fff;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: calc(var(--cell) * .58);
  font-weight: 900;
  color: var(--ink);
  cursor: pointer;
  user-select: none;
  transition: background .15s, color .15s, transform .12s;
}
.cell.br::after {
  content: ''; position: absolute; right: calc(var(--gap, 3px) * -1 - 1px);
  top: -1px; bottom: -1px; width: calc(var(--gap, 3px) + 2px);
  background: var(--line-strong);
}
.cell.bb::after {
  content: ''; position: absolute; bottom: calc(var(--gap, 3px) * -1 - 1px);
  left: -1px; right: -1px; height: calc(var(--gap, 3px) + 2px);
  background: var(--line-strong);
}
.cell.given { background: #fff3e3; color: #a9805b; }
.cell.user { color: var(--orange-deep); }
.cell.hinted { background: #e7fbf2; color: #149a6c; }
.cell.peer { background: #fffaf1; }
.cell.same { background: #ffeecf; }
.cell.selected { background: #fff2cd; box-shadow: inset 0 0 0 4px var(--sun); z-index: 2; }
.cell.wrong { background: #ffe6e4; color: var(--danger); animation: shake .4s; }
.cell.pop { animation: popIn .38s cubic-bezier(.2, 1.5, .4, 1); }
.cell.flash { animation: flash .7s ease; }
.cell.cross::before {
  content: '✕'; position: absolute; color: var(--danger);
  font-size: calc(var(--cell) * .55); opacity: .85;
}
.cell.demo-focus { box-shadow: inset 0 0 0 4px var(--sky); z-index: 2; }
.cell.demo-target { box-shadow: inset 0 0 0 4px var(--mint); background: #e7fbf2; z-index: 2; }
.cell.demo-bad { background: #ffe6e4; }

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-6px) rotate(-3deg); }
  40% { transform: translateX(6px) rotate(3deg); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(4px); }
}
@keyframes popIn {
  0% { transform: scale(.4); opacity: .2; }
  70% { transform: scale(1.18); }
  100% { transform: scale(1); }
}
@keyframes flash {
  0%, 100% { background: #fff; }
  40% { background: #b8f2d8; }
}

/* ===== 数字面板 ===== */
.pad {
  display: flex; flex-wrap: wrap; justify-content: center; gap: 10px;
  margin-bottom: 14px;
}
.num-btn {
  position: relative;
  width: 62px; height: 66px;
  border: none; border-radius: 18px;
  background: linear-gradient(180deg, #fff, #fff1dd);
  box-shadow: 0 5px 0 #e9cfa8;
  font-family: inherit; font-size: 28px; font-weight: 900; color: var(--orange-deep);
  cursor: pointer;
  transition: transform .12s, box-shadow .12s;
  padding-top: 6px;
}
.num-btn:active { transform: translateY(4px); box-shadow: 0 1px 0 #e9cfa8; }
.num-btn .left {
  display: block; font-size: 12px; font-weight: 800; color: var(--ink-soft);
  line-height: 1; margin-top: -2px;
}
.num-btn.is-done { opacity: .45; }
.num-btn.is-active { background: linear-gradient(180deg, #ffe9b3, #ffd77a); box-shadow: 0 5px 0 #e0a92c; }

/* ===== 工具条 ===== */
.tools { display: flex; gap: 8px; margin-bottom: 4px; }
.tool-btn {
  flex: 1 1 0; min-width: 0;
  border: none; cursor: pointer; font-family: inherit;
  background: #fff; border-radius: 18px; padding: 10px 2px 8px;
  font-size: 13px; font-weight: 800; color: var(--ink);
  box-shadow: 0 4px 0 #e6d6c4;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  transition: transform .12s, box-shadow .12s;
}
.tool-btn:active { transform: translateY(3px); box-shadow: 0 1px 0 #e6d6c4; }
.tool-btn span { font-size: 22px; }
.tool-btn b { color: var(--orange-deep); }

/* ===== 说话气泡 ===== */
.say { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.say-mascot .mascot { width: 74px; height: 74px; margin: 0; }
.say-text {
  flex: 1;
  background: #fff;
  border-radius: 18px;
  padding: 12px 16px;
  font-weight: 800;
  font-size: 16px;
  box-shadow: var(--shadow);
  position: relative;
  min-height: 56px;
  display: flex; align-items: center;
}
.say-text::before {
  content: ''; position: absolute; left: -8px; top: 50%; margin-top: -8px;
  border: 8px solid transparent; border-right-color: #fff; border-left: 0;
}
.say-text.good { color: #149a6c; }
.say-text.bad { color: var(--danger); }
.say-text.hint { color: #b06a00; }

/* ===== 规则课堂 ===== */
.learn-card {
  background: var(--card); border-radius: var(--radius);
  padding: 18px; box-shadow: var(--shadow); min-height: 340px;
}
.learn-card h3 { margin: 0 0 6px; font-size: 21px; font-weight: 900; }
.learn-card p { margin: 8px 0; font-size: 16px; font-weight: 600; }
.learn-card .lead { color: var(--ink-soft); font-size: 15px; font-weight: 700; }
.learn-card b.hl { color: var(--orange-deep); }
.learn-center { display: flex; justify-content: center; margin: 12px 0; }
.rule-list { list-style: none; padding: 0; margin: 14px 0 0; display: grid; gap: 10px; }
.rule-list li {
  background: #fff8ee; border-radius: 16px; padding: 12px 14px;
  font-weight: 800; display: flex; align-items: center; gap: 10px;
}
.rule-emoji { font-size: 24px; }
.pick-row { display: flex; gap: 10px; justify-content: center; margin: 14px 0 10px; flex-wrap: wrap; }
.pick-btn {
  border: none; cursor: pointer; font-family: inherit; font-weight: 900; font-size: 17px;
  padding: 10px 20px; border-radius: 16px; background: #fff2dd; color: #a9805b;
  box-shadow: 0 4px 0 #e9cfa8;
}
.pick-btn.on { background: var(--sun); color: #fff; box-shadow: 0 4px 0 #e0a92c; }
.learn-nav { display: flex; align-items: center; gap: 10px; margin-top: 14px; }
.dots { display: flex; gap: 6px; flex: 1; justify-content: center; }
.dots i { width: 9px; height: 9px; border-radius: 50%; background: #e6d6c4; }
.dots i.on { background: var(--orange); width: 22px; border-radius: 999px; }
.step-text {
  background: #fff8ee; border-radius: 16px; padding: 12px 14px;
  font-weight: 800; min-height: 62px; display: flex; align-items: center;
}
.tip-box {
  margin-top: 12px; background: #eaf7ff; border-radius: 16px; padding: 12px 14px;
  font-weight: 700; color: #2c6f9e; font-size: 15px;
}

/* ===== 徽章 ===== */
.badge-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.badge-card {
  background: var(--card); border-radius: 20px; padding: 16px 12px;
  text-align: center; box-shadow: var(--shadow);
}
.badge-card.locked { filter: grayscale(1); opacity: .5; }
.badge-emoji { font-size: 42px; line-height: 1.2; }
.badge-name { font-weight: 900; margin-top: 4px; }
.badge-desc { font-size: 13px; color: var(--ink-soft); font-weight: 700; }

/* ===== 提示条 ===== */
#toast-root {
  position: fixed; left: 0; right: 0; bottom: 26px;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  pointer-events: none; z-index: 60;
}
.toast {
  background: rgba(74, 59, 50, .94); color: #fff;
  padding: 12px 20px; border-radius: 999px;
  font-weight: 800; font-size: 16px;
  animation: toastIn .3s ease both;
  max-width: 88vw; text-align: center;
}
.toast.good { background: rgba(21, 154, 108, .95); }
.toast.bad { background: rgba(232, 80, 74, .95); }
@keyframes toastIn {
  from { opacity: 0; transform: translateY(16px) scale(.9); }
  to { opacity: 1; transform: none; }
}

/* ===== 弹窗 ===== */
#modal-root { position: fixed; inset: 0; z-index: 80; display: none; }
#modal-root.on { display: flex; align-items: center; justify-content: center; }
.mask { position: absolute; inset: 0; background: rgba(74, 59, 50, .45); backdrop-filter: blur(2px); }
.dialog {
  position: relative; width: min(92vw, 400px);
  background: var(--card); border-radius: 28px; padding: 22px 20px;
  text-align: center; box-shadow: 0 12px 30px rgba(0, 0, 0, .18);
  animation: dialogIn .35s cubic-bezier(.2, 1.4, .4, 1) both;
  max-height: 88vh; overflow-y: auto;
}
@keyframes dialogIn {
  from { opacity: 0; transform: scale(.7) translateY(20px); }
  to { opacity: 1; transform: none; }
}
.dialog h3 { margin: 4px 0 6px; font-size: 25px; font-weight: 900; }
.dialog p { margin: 6px 0; font-weight: 700; }
.dialog .mascot { width: 108px; height: 108px; }
.stars-row { display: flex; justify-content: center; gap: 8px; margin: 10px 0; font-size: 0; }
.stars-row span {
  font-size: 46px; opacity: 0; transform: scale(.3);
  animation: starPop .5s cubic-bezier(.2, 1.6, .4, 1) forwards;
}
.stars-row span:nth-child(2) { animation-delay: .18s; }
.stars-row span:nth-child(3) { animation-delay: .36s; }
.stars-row span.empty { opacity: 1; filter: grayscale(1); animation: none; transform: none; }
@keyframes starPop {
  to { opacity: 1; transform: scale(1) rotate(-8deg); }
}
.dialog-btns { display: grid; gap: 10px; margin-top: 16px; }
.praise { color: var(--orange-deep); font-weight: 900; font-size: 18px; }
.new-badges { display: flex; justify-content: center; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.new-badge {
  background: #fff3e3; border-radius: 14px; padding: 8px 12px;
  font-weight: 800; font-size: 14px; animation: popIn .5s both;
}

/* ===== 彩带 ===== */
#confetti-root { position: fixed; inset: 0; pointer-events: none; z-index: 70; overflow: hidden; }
.confetti {
  position: absolute; width: 10px; height: 14px; border-radius: 2px;
  animation: fall linear forwards;
}
@keyframes fall {
  0% { transform: translateY(-10vh) rotate(0deg); opacity: 1; }
  100% { transform: translateY(105vh) rotate(720deg); opacity: .9; }
}

/* ===== 变体数独 ===== */
.board-inner { position: relative; display: inline-block; }
.marks { position: absolute; left: 0; top: 0; right: 0; bottom: 0; pointer-events: none; }
.marks i {
  position: absolute;
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--orange-deep);
  box-shadow: 0 0 0 2px #fff8ee;
  transform: translate(-50%, -50%);
}

/* 对角线数独：斜纹底纹 */
.cell.diag {
  background-image: repeating-linear-gradient(45deg,
    transparent, transparent 5px,
    rgba(255, 176, 60, .30) 5px, rgba(255, 176, 60, .30) 10px);
}
/* 奇数数独：左上角紫色小圆点 */
.cell.odd::before {
  content: ''; position: absolute; top: 4px; left: 4px;
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--grape); box-shadow: 0 0 0 2px rgba(255, 255, 255, .8);
}
.cell.odd.given::before { background: #8a6ce0; }

.rule-bar {
  display: none;
  margin: 0 0 12px;
  background: linear-gradient(180deg, #fff6e8, #ffeedb);
  border-radius: 16px;
  padding: 10px 14px;
  font-weight: 800;
  font-size: 14px;
  color: #9a6a2c;
  text-align: center;
  box-shadow: 0 3px 0 #f0dfc8;
}
.rule-bar.on { display: block; }
.rule-bar b { color: var(--orange-deep); }

/* 变体规则弹窗里的小图例 */
.vr-legend { display: flex; justify-content: center; gap: 14px; flex-wrap: wrap; margin: 10px 0 4px; }
.vr-legend span { font-weight: 800; font-size: 14px; color: var(--ink-soft); }

@media (max-width: 380px) {
  .num-btn { width: 54px; height: 60px; font-size: 24px; }
  .home-title { font-size: 34px; }
  .tool-btn { font-size: 12px; }
}
