/* 时光画坊·旧画箱 Demo —— 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;
  --canvas: #fdfdfe; --grid: #eef2f7;
  --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: 44px; letter-spacing: 8px; margin-top: 2vh; color: #7a5c6b;
  text-shadow: 0 2px 0 #fff;
}
.demo-badge {
  display: inline-block; margin-top: 8px; padding: 3px 14px; font-size: 13px; letter-spacing: 2px;
  color: #b0728c; background: #fff; border: 1.5px dashed #f2b8cb; border-radius: 999px;
}
.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: 12px 0 4px; }
.boardbox { position: relative; }
.board {
  padding: 6px; border-radius: 14px; position: relative;
  border: 2px solid #f6dbe4;
  box-shadow: var(--card), 0 0 0 6px #fff;   /* 贴纸白边 */
  overflow: hidden;
}
.board::before { content: "🌸"; position: absolute; top: -17px; left: -13px; font-size: 20px; z-index: 5; }
.board::after { content: "💗"; position: absolute; bottom: -15px; right: -11px; font-size: 18px; z-index: 5; }
.board.shudder { animation: shudder .5s; }
@keyframes shudder { 20% { transform: translateX(-7px); } 40% { transform: translateX(6px); } 60% { transform: translateX(-4px); } 80% { transform: translateX(3px); } }

/* 底画（箱底的旧画）：格纸 + 像素珠，随揭示增饱和 */
.cells { display: grid; gap: 1px; background: var(--grid); }
.cell { background: var(--canvas); position: relative; }
.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);
}
.cell.diamond::after {
  content: ""; position: absolute; left: 20%; top: 18%;
  width: 16%; height: 16%; border-radius: 35%; background: rgba(255, 255, 255, .9);
}
.cell.diamond.shine::before { animation: beadShine .6s ease-out; }
@keyframes beadShine { 35% { filter: brightness(1.45) saturate(1.35); transform: scale(1.22); } }
/* 未揭示时底画蒙一层灰调，配对越多越鲜活 */
.art-veil { filter: saturate(.35) brightness(1.05); transition: filter 1.2s; }

/* ---------- 贴纸卡（堆叠的贴纸） ---------- */
.pile { position: absolute; inset: 0; z-index: 10; }
.stk {
  position: absolute; left: var(--x); top: var(--y);
  width: var(--stk); height: var(--stk);
  border-radius: 22%;
  background: #fff;
  border: 2px solid var(--cd);
  box-shadow: 0 4px 10px rgba(107, 85, 96, .28), 0 0 0 3.5px #fff;  /* 贴纸白边 */
  display: grid; place-items: center;
  transform: rotate(var(--rot));
  transition: transform .22s cubic-bezier(.34, 1.3, .64, 1), filter .3s, box-shadow .3s, opacity .3s;
}
.stk .motif { display: grid; }
/* 被压住：按下去的样子 */
.stk.covered {
  filter: brightness(.8) saturate(.6);
  box-shadow: none;
  transform: rotate(var(--rot)) translateY(3px) scale(.97);
}
.stk.covered .motif { filter: brightness(.9); }
/* 可点：浮起 */
.stk.free .motif { filter: none; }
/* 选中：抬起来 + 描边 */
.stk.sel {
  transform: rotate(calc(var(--rot) * .4)) translateY(-7px) scale(1.08);
  box-shadow: 0 12px 20px rgba(107, 85, 96, .3), 0 0 0 3.5px #fff, 0 0 0 7px var(--accent);
  z-index: 200;
}
.stk.sel .motif { animation: selWiggle 1s ease-in-out infinite; }
@keyframes selWiggle { 50% { transform: rotate(4deg) scale(1.05); } }
/* 点被压的卡：摇头 */
.stk.deny { animation: denyShake .35s; }
@keyframes denyShake { 25% { margin-left: -4px; } 75% { margin-left: 4px; } }
/* 配对不上的卡：小扭一下 */
.stk.wrong { animation: wrongWiggle .4s; }
@keyframes wrongWiggle { 30% { transform: rotate(calc(var(--rot) + 7deg)); } 70% { transform: rotate(calc(var(--rot) - 7deg)); } }
/* 配对飞走：JS 设 --fx/--fy 位移到中点 */
.stk.fly {
  transform: translate(var(--fx), var(--fy)) rotate(calc(var(--rot) + 200deg)) scale(1.35);
  opacity: 0; pointer-events: none;
  box-shadow: 0 12px 24px rgba(221, 111, 146, .35), 0 0 0 3.5px #fff;
}
/* 被解放：弹一下亮一下 */
.stk.unlocked { animation: unlockPop .55s cubic-bezier(.34, 1.5, .64, 1); }
@keyframes unlockPop {
  40% { transform: rotate(var(--rot)) translateY(-6px) scale(1.09); filter: brightness(1.12); }
}
/* 提示闪烁 */
.stk.hint-flash { animation: hintFlash .6s 3; }
@keyframes hintFlash { 50% { box-shadow: 0 4px 10px rgba(107,85,96,.28), 0 0 0 3.5px #fff, 0 0 0 7px #f2c94c; transform: rotate(var(--rot)) scale(1.07); } }

.board-tip { text-align: center; color: var(--ink2); font-size: 13px; padding: 8px 0 2px; }
.pair-flash {
  position: absolute; left: 50%; top: 44%; transform: translate(-50%, -50%);
  font-size: 22px; font-weight: 800; color: var(--accent2); pointer-events: none;
  text-shadow: 0 2px 0 #fff; animation: pairFlash .8s ease-out forwards; z-index: 210;
}
@keyframes pairFlash { 0% { opacity: 0; transform: translate(-50%, -30%) scale(.6); } 25% { opacity: 1; } 100% { opacity: 0; transform: translate(-50%, -110%) scale(1.1); } }

/* ---------- 结果页 ---------- */
#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; }

/* ---------- 弹层 ---------- */
.modal-mask { position: fixed; inset: 0; background: rgba(107, 85, 96, .38);
  display: flex; align-items: center; justify-content: center; z-index: 300; }
.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); }

/* ---------- 过关彩带 ---------- */
.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 320; 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); } }

/* ---------- 教学：歪斜便签卡 ---------- */
.tut-bubble {
  position: fixed; left: 50%; bottom: 90px;
  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: 250; 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; }

/* 轻提示 toast */
.toast {
  position: fixed; left: 50%; bottom: 150px; transform: translateX(-50%);
  background: #fff; color: var(--ink); font-size: 15px;
  padding: 10px 18px; border-radius: 999px; border: 1.5px solid #f6dbe4;
  box-shadow: var(--card); z-index: 260; animation: toastIn .3s;
}
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 8px); } }

@media (max-height: 700px) {
  .game-title { font-size: 38px; margin-top: 1vh; }
  .frame { padding: 8px; }
}
