/* 时光画坊 v3 - pastel 像素贴纸风：白格纸画布 · 奶油数字牌 · 贴纸珠 */
* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
:root {
  --ink: #6b5560; --ink2: #a5919c;
  --accent: #f291ad; --accent2: #dd6f92;
  --blue: #8fc7e8; --mint: #9fd6ae; --lav: #c9b8d8;
  --cream: #f7ecd7; --cream-ink: #8a6a4f;
  --canvas: #fdfdfe; --grid: #e9eef5;
  --card: 0 4px 14px rgba(107, 85, 96, .14);
}
html, body { height: 100%; }
body {
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--ink);
  /* 方格纸底纹（参考素材的网格画布） */
  background-color: #fdf9fb;
  background-image:
    linear-gradient(rgba(143, 199, 232, .13) 1px, transparent 1px),
    linear-gradient(90deg, rgba(242, 145, 173, .10) 1px, transparent 1px);
  background-size: 24px 24px;
  touch-action: manipulation; user-select: none; -webkit-user-select: none;
  overscroll-behavior: none;
}
button { font-family: inherit; border: none; background: none; color: inherit; }

#app { max-width: 520px; margin: 0 auto; min-height: 100%; position: relative; }
.screen { display: none; min-height: 100vh; min-height: 100dvh; flex-direction: column; padding: 16px; }
.screen.active { display: flex; }

/* ---------- 通用组件 ---------- */
.btn-big {
  display: block; width: 78%; margin: 14px auto; padding: 18px;
  font-size: 24px; font-weight: 700; color: #fff; letter-spacing: 2px;
  background: linear-gradient(180deg, #f8aec2, var(--accent));
  border-radius: 20px; box-shadow: 0 4px 0 var(--accent2), 0 8px 16px rgba(221, 111, 146, .3);
}
.btn-big:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--accent2); }
.btn-sub {
  display: block; margin: 8px auto; padding: 12px 22px; font-size: 18px;
  color: var(--ink); background: #fff; border-radius: 16px;
  box-shadow: 0 2px 0 #f3cdd8, var(--card);
}
.btn-sub:active { transform: translateY(2px); box-shadow: none; }
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 6px 2px 12px; font-size: 19px; font-weight: 700; letter-spacing: 1px;
}
.icon-btn {
  min-width: 48px; min-height: 48px; font-size: 21px; border-radius: 14px;
  background: #fff; box-shadow: var(--card); border: 1px solid #f6e3ea; color: var(--ink);
}
.icon-btn:active { transform: translateY(2px); box-shadow: none; }

