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

body {
    font-family: 'Noto Sans SC', 'Microsoft YaHei', 'Arial', sans-serif;
    background: linear-gradient(135deg, #f5f7fa 0%, #e4edf5 100%);
    overflow: hidden;
    width: 100vw;
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0;
    padding: 0;
    color: #2d3748;
}

#game-container {
    position: relative;
    width: 100%;
    max-width: 600px;
    height: 100vh;
    max-height: 900px;
    background: rgba(255, 255, 255, 0.95);
    box-shadow: 0 10px 50px rgba(0, 0, 0, 0.3);
    overflow: hidden;
    border-radius: 0;
}

/* PC端优化 */
@media (min-width: 768px) {
    #game-container {
        height: 95vh;
        max-height: 850px;
        border-radius: 16px;
    }
}

/* 屏幕通用样式 */
.screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: none;
    flex-direction: column;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

.screen.active {
    display: flex;
    opacity: 1;
    pointer-events: auto;
}

.screen-header {
    display: flex;
    align-items: center;
    padding: 20px;
    background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
    color: white;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.screen-header h2 {
    flex: 1;
    text-align: center;
    font-size: 24px;
    margin-left: -40px; /* 补偿返回按钮宽度 */
}

/* 按钮样式 */
.btn-primary, .btn-secondary, .btn-back, .btn-restart {
    border: none;
    border-radius: 8px;
    font-size: 18px;
    cursor: pointer;
    transition: all 0.2s ease;
    outline: none;
    position: relative;
    pointer-events: auto;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 15px 40px;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
    z-index: 100;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.6);
}

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

.btn-secondary {
    background: white;
    color: #667eea;
    padding: 12px 30px;
    border: 2px solid #667eea;
    z-index: 100;
}

.btn-secondary:hover {
    background: #f0f0f0;
}

.btn-secondary:active {
    background: #e0e0e0;
}

.btn-back, .btn-restart {
    background: rgba(79, 70, 229, 0.1);
    color: #4f46e5;
    padding: 8px 15px;
    font-size: 20px;
    min-width: 40px;
    position: relative;
    z-index: 20;
    flex-shrink: 0;
    border: 1px solid rgba(79, 70, 229, 0.2);
}

.btn-back:hover, .btn-restart:hover {
    background: rgba(79, 70, 229, 0.2);
    border-color: rgba(79, 70, 229, 0.3);
}

/* 开始界面 */
#start-screen {
    justify-content: center;
    align-items: center;
    gap: 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

#start-screen .btn-primary,
#start-screen .btn-secondary {
    position: relative;
    z-index: 100;
    pointer-events: auto;
}

.title-container {
    text-align: center;
    margin-bottom: 30px;
    pointer-events: none;
}

.game-title {
    font-size: 48px;
    color: white;
    text-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
    margin-bottom: 10px;
    animation: titlePulse 2s ease-in-out infinite;
    font-weight: bold;
}

.game-subtitle {
    font-size: 20px;
    color: rgba(255, 255, 255, 0.95);
    letter-spacing: 2px;
}

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

/* 关卡选择界面 */
#level-select-screen {
    background: linear-gradient(135deg, #f5f7fa 0%, #e4edf5 100%);
}

.level-grid {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    gap: 15px;
    align-content: start;
    position: relative;
    z-index: 1;
}

.level-item {
    aspect-ratio: 1;
    border: none;
    border-radius: 12px;
    background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
    color: white;
    font-size: 18px;
    font-weight: bold;
    cursor: pointer;
    position: relative;
    transition: all 0.2s ease;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
    z-index: 10;
    pointer-events: auto;
}

.level-item:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 15px rgba(0, 0, 0, 0.3);
}

.level-item:active {
    transform: translateY(-1px);
}

.level-item.locked {
    background: #ccc;
    cursor: not-allowed;
    opacity: 0.5;
}

.level-item .stars {
    position: absolute;
    bottom: 5px;
    left: 0;
    right: 0;
    text-align: center;
    font-size: 12px;
    pointer-events: none;
}

/* 游戏界面 */
#game-screen {
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
}

.game-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 15px 20px;
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    color: #2d3748;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    border-bottom: 1px solid rgba(255, 255, 255, 0.3);
    position: relative;
    z-index: 10;
}

.game-info {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    flex: 1;
    pointer-events: none; /* 允许点击穿透到下层按钮 */
}

