* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
    overflow: hidden;
    position: fixed;
    width: 100%;
    height: 100%;
}

body {
    font-family: 'Arial', sans-serif;
    background-color: #000000;
    color: #ffffff;
    line-height: 1.6;
}

.container {
    max-width: 100%;
    margin: 0 auto;
    padding: 20px;
    padding-top: calc(env(safe-area-inset-top) + 20px);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

/* iPad 适配 */
@media only screen and (min-width: 768px) and (max-width: 1024px) {
    .container {
        max-width: 90%;
        padding: 30px;
        padding-top: calc(env(safe-area-inset-top) + 30px);
    }
}

h1 {
    text-align: center;
    margin-bottom: 20px;
    color: #ffffff;
}

.game-controls {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    margin-bottom: 0; /* 移除底部边距，使控制区域与信息栏贴合 */
    padding: 15px;
    background-color: #333333;
    border-radius: 5px 5px 0 0; /* 修改底部圆角，使其与信息栏贴合 */
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.5);
}

.control-group {
    margin-bottom: 15px;
    flex: 1 0 200px;
    margin-right: 15px;
}

@media only screen and (min-width: 768px) and (max-width: 1024px) {
    .control-group {
        flex: 1 0 250px;
        margin-bottom: 20px;
    }
}

.control-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: bold;
    color: #ffffff;
}

/* 滑块样式 */
input[type="range"] {
    width: 100%;
    height: 20px;
    -webkit-appearance: none;
    appearance: none;
    background: #555555;
    outline: none;
    border-radius: 10px;
    margin-top: 12px;
    touch-action: none;
}

@media only screen and (min-width: 768px) and (max-width: 1024px) {
    input[type="range"] {
        height: 24px;
        margin-top: 15px;
    }
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 32px;
    height: 32px;
    background: #3498db;
    border-radius: 50%;
    cursor: pointer;
    transition: background 0.2s;
    border: 2px solid rgba(255, 255, 255, 0.5);
}

@media only screen and (min-width: 768px) and (max-width: 1024px) {
    input[type="range"]::-webkit-slider-thumb {
        width: 40px;
        height: 40px;
    }
}

input[type="range"]::-moz-range-thumb {
    width: 20px;
    height: 20px;
    background: #3498db;
    border-radius: 50%;
    cursor: pointer;
    transition: background 0.2s;
}

input[type="range"]:active::-webkit-slider-thumb {
    background: #2980b9;
}

input[type="range"]:active::-moz-range-thumb {
    background: #2980b9;
}

#speed-a::-webkit-slider-thumb {
    background: #e74c3c;
}

#speed-a::-moz-range-thumb {
    background: #e74c3c;
}

#speed-a:active::-webkit-slider-thumb {
    background: #c0392b;
}

#speed-a:active::-moz-range-thumb {
    background: #c0392b;
}

/* 初始距离滑块使用黑色 */
#initial-distance::-webkit-slider-thumb {
    background: #ffffff;
}

#initial-distance::-moz-range-thumb {
    background: #ffffff;
}

#initial-distance:active::-webkit-slider-thumb {
    background: #dddddd;
}

#initial-distance:active::-moz-range-thumb {
    background: #dddddd;
}

.control-group span {
    font-weight: bold;
    color: #ffffff;
}

.control-group input {
    width: 100%;
    padding: 8px;
    border: 1px solid #555555;
    border-radius: 4px;
}

.button-group {
    display: flex;
    gap: 10px;
    flex: 1 0 160px; /* 减少20%，从200px到160px */
    align-items: flex-end;
}

button {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 16px;
    transition: background-color 0.3s;
    min-width: 100px;
}

@media only screen and (min-width: 768px) and (max-width: 1024px) {
    button {
        padding: 15px 30px;
        font-size: 18px;
        min-width: 120px;
    }
}

#start-btn {
    background-color: #27ae60;
    color: white;
}

#start-btn:hover {
    background-color: #2ecc71;
}

#reset-btn {
    background-color: #e74c3c;
    color: white;
}

#reset-btn:hover {
    background-color: #f1716d;
}

.game-info {
    display: flex;
    justify-content: space-between;
    margin-bottom: 15px;
    padding: 8px; /* 减小内边距 */
    background-color: #3498db;
    color: white;
    border-radius: 0 0 5px 5px; /* 修改顶部圆角，使其与控制区域贴合 */
    font-size: 14px; /* 减小字体大小 */
}

#game-canvas {
    width: 100%;
    height: 250px;
    background-color: #ffffff;
    border: 2px solid #444444;
    border-radius: 10px;
    margin-bottom: 20px;
    box-shadow: 0 4px 8px rgba(255, 255, 255, 0.15);
    touch-action: none;
}

@media only screen and (min-width: 768px) and (max-width: 1024px) {
    #game-canvas {
        height: 300px;
        border-width: 3px;
    }
}

.explanation {
    background-color: #333333;
    padding: 15px;
    border-radius: 5px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

.explanation h2 {
    margin-bottom: 10px;
    color: #ffffff;
}

.explanation ul {
    margin-left: 20px;
    margin-bottom: 10px;
}


.back-button {
    position: fixed;
    top: calc(env(safe-area-inset-top) + 20px);
    left: 20px;
    width: 32px;
    height: 32px;
    background: transparent;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 1000;
    transition: opacity 0.3s ease;
}

.back-button:hover {
    opacity: 0.8;
    transform: none;
    box-shadow: none;
}

.back-button i {
    color: white;
    font-size: 12px;
}