/* ---------- 首页 ---------- */
#screen-home { justify-content: center; text-align: center; }
.home-deco { position: relative; height: 0; }
.home-deco span { position: absolute; font-size: 26px; opacity: .85; animation: floaty 3.4s ease-in-out infinite; }
.home-deco span:nth-child(1) { left: 10%; top: -8vh; }
.home-deco span:nth-child(2) { right: 12%; top: -4vh; animation-delay: 1.1s; }
.home-deco span:nth-child(3) { left: 24%; top: 1vh; animation-delay: 2s; }
@keyframes floaty { 50% { transform: translateY(-9px) rotate(8deg); } }
.game-title {
  font-family: "STKaiti", "KaiTi", "Kaiti SC", serif;
  font-size: 48px; letter-spacing: 10px; margin-top: 2vh; color: #7a5c6b;
  text-shadow: 0 2px 0 #fff;
}
.tagline {
  font-family: "STKaiti", "KaiTi", "Kaiti SC", serif;
  color: var(--ink2); font-size: 17px; margin: 10px 0 2.5vh; letter-spacing: 4px;
}
.level-dots { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; padding: 12px 8px; }
.dot {
  width: 52px; height: 52px; border-radius: 50%; font-size: 18px; font-weight: 700;
  background: #fff; color: var(--ink2); box-shadow: 0 2px 0 #f3cdd8;
  display: flex; align-items: center; justify-content: center; flex-direction: column;
  border: 2px solid #f6e3ea;
}
.dot.passed { background: linear-gradient(180deg, #f8aec2, var(--accent)); color: #fff; border-color: var(--accent); }
.dot.current { background: var(--blue); color: #fff; border-color: #6fb0d8; animation: pulse 1.2s infinite; }
.dot.locked { opacity: .45; }
.dot .mini-stars { font-size: 9px; line-height: 1; }
@keyframes pulse { 50% { transform: scale(1.12); } }
.home-entries { display: flex; justify-content: center; gap: 12px; margin-top: 2vh; }

/* ---------- 游戏页 ---------- */
.game-hud {
  display: flex; justify-content: space-around; background: #fff;
  border: 1px solid #f6e3ea; border-radius: 16px; padding: 10px 6px;
  font-size: 17px; font-weight: 700; margin-bottom: 10px; box-shadow: var(--card);
}
.game-hud .hud-item { text-align: center; }
.game-hud .hud-label { display: block; font-size: 12px; color: var(--ink2); font-weight: 400; }

.board-wrap { flex: 1; display: flex; align-items: center; justify-content: center; padding: 10px 0 4px; }
.cells { display: grid; gap: 1px; background: var(--grid); }
.board {
  padding: 5px; border-radius: 14px; position: relative;
  border: 2px solid #f6dbe4;
  box-shadow: var(--card), 0 0 0 6px #fff;   /* 贴纸白边 */
}
.board::before { content: "🌸"; position: absolute; top: -17px; left: -13px; font-size: 20px; }
.board::after { content: "💗"; position: absolute; bottom: -15px; right: -11px; font-size: 18px; }
.cell { background: var(--canvas); position: relative; }

/* 数字牌：奶油小牌（黑号）/ 同色淡彩小牌（彩号，颜色由 JS 内联） */
.cell .num {
  position: absolute; inset: 10%;
  display: flex; align-items: center; justify-content: center;
  background: var(--cream); color: var(--cream-ink);
  border: 1px solid rgba(138, 106, 79, .3); border-radius: 28%;
  font-size: calc(var(--cp) * .46); font-weight: 800; line-height: 1;
  box-shadow: 0 1px 0 rgba(138, 106, 79, .2);
  transition: opacity .45s, transform .45s;
}
/* 布点：淡紫底 + 角点，数字牌褪淡 */
.cell.dotted { background: #f6f3f8; }
.cell.dotted .num { opacity: .38; background: transparent; border-color: transparent; box-shadow: none; }
.cell.dotted::after {
  content: ""; position: absolute; right: 12%; bottom: 12%;
  width: 16%; height: 16%; border-radius: 50%; background: #cfc3d8;
}
/* 磨损：磨白的格子，无数字 */
.cell.worn { background: #f7f3ec; }
.cell.worn::after {
  content: ""; position: absolute; inset: 26%; border-radius: 45%;
  background: rgba(201, 184, 216, .16);
}
/* 像素贴纸珠 */
.cell.diamond { background: var(--canvas); }
.cell.diamond::before {
  content: ""; position: absolute; inset: 7%;
  border-radius: 26%;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, .5) 0 26%, rgba(255, 255, 255, 0) 26%),
    var(--c);
  border: 2px solid var(--cd);
  box-shadow: inset 0 -2px 0 rgba(0, 0, 0, .07), 0 1px 2px rgba(107, 85, 96, .22);
  animation: beadIn .22s cubic-bezier(.34, 1.56, .64, 1);
}
.cell.diamond::after {
  content: ""; position: absolute; left: 20%; top: 18%;
  width: 16%; height: 16%; border-radius: 35%; background: rgba(255, 255, 255, .9);
}
@keyframes beadIn { 0% { transform: scale(.2); } 60% { transform: scale(1.18); } }
/* 贴钻格角落小数字（九宫格定案后淡出） */
.cell.diamond .num {
  inset: auto; top: 1%; right: 5%;
  background: none; border: none; box-shadow: none;
  font-size: calc(var(--cp) * .3); color: #fff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, .4);
}
.cell.settled .num { opacity: 0; transform: scale(.5); }

/* 按住高亮九宫格 */
.cell.hl { background: #fff6dd; box-shadow: inset 0 0 0 2px rgba(242, 145, 173, .55); }
.cell.err { animation: shake .3s; }
@keyframes shake { 25% { transform: translateX(-3px); } 75% { transform: translateX(3px); } }
.cell.hint-flash { animation: hintFlash .7s 2; }
@keyframes hintFlash { 50% { background: #ffe1ec; box-shadow: inset 0 0 0 3px var(--accent); } }
.cell.diamond.shine::before { animation: beadShine .6s ease-out; }
@keyframes beadShine { 35% { filter: brightness(1.45) saturate(1.35); transform: scale(1.22); } }

/* 色号图例条 */
.legend { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px 12px; padding: 10px 2px 0; }
.lg { display: inline-flex; align-items: center; gap: 5px; font-size: 13px; color: var(--ink2); }
.lg i { width: 14px; height: 14px; border-radius: 4px; border: 2px solid; }
.board-tip { text-align: center; color: var(--ink2); font-size: 13px; padding: 6px 0 2px; }

/* ---------- 结果页：贴纸相框 ---------- */
#screen-result { justify-content: center; text-align: center; }
.result-title {
  font-family: "STKaiti", "KaiTi", "Kaiti SC", serif;
  font-size: 38px; margin: 1vh 0 6px; letter-spacing: 3px; color: #7a5c6b;
}
.stars { font-size: 40px; letter-spacing: 8px; margin: 4px 0; color: #f2b544; }
.stars .dim { opacity: .25; }
.frame {
  width: fit-content; margin: 12px auto; padding: 12px; background: #fff;
  border: 3px solid #f6cdd9; border-radius: 16px; box-shadow: var(--card);
  position: relative;
}
.frame::before { content: "💗"; position: absolute; top: -16px; left: -13px; font-size: 22px; }
.frame::after { content: "🌸"; position: absolute; bottom: -16px; right: -13px; font-size: 22px; }
.frame-in { background: var(--grid); padding: 4px; border-radius: 10px; }
.frame-in .cells { border-radius: 6px; overflow: hidden; }
.art-name { font-size: 26px; font-weight: 700; margin-top: 12px; letter-spacing: 2px; }
.art-story {
  font-family: "STKaiti", "KaiTi", "Kaiti SC", serif;
  color: var(--ink2); font-size: 17px; margin: 6px 18px 12px; line-height: 1.7; letter-spacing: 1px;
}
.stat-row { display: flex; justify-content: center; gap: 34px; margin: 10px 0 1vh; }
.stat { font-size: 15px; color: var(--ink2); }
.stat b { display: block; font-size: 22px; color: var(--ink); }

/* 小图（图鉴/相框内）：细描边、去高光 */
.art-cells .cell.diamond::before { border-width: 1px; animation: none; }
.art-cells .cell.diamond::after { display: none; }

/* ---------- 图鉴 ---------- */
.coll-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; padding: 8px 0; }
.coll-item {
  background: #fff; border-radius: 14px; padding: 10px 6px; text-align: center;
  box-shadow: var(--card); border: 1px solid #f6e3ea;
}
.coll-item .nm { font-size: 15px; font-weight: 600; margin-top: 6px; }
.coll-item.locked { opacity: .5; }
.coll-item.locked .nm { color: var(--ink2); }

/* ---------- 弹层 / 便签卡 ---------- */
.modal-mask { position: fixed; inset: 0; background: rgba(107, 85, 96, .38);
  display: flex; align-items: center; justify-content: center; z-index: 50; }
.modal { width: 84%; max-width: 420px; background: #fff; border-radius: 22px;
  border: 2px solid #f6dbe4; padding: 22px; text-align: center;
  box-shadow: 0 10px 30px rgba(107, 85, 96, .3); }
.modal h2 { font-size: 24px; margin-bottom: 12px; color: #7a5c6b; }
.modal p { font-size: 17px; line-height: 1.8; color: var(--ink); text-align: left; margin: 8px 0; }
.modal p b { color: var(--accent2); }
.note-small { display: block; margin-top: 6px; font-size: 14px; color: var(--ink2); }
.switch-row { display: flex; justify-content: space-between; align-items: center;
  padding: 12px 4px; font-size: 19px; }
.switch { width: 60px; height: 34px; border-radius: 17px; background: #e8dfe4;
  position: relative; transition: .2s; }
.switch.on { background: var(--mint); }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 28px; height: 28px;
  border-radius: 50%; background: #fff; transition: .2s; box-shadow: 0 1px 3px rgba(0,0,0,.2); }
.switch.on::after { left: 29px; }

/* ---------- 过关彩带 / 连贴 ---------- */
.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 60; overflow: hidden; }
.confetti i { position: absolute; top: -12px; width: 10px; height: 16px; border-radius: 3px;
  animation: fall linear forwards; }
@keyframes fall { to { transform: translateY(110vh) rotate(720deg); } }
.combo-pop { position: fixed; left: 50%; top: 30%; transform: translateX(-50%);
  font-size: 30px; font-weight: 800; color: var(--accent2); z-index: 55;
  animation: comboPop .8s ease-out forwards; pointer-events: none;
  text-shadow: 0 2px 0 #fff; }
@keyframes comboPop { 0% { transform: translateX(-50%) scale(.5); opacity: 0; }
  30% { transform: translateX(-50%) scale(1.2); opacity: 1; } 100% { transform: translateX(-50%) translateY(-40px); opacity: 0; } }

/* ---------- L1 教学：歪斜便签卡 ---------- */
.tut-bubble {
  position: fixed; left: 50%; bottom: 96px;
  transform: translateX(-50%) rotate(-1.2deg);
  width: 86%; max-width: 430px; background: #fff9ea;
  border: 2px solid #f0d9a6; border-radius: 4px 16px 4px 16px;
  padding: 16px 16px 12px; box-shadow: 0 8px 20px rgba(107, 85, 96, .22);
  z-index: 40; text-align: center;
}
.tut-bubble::before {
  content: "📌"; position: absolute; top: -16px; left: 50%; margin-left: -12px; font-size: 22px;
}
.tut-text { font-size: 17px; line-height: 1.75; color: var(--ink); }
.tut-text b { color: var(--accent2); }
.tut-bubble .btn-sub { margin: 10px auto 0; padding: 8px 30px; font-size: 16px; }
.tut-hl { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 8px;
  animation: tutPulse 1.2s infinite; }
@keyframes tutPulse { 50% { outline-color: var(--blue); } }

/* 小尺寸适配 */
@media (max-height: 700px) {
  .game-title { font-size: 40px; margin-top: 1vh; }
  .frame { padding: 8px; }
}
