* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary: #6c5ce7;
    --secondary: #00cec9;
    --accent: #fdcb6e;
    --bg-dark: #2d3436;
    --bg-light: #f7f9fc;
    --text-dark: #2d3436;
    --text-light: #f7f9fc;
    --success: #00b894;
    --danger: #d63031;
    --border-radius: 12px;
    --shadow: 0 4px 12px rgba(0,0,0,0.15);
    --transition: all 0.3s ease;
}

body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: linear-gradient(135deg, #6c5ce7, #a29bfe);
    color: var(--text-dark);
    height: 100vh;
    overflow: hidden;
    touch-action: manipulation;
}

#game-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1;
}

canvas {
    max-width: 100%;
    max-height: 100vh;
    display: block;
}

#ui-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 100;
    pointer-events: none;
}

#ui-container * {
    pointer-events: auto;
}

.hidden {
    display: none !important;
}

/* ========== 加载界面 ========== */
#loading-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #6c5ce7, #a29bfe);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    transition: opacity 0.5s ease;
}

.loading-content {
    text-align: center;
    color: white;
    padding: 40px;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
}

.loading-spinner {
    width: 60px;
    height: 60px;
    border: 4px solid rgba(255,255,255,0.3);
    border-top-color: white;
    border-radius: 50%;
    margin: 0 auto 20px;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ========== 主菜单 ========== */
#main-menu {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, rgba(108, 92, 231, 0.95), rgba(162, 155, 254, 0.95));
    display: flex;
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(10px);
}

.menu-content {
    background: white;
    padding: 40px;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    max-width: 90%;
    width: 400px;
    text-align: center;
}

.menu-content h1 {
    font-size: 2.5rem;
    margin-bottom: 10px;
    background: linear-gradient(135deg, #6c5ce7, #00cec9);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.subtitle {
    color: #666;
    margin-bottom: 30px;
    font-size: 1.1rem;
}

.btn-primary, .btn-secondary, .btn-danger {
    display: block;
    width: 100%;
    padding: 14px;
    margin: 10px 0;
    border: none;
    border-radius: 8px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    outline: none;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), #5e4ae9);
    color: white;
    box-shadow: 0 4px 15px rgba(108, 92, 231, 0.4);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(108, 92, 231, 0.6);
}

.btn-secondary {
    background: white;
    color: var(--primary);
    border: 2px solid var(--primary);
}

.btn-secondary:hover {
    background: #f0f0ff;
}

.btn-danger {
    background: var(--danger);
    color: white;
}

.btn-danger:hover {
    background: #c22222;
}

.btn-large {
    padding: 18px;
    font-size: 1.2rem;
}

.btn-icon {
    background: rgba(255,255,255,0.8);
    border: 2px solid white;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.2rem;
    cursor: pointer;
    transition: var(--transition);
}

.btn-icon:hover {
    transform: scale(1.1);
    background: white;
}

.save-info {
    background: #f0f0f0;
    padding: 15px;
    border-radius: 8px;
    margin: 20px 0;
    text-align: left;
    font-size: 0.95rem;
}

.save-time {
    color: #888;
    font-size: 0.9rem;
    margin-top: 8px;
}

.menu-footer {
    margin-top: 30px;
    padding-top: 20px;
    border-top: 1px solid #eee;
    color: #888;
    font-size: 0.9rem;
}

/* ========== 游戏UI ========== */
#game-ui {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    padding: 20px;
    pointer-events: none;
}

#game-ui * {
    pointer-events: auto;
}

.ui-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 800px;
    margin: 0 auto;
}

.ui-item {
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px);
    padding: 10px 20px;
    border-radius: 50px;
    box-shadow: var(--shadow);
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}

.stars-count {
    background: linear-gradient(135deg, #ffd700, #ffed4e);
    color: #333;
}

.level-info {
    background: linear-gradient(135deg, #6c5ce7, #a29bfe);
    color: white;
}

/* ========== 暂停菜单 ========== */
#pause-menu, #settings-menu {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(5px);
}

.pause-content, .settings-content {
    background: white;
    padding: 30px;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    width: 90%;
    max-width: 400px;
    text-align: center;
}

.pause-content h3, .settings-content h3 {
    margin-bottom: 25px;
    color: var(--primary);
}

.pause-content button {
    margin: 10px 0;
    width: 100%;
}

/* ========== 弹窗 ========== */
#level-complete, #game-complete {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(5px);
}

.modal-content {
    background: white;
    padding: 30px;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    width: 90%;
    max-width: 450px;
    text-align: center;
}

.modal-content h2 {
    color: var(--primary);
    margin-bottom: 20px;
    font-size: 1.8rem;
}

.stars-earned, .final-stats {
    margin: 20px 0;
    padding: 15px;
    background: #f9f9f9;
    border-radius: 8px;
    text-align: left;
}

.stars-earned p, .final-stats p {
    margin: 8px 0;
    font-size: 1.1rem;
}

.garden-progress {
    margin: 20px 0;
}

.garden-progress p {
    margin-bottom: 10px;
    font-weight: 600;
    color: var(--primary);
}

.progress-bar {
    width: 100%;
    height: 20px;
    background: #e0e0e0;
    border-radius: 10px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), var(--secondary));
    border-radius: 10px;
    transition: width 0.5s ease;
}

.completion-message {
    margin: 20px 0;
    padding: 15px;
    background: linear-gradient(135deg, #6c5ce7, #00cec9);
    color: white;
    border-radius: 8px;
    font-size: 1.1rem;
}

/* ========== 设置菜单 ========== */
.setting-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 15px 0;
    padding: 10px;
    background: #f5f5f5;
    border-radius: 8px;
}

.setting-item label {
    font-weight: 600;
    color: var(--text-dark);
}

.setting-item input[type="range"] {
    width: 150px;
    accent-color: var(--primary);
}

/* ========== 响应式 ========== */
@media (max-width: 768px) {
    .menu-content {
        padding: 30px 20px;
        width: 95%;
    }

    .menu-content h1 {
        font-size: 2rem;
    }

    .btn-large {
        padding: 16px;
    }

    .ui-top {
        flex-direction: column;
        gap: 15px;
        align-items: stretch;
    }

    .ui-item {
        justify-content: center;
        font-size: 1rem;
    }
}

@media (max-width: 480px) {
    .loading-content {
        padding: 30px 20px;
    }

    .loading-spinner {
        width: 40px;
        height: 40px;
    }

    .btn-icon {
        width: 40px;
        height: 40px;
        font-size: 1rem;
    }

    .pause-content, .settings-content, .modal-content {
        padding: 20px;
        margin: 10px;
    }
}