/* Fruit Crush — Global Styles */

/* ======================== CSS 变量 ======================== */
:root {
    --c-primary: #7c91f5;
    --c-primary-dark: #667eea;
    --c-secondary: #9b4dd4;
    --c-secondary-dark: #764ba2;
    --c-accent: #ff4081;
    --c-gold: #FFD700;
    --c-gold-light: #FFE55C;
    --c-emerald: #00e676;
    --c-bg-dark: #0c0a20;
    --c-bg-mid: #161630;
    --c-surface: rgba(255,255,255,0.07);
    --c-surface-hover: rgba(255,255,255,0.13);
    --c-border: rgba(255,255,255,0.09);
    --c-border-hover: rgba(124,145,245,0.45);
    --c-text: #FFFFFF;
    --c-text-muted: rgba(255,255,255,0.5);
    --radius-sm: 8px;
    --radius-md: 16px;
    --radius-lg: 24px;
    --glow-primary: 0 0 30px rgba(124, 145, 245, 0.5);
    --glow-gold: 0 0 20px rgba(255, 215, 0, 0.5);
    --transition-fast: 120ms cubic-bezier(0.25, 0.46, 0.45, 0.94);
    --transition-bounce: 300ms cubic-bezier(0.34, 1.56, 0.64, 1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: #0a0818;
    font-family: 'Nunito', "PingFang SC", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
    display: flex;
    align-items: center;
    justify-content: center;
    /* Prevent rubber-band scroll on iOS */
    overscroll-behavior: none;
}

/* ======================== 根容器 ======================== */
#game-container {
    width: 480px;
    height: 720px;
    flex-shrink: 0;
    position: relative;
    overflow: hidden;
    background: linear-gradient(170deg, #0c0a20 0%, #161630 28%, #1e1840 55%, #14122a 100%);
    box-shadow:
        0 0 100px rgba(124, 145, 245, 0.18),
        0 0 0 1px rgba(255,255,255,0.05),
        0 30px 80px rgba(0,0,0,0.6);
}

/* Ambient animated background glow */
#game-container::before {
    content: '';
    position: absolute;
    top: -20%;
    left: -20%;
    width: 140%;
    height: 140%;
    background:
        radial-gradient(ellipse 60% 40% at 30% 20%, rgba(124, 145, 245, 0.08) 0%, transparent 70%),
        radial-gradient(ellipse 50% 35% at 70% 80%, rgba(155, 77, 212, 0.07) 0%, transparent 70%);
    animation: ambientShift 12s ease-in-out infinite alternate;
    pointer-events: none;
    z-index: 0;
}

@keyframes ambientShift {
    0%   { transform: translate(0, 0) scale(1); }
    50%  { transform: translate(3%, 2%) scale(1.03); }
    100% { transform: translate(-2%, 4%) scale(0.98); }
}

/* 移动端适配 */
@media screen and (max-width: 520px) {
    html, body {
        align-items: flex-start;
    }
    #game-container {
        width: min(100vw, 66.667dvh, 66.667vh);
        height: min(100dvh, 100vh, 150vw);
        box-shadow: none;
        padding-top: env(safe-area-inset-top, 0px);
        padding-bottom: env(safe-area-inset-bottom, 0px);
    }
}

/* Landscape on small screens */
@media screen and (max-height: 520px) and (max-width: 900px) {
    html, body {
        align-items: center;
    }
    #game-container {
        width: min(480px, 66.667vh);
        height: min(720px, 100vh);
        box-shadow: none;
    }
}

@media screen and (max-height: 720px) and (min-width: 521px) {
    #game-container {
        width: min(480px, 66.667vh);
        height: min(720px, 100vh);
    }
}

/* ======================== 场景容器 ======================== */
.scene {
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
    z-index: 1;
}

