/* =====================================================================
   标题字体 · 猫啃什锦黑（MaokenAssortedSans）OFL-1.1
   来源：https://fonts.zeoseven.com/items/382/ · 字体说明见 assets/fonts/LICENSE.md
   仅子集化「数 字 华 容 道」5 个字符（约 1.9KB WOFF2），base64 内联：
   - 不请求字体 API / CDN，完全本地；
   - 不产生额外字体请求，file:// 双击也能稳定加载。
   ===================================================================== */

@font-face {
  font-family: "NK Title Sans";
  src: url("../assets/fonts/PotatoTitle.woff2") format("woff2");
  font-style: normal;
  font-weight: 400;
  font-display: swap;
}

/* =====================================================================
   数字华容道 · 主题变量与纸面基底
   视觉沿用原「思维游戏」项目：手绘绘本 / 水彩暖色
   ===================================================================== */

:root {
  /* —— 纸面与背景 —— */
  --paper:           #FBF6EC;
  --paper-warm:      #F3E9D2;
  --paper-deep:      #EADFC4;
  --ink:             #5A4A3A;
  --ink-soft:        #7A6A55;
  --ink-faint:       #B6A892;
  --ink-tile:        #44352A;   /* 方块数字专用深墨，保证彩色底上的可读性 */

  /* —— 强调色（绘本暖色系） —— */
  --pumpkin:         #E07A3F;
  --pumpkin-deep:    #C9622A;
  --orange-soft:     #F2A65A;
  --cherry:          #F4B6C2;
  --cherry-deep:     #E88EA0;
  --mint:            #A8D8B9;
  --mint-deep:       #7CC398;
  --sky:             #9EC9E8;
  --sky-deep:        #6FAFD8;
  --sunny:           #F5D547;
  --sunny-deep:      #E5BF2A;
  --grape:           #B59AD8;

  /* —— 语义色 —— */
  --success:         #7CC398;
  --error:           #E88EA0;
  --star:            #F5C842;

  /* —— 描边与阴影 —— */
  --stroke:          #5A4A3A;
  --stroke-soft:     #B6A892;
  --shadow-soft:     0 6px 0 rgba(90, 74, 58, 0.12), 0 10px 22px rgba(90, 74, 58, 0.10);
  --shadow-press:    0 2px 0 rgba(90, 74, 58, 0.12), 0 4px 10px rgba(90, 74, 58, 0.10);
  --shadow-card:     0 8px 0 rgba(90, 74, 58, 0.10), 0 18px 32px rgba(90, 74, 58, 0.12);

  /* —— 圆角（不规整手绘感） —— */
  --r-sm:  12px;
  --r-md:  20px;
  --r-lg:  28px;
  --r-xl:  36px;

  /* —— 字体 —— */
  --font-hand: "Chalkboard SE", "Comic Sans MS", "Marker Felt", "Bradley Hand",
               "Kaiti SC", "Kaiti", "STKaiti", "KaiTi", "楷体", "华文楷体", cursive;
  --font-body: "Chalkboard SE", "Comic Sans MS", "Segoe UI", "PingFang SC",
               "Hiragino Sans GB", "Microsoft YaHei", "Kaiti SC", "STKaiti", sans-serif;
  --font-num:  "Baloo 2", "Chalkboard SE", "Comic Sans MS", "Trebuchet MS", cursive;

  /* —— 字号（自适应收缩，保持原项目的大字号气质） —— */
  --fs-xs:  clamp(12px, 0.8rem, 14px);
  --fs-sm:  clamp(14px, 0.95rem, 17px);
  --fs-md:  clamp(16px, 1.1rem, 20px);
  --fs-lg:  clamp(20px, 1.45rem, 26px);
  --fs-xl:  clamp(26px, 2rem, 36px);
  --fs-2xl: clamp(34px, 3.2rem, 52px);
  --fs-hero: clamp(40px, 4.6rem, 72px);

  /* —— 间距 —— */
  --sp-1: 6px;
  --sp-2: 12px;
  --sp-3: 18px;
  --sp-4: 24px;
  --sp-5: 36px;
  --sp-6: 56px;

  /* —— 动效 —— */
  --ease-bounce: cubic-bezier(0.34, 1.56, 0.64, 1);
  --ease-soft:   cubic-bezier(0.4, 0.0, 0.2, 1);
  --dur-fast: 0.18s;
  --dur:      0.32s;
  --dur-slow: 0.6s;

  /* —— 布局 —— */
  --topbar-pad-y: 14px;
  --topbar-pad-x: 28px;
  --page-pad: 28px;
}

