/* 像素点灯大师 - 8位像素风格样式 */

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

@font-face {
    font-family: 'PixelFont';
    src: local('Courier New'), local('monospace');
}

:root {
    --bg-primary: #0a0e27;
    --bg-secondary: #16213e;
    --bg-tertiary: #1a1a2e;
    --accent-color: #00ff88;
    --light-on: #ffd700;
    --light-glow: #fff3a0;
    --light-off: #2a2a3a;
    --text-primary: #e0e0e0;
    --text-secondary: #b8b8b8;
    --border-color: #0f3460;
    --button-bg: #0f3460;
    --button-hover: #e94560;
    --shadow-color: #533483;
}

body {
    font-family: 'PixelFont', 'Courier New', monospace;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    overflow: hidden;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
}

/* 扫描线效果 */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: repeating-linear-gradient(
        0deg,
        rgba(0, 0, 0, 0.15),
        rgba(0, 0, 0, 0.15) 1px,
        transparent 1px,
        transparent 2px
    );
    pointer-events: none;
    z-index: 1000;
    opacity: 0.03;
}

#game-container {
    width: 100vw;
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
}

.screen {
    position: absolute;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: opacity 0.3s ease;
}

.screen.hidden {
    display: none;
}

/* 像素风格边框 */
.pixel-border {
    background: linear-gradient(135deg, var(--bg-secondary) 0%, var(--bg-tertiary) 100%);
    border: 4px solid var(--border-color);
    box-shadow: 
        0 0 0 4px var(--bg-tertiary),
        0 0 0 8px var(--border-color),
        inset 0 0 20px rgba(0, 0, 0, 0.5),
        0 8px 32px rgba(0, 0, 0, 0.4);
    padding: 30px 40px;
    text-align: center;
    image-rendering: pixelated;
}

/* 标题样式 */
.game-title {
    font-size: 2.5rem;
    color: var(--light-on);
    text-shadow: 
        4px 4px 0 var(--border-color),
        -2px -2px 0 var(--shadow-color),
        0 0 20px var(--light-glow);
    margin-bottom: 10px;
    letter-spacing: 4px;
    animation: titlePulse 2s ease-in-out infinite;
}

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

.subtitle {
    font-size: 1rem;
    color: var(--accent-color);
    letter-spacing: 8px;
    margin-bottom: 20px;
}

/* 总星数显示 */
.total-stars {
    font-size: 1.2rem;
    margin-bottom: 30px;
    color: var(--light-on);
}

.star-icon {
    font-size: 1.5rem;
}

/* 像素按钮 */
.pixel-btn {
    font-family: 'PixelFont', 'Courier New', monospace;
    font-size: 1.1rem;
    padding: 12px 30px;
    margin: 8px;
    background: linear-gradient(180deg, var(--button-bg) 0%, var(--bg-secondary) 100%);
    border: 3px solid var(--button-hover);
    color: var(--text-primary);
    cursor: pointer;
    position: relative;
    transition: all 0.1s ease;
    text-transform: uppercase;
    letter-spacing: 2px;
    box-shadow: 0 4px 0 var(--shadow-color);
}