/* ======================== 标题画面 ======================== */
.title-scene {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background:
        radial-gradient(ellipse 600px 400px at 50% 40%, rgba(124, 145, 245, 0.28) 0%, transparent 70%),
        radial-gradient(ellipse 400px 300px at 28% 72%, rgba(155, 77, 212, 0.2) 0%, transparent 70%),
        radial-gradient(ellipse 300px 200px at 72% 28%, rgba(255, 64, 129, 0.12) 0%, transparent 70%);
}

/* Enhanced star field */
.title-scene::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background:
        radial-gradient(1.5px 1.5px at 8%  12%, rgba(255,255,255,0.7), transparent),
        radial-gradient(2px   2px   at 18% 7%,  rgba(255,255,255,0.5), transparent),
        radial-gradient(1px   1px   at 30% 22%, rgba(255,255,255,0.4), transparent),
        radial-gradient(2px   2px   at 45% 8%,  rgba(255,255,255,0.6), transparent),
        radial-gradient(1.5px 1.5px at 58% 17%, rgba(255,255,255,0.45), transparent),
        radial-gradient(1px   1px   at 72% 5%,  rgba(255,255,255,0.35), transparent),
        radial-gradient(2px   2px   at 85% 20%, rgba(255,255,255,0.55), transparent),
        radial-gradient(1px   1px   at 93% 10%, rgba(255,255,255,0.4), transparent),
        radial-gradient(1.5px 1.5px at 12% 38%, rgba(255,255,255,0.3), transparent),
        radial-gradient(1px   1px   at 62% 45%, rgba(255,255,255,0.35), transparent),
        radial-gradient(2px   2px   at 78% 55%, rgba(255,255,255,0.5), transparent),
        radial-gradient(1px   1px   at 22% 60%, rgba(255,255,255,0.3), transparent),
        radial-gradient(1.5px 1.5px at 88% 72%, rgba(255,255,255,0.4), transparent),
        radial-gradient(1px   1px   at 40% 80%, rgba(255,255,255,0.25), transparent),
        radial-gradient(2px   2px   at 55% 90%, rgba(255,255,255,0.35), transparent),
        radial-gradient(1px   1px   at 5%  85%, rgba(255,255,255,0.3), transparent),
        radial-gradient(1.5px 1.5px at 95% 88%, rgba(255,255,255,0.45), transparent);
    pointer-events: none;
    animation: twinkle 4s ease-in-out infinite alternate;
}

/* Secondary star layer offset for depth */
.title-scene::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background:
        radial-gradient(1px 1px at 25% 32%, rgba(124,145,245,0.5), transparent),
        radial-gradient(1px 1px at 65% 28%, rgba(155,77,212,0.4), transparent),
        radial-gradient(1px 1px at 48% 65%, rgba(255,64,129,0.35), transparent),
        radial-gradient(1px 1px at 82% 42%, rgba(124,145,245,0.4), transparent),
        radial-gradient(1px 1px at 15% 55%, rgba(255,215,0,0.3), transparent);
    pointer-events: none;
    animation: twinkle 6s 2s ease-in-out infinite alternate;
}

@keyframes twinkle {
    0%   { opacity: 0.4; }
    50%  { opacity: 0.9; }
    100% { opacity: 0.6; }
}

/* Entrance animations */
@keyframes slideUpFade {
    from { opacity: 0; transform: translateY(32px); }
    to   { opacity: 1; transform: translateY(0); }
}

@keyframes scaleIn {
    from { opacity: 0; transform: scale(0.7); }
    to   { opacity: 1; transform: scale(1); }
}

.title-fruits {
    font-size: 46px;
    letter-spacing: 10px;
    margin-bottom: 12px;
    position: relative;
    z-index: 1;
    animation: slideUpFade 0.6s cubic-bezier(0.22, 1, 0.36, 1) both;
    filter: drop-shadow(0 4px 8px rgba(0,0,0,0.4));
}

