/* ===== 变量定义 ===== */
:root {
    /* 主色调 - 简约现代配色 */
    --candy-pink: #ff7b54;
    --candy-orange: #ffb26b;
    --candy-yellow: #ffd56f;
    --candy-green: #8bc34a;
    --candy-blue: #42a5f5;
    --candy-purple: #ab8a76;
    
    /* 背景 - 淡紫色系 */
    --bg-gradient: linear-gradient(160deg, #f3e8ff 0%, #e9d5ff 50%, #ddd6fe 100%);
    --board-bg: #ffffff;
    --card-bg: #ffffff;
    
    /* 阴影 - 极简风格 */
    --shadow-soft: 0 2px 8px rgba(0, 0, 0, 0.06);
    --shadow-candy: 0 4px 20px rgba(0, 0, 0, 0.08);
    --shadow-glow: 0 0 20px rgba(0, 0, 0, 0.05);
    
    /* 主题色 */
    --primary: #ff7b54;
    --text-dark: #2d3436;
    --text-light: #636e72;
    --border-color: #e9ecef;
    
    /* 尺寸 - 响应式 */
    --board-size: min(88vw, calc(100vh - 200px), 600px);
    --cell-gap: clamp(3px, 1vw, 8px);
    --border-radius: clamp(12px, 3vw, 28px);
    --candy-radius: clamp(10px, 2.5vw, 20px);
    --board-padding: clamp(10px, 2.5vw, 20px);
    --board-radius: clamp(20px, 4vw, 36px);
    
    /* 动画 */
    --transition-fast: 0.15s ease;
    --transition-normal: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-bounce: 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

/* ===== 重置样式 ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html, body {
    height: 100%;
    overflow: hidden;
}

body {
    font-family: 'Fredoka', 'Segoe UI', system-ui, sans-serif;
    background: var(--bg-gradient);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 10px;
    /* iOS安全区域适配 - 为刘海/灵动岛留出空间 */
    padding-top: max(60px, calc(env(safe-area-inset-top) + 20px));
    padding-bottom: max(20px, calc(env(safe-area-inset-bottom) + 10px));
    padding-left: max(10px, env(safe-area-inset-left));
    padding-right: max(10px, env(safe-area-inset-right));
}

/* ===== 游戏容器 ===== */
.game-container {
    width: 100%;
    max-width: 420px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    position: relative;
    z-index: 1;
    margin-top: 10px;
}

/* ===== 背景装饰 - 简约几何 ===== */
.bg-decoration {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    overflow: hidden;
    z-index: 0;
}

.bubble {
    position: absolute;
    border-radius: 50%;
    opacity: 0.25;
    background: #c4b5fd;
    animation: float 8s ease-in-out infinite;
}

.bubble-1 {
    width: 300px;
    height: 300px;
    top: -100px;
    right: -100px;
    background: linear-gradient(135deg, #c4b5fd, #ddd6fe);
    animation-delay: 0s;
}

.bubble-2 {
    width: 200px;
    height: 200px;
    bottom: 10%;
    left: -60px;
    background: linear-gradient(135deg, #a78bfa, #c4b5fd);
    animation-delay: -3s;
}

.bubble-3 {
    display: block;
    width: 120px;
    height: 120px;
    top: 50%;
    right: -40px;
    background: linear-gradient(135deg, #ddd6fe, #ede9fe);
    animation-delay: -5s;
}

.bubble-4 {
    display: block;
    width: 80px;
    height: 80px;
    top: 30%;
    left: 20px;
    background: linear-gradient(135deg, #c4b5fd, #e9d5ff);
    animation-delay: -2s;
}

.bubble-5 {
    display: block;
    width: 60px;
    height: 60px;
    bottom: 25%;
    right: 30px;
    background: linear-gradient(135deg, #ddd6fe, #fae8ff);
    animation-delay: -6s;
}

@keyframes float {
    0%, 100% {
        transform: translate(0, 0) scale(1);
    }
    25% {
        transform: translate(10px, -15px) scale(1.03);
    }
    50% {
        transform: translate(-5px, -25px) scale(1.05);
    }
    75% {
        transform: translate(-10px, -10px) scale(1.02);
    }
}

/* ===== 游戏头部 ===== */
.game-header {
    text-align: center;
}

.logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-bottom: 16px;
}

.logo-icon {
    font-size: 2.2rem;
}

.logo-text {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-dark);
    letter-spacing: 1px;
}

.stats-bar {
    display: flex;
    justify-content: center;
    gap: 10px;
    width: var(--board-size);
    margin: 0 auto;
}

.stat-item {
    flex: 1;
    background: white;
    padding: 12px 14px;
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.06);
}

.stat-icon {
    font-size: 1.2rem;
    opacity: 0.9;
}

.stat-content {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}

.stat-label {
    font-size: 0.6rem;
    color: var(--text-light);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stat-value {
    font-size: 1.15rem;
    font-weight: 600;
    color: var(--text-dark);
}

.score-display .stat-value {
    color: var(--candy-pink);
}

.moves-display .stat-value {
    color: var(--candy-blue);
}

.level-display .stat-value {
    color: var(--candy-purple);
}

/* ===== 目标分数卡片 ===== */
.target-bar {
    background: white;
    padding: 12px 14px;
    border-radius: 16px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.06);
    width: var(--board-size);
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.target-icon {
    font-size: 1.2rem;
}

.target-info {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}

.target-label {
    font-size: 0.6rem;
    color: var(--text-light);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.target-info strong {
    color: var(--primary);
    font-weight: 600;
    font-size: 1.15rem;
}


/* ===== 游戏棋盘 ===== */
.board-wrapper {
    display: flex;
    justify-content: center;
    padding: 0;
    margin-top: 20px;
    margin-bottom: 0;
}

.game-board {
    width: var(--board-size);
    height: var(--board-size);
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    grid-template-rows: repeat(8, 1fr);
    gap: var(--cell-gap);
    padding: var(--board-padding);
    background: linear-gradient(165deg, #ffffff 0%, #f8f9fa 50%, #f0f0f5 100%);
    border-radius: var(--board-radius);
    box-shadow: 
        0 20px 40px rgba(0, 0, 0, 0.12),
        0 8px 16px rgba(0, 0, 0, 0.08),
        0 2px 4px rgba(0, 0, 0, 0.04),
        inset 0 2px 4px rgba(255, 255, 255, 0.9),
        inset 0 -2px 4px rgba(0, 0, 0, 0.05);
}

/* ===== 糖果方块 ===== */
.candy {
    width: 100%;
    height: 100%;
    border-radius: var(--candy-radius);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: clamp(1rem, 4vw, 1.8rem);
    cursor: pointer;
    transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1),
                box-shadow 0.25s ease;
    position: relative;
    user-select: none;
    -webkit-user-select: none;
    /* 动画性能优化 */
    will-change: transform;
    /* 增强3D立体效果 */
    box-shadow: 
        0 6px 12px rgba(0, 0, 0, 0.25),
        0 3px 6px rgba(0, 0, 0, 0.15),
        inset 0 3px 6px rgba(255, 255, 255, 0.5),
        inset 0 -3px 6px rgba(0, 0, 0, 0.15);
    transform: translateZ(0);
    background-image: linear-gradient(
        180deg,
        rgba(255, 255, 255, 0.15) 0%,
        rgba(255, 255, 255, 0) 50%,
        rgba(0, 0, 0, 0.1) 100%
    );
}

.candy::before {
    content: '';
    position: absolute;
    top: 4px;
    left: 12%;
    width: 76%;
    height: 35%;
    background: linear-gradient(
        to bottom, 
        rgba(255, 255, 255, 0.6), 
        rgba(255, 255, 255, 0.2) 50%,
        transparent
    );
    border-radius: 50% 50% 40% 40%;
    pointer-events: none;
}

.candy:hover {
    transform: translateZ(0) scale(1.08);
    box-shadow: 
        0 10px 20px rgba(0, 0, 0, 0.3),
        0 5px 10px rgba(0, 0, 0, 0.2),
        inset 0 3px 6px rgba(255, 255, 255, 0.6),
        inset 0 -3px 6px rgba(0, 0, 0, 0.1);
}

.candy:active {
    transform: translateZ(0) scale(0.95);
    box-shadow: 
        0 2px 4px rgba(0, 0, 0, 0.2),
        0 1px 2px rgba(0, 0, 0, 0.15),
        inset 0 3px 6px rgba(255, 255, 255, 0.3),
        inset 0 -3px 6px rgba(0, 0, 0, 0.2);
}

.candy.selected {
    transform: scale(1.1);
    z-index: 10;
    animation: pulse 0.8s infinite;
}

@keyframes pulse {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(255, 255, 255, 0.7);
    }
    50% {
        box-shadow: 0 0 0 8px rgba(255, 255, 255, 0);
    }
}

.candy.hint {
    animation: hintGlow 1s infinite;
}

@keyframes hintGlow {
    0%, 100% {
        transform: scale(1);
        filter: brightness(1);
    }
    50% {
        transform: scale(1.1);
        filter: brightness(1.3);
    }
}

.candy.matched {
    animation: match 0.5s forwards;
}

.candy.matched::after {
    content: '✨';
    position: absolute;
    font-size: 1.5rem;
    animation: sparkle 0.5s ease-out forwards;
}

@keyframes match {
    0% {
        transform: scale(1);
        opacity: 1;
        filter: brightness(1);
    }
    30% {
        transform: scale(1.4) rotate(10deg);
        opacity: 1;
        filter: brightness(1.5);
        box-shadow: 0 0 20px rgba(255, 200, 100, 0.8);
    }
    100% {
        transform: scale(0) rotate(45deg);
        opacity: 0;
        filter: brightness(2);
    }
}

@keyframes sparkle {
    0% {
        transform: scale(0);
        opacity: 1;
    }
    50% {
        transform: scale(1.5);
        opacity: 1;
    }
    100% {
        transform: scale(2) translateY(-20px);
        opacity: 0;
    }
}

.candy.dropping {
    animation: drop 0.4s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

@keyframes drop {
    0% {
        transform: translateY(-100%);
        opacity: 0;
    }
    60% {
        transform: translateY(10%);
    }
    100% {
        transform: translateY(0);
        opacity: 1;
    }
}

.candy.swapping {
    transition: transform 0.25s ease-in-out;
    z-index: 5;
}

/* 糖果颜色样式 - 精致柔和风格 */
.candy-red {
    background: linear-gradient(135deg, #ff8a65 0%, #ff7043 100%);
    box-shadow: 0 4px 12px rgba(255, 112, 67, 0.3);
}

.candy-orange {
    background: linear-gradient(135deg, #ffcc80 0%, #ffb74d 100%);
    box-shadow: 0 4px 12px rgba(255, 183, 77, 0.3);
}

.candy-yellow {
    background: linear-gradient(135deg, #fff59d 0%, #ffee58 100%);
    box-shadow: 0 4px 12px rgba(255, 238, 88, 0.3);
}

.candy-green {
    background: linear-gradient(135deg, #a5d6a7 0%, #81c784 100%);
    box-shadow: 0 4px 12px rgba(129, 199, 132, 0.3);
}

.candy-blue {
    background: linear-gradient(135deg, #90caf9 0%, #64b5f6 100%);
    box-shadow: 0 4px 12px rgba(100, 181, 246, 0.3);
}

.candy-purple {
    background: linear-gradient(135deg, #d7ccc8 0%, #bcaaa4 100%);
    box-shadow: 0 4px 12px rgba(188, 170, 164, 0.3);
}

/* ===== 连击显示 ===== */
.combo-display {
    position: fixed;
    top: 40%;
    left: 0;
    right: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    pointer-events: none;
    z-index: 1000;
}

.combo-text {
    display: inline-block;
    font-family: 'ZCOOL KuaiLe', cursive, sans-serif;
    font-size: 2rem;
    font-weight: 400;
    color: white;
    text-shadow: 
        0 0 10px rgba(255, 123, 84, 0.8),
        0 0 20px rgba(255, 123, 84, 0.6);
    opacity: 0;
    background: linear-gradient(135deg, var(--candy-pink), var(--candy-orange));
    padding: 12px 24px;
    border-radius: 16px;
    box-shadow: 
        0 6px 20px rgba(255, 123, 84, 0.5),
        inset 0 2px 4px rgba(255, 255, 255, 0.3);
    white-space: nowrap;
}

.combo-text.show {
    animation: comboShow 1s forwards;
}

@keyframes comboShow {
    0% {
        opacity: 0;
        transform: scale(0.5);
    }
    20% {
        opacity: 1;
        transform: scale(1.2);
    }
    40% {
        transform: scale(1);
    }
    80% {
        opacity: 1;
        transform: scale(1);
    }
    100% {
        opacity: 0;
        transform: scale(0.8) translateY(-20px);
    }
}

/* ===== 控制按钮 ===== */
.controls {
    display: flex;
    justify-content: center;
    gap: 10px;
    padding: 10px 0;
    width: var(--board-size);
    margin: 0 auto;
}

.btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 14px 16px;
    border: none;
    border-radius: 14px;
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.25s ease;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.06);
}

.btn-restart {
    background: linear-gradient(135deg, #ff8a65, #ff7043);
    color: white;
}

.btn-restart:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(255, 112, 67, 0.35);
}

.btn-shuffle {
    background: linear-gradient(135deg, #90caf9, #64b5f6);
    color: white;
}

.btn-shuffle:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(100, 181, 246, 0.35);
}

.btn-hint {
    background: linear-gradient(135deg, #fff59d, #ffee58);
    color: #5d4e37;
}

.btn-hint:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(255, 238, 88, 0.4);
}

.btn:active {
    transform: translateY(0) scale(0.96);
}

/* ===== 弹窗 ===== */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 3000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.modal.show {
    opacity: 1;
    visibility: visible;
}

.modal-content {
    background: white;
    padding: clamp(20px, 6vw, 36px);
    border-radius: clamp(16px, 5vw, 28px);
    text-align: center;
    max-width: min(300px, 85vw);
    width: 90%;
    transform: scale(0.9) translateY(20px);
    transition: transform 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    box-shadow: var(--shadow-candy);
    border: 1px solid var(--border-color);
}

.modal.show .modal-content {
    transform: scale(1) translateY(0);
}

.modal-icon {
    font-size: clamp(2.5rem, 10vw, 3.5rem);
    margin-bottom: clamp(8px, 2vw, 12px);
}

.modal-title {
    font-size: clamp(1.1rem, 4vw, 1.4rem);
    font-weight: 600;
    color: var(--text-dark);
    margin-bottom: clamp(10px, 3vw, 16px);
}

.modal-stars {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-bottom: 16px;
}

.modal-star {
    font-size: clamp(1.5rem, 6vw, 2rem);
    filter: grayscale(100%) opacity(0.25);
    transition: all 0.4s ease;
}

.modal-star.earned {
    filter: grayscale(0%) opacity(1);
    animation: starEarn 0.5s ease forwards;
}

@keyframes starEarn {
    0% { transform: scale(0); }
    50% { transform: scale(1.2); }
    100% { transform: scale(1); }
}

.modal-score {
    font-size: 1rem;
    color: var(--text-light);
    margin-bottom: 8px;
}

.modal-score span {
    font-weight: 600;
    color: var(--primary);
    font-size: 1.3rem;
}

.modal-high-score {
    font-size: 0.9rem;
    color: var(--text-light);
    margin-bottom: 8px;
}

.modal-high-score span {
    font-weight: 600;
    color: #6bb3d9;
}

.new-record {
    font-size: 1.1rem;
    font-weight: 600;
    color: #fbbf24;
    margin-bottom: 16px;
    animation: pulse 1s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

.modal-buttons {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin-bottom: 12px;
}

.modal-buttons-vertical {
    display: flex;
    flex-direction: column;
    gap: 10px;
    align-items: center;
    width: 100%;
}

.btn-share {
    background: linear-gradient(135deg, #6bb3d9, #4a9bc7);
    color: white;
    padding: clamp(10px, 3vw, 14px) clamp(20px, 5vw, 28px);
    font-size: clamp(0.85rem, 3vw, 0.95rem);
    border: none;
    border-radius: clamp(14px, 4vw, 20px);
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 3px 10px rgba(107, 179, 217, 0.3);
    width: 100%;
    max-width: min(260px, 80vw);
}

.btn-share:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 15px rgba(107, 179, 217, 0.4);
}

.btn-primary {
    background: var(--candy-green);
    color: white;
    padding: clamp(10px, 3vw, 14px) clamp(20px, 5vw, 28px);
    font-size: clamp(0.85rem, 3vw, 0.95rem);
    border: none;
}

.btn-secondary {
    background: #f8f9fa;
    color: var(--text-light);
    padding: clamp(10px, 3vw, 14px) clamp(20px, 5vw, 28px);
    font-size: clamp(0.85rem, 3vw, 0.95rem);
    border: 1px solid var(--border-color);
    width: 100%;
    max-width: min(260px, 80vw);
}

/* ===== 设置弹窗样式 ===== */
.settings-content {
    max-width: min(340px, 90vw);
}

.settings-desc {
    font-size: 0.85rem;
    color: var(--text-light);
    margin-bottom: 20px;
    line-height: 1.5;
}

.settings-form {
    margin-bottom: 20px;
}

.form-group {
    margin-bottom: 16px;
    text-align: left;
}

.form-group label {
    display: block;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-dark);
    margin-bottom: 8px;
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 12px 14px;
    font-size: 1rem;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    font-family: inherit;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    background: #fafafa;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: #a78bfa;
    box-shadow: 0 0 0 3px rgba(167, 139, 250, 0.2);
}

.form-group input::placeholder {
    color: #aaa;
}

.form-hint {
    font-size: 0.75rem;
    color: var(--text-light);
    margin-top: 6px;
    opacity: 0.8;
}

.settings-status {
    margin-top: 12px;
    font-size: 0.9rem;
    font-weight: 500;
    min-height: 1.2em;
}

/* ===== 分数弹出动画 ===== */
.score-popup {
    position: absolute;
    font-size: 1rem;
    font-weight: 700;
    color: white;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.3);
    pointer-events: none;
    z-index: 50;
    animation: scoreFloat 1s forwards;
}

@keyframes scoreFloat {
    0% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
    100% {
        opacity: 0;
        transform: translateY(-50px) scale(1.5);
    }
}

/* ===== 响应式调整 ===== */

/* 大屏幕平板 (iPad Pro等) */
@media (min-width: 768px) and (min-height: 900px) {
    :root {
        --board-size: min(70vw, calc(100vh - 250px), 550px);
        --cell-gap: clamp(4px, 1vw, 10px);
        --candy-radius: clamp(12px, 2vw, 24px);
        --board-padding: clamp(14px, 2vw, 24px);
        --board-radius: clamp(24px, 3vw, 40px);
    }
    
    .game-container {
        max-width: 600px;
    }
    
    .candy {
        font-size: clamp(1.5rem, 4vw, 2.5rem);
    }
    
    .mini-stats {
        padding: 16px 24px;
        border-radius: 20px;
    }
    
    .mini-stat {
        font-size: 1.1rem;
    }
    
    .mini-icon-btn {
        width: 44px;
        height: 44px;
        font-size: 1.3rem;
    }
}

/* 超大屏幕 */
@media (min-width: 1024px) and (min-height: 1000px) {
    :root {
        --board-size: min(60vw, calc(100vh - 300px), 600px);
    }
    
    .game-container {
        max-width: 650px;
    }
    
    .candy {
        font-size: clamp(1.8rem, 3.5vw, 2.8rem);
    }
}

/* 中等屏幕 */
@media (max-height: 700px) {
    :root {
        --board-size: min(85vw, calc(100vh - 200px));
    }
    
    body {
        padding-top: max(40px, calc(env(safe-area-inset-top) + 10px));
    }
    
    .game-container {
        gap: 8px;
        margin-top: 5px;
    }
    
    .mini-stats {
        padding: 8px 12px;
    }
    
    .board-wrapper {
        margin-top: 10px;
    }
    
    .game-board {
        padding: 10px;
        border-radius: 20px;
    }
    
    .candy {
        border-radius: 12px;
        font-size: clamp(1rem, 3.5vw, 1.5rem);
    }
}

/* 小屏幕高度 */
@media (max-height: 600px) {
    :root {
        --board-size: min(80vw, calc(100vh - 160px));
    }
    
    body {
        padding-top: max(30px, calc(env(safe-area-inset-top) + 5px));
    }
    
    .game-container {
        gap: 6px;
        margin-top: 0;
    }
    
    .mini-stats {
        padding: 6px 10px;
    }
    
    .mini-stat {
        font-size: 0.8rem;
    }
    
    .board-wrapper {
        margin-top: 6px;
    }
    
    .game-board {
        padding: 8px;
        border-radius: 16px;
    }
    
    .candy {
        border-radius: 10px;
        font-size: clamp(0.9rem, 3vw, 1.3rem);
    }
}

/* 窄屏幕宽度 */
@media (max-width: 360px) {
    :root {
        --board-size: 95vw;
        --cell-gap: 4px;
    }
    
    .mini-stats {
        padding: 6px 8px;
    }
    
    .mini-stat {
        font-size: 0.75rem;
    }
    
    .game-board {
        padding: 8px;
    }
    
    .candy {
        font-size: clamp(0.85rem, 3vw, 1.2rem);
    }
}

/* 横屏模式 */
@media (orientation: landscape) and (max-height: 500px) {
    :root {
        --board-size: min(60vw, calc(100vh - 100px));
    }
    
    body {
        padding-top: 10px;
        align-items: center;
    }
    
    .game-container {
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: center;
        max-width: 100%;
        gap: 10px;
    }
    
    .mini-stats {
        width: auto;
    }
    
    .board-wrapper {
        margin-top: 0;
    }
}

/* ===== 禁用文本选择 ===== */
.game-board, .candy, .btn, .icon-btn {
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

/* ===== 开始画面 ===== */
.start-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--bg-gradient);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    transition: opacity 0.5s ease, visibility 0.5s ease;
    /* iOS 刘海/灵动岛安全区域 */
    padding-top: max(40px, env(safe-area-inset-top));
    padding-bottom: max(20px, env(safe-area-inset-bottom));
    box-sizing: border-box;
}

.start-screen.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.start-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    animation: fadeInUp 0.8s ease;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.start-logo {
    font-size: 5rem;
    margin-bottom: 10px;
    animation: bounce 1.5s infinite;
}

.start-title {
    font-family: 'ZCOOL KuaiLe', cursive, sans-serif;
    font-size: 2.5rem;
    font-weight: 400;
    color: var(--primary);
    margin-bottom: 10px;
    text-shadow: 2px 2px 4px rgba(255, 123, 84, 0.3);
}

.start-subtitle {
    font-size: 1rem;
    color: var(--text-light);
    margin-bottom: 20px;
    opacity: 0.8;
}

.level-info {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 40px;
}

.level-number {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--primary);
}

.level-target,
.level-moves {
    font-size: 1.1rem;
    color: var(--text-light);
}

.start-btn {
    background: linear-gradient(135deg, var(--candy-pink), var(--candy-orange));
    color: white;
    border: none;
    padding: 16px 0;
    width: 200px;
    font-size: 1.2rem;
    font-weight: 600;
    border-radius: 30px;
    cursor: pointer;
    box-shadow: 0 6px 20px rgba(255, 123, 84, 0.4);
    transition: all 0.3s ease;
    font-family: inherit;
}

.start-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 30px rgba(255, 123, 84, 0.5);
}

.start-btn:active {
    transform: translateY(0);
}

.reset-btn {
    background: linear-gradient(135deg, #a8d8ea, #6bb3d9);
    color: white;
    border: none;
    padding: 14px 0;
    width: 200px;
    font-size: 1.1rem;
    font-weight: 600;
    border-radius: 30px;
    cursor: pointer;
    margin-top: 16px;
    box-shadow: 0 6px 20px rgba(107, 179, 217, 0.4);
    transition: all 0.3s ease;
    font-family: inherit;
}

.reset-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 30px rgba(107, 179, 217, 0.5);
}

.reset-btn:active {
    transform: translateY(0);
}

.settings-btn {
    background: transparent;
    color: var(--text-light);
    border: 2px dashed #ccc;
    padding: 10px 0;
    width: 200px;
    font-size: 0.85rem;
    font-weight: 500;
    border-radius: 20px;
    cursor: pointer;
    margin-top: 20px;
    transition: all 0.3s ease;
    font-family: inherit;
    opacity: 0.7;
}

.settings-btn:hover {
    opacity: 1;
    border-color: #a78bfa;
    color: #a78bfa;
    transform: scale(1.02);
}

.settings-btn:active {
    transform: scale(0.98);
}

.game-tip {
    margin-top: 30px;
    font-size: 0.85rem;
    color: var(--text-light);
    opacity: 0.8;
}

/* ===== 迷你状态栏 ===== */
.mini-stats {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: var(--board-size);
    background: rgba(255, 255, 255, 0.9);
    padding: 10px 16px;
    border-radius: 20px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    z-index: 100;
    backdrop-filter: blur(10px);
}

.stats-left {
    display: flex;
    gap: 16px;
}

.stats-right {
    display: flex;
    gap: 8px;
}

.mini-stat {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-dark);
    transition: transform 0.3s ease;
}

.mini-stat.score-changed {
    animation: scoreChange 0.4s ease;
}

@keyframes scoreChange {
    0% { transform: scale(1); }
    50% { transform: scale(1.3); color: var(--primary); }
    100% { transform: scale(1); }
}

.mini-icon-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    background: linear-gradient(145deg, #ff9a7b, #ff7b54);
    color: white;
    font-size: 1.1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.25s ease;
    /* 3D效果 */
    box-shadow: 
        0 4px 10px rgba(255, 123, 84, 0.4),
        0 2px 4px rgba(255, 123, 84, 0.2),
        inset 0 2px 4px rgba(255, 255, 255, 0.3),
        inset 0 -2px 4px rgba(0, 0, 0, 0.1);
    transform: perspective(200px) translateZ(0);
    position: relative;
}

.mini-icon-btn::before {
    content: '';
    position: absolute;
    top: 3px;
    left: 20%;
    width: 60%;
    height: 35%;
    background: linear-gradient(to bottom, rgba(255, 255, 255, 0.5), transparent);
    border-radius: 50%;
    pointer-events: none;
}

.mini-icon-btn:hover {
    transform: perspective(200px) translateZ(4px) scale(1.1);
    box-shadow: 
        0 8px 16px rgba(255, 123, 84, 0.5),
        0 4px 8px rgba(255, 123, 84, 0.3),
        inset 0 2px 4px rgba(255, 255, 255, 0.4),
        inset 0 -2px 4px rgba(0, 0, 0, 0.1);
}

.mini-icon-btn:active {
    transform: perspective(200px) translateZ(-2px) scale(0.95);
    box-shadow: 
        0 2px 4px rgba(255, 123, 84, 0.3),
        inset 0 2px 4px rgba(255, 255, 255, 0.2),
        inset 0 -2px 4px rgba(0, 0, 0, 0.15);
}

/* ===== 浮动图标按钮 ===== */
.floating-controls {
    position: relative;
    margin-top: 40px;
    display: flex;
    flex-direction: row;
    gap: 20px;
    z-index: 100;
}

.icon-btn {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: none;
    background: rgba(255, 255, 255, 0.95);
    font-size: 1.4rem;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.12);
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary);
    font-weight: bold;
}

.icon-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.18);
    background: var(--primary);
    color: white;
}

.icon-btn:active {
    transform: scale(0.95);
}

/* ===== 调整游戏容器 ===== */
.game-container {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    min-height: 100vh;
    padding: 20px 10px;
}

/* 隐藏旧的头部和目标栏 */
.game-header,
.target-bar {
    display: none;
}

/* 分享Toast提示 */
.share-toast {
    position: fixed;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 12px 24px;
    border-radius: 25px;
    font-size: 0.9rem;
    z-index: 3000;
    opacity: 0;
    transition: all 0.3s ease;
}

.share-toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

