/* 像素迷宫逃脱 - 8位像素风格 */

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

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    font-family: 'Courier New', monospace;
    background: #000000;
    color: #FFFFFF;
    user-select: none;
    -webkit-user-select: none;
    touch-action: manipulation;
}

/* 屏幕容器 */
.screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: none;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.screen.active {
    display: flex;
    opacity: 1;
}

.screen.overlay {
    background: rgba(0, 0, 0, 0.9);
    z-index: 100;
}

/* 容器 */
.container {
    width: 100%;
    max-width: 600px;
    margin: auto;
    padding: 20px;
    text-align: center;
}

/* 开始界面 */
.game-title {
    font-size: clamp(24px, 6vw, 48px);
    color: #00FF00;
    text-shadow: 4px 4px 0 #000000,
                 -2px -2px 0 #FFFFFF,
                 2px -2px 0 #FFFFFF,
                 -2px 2px 0 #FFFFFF;
    margin-bottom: 10px;
    letter-spacing: 2px;
}

.subtitle {
    font-size: clamp(12px, 3vw, 18px);
    color: #888888;
    margin-bottom: 30px;
    letter-spacing: 4px;
}

/* 难度选择 */
.difficulty-selector {
    margin-bottom: 30px;
}

.difficulty-selector h3 {
    font-size: clamp(16px, 4vw, 20px);
    margin-bottom: 15px;
    color: #FFD700;
}

.difficulty-buttons {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
}

.diff-btn {
    padding: 15px;
    border: 3px solid #FFFFFF;
    background: #000000;
    color: #FFFFFF;
    font-family: 'Courier New', monospace;
    font-size: clamp(12px, 3vw, 16px);
    cursor: pointer;
    transition: all 0.1s;
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.diff-btn:hover {
    background: #222222;
}

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

.diff-btn.selected {
    background: #00FF00;
    color: #000000;
    border-color: #00FF00;
}

.diff-btn.easy { border-color: #00FF00; }
.diff-btn.normal { border-color: #FFA500; }
.diff-btn.hard { border-color: #FF0000; }
.diff-btn.expert { border-color: #FF00FF; }

.diff-btn.easy.selected { background: #00FF00; }
.diff-btn.normal.selected { background: #FFA500; }
.diff-btn.hard.selected { background: #FF0000; }
.diff-btn.expert.selected { background: #FF00FF; }

.diff-label {
    font-weight: bold;
    font-size: clamp(14px, 3.5vw, 18px);
}

.diff-info {
    font-size: clamp(10px, 2.5vw, 14px);
    opacity: 0.8;
}

/* 记录显示 */
.records {
    margin-bottom: 30px;
    padding: 15px;
    border: 2px solid #333333;
    background: rgba(255, 255, 255, 0.05);
}

.records h3 {
    font-size: clamp(14px, 3.5vw, 18px);
    margin-bottom: 10px;
    color: #FFD700;
}

.record-item {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    font-size: clamp(12px, 3vw, 16px);
    border-bottom: 1px dashed #333333;
}

.record-item:last-child {
    border-bottom: none;
}

/* 按钮 */
.primary-btn {
    width: 100%;
    padding: 18px 40px;
    font-size: clamp(16px, 4vw, 20px);
    font-family: 'Courier New', monospace;
    font-weight: bold;
    color: #000000;
    background: #00FF00;
    border: 3px solid #00FF00;
    cursor: pointer;
    transition: all 0.1s;
    margin-bottom: 10px;
}

.primary-btn:hover {
    background: #00CC00;
    border-color: #00CC00;
}

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

.secondary-btn {
    width: 100%;
    padding: 15px 40px;
    font-size: clamp(14px, 3.5vw, 18px);
    font-family: 'Courier New', monospace;
    color: #FFFFFF;
    background: transparent;
    border: 3px solid #FFFFFF;
    cursor: pointer;
    transition: all 0.1s;
}

.secondary-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

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

/* 游戏界面 */
.game-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 15px;
    background: rgba(255, 255, 255, 0.05);
    border-bottom: 2px solid #333333;
}

.game-info {
    display: flex;
    gap: 20px;
}

.info-item {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.info-item .label {
    font-size: clamp(10px, 2.5vw, 12px);
    color: #888888;
}

.info-item .value {
    font-size: clamp(16px, 4vw, 20px);
    font-weight: bold;
    color: #00FF00;
}

.icon-btn {
    width: 44px;
    height: 44px;
    font-size: 20px;
    background: transparent;
    border: 2px solid #FFFFFF;
    color: #FFFFFF;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.1s;
}

.icon-btn:active {
    transform: scale(0.9);
    background: rgba(255, 255, 255, 0.1);
}

.game-container {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 10px;
}

#gameCanvas {
    max-width: 100%;
    max-height: 70vh;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
}

.touch-hint {
    padding: 10px;
    text-align: center;
    font-size: clamp(12px, 3vw, 14px);
    color: #666666;
}

/* 结束界面 */
#endScreen .container {
    padding: 30px 20px;
}

#endTitle {
    font-size: clamp(24px, 6vw, 36px);
    color: #00FF00;
    margin-bottom: 20px;
}

.stars {
    font-size: clamp(32px, 8vw, 48px);
    color: #FFD700;
    margin-bottom: 30px;
    text-shadow: 2px 2px 0 #000000;
}

.stars .star.empty {
    color: #333333;
}

.result-stats {
    margin-bottom: 20px;
}

.stat-item {
    display: flex;
    justify-content: space-between;
    padding: 12px 15px;
    margin-bottom: 10px;
    background: rgba(255, 255, 255, 0.05);
    border: 2px solid #333333;
}

.stat-label {
    font-size: clamp(14px, 3.5vw, 18px);
    color: #888888;
}

.stat-value {
    font-size: clamp(16px, 4vw, 20px);
    color: #00FF00;
    font-weight: bold;
}

.record-comparison {
    padding: 15px;
    margin-bottom: 20px;
    background: rgba(255, 215, 0, 0.1);
    border: 2px solid #FFD700;
    border-radius: 8px;
}

.record-comparison p {
    font-size: clamp(14px, 3.5vw, 18px);
    color: #FFD700;
}

.record-comparison.new-record {
    animation: pulse 0.5s ease-in-out infinite alternate;
}

@keyframes pulse {
    from {
        transform: scale(1);
    }
    to {
        transform: scale(1.05);
    }
}

.end-buttons {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* 响应式调整 */
@media (max-width: 480px) {
    .container {
        padding: 15px;
    }

    .difficulty-buttons {
        gap: 8px;
    }

    .diff-btn {
        padding: 12px;
    }

    .records {
        padding: 10px;
    }
}

/* 禁用缩放和滚动 */
@media touch-screen {
    * {
        touch-action: pan-y pinch-zoom;
    }

    .game-container {
        touch-action: none;
    }
}

/* 动画效果 */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.container > * {
    animation: fadeIn 0.3s ease-out forwards;
}

.container > *:nth-child(1) { animation-delay: 0.1s; }
.container > *:nth-child(2) { animation-delay: 0.2s; }
.container > *:nth-child(3) { animation-delay: 0.3s; }
.container > *:nth-child(4) { animation-delay: 0.4s; }