.title-text {
    font-family: 'Fredoka', 'Nunito', sans-serif;
    font-size: 68px;
    font-weight: 700;
    background: linear-gradient(135deg, #a0b4ff 0%, #c084fc 40%, #f472b6 80%, #fb923c 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    filter: drop-shadow(0 0 30px rgba(124, 145, 245, 0.7));
    margin-bottom: 10px;
    letter-spacing: 4px;
    position: relative;
    z-index: 1;
    animation: slideUpFade 0.6s 0.1s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.title-subtitle {
    font-family: 'Nunito', sans-serif;
    font-size: 12px;
    font-weight: 600;
    color: rgba(255,255,255,0.45);
    letter-spacing: 8px;
    text-transform: uppercase;
    margin-bottom: 60px;
    position: relative;
    z-index: 1;
    animation: slideUpFade 0.6s 0.2s cubic-bezier(0.22, 1, 0.36, 1) both;
}

/* Button shimmer sweep */
@keyframes shimmer {
    0%   { left: -100%; }
    55%  { left: 200%; }
    100% { left: 200%; }
}

.btn-start {
    width: 210px;
    height: 60px;
    border: none;
    border-radius: 30px;
    background: linear-gradient(135deg, #7c91f5 0%, #9b4dd4 55%, #b565e0 100%);
    color: #FFFFFF;
    font-family: 'Nunito', sans-serif;
    font-size: 20px;
    font-weight: 800;
    letter-spacing: 5px;
    cursor: pointer;
    touch-action: manipulation;
    overflow: hidden;
    box-shadow:
        0 6px 28px rgba(124, 145, 245, 0.55),
        0 0 60px rgba(155, 77, 212, 0.22),
        inset 0 1px 0 rgba(255,255,255,0.28),
        inset 0 -2px 0 rgba(0,0,0,0.12);
    transition: transform 0.18s ease, box-shadow 0.18s ease, filter 0.18s ease;
    position: relative;
    z-index: 1;
    animation: slideUpFade 0.6s 0.32s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.btn-start::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 60%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.25), transparent);
    animation: shimmer 2.6s 1.4s ease-in-out infinite;
    pointer-events: none;
}

.btn-start:hover {
    box-shadow:
        0 10px 36px rgba(124, 145, 245, 0.7),
        0 0 80px rgba(155, 77, 212, 0.32),
        inset 0 1px 0 rgba(255,255,255,0.28);
    transform: translateY(-4px);
    filter: brightness(1.08);
}

.btn-start:active {
    transform: scale(0.94) translateY(0);
    box-shadow:
        0 3px 14px rgba(124, 145, 245, 0.4),
        inset 0 2px 4px rgba(0,0,0,0.2);
    filter: brightness(0.95);
}

/* ======================== 关卡选择 ======================== */
.level-select-scene {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding-top: 44px;
    background:
        radial-gradient(ellipse 500px 350px at 50% 25%, rgba(124, 145, 245, 0.14) 0%, transparent 70%);
}

.level-select-title {
    font-size: 34px;
    font-weight: bold;
    background: linear-gradient(135deg, #c4d0ff 0%, #d4a8f7 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 36px;
    letter-spacing: 6px;
    filter: drop-shadow(0 0 16px rgba(124, 145, 245, 0.5));
}

.level-grid {
    display: grid;
    grid-template-columns: repeat(3, 128px);
    gap: 18px;
}

.level-cell {
    width: 128px;
    height: 110px;
    border-radius: 18px;
    background: rgba(255,255,255,0.06);
    backdrop-filter: blur(10px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    touch-action: manipulation;
    transition: transform 0.2s var(--transition-bounce), background 0.18s ease, box-shadow 0.18s ease;
    border: 1px solid rgba(255,255,255,0.09);
    position: relative;
    overflow: hidden;
}

/* Top shimmer line */
.level-cell::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.22), transparent);
    pointer-events: none;
}

/* Bottom gradient accent */
.level-cell::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 40%;
    background: linear-gradient(to top, rgba(0,0,0,0.15), transparent);
    pointer-events: none;
    border-radius: 0 0 18px 18px;
}

