/* 叠云塔：全屏 3D + 毛玻璃界面 */
:root {
  --font: "PingFang SC", "HarmonyOS Sans SC", "MiSans", "Microsoft YaHei UI", system-ui, -apple-system, "Segoe UI", sans-serif;
  --ease: cubic-bezier(.2, .8, .2, 1);
  --sky1: #ffe6c9; --sky2: #a9d6ff;
  color-scheme: light dark;
}
[data-theme="light"] {
  --text: #1d2440; --muted: #5f6886; --panel: rgba(255, 255, 255, .72); --panel-solid: #fff; --line: rgba(29, 36, 64, .1);
  --btn: rgba(255, 255, 255, .8); --shadow: 0 20px 50px -22px rgba(40, 60, 120, .5); color-scheme: light;
}
[data-theme="dark"] {
  --text: #eef1ff; --muted: #a6aecb; --panel: rgba(20, 24, 48, .7); --panel-solid: #171c38; --line: rgba(255, 255, 255, .09);
  --btn: rgba(255, 255, 255, .1); --shadow: 0 20px 50px -20px rgba(0, 0, 0, .8); color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; overflow: hidden; overscroll-behavior: none; }
body { font-family: var(--font); color: var(--text); -webkit-tap-highlight-color: transparent; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
button { font: inherit; color: inherit; cursor: pointer; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid #7c8cff; outline-offset: 2px; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }

#stage { position: fixed; inset: 0; background: linear-gradient(to top, var(--sky1), var(--sky2)); touch-action: none; }
#gl { display: block; width: 100%; height: 100%; }

/* 按钮 */
.ibtn {
  width: 44px; height: 44px; border-radius: 14px; border: 1px solid var(--line); background: var(--panel);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); font-size: 18px; display: grid; place-items: center; box-shadow: var(--shadow);
  transition: transform .15s var(--ease);
}
.ibtn:active { transform: scale(.92); }
.big {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; width: 100%; min-height: 60px; border: 0; border-radius: 20px;
  color: #fff; background: linear-gradient(135deg, #5b8cff, #a35bff 60%, #ff7ab0); box-shadow: 0 14px 30px -12px rgba(110, 80, 255, .8);
  transition: transform .15s var(--ease), filter .2s;
}
.big b { font-size: 19px; letter-spacing: .06em; }
.big small { font-size: 12.5px; opacity: .85; }
.big:hover { filter: brightness(1.06); }
.big:active { transform: scale(.97); }
.big.alt { background: var(--panel); color: var(--text); border: 1px solid var(--line); box-shadow: var(--shadow); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); }
.btn { flex: 1; min-height: 44px; padding: 0 12px; border-radius: 14px; border: 1px solid var(--line); background: var(--btn); font-weight: 650; font-size: 14px; white-space: nowrap; }
.btn:active { transform: scale(.97); }
.btn.danger { color: #ef4d5f; }
.link { border: 0; background: none; color: var(--text); opacity: .85; font-weight: 650; padding: 10px; font-size: 15px; text-shadow: 0 1px 8px rgba(255, 255, 255, .3); }
[data-theme="dark"] .link { text-shadow: 0 1px 8px rgba(0, 0, 0, .5); }
.row { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.pill { font-size: 13px; padding: 4px 12px; border-radius: 99px; background: var(--panel); border: 1px solid var(--line); font-weight: 650; }

/* 页面层 */
.screen { position: fixed; inset: 0; z-index: 10; display: flex; flex-direction: column; padding: calc(14px + env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) calc(20px + env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left)); animation: fade .35s var(--ease); }
.screen.dim { z-index: 20; align-items: center; justify-content: center; background: rgba(10, 14, 35, .35); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
.screen.scroll { overflow-y: auto; background: linear-gradient(to bottom, color-mix(in srgb, var(--panel-solid) 55%, transparent), color-mix(in srgb, var(--panel-solid) 85%, transparent)); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); }
@keyframes fade { from { opacity: 0; } }
.panel {
  width: min(400px, 100%); padding: 24px 20px 18px; border-radius: 28px; background: var(--panel-solid); border: 1px solid var(--line);
  box-shadow: 0 30px 80px -24px rgba(0, 0, 0, .55); text-align: center; animation: pop .45s cubic-bezier(.2, 1.3, .4, 1);
}
@keyframes pop { from { opacity: 0; transform: translateY(20px) scale(.94); } }
.panel h2 { margin: 0 0 6px; font-size: 22px; }
.panel .big { margin-top: 14px; }

/* 首页 */
.home-top { display: flex; justify-content: flex-end; gap: 8px; }
.logo { margin-top: 6vh; text-align: center; pointer-events: none; }
.logo h1 {
  margin: 0; font-size: clamp(46px, 13vw, 76px); letter-spacing: .12em; font-weight: 900; line-height: 1.1;
  color: #fff; text-shadow: 0 4px 0 rgba(80, 70, 160, .35), 0 12px 30px rgba(60, 40, 140, .35);
}
.logo p { margin: 8px 0 0; font-weight: 650; color: #fff; opacity: .92; text-shadow: 0 1px 10px rgba(40, 30, 100, .4); }
.home-actions { margin-top: auto; width: min(380px, 100%); align-self: center; display: flex; flex-direction: column; gap: 10px; align-items: stretch; }
.home-actions .link { align-self: center; }

/* 选关 */
.bar { position: sticky; top: calc(-14px - env(safe-area-inset-top)); z-index: 2; display: flex; align-items: center; gap: 10px; padding: 4px 0 12px; }
.bar h2 { flex: 1; margin: 0; font-size: 20px; }
#worlds { display: grid; gap: 16px; width: min(760px, 100%); margin: 0 auto; padding-bottom: 20px; }
.world { border-radius: 24px; padding: 16px; color: #fff; position: relative; overflow: hidden; box-shadow: var(--shadow); }
.world::after { content: ""; position: absolute; inset: 0; background: linear-gradient(to bottom, transparent, rgba(0, 0, 0, .12)); pointer-events: none; }
.world.locked { filter: grayscale(.7) brightness(.85); }
.w-head { position: relative; z-index: 1; display: flex; align-items: baseline; gap: 10px; margin-bottom: 4px; }
.w-head b { font-size: 19px; text-shadow: 0 1px 6px rgba(0, 0, 0, .25); }
.w-head span { margin-left: auto; font-weight: 700; font-size: 13px; background: rgba(255, 255, 255, .25); padding: 2px 10px; border-radius: 99px; }
.w-desc { position: relative; z-index: 1; font-size: 13px; opacity: .95; margin-bottom: 12px; text-shadow: 0 1px 6px rgba(0, 0, 0, .25); }
.lv-grid { position: relative; z-index: 1; display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.lv {
  aspect-ratio: 1; border: 0; border-radius: 16px; background: rgba(255, 255, 255, .88); color: #1d2440; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 1px; box-shadow: 0 6px 14px -8px rgba(0, 0, 0, .5); transition: transform .15s var(--ease);
}
.lv:active { transform: scale(.93); }
.lv b { font-size: 18px; line-height: 1; }
.lv .st { font-size: 11px; letter-spacing: -1px; color: #f6b21a; }
.lv .st i { font-style: normal; color: #c9cede; }
.lv .md { font-size: 10px; line-height: 1; height: 11px; }
.lv:disabled { background: rgba(255, 255, 255, .28); color: rgba(255, 255, 255, .9); cursor: not-allowed; }
.lv.next { box-shadow: 0 0 0 3px #fff, 0 0 18px rgba(255, 255, 255, .8); animation: glow 1.6s ease-in-out infinite; }
@keyframes glow { 50% { box-shadow: 0 0 0 3px #fff, 0 0 4px rgba(255, 255, 255, .4); } }

/* HUD */
#hud { position: fixed; inset: 0; z-index: 5; pointer-events: none; padding: calc(12px + env(safe-area-inset-top)) max(14px, env(safe-area-inset-right)) 0 max(14px, env(safe-area-inset-left)); }
#hud button { pointer-events: auto; }
.hud-top { display: grid; grid-template-columns: 44px 1fr 44px; align-items: start; }
.hud-mid { text-align: center; color: #fff; text-shadow: 0 2px 14px rgba(30, 30, 90, .35); }
.score { font-size: clamp(54px, 15vw, 84px); font-weight: 900; line-height: 1; font-variant-numeric: tabular-nums; transition: transform .15s; }
.score.bump { transform: scale(1.12); }
.goal { font-size: 14px; font-weight: 750; opacity: .95; margin-top: 4px; }
.hud-right { display: flex; flex-direction: column; align-items: flex-end; color: #fff; font-weight: 800; text-shadow: 0 2px 10px rgba(30, 30, 90, .35); font-size: 14px; }
.mods { display: flex; justify-content: center; gap: 6px; margin-top: 10px; flex-wrap: wrap; }
.mods span { font-size: 12.5px; font-weight: 700; color: #fff; background: rgba(20, 20, 60, .28); padding: 3px 10px; border-radius: 99px; backdrop-filter: blur(6px); }
.timebar { position: relative; width: min(320px, 70vw); height: 10px; margin: 10px auto 0; border-radius: 99px; background: rgba(255, 255, 255, .3); overflow: hidden; }
.timebar i { position: absolute; inset: 0; transform-origin: left; background: linear-gradient(90deg, #4ff0b0, #ffe066); border-radius: inherit; }
.timebar.low i { background: linear-gradient(90deg, #ff5d6c, #ff9f5a); }
.timebar span { position: absolute; right: 0; top: 12px; font-size: 12px; font-weight: 800; color: #fff; }
.pop { position: absolute; left: 0; right: 0; top: 34%; text-align: center; color: #fff; font-weight: 900; font-size: 28px; letter-spacing: .08em; text-shadow: 0 3px 16px rgba(80, 40, 160, .55); opacity: 0; }
.pop.show { animation: popText .9s var(--ease); }
@keyframes popText { 0% { opacity: 0; transform: translateY(10px) scale(.8); } 20% { opacity: 1; transform: translateY(0) scale(1.08); } 70% { opacity: 1; } 100% { opacity: 0; transform: translateY(-24px); } }
.tap-hint { position: absolute; left: 50%; bottom: calc(40px + env(safe-area-inset-bottom)); transform: translateX(-50%); color: #fff; font-weight: 750; font-size: 15px; padding: 10px 18px; border-radius: 99px; background: rgba(20, 20, 60, .3); backdrop-filter: blur(6px); animation: breathe 1.6s ease-in-out infinite; white-space: nowrap; }
@keyframes breathe { 50% { opacity: .45; } }

/* 结果 */
.r-badge { font-size: 13px; font-weight: 800; color: #a35bff; letter-spacing: .1em; min-height: 18px; }
.stars { display: flex; justify-content: center; gap: 8px; margin: 10px 0 6px; font-size: 44px; line-height: 1; }
.stars span { color: #d6dae8; transform: scale(.4); opacity: 0; animation: starIn .5s cubic-bezier(.2, 1.6, .4, 1) forwards; }
.stars span.on { color: #ffc21a; text-shadow: 0 4px 16px rgba(255, 180, 20, .55); }
@keyframes starIn { to { transform: scale(1); opacity: 1; } }
.r-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 12px 0 2px; }
.r-stats div { background: var(--btn); border: 1px solid var(--line); border-radius: 16px; padding: 10px 4px; }
.r-stats b { display: block; font-size: 22px; line-height: 1.15; }
.r-stats small { color: var(--muted); font-size: 12px; }
.tip-icon { font-size: 46px; }
#tip p { color: var(--muted); line-height: 1.7; margin: 6px 0 4px; }

/* 设置 */
.set { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 2px; border-bottom: 1px solid var(--line); text-align: left; flex-wrap: wrap; }
.sw { appearance: none; width: 50px; height: 30px; border-radius: 99px; background: rgba(120, 130, 160, .35); position: relative; cursor: pointer; margin: 0; transition: background .2s; flex: none; }
.sw::after { content: ""; position: absolute; left: 3px; top: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; box-shadow: 0 1px 4px rgba(0, 0, 0, .3); transition: transform .25s var(--ease); }
.sw:checked { background: linear-gradient(135deg, #5b8cff, #a35bff); }
.sw:checked::after { transform: translateX(20px); }
.seg { display: flex; padding: 3px; border-radius: 12px; background: var(--btn); gap: 2px; }
.seg button { border: 0; background: none; padding: 6px 10px; border-radius: 9px; font-size: 13px; font-weight: 650; color: var(--muted); }
.seg button[aria-pressed="true"] { background: var(--panel-solid); color: var(--text); box-shadow: 0 1px 4px rgba(0, 0, 0, .15); }

.toast { position: fixed; left: 50%; bottom: calc(30px + env(safe-area-inset-bottom)); z-index: 60; transform: translate(-50%, 16px); opacity: 0; pointer-events: none; transition: .3s var(--ease);
  background: var(--text); color: var(--panel-solid); padding: 10px 18px; border-radius: 14px; font-weight: 700; font-size: 14px; white-space: nowrap; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; } }
