/* 重置和基础样式 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

body {
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    color: #f1f1f1;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center; /* 改为居中而不是flex-start */
    padding: 10px;
    overflow-y: auto;
}

.container {
    max-width: 1200px;
    width: 100%;
    background: rgba(25, 25, 35, 0.9);
    border-radius: 20px;
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.5);
    padding: 15px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    margin: 10px 0;
}

/* 头部样式 */
header {
    text-align: center;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 2px solid rgba(100, 150, 255, 0.3);
}

header h1 {
    font-size: 2rem;
    background: linear-gradient(90deg, #4cc9f0, #4361ee);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    margin-bottom: 5px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

header .subtitle {
    font-size: 1rem;
    color: #a0a0c0;
    font-weight: 300;
}

/* 游戏区域 */
.game-area {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-bottom: 15px;
    /* 移除固定min-height，让内容决定高度 */
}

.canvas-container {
    position: relative;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.7);
    border: 2px solid rgba(100, 150, 255, 0.2);
    aspect-ratio: 3/4; /* 3:4比例 - 固定长宽比 */
    width: 100%;
    max-width: 600px; /* 最大宽度限制 */
    margin: 0 auto; /* 居中 */
    flex-shrink: 0;
    /* 移除 min-height 和 max-height，让 aspect-ratio 完全控制尺寸 */
}

#gameCanvas {
    display: block;
    background: #0f1525;
    width: 100%;
    height: 100%;
}

.game-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 21, 37, 0.9);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10;
}

.overlay-content {
    text-align: center;
    padding: 5%;
    background: rgba(30, 35, 50, 0.9);
    border-radius: 15px;
    border: 2px solid rgba(100, 150, 255, 0.3);
    max-width: 80%;
    width: 90%;
    margin: 0 auto;
}

.overlay-content h2 {
    font-size: 2.2rem;
    margin-bottom: 20px;
    color: #4cc9f0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.overlay-content p {
    font-size: 1.1rem;
    margin-bottom: 15px;
    color: #c0c0e0;
    line-height: 1.6;
}

/* 按钮样式 */
.btn-primary, .btn-secondary {
    padding: 15px 30px;
    font-size: 1.1rem;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    margin: 10px;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    font-weight: 600;
}