.level-cell:active {
    transform: scale(0.93);
}

.level-cell.unlocked {
    background: rgba(255,255,255,0.09);
    border-color: rgba(255,255,255,0.16);
    box-shadow: 0 4px 20px rgba(0,0,0,0.25), inset 0 0 30px rgba(124, 145, 245, 0.05);
}

.level-cell.unlocked:hover {
    background: rgba(124, 145, 245, 0.14);
    border-color: rgba(124, 145, 245, 0.42);
    box-shadow:
        0 8px 28px rgba(124, 145, 245, 0.28),
        inset 0 0 30px rgba(124, 145, 245, 0.08);
    transform: translateY(-4px);
}

.level-cell.locked {
    opacity: 0.32;
    cursor: default;
    pointer-events: none;
}

/* Completed level - subtle gold tint */
.level-cell.completed {
    background: rgba(255, 215, 0, 0.07);
    border-color: rgba(255, 215, 0, 0.2);
    box-shadow: 0 4px 20px rgba(255, 215, 0, 0.1), inset 0 0 30px rgba(255, 215, 0, 0.04);
}

.level-cell.completed:hover {
    background: rgba(255, 215, 0, 0.12);
    border-color: rgba(255, 215, 0, 0.35);
    box-shadow: 0 8px 28px rgba(255, 215, 0, 0.2), inset 0 0 30px rgba(255, 215, 0, 0.06);
    transform: translateY(-4px);
}

.level-cell .level-number {
    font-size: 34px;
    font-weight: bold;
    color: #FFFFFF;
    text-shadow: 0 0 14px rgba(124,145,245,0.4), 0 2px 4px rgba(0,0,0,0.4);
    position: relative;
    z-index: 1;
}

.level-cell .level-stars {
    font-size: 16px;
    color: var(--c-gold);
    margin-top: 5px;
    letter-spacing: 4px;
    text-shadow: 0 0 10px rgba(255,215,0,0.5);
    position: relative;
    z-index: 1;
}

.level-cell .level-lock {
    font-size: 32px;
    opacity: 0.55;
    position: relative;
    z-index: 1;
}

.level-cell .level-highscore {
    font-size: 11px;
    color: rgba(255,255,255,0.48);
    margin-top: 3px;
    position: relative;
    z-index: 1;
}

/* ======================== 游戏场景 ======================== */
.gameplay-scene {
    position: relative;
    width: 100%;
    height: 100%;
    background:
        radial-gradient(ellipse 500px 300px at 50% 58%, rgba(124, 145, 245, 0.09) 0%, transparent 70%);
}

/* ======================== HUD区域 ======================== */
.hud {
    position: absolute;
    top: 8px;
    left: 0;
    right: 0;
    height: 112px;
    padding: 10px 20px 6px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    z-index: 5;
    pointer-events: none;
}

.hud-row {
    display: flex;
    justify-content: space-around;
    align-items: center;
    pointer-events: none;
}

.hud-score-block,
.hud-moves-block,
.hud-target-block {
    text-align: center;
    min-width: 92px;
    padding: 5px 12px;
    border-radius: 12px;
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.08);
    backdrop-filter: blur(8px);
}

.hud-label {
    font-size: 11px;
    color: rgba(255,255,255,0.48);
    text-transform: uppercase;
    letter-spacing: 2px;
    margin-bottom: 2px;
}

.hud-value {
    font-size: 26px;
    font-weight: bold;
    color: #FFFFFF;
    text-shadow: 0 0 16px rgba(124, 145, 245, 0.5);
    transition: transform 0.15s var(--transition-bounce);
}

