@font-face { font-family: 'Fredoka'; src: url(fonts/fredoka-600.woff2) format('woff2'); font-weight: 600; font-display: swap; }
@font-face { font-family: 'Fredoka'; src: url(fonts/fredoka-700.woff2) format('woff2'); font-weight: 700; font-display: swap; }

:root {
  --bg0: #050c09; --bg1: #0b1f17; --jade: #1fa45c; --jade-d: #0d6a3a; --jade-l: #5fe39a;
  --gold: #f6c548; --gold-d: #b9780f; --gold-l: #fff0b3; --ivory: #fbf6e8; --ink: #13261d;
  --red: #d8443c; --txt: #f4f1e6; --mute: rgba(244, 241, 230, 0.62);
  --panel: linear-gradient(180deg, #173d2c 0%, #0d281c 100%);
  --sat: env(safe-area-inset-top, 0px); --sab: env(safe-area-inset-bottom, 0px);
  --font: 'Fredoka', 'PingFang SC', 'Hiragino Sans', 'Noto Sans CJK SC', 'Microsoft YaHei', system-ui, sans-serif;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--bg0); color: var(--txt); font-family: var(--font); font-weight: 600;
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; touch-action: none; overscroll-behavior: none; }
button { font: inherit; color: inherit; border: 0; background: none; padding: 0; cursor: pointer; touch-action: manipulation; }
#app { position: fixed; inset: 0; overflow: hidden; }
.ic { width: 24px; height: 24px; display: block; }

/* —— 背景：深翡翠色 + 柔光斑 —— */
#bg { position: absolute; inset: 0; background: radial-gradient(120% 70% at 50% 38%, #163a2b 0%, #0a1d15 45%, #040a07 100%); overflow: hidden; }
#bg .glow { position: absolute; left: 50%; top: 44%; width: 130vmax; height: 130vmax; transform: translate(-50%, -50%);
  background: radial-gradient(circle, rgba(64, 200, 130, 0.16) 0%, rgba(64, 200, 130, 0) 55%); }
#bg .bokeh { position: absolute; border-radius: 50%; filter: blur(30px); opacity: .45; animation: drift 18s ease-in-out infinite alternate; }
#bg .b1 { width: 46vw; height: 46vw; left: -12vw; top: 8%; background: rgba(246, 197, 72, .16); }
#bg .b2 { width: 60vw; height: 60vw; right: -24vw; top: 34%; background: rgba(60, 190, 120, .14); animation-duration: 24s; }
#bg .b3 { width: 40vw; height: 40vw; left: 20vw; bottom: -8vw; background: rgba(216, 68, 60, .10); animation-duration: 30s; }
@keyframes drift { to { transform: translate(6vw, -4vh) scale(1.15); } }
#gl { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }

.screen { position: absolute; inset: 0; pointer-events: none; opacity: 0; transition: opacity .35s; }
.screen.on { opacity: 1; }
.screen.on > * { pointer-events: auto; }
.screen.on > .goal, .screen.on > .toast, .screen.on > .logo { pointer-events: none; }

.topbar { position: absolute; left: 0; right: 0; top: calc(var(--sat) + 10px); padding: 0 14px; display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.round { width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center; color: var(--ivory);
  background: linear-gradient(180deg, rgba(255,255,255,.16), rgba(255,255,255,.04)); box-shadow: inset 0 0 0 1.5px rgba(255,255,255,.18), 0 4px 12px rgba(0,0,0,.35);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); transition: transform .12s; }
.round:active { transform: scale(.92); }
.pill { height: 38px; padding: 0 14px 0 6px; border-radius: 19px; display: flex; align-items: center; gap: 7px; font-size: 18px; letter-spacing: .3px;
  background: rgba(0, 0, 0, .38); box-shadow: inset 0 0 0 1.5px rgba(246, 197, 72, .35); font-variant-numeric: tabular-nums; }
.coin { width: 28px; height: 28px; flex: none; filter: drop-shadow(0 2px 2px rgba(0,0,0,.35)); }

/* —— 按钮 —— */
.btn { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 54px; padding: 0 26px; border-radius: 18px;
  font-size: 20px; font-weight: 700; letter-spacing: .4px; transition: transform .12s, filter .12s; }