/* —— 难度色板 —— */
[data-difficulty="easy"]   { --diff: var(--mint);        --diff-deep: var(--mint-deep); }
[data-difficulty="normal"] { --diff: var(--orange-soft); --diff-deep: var(--pumpkin-deep); }
[data-difficulty="hard"]   { --diff: var(--cherry);      --diff-deep: var(--cherry-deep); }

/* =====================================================================
   重置
   ===================================================================== */

*, *::before, *::after { box-sizing: border-box; }

html {
  height: 100%;
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100%;
  min-height: 100vh;
  min-height: 100dvh;
  font-family: var(--font-body);
  font-size: var(--fs-md);
  line-height: 1.55;
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;

  /* 纸面底色 + 柔和暖色水彩晕染 */
  background-color: var(--paper);
  background-image:
    radial-gradient(circle at 12% 18%, rgba(244, 182, 194, 0.22) 0, transparent 38%),
    radial-gradient(circle at 88% 12%, rgba(158, 201, 232, 0.20) 0, transparent 42%),
    radial-gradient(circle at 78% 88%, rgba(168, 216, 185, 0.22) 0, transparent 44%),
    radial-gradient(circle at 18% 82%, rgba(245, 213, 71, 0.18) 0, transparent 40%);
  background-attachment: fixed;
}

/* 纸张颗粒纹理（SVG noise，无外网依赖） */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: 0.5;
  mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='220' height='220'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0.35  0 0 0 0 0.29  0 0 0 0 0.22  0 0 0 0.12 0'/></filter><rect width='100%25' height='100%25' filter='url(%23n)'/></svg>");
}

/* 漂浮云朵装饰 */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background-image:
    url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='180' height='80' viewBox='0 0 180 80'><path d='M30 60 Q10 60 14 44 Q12 28 32 30 Q40 12 60 18 Q72 6 88 18 Q108 8 116 26 Q138 22 140 40 Q160 42 154 60 Z' fill='%23ffffff' opacity='0.5'/></svg>"),
    url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='120' height='54' viewBox='0 0 120 54'><path d='M20 42 Q6 42 9 30 Q8 18 24 20 Q30 6 46 12 Q58 2 70 12 Q88 6 92 22 Q108 22 104 38 Q116 40 110 42 Z' fill='%23ffffff' opacity='0.4'/></svg>");
  background-position: 8% 14%, 86% 22%;
  background-repeat: no-repeat;
  background-size: 180px 80px, 120px 54px;
  animation: cloudDrift 28s ease-in-out infinite alternate;
}

@keyframes cloudDrift {
  0%   { background-position: 8% 14%, 86% 22%; }
  100% { background-position: 12% 18%, 82% 18%; }
}

/* =====================================================================
   排版
   ===================================================================== */

h1, h2, h3, h4 {
  font-family: var(--font-hand);
  color: var(--ink);
  margin: 0;
  line-height: 1.2;
  font-weight: 700;
}

p { margin: 0; }

button {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
  cursor: pointer;
  border: none;
  background: none;
}

a { color: inherit; text-decoration: none; }

[hidden] { display: none !important; }

::selection {
  background: var(--sunny);
  color: var(--ink);
}

:focus-visible {
  outline: 3px dashed var(--pumpkin);
  outline-offset: 3px;
}

/* 通用滚动条（绘本风） */
* { scrollbar-width: thin; scrollbar-color: var(--paper-deep) transparent; }
*::-webkit-scrollbar { width: 12px; height: 12px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb {
  background: var(--paper-deep);
  border-radius: 10px;
  border: 3px solid transparent;
  background-clip: padding-box;
}
*::-webkit-scrollbar-thumb:hover { background: var(--stroke-soft); background-clip: padding-box; }

/* =====================================================================
   工具类
   ===================================================================== */

.row { display: flex; align-items: center; gap: var(--sp-2); }
.col { display: flex; flex-direction: column; gap: var(--sp-2); }
.center { display: flex; align-items: center; justify-content: center; }
.wrap { flex-wrap: wrap; }
.spacer { flex: 1; }
.muted { color: var(--ink-soft); }
.faint { color: var(--ink-faint); }
.hand { font-family: var(--font-hand); }
.num  { font-family: var(--font-num); }
.center-text { text-align: center; }

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

/* =====================================================================
   可访问性：减少动效
   ===================================================================== */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}