/* Score pop micro-animation */
.hud-value.pop {
    animation: valuePop 0.28s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes valuePop {
    0%   { transform: scale(1); }
    50%  { transform: scale(1.22); }
    100% { transform: scale(1); }
}

.hud-moves-block .hud-value {
    color: var(--c-gold);
    text-shadow: 0 0 14px rgba(255, 215, 0, 0.4);
}

/* Low moves warning */
.hud-moves-block.low-moves .hud-value {
    color: #ff5252;
    text-shadow: 0 0 14px rgba(255, 82, 82, 0.5);
    animation: urgentPulse 0.8s ease-in-out infinite;
}

@keyframes urgentPulse {
    0%, 100% { opacity: 1; }
    50%       { opacity: 0.65; }
}

.hud-stars-display {
    font-size: 22px;
    color: var(--c-gold);
    letter-spacing: 4px;
    text-shadow: 0 0 14px rgba(255,215,0,0.5);
    text-align: center;
}

/* 星级进度条 */
.progress-bar-container {
    position: relative;
    margin: 2px 0 0;
    height: 8px;
    background: rgba(255,255,255,0.09);
    border-radius: 4px;
    overflow: hidden;
    border: 1px solid rgba(255,255,255,0.05);
}

.progress-bar-fill {
    height: 100%;
    border-radius: 4px;
    background: linear-gradient(90deg, #7c91f5 0%, #9b4dd4 50%, #ff4081 100%);
    transition: width 0.4s cubic-bezier(0.22, 1, 0.36, 1);
    width: 0%;
    box-shadow: 0 0 12px rgba(124, 145, 245, 0.5);
    position: relative;
    overflow: hidden;
}

/* Shimmer on progress bar */
.progress-bar-fill::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 60%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.35), transparent);
    animation: progressShimmer 2s ease-in-out infinite;
}

@keyframes progressShimmer {
    0%   { left: -100%; }
    100% { left: 200%; }
}

.progress-bar-markers {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 100%;
    pointer-events: none;
}

.progress-marker {
    position: absolute;
    top: -4px;
    width: 2px;
    height: 16px;
    background: rgba(255,255,255,0.4);
    border-radius: 1px;
}

/* ======================== 棋盘 ======================== */
.board-bg {
    position: absolute;
    top: 126px;
    left: 50%;
    transform: translateX(-50%);
    width: 436px;
    height: 436px;
    background: rgba(255,255,255,0.04);
    border-radius: 20px;
    box-shadow:
        0 10px 50px rgba(0,0,0,0.35),
        0 0 0 1px rgba(255,255,255,0.06),
        inset 0 0 80px rgba(124, 145, 245, 0.04);
    padding: 6px;
    backdrop-filter: blur(4px);
}

.board-grid {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    grid-template-rows: repeat(8, 1fr);
    width: 100%;
    height: 100%;
    gap: 3px;
}

.board-cell {
    position: relative;
    border-radius: 7px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    touch-action: manipulation;
    overflow: visible;
    transition: background 0.1s ease;
    -webkit-user-select: none;
    user-select: none;
}

/* Checkerboard pattern — slightly more visible */
.board-cell.cell-light {
    background: rgba(255,255,255,0.07);
}

.board-cell.cell-dark {
    background: rgba(255,255,255,0.03);
}

.board-cell:hover {
    background: rgba(124, 145, 245, 0.12);
}

/* 格子中的元素 */
.board-cell .cell-element {
    width: 86%;
    height: 86%;
    transition: transform 0.12s ease-out, filter 0.12s ease;
    position: relative;
    z-index: 1;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.35));
    will-change: transform;
}

.board-cell .cell-element svg {
    width: 100%;
    height: 100%;
    display: block;
}

/* Hover: subtle lift */
.board-cell:not(.selected):not(.stone-cell):hover .cell-element {
    transform: scale(1.08);
    filter: drop-shadow(0 4px 8px rgba(0,0,0,0.4)) drop-shadow(0 0 6px rgba(255,255,255,0.15));
}

/* 选中态 */
.board-cell.selected {
    z-index: 2;
    background: rgba(124, 145, 245, 0.22);
}