.game-info span {
    font-size: 16px;
    font-weight: bold;
    color: #4f46e5;
}

/* 游戏状态区 */
.game-stats {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 20px;
    background: rgba(255, 255, 255, 0.7);
    border-bottom: 1px solid rgba(79, 70, 229, 0.1);
}

.moves-counter {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 15px;
    font-weight: bold;
    color: #2d3748;
}

.moves-counter i {
    color: #4f46e5;
    font-size: 18px;
}

.moves-counter span span {
    color: #4f46e5;
    font-size: 16px;
}

.stars-container {
    display: flex;
    gap: 6px;
}

.stars-container .star {
    color: #d1d5db;
    font-size: 20px;
    transition: all 0.3s ease;
}

.stars-container .star.active {
    color: #fbbf24;
    filter: drop-shadow(0 0 4px rgba(251, 191, 36, 0.6));
}

/* 关卡目标 */
.game-goal {
    padding: 12px 20px;
    background: linear-gradient(135deg, rgba(79, 70, 229, 0.1) 0%, rgba(124, 58, 237, 0.1) 100%);
    border-left: 4px solid #4f46e5;
    margin: 0 20px;
    border-radius: 8px;
    margin-top: 10px;
}

.game-goal h3 {
    font-size: 14px;
    font-weight: bold;
    color: #4f46e5;
    margin-bottom: 6px;
}

.game-goal p {
    font-size: 13px;
    color: #2d3748;
    line-height: 1.5;
    margin: 0;
}

#game-canvas {
    flex: 1;
    background: #f5f5f5;
    display: block;
    margin: 10px auto;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    border-radius: 8px;
    cursor: pointer;
    transition: box-shadow 0.2s ease;
    max-width: calc(100% - 40px);
    max-height: 100%;
    object-fit: contain;
}

#game-canvas:hover {
    box-shadow: 0 6px 25px rgba(0, 0, 0, 0.15);
}

.game-tip {
    padding: 10px 20px;
    text-align: center;
    font-size: 12px;
    color: #2d3748;
    min-height: 40px;
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 8px;
    border-top: 1px solid rgba(255, 255, 255, 0.3);
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.05);
}

/* 特殊块说明 */
.special-blocks-info {
    display: flex;
    justify-content: center;
    gap: 15px;
    padding: 12px 20px;
    background: rgba(255, 255, 255, 0.5);
    border-top: 1px solid rgba(79, 70, 229, 0.1);
}

.special-block-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.special-block-item span {
    font-size: 11px;
    color: #6b7280;
    font-weight: 500;
}

.special-block-preview {
    width: 36px;
    height: 36px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    font-weight: bold;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
    transition: transform 0.2s ease;
}

.special-block-preview:hover {
    transform: scale(1.1);
}