.btn:active { transform: scale(.95) translateY(2px); filter: brightness(.95); }
.btn.gold { color: #4a2a00; background: linear-gradient(180deg, #ffe58a 0%, #f6c548 45%, #e0a124 100%);
  box-shadow: inset 0 2px 0 rgba(255,255,255,.7), inset 0 -4px 0 rgba(150, 90, 0, .45), 0 6px 0 #8b5a07, 0 12px 24px rgba(0,0,0,.45); text-shadow: 0 1px 0 rgba(255,255,255,.5); }
.btn.jade { color: #fff; background: linear-gradient(180deg, #4fdc8e 0%, #1fa45c 50%, #13803f 100%);
  box-shadow: inset 0 2px 0 rgba(255,255,255,.45), inset 0 -4px 0 rgba(0, 60, 25, .4), 0 5px 0 #0a5228, 0 10px 20px rgba(0,0,0,.4); text-shadow: 0 1px 1px rgba(0,0,0,.3); }
.btn.ghost { min-height: 46px; font-size: 17px; color: var(--ivory); background: rgba(255,255,255,.08); box-shadow: inset 0 0 0 1.5px rgba(255,255,255,.2); }
.btn.big { min-height: 72px; width: min(76vw, 320px); border-radius: 24px; font-size: 26px; }
.btn .sub { font-size: 14px; font-weight: 600; opacity: .75; margin-top: 1px; }
.btn .ic { width: 22px; height: 22px; }
.btn.row { flex-direction: row; gap: 8px; }

/* —— 首页 —— */
.logo { position: absolute; left: 0; right: 0; top: calc(var(--sat) + 70px); display: flex; flex-direction: column; align-items: center; }
.logo .tiles { display: flex; gap: 4px; margin-bottom: 4px; }
.logo .tiles canvas { width: 34px; height: 44px; filter: drop-shadow(0 4px 6px rgba(0,0,0,.45)); }
.logo .tiles canvas:nth-child(1) { transform: rotate(-12deg) translateY(4px); }
.logo .tiles canvas:nth-child(3) { transform: rotate(12deg) translateY(4px); }
.logo h1 { margin: 0; font-size: 50px; line-height: 1; font-weight: 700; letter-spacing: 1px; text-align: center;
  background: linear-gradient(180deg, #fff6cf 0%, #f6c548 48%, #c98410 100%); -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 3px 0 #6b3d00) drop-shadow(0 8px 14px rgba(0,0,0,.55)); }
.logo h1 small { display: block; font-size: 24px; letter-spacing: 6px; margin-bottom: 2px; }
.logo p { margin: 8px 0 0; font-size: 14px; letter-spacing: 2px; color: var(--mute); }
.home-bottom { position: absolute; left: 0; right: 0; bottom: calc(var(--sab) + 26px); display: flex; flex-direction: column; align-items: center; gap: 14px; }
.home-stars { display: flex; align-items: center; gap: 6px; font-size: 16px; color: var(--gold-l); }
.home-stars .ic { width: 18px; height: 18px; color: var(--gold); }

/* —— 局内 HUD —— */
.lvl { flex: 1; text-align: center; font-size: 22px; font-weight: 700; text-shadow: 0 2px 6px rgba(0,0,0,.6); display: flex; flex-direction: column; align-items: center; line-height: 1.1; }
.lvl em { font-style: normal; font-size: 12px; letter-spacing: 1px; padding: 1px 8px; border-radius: 8px; margin-top: 3px; display: none; }
.lvl em.hard { display: inline-block; background: var(--red); color: #fff; }
.lvl em.easy { display: inline-block; background: var(--jade); color: #fff; }
.goal { position: absolute; left: 50%; transform: translateX(-50%); top: calc(var(--sat) + 66px); width: min(88vw, 380px); padding: 8px 14px 10px; border-radius: 16px;
  background: rgba(0,0,0,.35); box-shadow: inset 0 0 0 1px rgba(255,255,255,.1); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
.goal-row { display: flex; align-items: baseline; gap: 8px; font-size: 14px; color: var(--mute); }
.goal-row b { font-size: 22px; color: var(--ivory); font-variant-numeric: tabular-nums; }
.goal-row .goal-txt { margin-left: auto; color: var(--gold-l); }
.bar { position: relative; height: 10px; margin-top: 6px; border-radius: 5px; background: rgba(255,255,255,.12); overflow: visible; }
.bar i { position: absolute; left: 0; top: 0; bottom: 0; width: 0; border-radius: 5px; background: linear-gradient(90deg, #1fa45c, #5fe39a); box-shadow: 0 0 10px rgba(95,227,154,.6); transition: width .35s cubic-bezier(.2,.8,.2,1); }
.bar s { position: absolute; top: 50%; width: 16px; height: 16px; margin: -8px 0 0 -8px; text-decoration: none;
  background: no-repeat center/contain url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='m12 2.8 2.8 5.8 6.3.9-4.6 4.4 1.1 6.3L12 17.2 6.4 20.2l1.1-6.3L2.9 9.5l6.3-.9z' fill='%23555' stroke='%23222' stroke-width='1.5'/%3E%3C/svg%3E"); transition: transform .3s; }
.bar s.on { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='m12 2.8 2.8 5.8 6.3.9-4.6 4.4 1.1 6.3L12 17.2 6.4 20.2l1.1-6.3L2.9 9.5l6.3-.9z' fill='%23f6c548' stroke='%238a5208' stroke-width='1.5'/%3E%3C/svg%3E"); transform: scale(1.25); }

.boost { position: absolute; left: 0; right: 0; bottom: calc(var(--sab) + 14px); display: flex; justify-content: center; gap: 14px; padding: 0 12px; }
.bst { position: relative; width: 70px; display: flex; flex-direction: column; align-items: center; gap: 5px; font-size: 13px; color: var(--ivory); transition: transform .12s; }
.bst:active { transform: scale(.92); }
.bst .face { width: 62px; height: 62px; border-radius: 20px; display: grid; place-items: center; color: #fff;
  background: linear-gradient(180deg, #2fb86c 0%, #148347 60%, #0e6a38 100%); box-shadow: inset 0 2px 0 rgba(255,255,255,.4), inset 0 -3px 0 rgba(0,0,0,.25), 0 4px 0 #084a26, 0 8px 16px rgba(0,0,0,.4); }
.bst .face .ic { width: 32px; height: 32px; filter: drop-shadow(0 2px 1px rgba(0,0,0,.3)); }
.bst.on .face { background: linear-gradient(180deg, #ffe58a, #f6c548 50%, #d9951b); color: #5a3300; box-shadow: inset 0 2px 0 rgba(255,255,255,.6), 0 4px 0 #8b5a07, 0 0 22px rgba(246,197,72,.8); }
.bst .n { position: absolute; top: -6px; right: -2px; min-width: 26px; height: 26px; padding: 0 6px; border-radius: 13px; display: flex; align-items: center; justify-content: center; gap: 2px;
  background: #e2463d; color: #fff; font-size: 15px; box-shadow: 0 0 0 2.5px #0b1f17, 0 2px 4px rgba(0,0,0,.4); }
.bst .n.price { background: #22180a; color: var(--gold-l); font-size: 13px; padding-left: 2px; }
.bst .n.price .coin { width: 18px; height: 18px; }
.bst.off { opacity: .45; }

.toast { position: absolute; left: 50%; top: 44%; transform: translate(-50%, -50%) scale(.9); padding: 10px 18px; border-radius: 14px; font-size: 17px; text-align: center; max-width: 86vw;
  background: rgba(10, 25, 18, .86); box-shadow: inset 0 0 0 1.5px rgba(246,197,72,.4), 0 8px 24px rgba(0,0,0,.5); opacity: 0; transition: opacity .25s, transform .25s; }
.toast.on { opacity: 1; transform: translate(-50%, -50%) scale(1); }

/* —— 飘字 —— */
#fx { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.pop { position: absolute; transform: translate(-50%, -50%); font-weight: 700; white-space: nowrap; animation: pop 1.1s cubic-bezier(.2,.9,.3,1) forwards; text-align: center; }
.pop.praise { font-size: 34px; background: linear-gradient(180deg, #fff6cf, #f6c548 55%, #d48b12); -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 2px 0 #6b3d00) drop-shadow(0 4px 8px rgba(0,0,0,.6)); }
.pop.count { font-size: 22px; color: #fff; text-shadow: 0 2px 0 rgba(0,0,0,.5), 0 0 12px rgba(95,227,154,.8); }
.pop.ice { font-size: 18px; color: #bfe8ff; text-shadow: 0 2px 4px rgba(0,0,0,.6); }
@keyframes pop { 0% { opacity: 0; transform: translate(-50%, -30%) scale(.5); } 18% { opacity: 1; transform: translate(-50%, -60%) scale(1.15); } 30% { transform: translate(-50%, -65%) scale(1); } 100% { opacity: 0; transform: translate(-50%, -150%) scale(1); } }
.flycoin { position: absolute; width: 26px; height: 26px; margin: -13px 0 0 -13px; transition: left .7s cubic-bezier(.5,0,.8,.4), top .7s cubic-bezier(.2,.6,.4,1), transform .7s; }
.flycoin .coin { width: 26px; height: 26px; }

/* —— 教学 —— */
#tut { position: absolute; inset: 0; pointer-events: none; }
.tut-bubble { position: absolute; left: 50%; transform: translateX(-50%); width: min(84vw, 340px); padding: 12px 16px; border-radius: 16px; text-align: center; font-size: 17px; line-height: 1.35;
  color: var(--ink); background: var(--ivory); box-shadow: 0 0 0 3px var(--gold), 0 10px 26px rgba(0,0,0,.5); animation: bob 1.8s ease-in-out infinite; }
.tut-bubble.tap { pointer-events: auto; }
.tut-bubble small { display: block; margin-top: 4px; font-size: 13px; color: #6b6a5c; }
@keyframes bob { 50% { transform: translateX(-50%) translateY(-4px); } }
.hand { position: absolute; width: 64px; height: 64px; margin: -8px 0 0 -20px; filter: drop-shadow(0 6px 8px rgba(0,0,0,.5)); }
.hand.tap { animation: tap 1.1s ease-in-out infinite; }
.hand.swipe { animation: swipe 1.8s ease-in-out infinite; }
@keyframes tap { 0%, 100% { transform: translate(0, 0) scale(1); } 45% { transform: translate(-4px, -6px) scale(1.06); } 60% { transform: translate(0, 0) scale(.94); } }
@keyframes swipe { 0% { transform: translateX(-70px); opacity: 0; } 15% { opacity: 1; } 70% { transform: translateX(70px); opacity: 1; } 100% { transform: translateX(70px); opacity: 0; } }
.ring { position: absolute; width: 70px; height: 70px; margin: -35px 0 0 -35px; border-radius: 50%; border: 3px solid var(--gold); animation: ring 1.1s ease-out infinite; }
@keyframes ring { 0% { transform: scale(.4); opacity: 1; } 100% { transform: scale(1.4); opacity: 0; } }

/* —— 弹窗 —— */
#modal { position: absolute; inset: 0; display: none; align-items: center; justify-content: center; background: rgba(2, 8, 5, .62); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px); padding: calc(var(--sat) + 16px) 16px calc(var(--sab) + 16px); }
#modal.on { display: flex; animation: fade .2s; }
@keyframes fade { from { opacity: 0; } }
.panel { position: relative; width: min(92vw, 380px); max-height: 100%; display: flex; flex-direction: column; border-radius: 26px; padding: 22px 20px 20px; background: var(--panel);
  box-shadow: inset 0 0 0 2px rgba(246,197,72,.55), inset 0 0 0 5px rgba(0,0,0,.25), 0 18px 50px rgba(0,0,0,.6); animation: rise .32s cubic-bezier(.2,1.2,.4,1); }
@keyframes rise { from { transform: translateY(30px) scale(.9); opacity: 0; } }
.panel h2 { margin: 0 0 12px; text-align: center; font-size: 28px; font-weight: 700; color: var(--gold-l); text-shadow: 0 2px 0 rgba(0,0,0,.4); }
.panel p { margin: 0 0 14px; text-align: center; font-size: 16px; line-height: 1.45; color: var(--mute); white-space: pre-line; }
.panel .x { position: absolute; top: 10px; right: 10px; width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; color: var(--mute); background: rgba(255,255,255,.07); }
.panel .acts { display: flex; flex-direction: column; gap: 12px; margin-top: 6px; }
.panel .acts.h { flex-direction: row; }
.panel .acts.h .btn { flex: 1; padding: 0 10px; }
.stars { display: flex; justify-content: center; align-items: flex-end; gap: 6px; margin: 4px 0 14px; }
.stars .st { width: 64px; height: 64px; color: rgba(0,0,0,.35); filter: drop-shadow(0 2px 0 rgba(0,0,0,.3)); }
.stars .st:nth-child(2) { width: 82px; height: 82px; margin-bottom: 10px; }
.stars .st .ic { width: 100%; height: 100%; stroke: rgba(0,0,0,.4); stroke-width: 1; }
.stars .st.on { color: var(--gold); animation: starIn .45s cubic-bezier(.2,1.6,.4,1) both; filter: drop-shadow(0 0 12px rgba(246,197,72,.8)) drop-shadow(0 3px 0 #8a5208); }
@keyframes starIn { from { transform: scale(2.2) rotate(-30deg); opacity: 0; } }
.reward { display: flex; justify-content: center; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; }
.reward span { display: flex; align-items: center; gap: 6px; padding: 6px 14px 6px 6px; border-radius: 16px; background: rgba(0,0,0,.3); font-size: 18px; }
.reward span .ic { width: 26px; height: 26px; padding: 3px; border-radius: 8px; background: var(--jade); }
.rescue { display: flex; justify-content: center; gap: 12px; margin: 4px 0 18px; }
.rescue .bst .face { width: 58px; height: 58px; }

.set-list { display: flex; flex-direction: column; gap: 10px; margin-bottom: 14px; overflow-y: auto; }
.set-row { display: flex; align-items: center; gap: 12px; min-height: 52px; padding: 0 14px; border-radius: 14px; background: rgba(0,0,0,.25); font-size: 17px; width: 100%; text-align: left; }
.set-row .ic { color: var(--gold); flex: none; }
.set-row .val { margin-left: auto; color: var(--mute); font-size: 15px; }
.tog { margin-left: auto; width: 52px; height: 30px; border-radius: 15px; background: rgba(255,255,255,.18); position: relative; transition: background .2s; flex: none; }
.tog::after { content: ''; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; transition: transform .2s; box-shadow: 0 2px 4px rgba(0,0,0,.3); }
.tog.on { background: var(--jade); }
.tog.on::after { transform: translateX(22px); }
.ver { text-align: center; font-size: 12px; color: rgba(255,255,255,.35); }

/* —— 关卡选择 —— */
.panel.full { height: 100%; width: min(96vw, 460px); padding: 18px 12px 14px; }
.lv-grid { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; touch-action: pan-y; display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px 8px; padding: 6px 6px 20px; align-content: start; }
.lv { position: relative; aspect-ratio: .78; border-radius: 12px; display: flex; flex-direction: column; align-items: center; justify-content: center; color: var(--ink); font-size: 22px; font-weight: 700;
  background: linear-gradient(180deg, #fffdf6, #ece4cf); box-shadow: inset 0 -3px 0 rgba(0,0,0,.08), 0 5px 0 #0e6b3b, 0 7px 10px rgba(0,0,0,.4); }
.lv.cur { box-shadow: 0 0 0 3px var(--gold), 0 5px 0 #0e6b3b, 0 0 18px rgba(246,197,72,.7); }
.lv.hard { color: #b3261e; }
.lv.lock { background: linear-gradient(180deg, #2a4237, #1d3128); color: rgba(255,255,255,.3); box-shadow: 0 5px 0 #0c1f16; }
.lv.lock .ic { width: 22px; height: 22px; }
.lv .ss { display: flex; gap: 1px; margin-top: 2px; }
.lv .ss .ic { width: 13px; height: 13px; color: #cfc6ad; stroke: none; }
.lv .ss .ic.on { color: #e9a91d; }

#boot { position: absolute; inset: 0; display: grid; place-items: center; background: var(--bg0); transition: opacity .5s; z-index: 9; }
#boot.off { opacity: 0; pointer-events: none; }
.spin { width: 42px; height: 42px; border-radius: 50%; border: 4px solid rgba(255,255,255,.15); border-top-color: var(--gold); animation: sp 0.9s linear infinite; }
@keyframes sp { to { transform: rotate(360deg); } }

@media (max-height: 700px) {
  .logo { top: calc(var(--sat) + 56px); }
  .logo h1 { font-size: 42px; }
  .bst .face { width: 54px; height: 54px; border-radius: 17px; }
  .bst .face .ic { width: 28px; height: 28px; }
  .goal { top: calc(var(--sat) + 60px); }
}