.btn-primary {
    background: linear-gradient(90deg, #4361ee, #3a0ca3);
    color: white;
}

.btn-primary:hover {
    background: linear-gradient(90deg, #3a0ca3, #4361ee);
    transform: translateY(-3px);
    box-shadow: 0 7px 15px rgba(67, 97, 238, 0.4);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.1);
    color: #c0c0e0;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: translateY(-3px);
}

/* 底部控制面板 */
.bottom-controls {
    margin-top: 5px;
    width: 100%;
    max-width: 600px; /* 与游戏框相同宽度 */
    margin-left: auto;
    margin-right: auto; /* 居中 */
    flex-shrink: 0;
}

.control-panel {
    background: rgba(30, 35, 50, 0.8);
    border-radius: 12px;
    padding: 15px;
    border: 1px solid rgba(100, 150, 255, 0.2);
}

.slider-container {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.slider-container label {
    font-size: 1.2rem;
    color: #4cc9f0;
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 600;
}

.slider-container label i {
    font-size: 1.3rem;
}

.slider-wrapper {
    display: flex;
    align-items: center;
    gap: 20px;
}

.slider {
    flex: 1;
    -webkit-appearance: none;
    height: 10px;
    background: linear-gradient(90deg, #4361ee, #3a0ca3);
    border-radius: 5px;
    outline: none;
}

.slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 25px;
    height: 25px;
    border-radius: 50%;
    background: #ffd166;
    cursor: pointer;
    border: 2px solid #fff;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
}

.slider::-moz-range-thumb {
    width: 25px;
    height: 25px;
    border-radius: 50%;
    background: #ffd166;
    cursor: pointer;
    border: 2px solid #fff;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
}

.slider-value {
    min-width: 40px;
    text-align: center;
    background: rgba(67, 97, 238, 0.2);
    padding: 8px 12px;
    border-radius: 8px;
    font-weight: bold;
    color: #ffd166;
    font-size: 1.1rem;
}

.slider-labels {
    display: flex;
    justify-content: space-between;
    margin-top: 5px;
    color: #a0a0c0;
    font-size: 0.9rem;
}


/* 键盘按键样式 */
kbd {
    background: linear-gradient(135deg, #2d3047, #1c1e2e);
    border: 1px solid rgba(100, 150, 255, 0.5);
    border-radius: 5px;
    padding: 3px 8px;
    font-family: monospace;
    font-size: 1rem;
    color: #ffd166;
    box-shadow: 0 3px 0 rgba(0, 0, 0, 0.3);
    margin: 0 5px;
}

/* 响应式设计 */
@media (max-width: 1024px) {
    body {
        padding: 10px;
        align-items: center;
        display: flex;
        justify-content: center;
        min-height: 100vh;
    }
    
    .container {
        display: flex;
        flex-direction: column;
        min-height: 0;
    }
    
    .game-area {
        flex-direction: column;
        min-height: 0;
        flex: 1;
        overflow: hidden;
    }
    
    .canvas-container {
        order: 1;
        flex: 1;
    }
    
    .bottom-controls {
        order: 2;
        margin-top: 10px;
        margin-bottom: 5px;
        flex-shrink: 0;
    }
    
    header h1 {
        font-size: 2.2rem;
    }
}

@media (max-width: 768px) {
    body {
        padding: 8px;
        align-items: center; /* 改为居中 */
        display: flex;
        justify-content: center;
        min-height: 100vh;
    }
    
    .container {
        padding: 12px;
        margin: 8px 0;
        display: flex;
        flex-direction: column;
        min-height: 0;
    }
    
    header {
        margin-bottom: 12px;
        padding-bottom: 8px;
        flex-shrink: 0;
    }
    
    header h1 {
        font-size: 1.6rem;
        gap: 8px;
    }
    
    header .subtitle {
        font-size: 0.9rem;
    }
    
    .game-area {
        gap: 12px;
        margin-bottom: 12px;
        min-height: 0;
        display: flex;
        flex-direction: column;
        flex: 1;
        overflow: hidden;
    }
    
    .canvas-container {
        border-radius: 10px;
        flex: 1;
        aspect-ratio: 3/4; /* 确保保持3:4宽高比 */
        /* 移除 min-height，让 aspect-ratio 完全控制 */
    }
    
    .overlay-content {
        padding: 15px;
        max-width: 85%;
        width: 95%;
    }
    
    .overlay-content h2 {
        font-size: 1.6rem;
        margin-bottom: 12px;
    }
    
    .overlay-content p {
        font-size: 0.95rem;
        margin-bottom: 10px;
        line-height: 1.5;
    }
    
    .btn-primary, .btn-secondary {
        padding: 10px 20px;
        font-size: 0.95rem;
        margin: 6px;
    }
    
    .bottom-controls {
        margin-top: 8px; /* 增加上边距 */
        margin-bottom: 5px;
        flex-shrink: 0;
    }
    
    .control-panel {
        padding: 12px;
        border-radius: 10px;
    }
    
    .slider-container {
        gap: 10px;
    }
    
    .slider-container label {
        font-size: 1rem;
    }
    
    .slider-wrapper {
        gap: 15px;
    }
    
    /* 增大移动端滑动条触摸区域 */
    .slider {
        height: 12px; /* 增大轨道高度 */
    }
    
    .slider::-webkit-slider-thumb {
        width: 50px; /* 增大两倍 */
        height: 50px; /* 增大两倍 */
        border: 3px solid #fff; /* 增大边框 */
    }
    
    .slider::-moz-range-thumb {
        width: 50px; /* 增大两倍 */
        height: 50px; /* 增大两倍 */
        border: 3px solid #fff; /* 增大边框 */
    }
}

@media (max-width: 600px) {
    body {
        padding: 5px;
        align-items: center; /* 改为居中而不是flex-start */
        overflow-y: auto;
        min-height: 100vh;
        display: flex;
        justify-content: center;
    }
    
    .container {
        padding: 8px;
        margin: 5px 0;
        border-radius: 12px;
        width: 100%;
        max-width: 600px;
        display: flex;
        flex-direction: column;
        min-height: 0; /* 允许容器缩小 */
    }
    
    header {
        margin-bottom: 10px;
        padding-bottom: 8px;
        flex-shrink: 0; /* 防止头部被压缩 */
    }
    
    header h1 {
        font-size: 1.3rem;
        margin-bottom: 3px;
    }
    
    header .subtitle {
        font-size: 0.8rem;
    }
    
    .game-area {
        gap: 8px;
        margin-bottom: 8px;
        min-height: 0; /* 允许游戏区域缩小 */
        display: flex;
        flex-direction: column;
        flex: 1; /* 占据可用空间 */
        overflow: hidden; /* 防止溢出 */
    }
    
    .canvas-container {
        aspect-ratio: 3/4; /* 保持3:4宽高比 */
        width: 100%;
        max-width: 100%;
        flex-shrink: 0;
        flex: 1; /* 占据可用空间 */
        /* 移除 min-height 和 max-height，让 aspect-ratio 完全控制 */
    }
    
    .overlay-content {
        padding: 10px;
        max-width: 95%;
        width: 98%;
        border-radius: 8px;
    }
    
    .overlay-content h2 {
        font-size: 1.2rem;
        margin-bottom: 8px;
    }
    
    .overlay-content p {
        font-size: 0.8rem;
        margin-bottom: 6px;
        line-height: 1.4;
    }
    
    .btn-primary, .btn-secondary {
        padding: 6px 12px;
        font-size: 0.8rem;
        margin: 4px;
    }
    
    .bottom-controls {
        margin-top: 10px; /* 增加上边距 */
        max-width: 100%;
        flex-shrink: 0;
        margin-bottom: 5px; /* 添加下边距 */
    }
    
    .control-panel {
        padding: 8px;
        border-radius: 8px;
    }
    
    .slider-container {
        gap: 8px;
    }
    
    .slider-container label {
        font-size: 0.85rem;
    }
    
    .slider-wrapper {
        gap: 10px;
    }
    
    .slider {
        height: 10px; /* 增大轨道高度 */
    }
    
    .slider-value {
        padding: 4px 8px;
        font-size: 0.8rem;
        min-width: 35px;
    }
    
    .slider-labels {
        font-size: 0.75rem;
    }
    
    /* 增大移动端滑动条触摸区域 */
    .slider::-webkit-slider-thumb {
        width: 50px; /* 增大两倍 */
        height: 50px; /* 增大两倍 */
        border: 3px solid #fff; /* 增大边框 */
    }
    
    .slider::-moz-range-thumb {
        width: 50px; /* 增大两倍 */
        height: 50px; /* 增大两倍 */
        border: 3px solid #fff; /* 增大边框 */
    }
}

@media (max-width: 480px) {
    body {
        padding: 3px;
        align-items: center;
        display: flex;
        justify-content: center;
        min-height: 100vh;
    }
    
    .container {
        padding: 6px;
        margin: 3px 0;
        display: flex;
        flex-direction: column;
        min-height: 0;
    }
    
    header {
        margin-bottom: 8px;
        padding-bottom: 6px;
        flex-shrink: 0;
    }
    
    header h1 {
        font-size: 1.2rem;
    }
    
    header .subtitle {
        font-size: 0.7rem;
    }
    
    .game-area {
        gap: 6px;
        margin-bottom: 6px;
        min-height: 0;
        display: flex;
        flex-direction: column;
        flex: 1;
        overflow: hidden;
    }
    
    .canvas-container {
        aspect-ratio: 3/4; /* 保持3:4宽高比 */
        flex: 1;
        /* 移除 min-height 和 max-height，让 aspect-ratio 完全控制 */
    }
    
    .overlay-content {
        padding: 8px;
        max-width: 98%;
        width: 99%;
        border-radius: 6px;
    }
    
    .overlay-content h2 {
        font-size: 1.2rem;
        margin-bottom: 6px;
    }
    
    .overlay-content p {
        font-size: 0.7rem;
        margin-bottom: 4px;
        line-height: 1.3;
    }
    
    .btn-primary, .btn-secondary {
        padding: 4px 8px;
        font-size: 0.7rem;
        margin: 3px;
    }
    
    .bottom-controls {
        margin-top: 8px;
        margin-bottom: 3px;
        flex-shrink: 0;
    }
    
    .control-panel {
        padding: 6px;
        border-radius: 6px;
    }
    
    .slider-container {
        gap: 6px;
    }
    
    .slider-container label {
        font-size: 0.75rem;
    }
    
    .slider-wrapper {
        gap: 8px;
    }
    
    .slider {
        height: 8px; /* 增大轨道高度 */
    }
    
    .slider-value {
        padding: 3px 6px;
        font-size: 0.7rem;
        min-width: 30px;
    }
    
    .slider-labels {
        font-size: 0.65rem;
    }
    
    /* 增大移动端滑动条触摸区域 */
    .slider::-webkit-slider-thumb {
        width: 50px; /* 增大两倍 */
        height: 50px; /* 增大两倍 */
        border: 3px solid #fff; /* 增大边框 */
    }
    
    .slider::-moz-range-thumb {
        width: 50px; /* 增大两倍 */
        height: 50px; /* 增大两倍 */
        border: 3px solid #fff; /* 增大边框 */
    }
}