.pixel-btn:hover {
    background: linear-gradient(180deg, var(--button-hover) 0%, #c73659 100%);
    transform: translateY(-2px);
    box-shadow: 0 6px 0 var(--shadow-color);
}

.pixel-btn:active {
    transform: translateY(2px);
    box-shadow: none;
}

.pixel-btn.hidden {
    display: none;
}

.menu-buttons {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

/* 难度标签 */
.difficulty-tabs {
    display: flex;
    gap: 5px;
    margin-bottom: 20px;
    flex-wrap: wrap;
    justify-content: center;
}

.tab-btn {
    font-family: 'PixelFont', monospace;
    font-size: 0.8rem;
    padding: 8px 12px;
    background: linear-gradient(180deg, var(--bg-secondary) 0%, var(--button-bg) 100%);
    border: 2px solid var(--border-color);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s ease;
}

.tab-btn.active {
    background: linear-gradient(180deg, var(--button-hover) 0%, #c73659 100%);
    border-color: var(--accent-color);
    color: var(--text-primary);
}

.tab-btn:hover:not(.active) {
    border-color: var(--button-hover);
}

/* 关卡选择网格 */
.level-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 10px;
    margin: 20px 0;
    max-width: 350px;
}

.level-btn {
    width: 50px;
    height: 50px;
    font-family: 'PixelFont', monospace;
    font-size: 1.2rem;
    background: linear-gradient(180deg, var(--bg-secondary) 0%, var(--button-bg) 100%);
    border: 3px solid var(--shadow-color);
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.1s ease;
    position: relative;
}

.level-btn:hover {
    border-color: var(--button-hover);
    background: linear-gradient(180deg, var(--button-bg) 0%, var(--bg-secondary) 100%);
}

.level-btn.completed {
    background: linear-gradient(180deg, #2d6a4f 0%, #1b4332 100%);
    border-color: #40916c;
}

.level-btn.completed::after {
    content: '⭐';
    position: absolute;
    top: 2px;
    right: 2px;
    font-size: 0.6rem;
}

.level-btn.current {
    background: linear-gradient(180deg, var(--button-hover) 0%, #c73659 100%);
    border-color: var(--accent-color);
    animation: currentLevelPulse 1.5s ease-in-out infinite;
}

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

.level-btn.locked {
    opacity: 0.3;
    cursor: not-allowed;
}

/* 帮助界面 */
.help-content {
    max-width: 400px;
}

.help-text {
    text-align: left;
    margin: 20px 0;
    line-height: 1.8;
    font-size: 0.95rem;
}

.legend {
    display: flex;
    gap: 20px;
    margin: 15px 0;
    padding: 15px;
    background: rgba(0, 0, 0, 0.3);
    border: 2px solid var(--border-color);
    justify-content: center;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.9rem;
}

.icon {
    width: 30px;
    height: 30px;
    border: 2px solid var(--border-color);
}

.icon.light-on {
    background: var(--light-on);
    box-shadow: 0 0 10px var(--light-glow);
}

.icon.light-off {
    background: var(--light-off);
}

/* 游戏界面 */
#game-screen {
    flex-direction: column;
    padding: 10px;
}

.game-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    max-width: 500px;
    padding: 10px 15px;
    background: rgba(0, 0, 0, 0.5);
    border: 3px solid var(--border-color);
    margin-bottom: 10px;
}

.back-btn {
    font-family: 'PixelFont', monospace;
    font-size: 1.5rem;
    background: none;
    border: none;
    color: var(--text-primary);
    cursor: pointer;
    padding: 5px 10px;
    transition: transform 0.1s ease;
}

.back-btn:active {
    transform: scale(0.9);
}

.level-info, .move-counter {
    font-size: 1rem;
    color: var(--light-on);
}

#game-canvas {
    border: 4px solid var(--border-color);
    box-shadow: 
        0 0 0 4px var(--bg-tertiary),
        0 0 0 8px var(--shadow-color),
        0 8px 32px rgba(0, 0, 0, 0.5);
    background: var(--bg-secondary);
    image-rendering: pixelated;
    image-rendering: crisp-edges;
    max-width: 95vw;
    max-height: 60vh;
    touch-action: none;
}

/* 游戏控制按钮 */
.game-controls {
    display: flex;
    gap: 10px;
    margin-top: 15px;
}

.control-btn {
    font-family: 'PixelFont', monospace;
    font-size: 0.9rem;
    padding: 10px 15px;
    background: linear-gradient(180deg, var(--button-bg) 0%, var(--bg-secondary) 100%);
    border: 3px solid var(--shadow-color);
    color: var(--text-primary);
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    transition: all 0.1s ease;
    position: relative;
}

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

.btn-icon {
    font-size: 1.5rem;
}

.btn-text {
    font-size: 0.75rem;
}

.control-btn .count {
    position: absolute;
    top: 5px;
    right: 5px;
    font-size: 0.7rem;
    background: var(--button-hover);
    padding: 2px 5px;
    border-radius: 3px;
}

.control-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* 胜利界面 */
.win-buttons {
    display: flex;
    flex-direction: column;
    gap: 5px;
    margin-top: 15px;
}

#win-screen h2 {
    color: var(--light-on);
    font-size: 2rem;
    text-shadow: 3px 3px 0 var(--button-hover);
    animation: winBounce 0.5s ease-in-out;
}

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

#win-screen p {
    font-size: 1.1rem;
    margin: 8px 0;
    color: var(--text-secondary);
}

.star-rating {
    font-size: 2.5rem;
    margin: 20px 0;
}

.star {
    display: inline-block;
    opacity: 0.3;
    transition: all 0.3s ease;
    transform: scale(0.5);
}

.star.earned {
    opacity: 1;
    transform: scale(1);
    animation: starEarned 0.5s ease-out;
}

@keyframes starEarned {
    0% { transform: scale(0.5) rotate(-180deg); }
    50% { transform: scale(1.3) rotate(0deg); }
    100% { transform: scale(1) rotate(0deg); }
}

/* 横屏提示 */
.landscape-warning {
.landscape-warning.hidden {
    display: none;
}
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
}

.warning-content {
    text-align: center;
    color: var(--text-primary);
}

.warning-content p:first-child {
    font-size: 3rem;
    margin-bottom: 20px;
}

/* Toast 提示 */
.toast {
    position: fixed;
    bottom: 100px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.9);
    border: 2px solid var(--accent-color);
    color: var(--text-primary);
    padding: 15px 25px;
    font-size: 1rem;
    z-index: 1500;
    animation: toastFadeIn 0.3s ease;
}

@keyframes toastFadeIn {
    from { opacity: 0; transform: translateX(-50%) translateY(20px); }
    to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* 移动端适配 */
@media (max-width: 480px) {
    .game-title {
        font-size: 1.8rem;
    }
    
    .subtitle {
        font-size: 0.8rem;
        letter-spacing: 4px;
    }
    
    .pixel-btn {
        font-size: 1rem;
        padding: 10px 25px;
    }
    
    .pixel-border {
        padding: 20px;
        margin: 10px;
    }
    
    .level-grid {
        grid-template-columns: repeat(5, 1fr);
        gap: 8px;
    }
    
    .level-btn {
        width: 45px;
        height: 45px;
        font-size: 1rem;
    }
    
    .game-header {
        padding: 8px 15px;
        font-size: 0.9rem;
    }
    
    .difficulty-tabs {
        gap: 3px;
    }
    
    .tab-btn {
        font-size: 0.7rem;
        padding: 6px 10px;
    }
}

/* 横屏适配 */
@media (orientation: landscape) and (max-height: 500px) {
    .game-title {
        font-size: 1.5rem;
    }
    
    .pixel-border {
        padding: 15px 25px;
    }
    
    #game-canvas {
        max-height: 70vh;
    }
}

/* 触控反馈 */
@media (hover: none) {
    .pixel-btn:active {
        background: linear-gradient(180deg, var(--button-hover) 0%, #c73659 100%);
        transform: scale(0.95);
    }
    
    .level-btn:active {
        transform: scale(0.9);
    }
    
    .control-btn:active {
        transform: scale(0.9);
    }
}