.board-cell.selected::after {
    content: '';
    position: absolute;
    top: -2px;
    left: -2px;
    right: -2px;
    bottom: -2px;
    border-radius: 9px;
    border: 2px solid rgba(255,255,255,0.75);
    box-shadow: 0 0 14px rgba(124, 145, 245, 0.7), inset 0 0 10px rgba(124, 145, 245, 0.2);
    pointer-events: none;
    animation: selectPulse 1s ease-in-out infinite;
}

@keyframes selectPulse {
    0%, 100% {
        box-shadow: 0 0 12px rgba(124, 145, 245, 0.6), inset 0 0 8px rgba(124, 145, 245, 0.18);
        border-color: rgba(255,255,255,0.75);
    }
    50% {
        box-shadow: 0 0 22px rgba(124, 145, 245, 0.95), inset 0 0 14px rgba(124, 145, 245, 0.35);
        border-color: rgba(255,255,255,1);
    }
}

.board-cell.selected .cell-element {
    transform: scale(1.15);
    filter:
        drop-shadow(0 0 10px rgba(255,255,255,0.55))
        drop-shadow(0 0 20px rgba(124,145,245,0.5))
        drop-shadow(0 2px 4px rgba(0,0,0,0.3));
}

/* 障碍物覆盖层 */
.cell-obstacle {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 3;
    pointer-events: none;
}

.cell-obstacle svg {
    width: 100%;
    height: 100%;
}

/* 石块格子 */
.board-cell.stone-cell {
    cursor: default;
}

.board-cell.stone-cell:hover {
    background: rgba(255,255,255,0.05);
}

/* ======================== 消除动画 ======================== */
.cell-removing .cell-element {
    animation: removeAnim 280ms cubic-bezier(0.55, 0, 1, 0.45) forwards;
}

@keyframes removeAnim {
    0%   { transform: scale(1);    opacity: 1; }
    30%  { transform: scale(1.22); opacity: 0.9; filter: brightness(1.4) saturate(1.3); }
    100% { transform: scale(0);    opacity: 0; filter: brightness(2) saturate(0); }
}

/* ======================== 下落动画 ======================== */
.cell-falling .cell-element {
    transition-property: transform;
    transition-timing-function: cubic-bezier(0.55, 0, 1, 0.45);
}

/* Bounce on land */
.cell-landed .cell-element {
    animation: landBounce 200ms cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes landBounce {
    0%   { transform: scale(1); }
    40%  { transform: scale(1.12, 0.88); }
    70%  { transform: scale(0.95, 1.05); }
    100% { transform: scale(1); }
}

/* ======================== 交换动画 ======================== */
.cell-swapping .cell-element {
    transition: transform 150ms cubic-bezier(0.34, 1.2, 0.64, 1);
}

/* ======================== 无效交换抖动 ======================== */
.cell-invalid-swap .cell-element {
    animation: invalidShake 240ms ease-out;
}

@keyframes invalidShake {
    0%   { transform: translate(0, 0) rotate(0deg); }
    20%  { transform: translate(9px, 0) rotate(2deg); }
    40%  { transform: translate(-9px, 0) rotate(-2deg); }
    60%  { transform: translate(5px, 0) rotate(1deg); }
    80%  { transform: translate(-3px, 0) rotate(-1deg); }
    100% { transform: translate(0, 0) rotate(0deg); }
}

/* ======================== 得分浮动文字 ======================== */
.score-popup {
    position: absolute;
    font-size: 22px;
    font-weight: 800;
    color: #FFFFFF;
    text-shadow:
        0 0 12px rgba(124, 145, 245, 0.8),
        0 2px 4px rgba(0,0,0,0.5);
    pointer-events: none;
    z-index: 80;
    animation: scoreFloat 800ms cubic-bezier(0.22, 1, 0.36, 1) forwards;
    letter-spacing: 1px;
}

.score-popup.gold {
    color: var(--c-gold);
    text-shadow: 0 0 14px rgba(255, 215, 0, 0.8), 0 2px 4px rgba(0,0,0,0.5);
}

@keyframes scoreFloat {
    0%   { transform: translateY(0)    scale(0.6); opacity: 0; }
    20%  { transform: translateY(-8px)  scale(1.1); opacity: 1; }
    60%  { transform: translateY(-28px) scale(1);   opacity: 1; }
    100% { transform: translateY(-50px) scale(0.85); opacity: 0; }
}

/* ======================== Combo文字 ======================== */
.combo-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0);
    font-size: 52px;
    font-weight: 900;
    background: linear-gradient(135deg, #fff 0%, #ffd700 40%, #ff9800 80%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    filter: drop-shadow(0 0 20px rgba(255,165,0,0.8)) drop-shadow(0 4px 8px rgba(0,0,0,0.5));
    z-index: 100;
    pointer-events: none;
    animation: comboPopup 700ms cubic-bezier(0.68, -0.55, 0.265, 1.55) forwards;
    letter-spacing: 4px;
    white-space: nowrap;
}