.penetrate-preview {
    background: linear-gradient(135deg, #93c5fd 0%, #60a5fa 100%);
    color: white;
    border: 2px dashed rgba(255, 255, 255, 0.6);
}

.bounce-preview {
    background: linear-gradient(135deg, #fde047 0%, #facc15 100%);
    color: #78350f;
    position: relative;
}

.bounce-preview::after {
    content: '';
    position: absolute;
    inset: 4px;
    border: 2px solid rgba(120, 53, 15, 0.3);
    border-radius: 4px;
}

.split-preview {
    background: linear-gradient(135deg, #c084fc 0%, #a855f7 100%);
    color: white;
    position: relative;
}

.split-preview::before,
.split-preview::after {
    content: '';
    position: absolute;
    background: rgba(255, 255, 255, 0.3);
}

.split-preview::before {
    width: 2px;
    height: 100%;
    left: 50%;
    transform: translateX(-50%);
}

.split-preview::after {
    height: 2px;
    width: 100%;
    top: 50%;
    transform: translateY(-50%);
}

.fixed-preview {
    background: linear-gradient(135deg, #9ca3af 0%, #6b7280 100%);
    position: relative;
    overflow: hidden;
}

.fixed-preview::before {
    content: '';
    position: absolute;
    inset: 0;
    background: repeating-linear-gradient(
        45deg,
        transparent,
        transparent 4px,
        rgba(0, 0, 0, 0.1) 4px,
        rgba(0, 0, 0, 0.1) 8px
    );
}

.level-tip {
    font-size: 14px;
    color: #4f46e5;
    font-weight: bold;
}

/* PC端显示快捷键提示 */
.keyboard-hint {
    display: none;
    font-size: 12px;
    color: #999;
}

@media (min-width: 768px) {
    .keyboard-hint {
        display: block;
    }
    
    .game-tip {
        font-size: 15px;
    }
    
    .level-tip {
        font-size: 15px;
    }
}

/* 结算界面 */
#result-screen {
    background: linear-gradient(135deg, #f5f7fa 0%, #e4edf5 100%);
}

.result-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 40px 20px;
    gap: 20px;
}

#result-title {
    font-size: 32px;
    background: linear-gradient(to right, #4f46e5, #7c3aed);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 10px;
    font-weight: bold;
}

.stars-display {
    font-size: 48px;
    margin: 10px 0;
    filter: drop-shadow(0 2px 4px rgba(251, 191, 36, 0.3));
}

.result-info {
    text-align: center;
    font-size: 18px;
    color: #2d3748;
    line-height: 2;
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(10px);
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.result-info span {
    font-weight: bold;
    color: #4f46e5;
}

.result-buttons {
    display: flex;
    flex-direction: column;
    gap: 15px;
    width: 100%;
    max-width: 300px;
}

/* 玩法说明界面 */
#how-to-play-screen {
    background: linear-gradient(135deg, #f5f7fa 0%, #e4edf5 100%);
}

.help-content {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
}

.help-section {
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.help-section h3 {
    color: #4f46e5;
    font-size: 20px;
    margin-bottom: 15px;
    font-weight: bold;
}

.help-section p {
    color: #2d3748;
    font-size: 16px;
    line-height: 1.8;
    margin: 8px 0;
}

/* 滚动条美化 */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* 响应式设计 */

/* 移动端优化 */
@media (max-width: 600px) {
    .game-title {
        font-size: 36px;
    }
    
    .game-subtitle {
        font-size: 16px;
    }
    
    #result-title {
        font-size: 28px;
    }
    
    .btn-primary {
        font-size: 16px;
        padding: 12px 30px;
    }
    
    .btn-secondary {
        font-size: 14px;
        padding: 10px 20px;
    }
    
    #game-canvas {
        margin: 8px auto;
    }
    
    .game-header {
        padding: 10px 15px;
    }
    
    .game-info span {
        font-size: 14px;
    }
    
    .game-stats {
        padding: 10px 15px;
    }
    
    .moves-counter {
        font-size: 13px;
    }
    
    .moves-counter i {
        font-size: 16px;
    }
    
    .stars-container .star {
        font-size: 18px;
    }
    
    .game-goal {
        padding: 10px 15px;
        margin: 0 15px;
        margin-top: 8px;
    }
    
    .game-goal h3 {
        font-size: 13px;
    }
    
    .game-goal p {
        font-size: 12px;
    }
    
    .special-blocks-info {
        padding: 10px 15px;
        gap: 10px;
    }
    
    .special-block-preview {
        width: 32px;
        height: 32px;
        font-size: 14px;
    }
    
    .special-block-item span {
        font-size: 10px;
    }
    
    .game-tip {
        padding: 8px 15px;
        min-height: 35px;
        font-size: 11px;
    }
}

/* 平板端优化 (768px - 1024px) */
@media (min-width: 768px) and (max-width: 1024px) {
    #game-container {
        max-width: 700px;
    }
    
    .game-title {
        font-size: 56px;
    }
    
    .level-grid {
        grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
    }
}

/* PC端优化 (>1024px) */
@media (min-width: 1025px) {
    #game-container {
        max-width: 750px;
    }
    
    .game-title {
        font-size: 64px;
    }
    
    .game-subtitle {
        font-size: 24px;
    }
    
    .level-grid {
        grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
        gap: 20px;
    }
    
    .level-item {
        font-size: 20px;
    }
    
    .btn-primary {
        font-size: 20px;
        padding: 18px 50px;
    }
    
    .btn-secondary {
        font-size: 18px;
        padding: 14px 35px;
    }
    
    #result-title {
        font-size: 40px;
    }
    
    .stars-display {
        font-size: 60px;
    }
    
    .result-info {
        font-size: 20px;
    }
    
    .help-section h3 {
        font-size: 22px;
    }
    
    .help-section p {
        font-size: 18px;
    }
}

/* 超大屏幕优化 (>1440px) */
@media (min-width: 1440px) {
    #game-container {
        max-width: 800px;
    }
}
