:root {
  color-scheme: light;
  --pink: #f24370;
  --pink-deep: #cf2e5c;
  --pink-soft: #ffdbe6;
  --paper: rgba(255, 255, 255, 0.92);
  --ink: #713448;
  --muted: #8b6f78;
  --line: rgba(235, 104, 143, 0.22);
  --shadow: 0 18px 48px rgba(204, 75, 112, 0.16);
}

* { box-sizing: border-box; }
html, body { width: 100%; height: 100%; margin: 0; overflow: hidden; }
body {
  font-family: "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  color: var(--ink);
  background: #fff5f7;
}
button, input, select { font: inherit; }
button { cursor: pointer; }
button:focus-visible, input:focus-visible, select:focus-visible { outline: 3px solid rgba(242, 67, 112, .3); outline-offset: 2px; }

.app-shell { width: 100vw; height: 100dvh; overflow: hidden; }
.screen {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: #fff3f7;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
}
.home-screen { background-image: url("./assets/images/欢迎页背景.jpg"); }
.game-screen, .history-screen { background-image: url("./assets/images/数字页背景.jpg"); }
.screen::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: .14;
  background: radial-gradient(circle at 50% 35%, rgba(255,255,255,.72), transparent 45%);
}

.curtain, .light-string { display: none; }
.curtain { position: absolute; top: 0; width: 25%; height: 54%; opacity: .72; filter: blur(.2px); }
.curtain-left { left: 0; background: linear-gradient(120deg, #f6b8ca 0 28%, #ffe5ed 45%, transparent 70%); clip-path: polygon(0 0,100% 0,57% 52%,36% 100%,0 85%); }
.curtain-right { right: 0; transform: scaleX(-1); background: linear-gradient(120deg, #f6b8ca 0 28%, #ffe5ed 45%, transparent 70%); clip-path: polygon(0 0,100% 0,57% 52%,36% 100%,0 85%); }
.light-string { position: absolute; inset: 2% 8% auto; height: 18%; border-top: 2px solid rgba(211,156,68,.22); border-radius: 50%; }
.light-string::before { content: "✦   ☆   ✦      ☆     ✦    ☆"; position: absolute; inset: -7px 0 auto; color: #e7b44d; letter-spacing: clamp(18px,4vw,62px); text-align: center; font-size: clamp(14px,1.8vw,26px); }

.page-doll { position: absolute; z-index: 2; display: block; object-fit: contain; pointer-events: none; }
.home-doll {
  left: calc(50vw - max(30.5vw, 54.3vh));
  bottom: calc(50vh - max(33vh, 18.55vw));
  width: auto;
  height: 48%;
  max-width: none;
  max-height: none;
}
.home-copy { position: absolute; z-index: 3; top: 28.5%; left: 20%; width: 60%; text-align: center; }
.title-art { position: relative; width: 100%; aspect-ratio: 2912 / 1344; overflow: hidden; }
.title-layer { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
.title-font { clip-path: inset(23% 7% 28% 7%); }
.home-title-art { width: 100%; height: 32vh; aspect-ratio: auto; margin-inline: auto; }
.home-title-art .title-layer { transform: translateY(-10%); }
.brand-title { margin: 0; color: var(--pink); font-family: "STKaiti", "KaiTi", serif; font-weight: 800; font-size: clamp(34px,4.5vw,76px); line-height: 1.08; text-shadow: 0 3px 0 #fff; }
.brand-title::after { content: ""; display: block; width: 72%; height: 2px; margin: .18em auto 0; background: linear-gradient(90deg, transparent, var(--pink), transparent); }
.title-bow { position: relative; display: inline-block; width: .78em; height: .68em; margin-left: .16em; vertical-align: .05em; transform: rotate(-5deg); }
.title-bow::before, .title-bow::after { content: ""; position: absolute; top: 9%; width: 47%; height: 48%; border: .08em solid #ef6087; background: linear-gradient(145deg,#ffd3df,#f06d92); box-shadow: inset 0 0 .1em #fff; }
.title-bow::before { right: 49%; border-radius: 70% 24% 70% 24%; transform: rotate(13deg); }
.title-bow::after { left: 49%; border-radius: 24% 70% 24% 70%; transform: rotate(-13deg); }
.title-bow i { position: absolute; z-index: 2; left: 42%; top: 24%; width: 19%; height: 19%; border-radius: 50%; background: #e74774; box-shadow: -.15em .25em 0 -.05em #f38caa, .15em .25em 0 -.05em #f38caa; }
.primary-button, .soft-button, .action-pill, .filter-button {
  border: 1px solid rgba(239,77,124,.25);
  border-radius: 999px;
  box-shadow: 0 8px 18px rgba(219,65,107,.16), inset 0 1px 0 #fff;
}
.primary-button { background: linear-gradient(180deg,#ff779a,#ed3f6e); color: #fff; font-weight: 800; }
.enter-button { min-width: min(370px,80%); margin-top: -2vh; padding: .72em 1.8em; font-size: clamp(22px,2.1vw,35px); transition: transform .16s ease, box-shadow .16s ease, filter .16s ease; }
.enter-button:hover {
  transform: scale(1.1);
  filter: brightness(1.05);
  box-shadow:
    0 0 0 4px rgba(255,255,255,.88),
    0 0 0 8px rgba(255,127,164,.22),
    0 0 32px 14px rgba(255,76,132,.42),
    0 14px 28px rgba(191,51,91,.24);
}
.soft-button { padding: 9px 16px; background: rgba(255,255,255,.83); color: var(--pink-deep); font-weight: 700; }
.danger-button { color: #a84261; border-color: rgba(168,66,97,.28); }
.danger-button:hover { background: #fff0f4; box-shadow: 0 0 18px rgba(226,76,119,.24); }
.small-button { padding: 11px 26px; font-size: clamp(14px,1.1vw,18px); }

.audio-dock { position: absolute; z-index: 9; display: flex; gap: 8px; }
.home-audio { right: 3.5%; bottom: 4%; }
.game-audio { right: 1.7%; top: 1.8%; }
.audio-icon { width: clamp(34px,3.2vw,50px); aspect-ratio: 1; border: 1px solid var(--line); border-radius: 50%; background: rgba(255,255,255,.91); color: var(--pink); box-shadow: 0 7px 18px rgba(196,76,111,.15); font-size: clamp(17px,1.5vw,25px); font-weight: 900; }

.game-screen { padding: clamp(10px,1.4vw,24px); }
.game-header { position: relative; z-index: 4; height: 17%; display: flex; align-items: flex-start; justify-content: center; }
.game-heading { width: 55%; text-align: center; }
.game-title-art { height: 14vh; aspect-ratio: auto; margin: -2.2vh auto -1vh; overflow: visible; }
.game-title-art .title-layer { transform: translateY(2%) scale(1.38); }
.compact-title { font-size: clamp(29px,3.5vw,58px); }
.round-progress { display: inline-block; margin: 1.2vh 0 0; padding: 6px 24px; border: 1px solid var(--line); border-radius: 999px; background: rgba(255,255,255,.86); font-size: clamp(13px,1.2vw,20px); font-weight: 700; }
.back-button { position: absolute; left: 0; top: 0; z-index: 5; }
.game-doll { left: 2%; bottom: 4%; width: 17%; max-height: 69%; }
.board-wrap { position: absolute; z-index: 3; left: 18%; top: 20%; width: 64%; height: 72%; padding: clamp(8px,1vw,17px); border: 1px solid rgba(255,255,255,.95); border-radius: 22px; background: rgba(255,255,255,.58); box-shadow: var(--shadow); }
.number-board { width: 100%; height: 100%; display: grid; grid-template-columns: repeat(10,minmax(0,1fr)); grid-template-rows: repeat(5,minmax(0,1fr)); gap: clamp(4px,.65vw,11px); }
.number-tile { min-width: 0; min-height: 0; border: 1px solid var(--line); border-radius: clamp(7px,.75vw,13px); background: rgba(255,255,255,.94); color: var(--pink); font-weight: 700; font-size: clamp(15px,1.75vw,30px); transition: transform .16s ease, background .16s ease; }
.number-tile:not(.selected):hover {
  position: relative;
  z-index: 5;
  transform: translateY(-4px) scale(1.13);
  background: #fff;
  border-color: rgba(242,67,112,.58);
  box-shadow:
    0 0 0 4px rgba(255,255,255,.88),
    0 0 0 8px rgba(255,127,164,.2),
    0 0 26px 12px rgba(255,94,140,.32),
    0 12px 24px rgba(191,51,91,.2);
}
.number-tile.selected { cursor: default; color: #7d7779; background: linear-gradient(180deg,#e7e7e7,#d6d6d6); border-color: #ddd; box-shadow: inset 0 1px 6px rgba(0,0,0,.08); }
.action-dock { position: absolute; z-index: 7; right: 1.7%; top: 33%; width: 11.5%; display: grid; gap: 10px; }
.action-pill { min-height: clamp(42px,4vw,58px); padding: 8px 12px; background: rgba(255,255,255,.91); color: var(--ink); font-size: clamp(12px,1vw,16px); font-weight: 800; white-space: nowrap; }
.action-pill span { color: var(--pink); margin-right: 7px; }
.action-pill:disabled { opacity: .45; cursor: not-allowed; }

dialog { border: 0; color: var(--ink); }
dialog::backdrop { background: rgba(65,37,47,.65); }
.reveal-dialog { width: min(440px,86vw); min-height: min(68vh,560px); padding: 92px 34px 30px; overflow: visible; text-align: center; border-radius: 34px; background: linear-gradient(180deg,#fff,#fff7f9); box-shadow: 0 28px 75px rgba(83,30,49,.35); }
.reveal-doll { position: absolute; z-index: 4; left: -48%; bottom: -5%; width: 68%; max-height: 76%; object-fit: contain; pointer-events: none; }
.reveal-dialog::before, .reveal-dialog::after { content: "✦  ·  ✧  ·  ✦"; position: absolute; left: 0; right: 0; color: #f7b64d; font-size: 20px; letter-spacing: 9px; pointer-events: none; }
.reveal-dialog::before { top: 90px; } .reveal-dialog::after { bottom: 92px; }
.reveal-ribbon { position: absolute; z-index: 3; top: -25px; left: 9%; right: 9%; padding: 17px; border-radius: 18px 18px 35px 35px; background: linear-gradient(180deg,#ff9cb5,#e83e6d); color: #fff; font: 800 clamp(23px,2.3vw,35px) "STKaiti","KaiTi",serif; box-shadow: 0 9px 18px rgba(199,54,95,.28), inset 0 2px 0 rgba(255,255,255,.6); }
.reveal-ribbon::before, .reveal-ribbon::after { content: ""; position: absolute; top: 16px; width: 42px; height: 56px; z-index: -1; background: linear-gradient(145deg,#f77d9f,#d93362); }
.reveal-ribbon::before { left: -27px; clip-path: polygon(0 0,100% 14%,76% 50%,100% 88%,0 100%,23% 50%); }
.reveal-ribbon::after { right: -27px; transform: scaleX(-1); clip-path: polygon(0 0,100% 14%,76% 50%,100% 88%,0 100%,23% 50%); }
.reveal-balloons { position: absolute; z-index: 2; top: 105px; width: 72px; height: 150px; pointer-events: none; }
.balloons-left { left: -32px; } .balloons-right { right: -32px; transform: scaleX(-1); }
.reveal-balloons i { position: absolute; width: 42px; height: 54px; border-radius: 50% 50% 46% 46%; background: radial-gradient(circle at 35% 27%,#fff 0 8%,#ffb5c9 10%,#ee5c87 78%); box-shadow: 0 5px 13px rgba(215,67,109,.16); }
.reveal-balloons i::after { content: ""; position: absolute; top: 51px; left: 21px; width: 1px; height: 65px; background: rgba(219,95,130,.5); transform: rotate(-8deg); }
.reveal-balloons i:nth-child(2) { left: 29px; top: 31px; transform: scale(.82); background: radial-gradient(circle at 35% 27%,#fff 0 8%,#fce4b9 10%,#efbc62 78%); }
.reveal-number { margin-top: 40px; color: var(--pink); font-size: clamp(42px,4.4vw,72px); font-weight: 800; }
.reveal-text { margin: 34px 0 76px; color: var(--pink-deep); font-size: clamp(38px,4.2vw,62px); font-weight: 900; line-height: 1.2; overflow-wrap: anywhere; }
.reveal-dialog .primary-button { position: relative; z-index: 6; transition: transform .16s ease, box-shadow .16s ease, filter .16s ease; }
.reveal-dialog .primary-button:hover {
  transform: scale(1.14);
  filter: brightness(1.05);
  box-shadow:
    0 0 0 4px rgba(255,255,255,.88),
    0 0 0 8px rgba(255,127,164,.22),
    0 0 28px 12px rgba(255,76,132,.42),
    0 12px 24px rgba(191,51,91,.24);
}

.add-dialog { width: min(390px,90vw); padding: 25px; border-radius: 24px; background: #fff9fb; box-shadow: var(--shadow); }
.dialog-header { display: flex; justify-content: space-between; align-items: center; }
.dialog-header h2 { margin: 0; color: var(--pink-deep); }
.icon-close, #close-audio { border: 0; background: transparent; color: var(--pink); font-size: 25px; }
.add-dialog label { display: grid; gap: 7px; margin-top: 18px; font-weight: 700; }
.add-dialog input, .add-dialog select { width: 100%; border: 1px solid var(--line); border-radius: 11px; padding: 12px; background: #fff; color: var(--ink); }
.add-dialog fieldset { display: flex; flex-wrap: nowrap; gap: 26px; margin: 18px 0 0; border: 0; padding: 0; }
.add-dialog fieldset label { display: inline-flex; flex: 0 0 auto; gap: 6px; align-items: center; margin: 0; white-space: nowrap; writing-mode: horizontal-tb; }
.form-note { color: var(--muted); font-size: 13px; line-height: 1.6; }

.audio-popover { position: fixed; z-index: 30; right: 2%; top: 8%; width: min(250px,80vw); padding: 13px; border: 1px solid var(--line); border-radius: 16px; background: rgba(255,255,255,.97); box-shadow: var(--shadow); }
.popover-head, .audio-row { display: flex; align-items: center; gap: 9px; }
.popover-head { justify-content: space-between; margin-bottom: 9px; }
.audio-row input { min-width: 0; flex: 1; accent-color: var(--pink); }
.tiny-toggle { border: 0; border-radius: 999px; padding: 5px 10px; background: var(--pink); color: #fff; font-weight: 800; }
.audio-row output { width: 42px; font-size: 12px; }

.history-screen { padding: clamp(13px,2vw,32px) 5%; }
.history-header { position: relative; z-index: 4; display: flex; justify-content: space-between; align-items: center; height: 12%; }
.history-title { font-size: clamp(31px,3.5vw,58px); }
.history-header p { margin: 5px 0 0; text-align: center; font-weight: 700; }
.history-actions { display: flex; gap: 9px; }
.round-filter { position: relative; z-index: 4; display: flex; width: fit-content; margin: 1vh 0; padding: 3px; border-radius: 999px; background: #fff; box-shadow: 0 5px 15px rgba(202,87,120,.12); }
.filter-button { border: 0; box-shadow: none; padding: 8px 23px; background: transparent; color: var(--ink); }
.filter-button.active { background: var(--pink); color: #fff; }
.history-content { position: relative; z-index: 3; height: 78%; overflow: auto; padding: 16px; border: 1px solid var(--line); border-radius: 24px; background: rgba(255,255,255,.78); box-shadow: var(--shadow); }
.round-section + .round-section { margin-top: 20px; }
.round-section h2 { margin: 0 0 12px; color: var(--pink-deep); font-size: clamp(18px,1.6vw,27px); }
.record-grid { display: grid; grid-template-columns: repeat(5,minmax(0,1fr)); gap: 7px 12px; }
.record-row { display: grid; grid-template-columns: 36px 1fr; gap: 7px; align-items: center; min-height: 35px; padding: 5px 9px; border: 1px solid var(--line); border-radius: 8px; background: rgba(255,255,255,.8); font-size: clamp(11px,.82vw,14px); }
.record-number { color: var(--pink); font-weight: 900; }
.record-empty { color: #c8b9be; }
.history-doll { left: 18.5%; right: auto; top: .2%; bottom: auto; width: auto; height: 15%; max-width: none; max-height: none; opacity: .98; z-index: 4; }

.toast { position: fixed; z-index: 60; left: 50%; bottom: 24px; transform: translate(-50%,20px); opacity: 0; pointer-events: none; padding: 11px 18px; border-radius: 999px; background: #653747; color: #fff; transition: .2s; }
.toast.show { opacity: 1; transform: translate(-50%,0); }

@media (max-aspect-ratio: 4/3) {
  .home-copy { left: 20%; width: 60%; }
  .game-doll { width: 19%; }
  .board-wrap { left: 17.5%; width: 65%; }
  .action-dock { width: 12.5%; }
  .record-grid { grid-template-columns: repeat(4,minmax(0,1fr)); }
}
@media (max-width: 760px) {
  .home-copy { top: 16%; left: 6%; width: 88%; }
  .home-title-art { height: 27vh; }
  .home-title-art .title-layer { transform: translateY(-12%); }
  .home-doll { left: 2%; bottom: 13%; width: auto; height: 37%; }
  .enter-button { min-width: 78%; margin-top: -2.5vh; padding: .78em 1em; font-size: clamp(19px,5.8vw,25px); }
  .home-audio { right: 4%; bottom: 2.5%; }
  .audio-icon { width: 34px; font-size: 17px; }

  .game-screen { padding: 6px; }
  .game-header { height: 18%; }
  .game-heading { width: 72%; }
  .game-title-art { height: 10vh; margin: -.8vh auto -1.2vh; }
  .game-title-art .title-layer { transform: translateY(2%) scale(1.18); }
  .round-progress { margin-top: .6vh; padding: 4px 12px; font-size: 11px; }
  .back-button { padding: 7px 9px; font-size: 11px; }
  .game-audio { right: 1.5%; top: 1%; gap: 4px; }
  .board-wrap { left: 4%; top: 19%; width: 92%; height: 64%; padding: 6px; border-radius: 15px; }
  .number-board { grid-template-columns: repeat(5,minmax(0,1fr)); grid-template-rows: repeat(10,minmax(0,1fr)); gap: 3px; }
  .number-tile { border-radius: 6px; font-size: clamp(12px,3.7vw,16px); }
  .number-tile:not(.selected):hover { transform: translateY(-2px) scale(1.06); }
  .game-doll { left: 0; bottom: .5%; width: auto; height: 14%; }
  .action-dock { left: 2%; right: 2%; top: auto; bottom: 1.4%; width: 96%; grid-template-columns: repeat(4,minmax(0,1fr)); gap: 4px; }
  .action-pill { min-height: 36px; padding: 5px 2px; font-size: 10px; white-space: normal; line-height: 1.15; }
  .action-pill span { display: block; margin: 0 0 2px; }

  .reveal-dialog { width: 84vw; min-height: 58vh; padding: 76px 18px 24px; border-radius: 26px; }
  .reveal-ribbon { top: -19px; padding: 13px; font-size: 24px; }
  .reveal-dialog::before { top: 72px; }
  .reveal-dialog::after { bottom: 72px; }
  .reveal-balloons { top: 86px; transform: scale(.78); }
  .balloons-right { transform: scaleX(-1) scale(.78); }
  .reveal-number { margin-top: 34px; font-size: 44px; }
  .reveal-text { margin: 25px 0 60px; font-size: clamp(30px,9vw,42px); }
  .reveal-doll { left: -13%; bottom: -3%; width: 41%; max-height: 47%; }
  .add-dialog { width: 90vw; max-height: 90dvh; overflow-y: auto; padding: 20px; }

  .history-screen { padding: 8px 3%; }
  .history-header { height: 15%; align-items: flex-start; }
  .history-title { font-size: 29px; }
  .history-header p { margin-top: 2px; text-align: left; font-size: 11px; }
  .history-actions { width: 58%; display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 4px; }
  .history-actions button { min-width: 0; padding: 6px 3px; font-size: 10px; white-space: nowrap; }
  .history-doll { left: 31%; top: .3%; width: auto; height: 13.5%; }
  .round-filter { margin: .4vh 0; padding: 2px; }
  .filter-button { padding: 6px 14px; font-size: 11px; }
  .history-content { height: 78%; padding: 8px; border-radius: 16px; }
  .round-section + .round-section { margin-top: 12px; }
  .round-section h2 { margin-bottom: 7px; font-size: 15px; }
  .record-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .record-row { grid-template-columns: 25px 1fr; gap: 4px; min-height: 29px; padding: 4px 5px; font-size: 10px; }
  .toast { bottom: 52px; max-width: 88vw; text-align: center; font-size: 12px; }
}

@media (max-width: 380px), (max-height: 700px) and (max-width: 760px) {
  .home-copy { top: 12%; }
  .home-title-art { height: 24vh; }
  .home-doll { bottom: 12%; height: 35%; }
  .board-wrap { top: 18%; height: 63%; }
  .action-dock { bottom: 1%; }
  .action-pill { min-height: 33px; font-size: 9px; }
  .history-header { height: 16%; }
  .history-doll { height: 14.5%; }
  .history-content { height: 76%; }
}
@media (prefers-reduced-motion: reduce) { *,*::before,*::after { animation-duration: .01ms !important; transition-duration: .01ms !important; } }