@keyframes comboPopup {
    0%   { transform: translate(-50%, -50%) scale(0) rotate(-5deg); opacity: 1; }
    40%  { transform: translate(-50%, -50%) scale(1.25) rotate(2deg); opacity: 1; }
    65%  { transform: translate(-50%, -50%) scale(1.05) rotate(0deg); opacity: 1; }
    85%  { transform: translate(-50%, -55%) scale(0.9) rotate(0deg); opacity: 0.9; }
    100% { transform: translate(-50%, -70%) scale(0.7) rotate(0deg); opacity: 0; }
}

/* ======================== 特殊元素爆炸闪光 ======================== */
.special-flash {
    position: absolute;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(255,255,255,1) 0%, rgba(255,200,100,0.6) 50%, transparent 100%);
    z-index: 50;
    pointer-events: none;
    animation: flashExpand 550ms ease-out forwards;
}

@keyframes flashExpand {
    0%   { transform: scale(0); opacity: 1; }
    40%  { opacity: 0.75; }
    100% { transform: scale(3.5); opacity: 0; }
}

/* ======================== 障碍物破碎动画 ======================== */
.obstacle-breaking {
    animation: obstacleBreak 320ms cubic-bezier(0.55, 0, 1, 0.45) forwards;
}

@keyframes obstacleBreak {
    0%   { transform: scale(1); opacity: 1; }
    35%  { transform: scale(1.15); opacity: 0.7; filter: brightness(1.5); }
    100% { transform: scale(0); opacity: 0; }
}

/* ======================== 粒子爆炸 ======================== */
.burst-particle {
    position: absolute;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    pointer-events: none;
    z-index: 60;
    animation: burstFly 500ms ease-out forwards;
}

@keyframes burstFly {
    0%   { transform: translate(0, 0) scale(1); opacity: 1; }
    100% { transform: var(--tx, translate(30px,-40px)) scale(0); opacity: 0; }
}

/* ======================== 暂停按钮 ======================== */
.btn-pause {
    position: absolute;
    bottom: 50px;
    left: 50%;
    transform: translateX(-50%);
    width: 54px;
    height: 54px;
    border: none;
    border-radius: 50%;
    background: rgba(255,255,255,0.07);
    color: rgba(255,255,255,0.7);
    font-size: 18px;
    cursor: pointer;
    touch-action: manipulation;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255,255,255,0.12);
    transition: background 0.15s ease, transform 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
    z-index: 10;
}

.btn-pause:hover {
    background: rgba(255,255,255,0.13);
    border-color: rgba(255,255,255,0.24);
    box-shadow: 0 0 20px rgba(124, 145, 245, 0.2);
}

.btn-pause:active {
    background: rgba(255,255,255,0.2);
    transform: translateX(-50%) scale(0.90);
}

/* ======================== 弹窗/模态框 ======================== */
.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.68);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
    animation: modalFadeIn 0.22s ease-out;
}

@keyframes modalFadeIn {
    0%   { opacity: 0; }
    100% { opacity: 1; }
}

.modal-box {
    width: 340px;
    background: linear-gradient(160deg, #1a1838 0%, #252248 60%, #1e1c40 100%);
    border-radius: 26px;
    padding: 42px 32px 36px;
    text-align: center;
    box-shadow:
        0 24px 80px rgba(0,0,0,0.55),
        0 0 0 1px rgba(255,255,255,0.08),
        inset 0 1px 0 rgba(255,255,255,0.12),
        inset 0 0 60px rgba(124, 145, 245, 0.04);
    animation: modalSlideIn 0.32s cubic-bezier(0.34, 1.56, 0.64, 1);
    position: relative;
    overflow: hidden;
}

/* Top shimmer accent */
.modal-box::before {
    content: '';
    position: absolute;
    top: 0;
    left: 10%;
    width: 80%;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(124,145,245,0.5), transparent);
    pointer-events: none;
}

@keyframes modalSlideIn {
    0%   { transform: scale(0.8) translateY(24px); opacity: 0; }
    100% { transform: scale(1) translateY(0);      opacity: 1; }
}

.modal-title {
    font-size: 30px;
    font-weight: bold;
    color: #FFFFFF;
    margin-bottom: 14px;
    text-shadow: 0 0 24px rgba(124, 145, 245, 0.6);
    letter-spacing: 1px;
}

.modal-stars {
    font-size: 42px;
    color: var(--c-gold);
    margin-bottom: 10px;
    letter-spacing: 8px;
    text-shadow: 0 0 24px rgba(255,215,0,0.6);
    animation: starsAppear 0.5s 0.2s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

@keyframes starsAppear {
    0%   { transform: scale(0.5); opacity: 0; }
    100% { transform: scale(1);   opacity: 1; }
}

.modal-score {
    font-size: 18px;
    color: rgba(255,255,255,0.58);
    margin-bottom: 28px;
}

.modal-btn {
    display: block;
    width: 220px;
    height: 52px;
    margin: 12px auto;
    border: none;
    border-radius: 26px;
    font-size: 18px;
    font-weight: bold;
    cursor: pointer;
    touch-action: manipulation;
    transition: transform 0.14s ease, box-shadow 0.14s ease, filter 0.14s ease;
    letter-spacing: 3px;
    font-family: 'Nunito', sans-serif;
    position: relative;
    overflow: hidden;
}

.modal-btn::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 50%;
    background: rgba(255,255,255,0.06);
    border-radius: 26px 26px 0 0;
    pointer-events: none;
}

.modal-btn:hover {
    filter: brightness(1.08);
}

.modal-btn:active {
    transform: scale(0.94);
    filter: brightness(0.92);
}

.modal-btn-primary {
    background: linear-gradient(135deg, #7c91f5 0%, #9b4dd4 100%);
    color: #FFFFFF;
    box-shadow:
        0 5px 22px rgba(124, 145, 245, 0.5),
        inset 0 1px 0 rgba(255,255,255,0.18);
}

.modal-btn-primary:hover {
    box-shadow:
        0 8px 32px rgba(124, 145, 245, 0.65),
        inset 0 1px 0 rgba(255,255,255,0.18);
}

.modal-btn-secondary {
    background: rgba(255,255,255,0.07);
    color: rgba(255,255,255,0.68);
    border: 1px solid rgba(255,255,255,0.12);
    box-shadow: 0 2px 10px rgba(0,0,0,0.25);
}

.modal-btn-secondary:hover {
    background: rgba(255,255,255,0.12);
    border-color: rgba(255,255,255,0.22);
}

/* ======================== 底部HUD ======================== */
.hud-bottom {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 145px;
    padding: 8px 20px;
    pointer-events: none;
}

/* ======================== 过渡/通用工具类 ======================== */
.fade-in {
    animation: fadeIn 0.3s ease-out both;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

.slide-up {
    animation: slideUpFade 0.4s cubic-bezier(0.22, 1, 0.36, 1) both;
}

/* ======================== 辅助: 减少动效模式 ======================== */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
