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

body {
    background-color: #1a1a2e;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    overflow: hidden;
    padding: 10px;
    box-sizing: border-box;
}

.game-layout {
    display: flex;
    gap: 20px;
    align-items: flex-start;
    max-width: 100%;
    max-height: 100vh;
}

.left-panel {
    display: flex;
    flex-direction: column;
    gap: 15px;
    width: 180px;
    min-width: 150px;
    flex-shrink: 0;
}

#gameCanvas {
    border: 3px solid #4a4a6a;
    border-radius: 8px;
    background-color: #2d4a2d;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    max-width: 100%;
    max-height: calc(100vh - 20px);
}

.side-panel {
    display: flex;
    flex-direction: column;
    gap: 15px;
    width: 180px;
    min-width: 150px;
    flex-shrink: 0;
}

@media (max-width: 1400px) {
    .game-layout {
        gap: 15px;
    }

    .left-panel,
    .side-panel {
        width: 160px;
        min-width: 140px;
        gap: 10px;
    }
}

@media (max-width: 1200px) {
    .left-panel,
    .side-panel {
        width: 140px;
        min-width: 120px;
    }
}

@media (max-width: 900px) {
    body {
        padding: 5px;
    }

    .game-layout {
        flex-direction: column;
        align-items: center;
        gap: 10px;
    }

    .left-panel {
        flex-direction: row;
        width: 100%;
        max-width: 600px;
        justify-content: space-around;
    }

    .side-panel {
        width: 100%;
        max-width: 600px;
    }

    #gameCanvas {
        max-height: 50vh;
    }

    .controls-info,
    .steering-wheel {
        flex: 1;
    }

    .controls-info h3 {
        font-size: 14px;
    }

    .controls-info p {
        font-size: 12px;
    }

    #steeringCanvas {
        width: 100px;
        height: 100px;
    }
}

@media (max-height: 700px) {
    .left-panel,
    .side-panel {
        gap: 8px;
    }

    .timer-display,
    .speedometer,
    .seed-display {
        padding: 8px 12px;
    }

    .timer-value {
        font-size: 24px;
    }

    .panel-button {
        padding: 8px 12px;
        font-size: 12px;
    }
}

.controls-info {
    background: rgba(0, 0, 0, 0.8);
    color: #fff;
    padding: 15px;
    border-radius: 8px;
    font-size: 14px;
}

.controls-info h3 {
    margin-bottom: 10px;
    color: #7dd87d;
    font-size: 16px;
}

.controls-info p {
    margin: 5px 0;
}

kbd {
    background: #444;
    padding: 2px 8px;
    border-radius: 4px;
    font-family: monospace;
    font-size: 12px;
    border: 1px solid #666;
}

.speedometer {
    background: rgba(0, 0, 0, 0.8);
    color: #fff;
    padding: 15px 20px;
    border-radius: 8px;
    font-size: 18px;
    text-align: center;
}

#speedDisplay {
    color: #7dd87d;
    font-weight: bold;
    font-size: 28px;
    display: block;
}

.steering-wheel {
    background: rgba(0, 0, 0, 0.8);
    color: #fff;
    padding: 15px;
    border-radius: 8px;
    text-align: center;
}

#steeringCanvas {
    background: #222;
    border-radius: 50%;
    border: 2px solid #444;
}

#steeringLabel {
    margin-top: 5px;
    font-size: 12px;
    color: #aaa;
}

.steering-mode-btn {
    margin-top: 8px;
    background: #4a7c4a;
    color: #fff;
    border: none;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 12px;
    cursor: pointer;
    transition: background 0.2s;
    width: 100%;
}

.steering-mode-btn:hover {
    background: #5a9c5a;
}

.steering-mode-btn.auto-center {
    background: #7c4a7c;
}

.steering-mode-btn.auto-center:hover {
    background: #9c5a9c;
}

.hint-display {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.7);
    color: #fff;
    padding: 15px 30px;
    border-radius: 8px;
    font-size: 18px;
    font-weight: bold;
    display: none;
    z-index: 100;
    border: 2px solid rgba(255, 255, 255, 0.3);
    max-width: 90vw;
    text-align: center;
}

@media (max-width: 600px) {
    .hint-display {
        font-size: 16px;
        padding: 12px 24px;
    }
}

.win-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 200;
}

.win-screen.show {
    display: flex;
}

.win-content {
    background: #2d4a2d;
    padding: 40px 60px;
    border-radius: 16px;
    text-align: center;
    color: #fff;
    border: 3px solid #7dd87d;
    max-width: calc(100vw - 40px);
}

@media (max-width: 600px) {
    .win-content {
        padding: 30px 40px;
    }

    .win-content h1 {
        font-size: 24px;
    }

    .win-content p {
        font-size: 16px;
    }

    .win-content button {
        padding: 10px 20px;
        font-size: 14px;
    }
}

.win-content h1 {
    color: #7dd87d;
    margin-bottom: 10px;
    font-size: 32px;
}

.win-content p {
    margin-bottom: 20px;
    font-size: 18px;
}

.win-content button {
    background: #4a7c4a;
    color: #fff;
    border: none;
    padding: 12px 24px;
    margin: 5px;
    border-radius: 8px;
    font-size: 16px;
    cursor: pointer;
    transition: background 0.2s;
}

.win-content button:hover {
    background: #5a9c5a;
}

.panel-button {
    background: #4a7c4a;
    color: #fff;
    border: none;
    padding: 10px 16px;
    border-radius: 8px;
    font-size: 13px;
    cursor: pointer;
    transition: background 0.2s;
    width: 100%;
    margin-top: 1px;
}

.panel-button:hover {
    background: #5a9c5a;
}

.panel-button.danger {
    background: #7c4a4a;
}

.panel-button.danger:hover {
    background: #9c5a5a;
}

.seed-display {
    background: rgba(0, 0, 0, 0.8);
    color: #fff;
    padding: 10px 15px;
    border-radius: 8px;
    text-align: center;
}

.seed-label {
    font-size: 11px;
    color: #aaa;
    margin-bottom: 3px;
}

.seed-value {
    font-size: 16px;
    font-weight: bold;
    color: #7dd87d;
    font-family: monospace;
    cursor: pointer;
    user-select: all;
}

.seed-value:hover {
    color: #9df89d;
    text-decoration: underline;
}

.timer-display {
    background: rgba(0, 0, 0, 0.8);
    color: #fff;
    padding: 15px;
    border-radius: 8px;
    text-align: center;
}

.timer-label {
    font-size: 12px;
    color: #aaa;
    margin-bottom: 5px;
}

.timer-value {
    font-size: 28px;
    font-weight: bold;
    color: #7dd87d;
}

.best-time {
    font-size: 12px;
    color: #aaa;
    margin-top: 5px;
}

.progress-container {
    background: rgba(0, 0, 0, 0.5);
    border-radius: 4px;
    height: 8px;
    margin: 4px 0;
    overflow: hidden;
}

.progress-bar {
    width: 0%;
    height: 100%;
    background: linear-gradient(90deg, #7dd87d, #4a7c4a);
    transition: width 0.1s linear;
}

.settings-panel {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 300;
}

.settings-panel.show {
    display: flex;
}

.settings-content {
    background: #2d3a2d;
    padding: 30px;
    border-radius: 16px;
    color: #fff;
    border: 3px solid #4a7c4a;
    max-width: 500px;
    max-height: 80vh;
    overflow-y: auto;
    width: 90%;
    max-width: calc(100vw - 40px);
    position: relative;
}

.settings-header {
    position: sticky;
    top: -30px;
    left: -30px;
    right: -30px;
    margin: -30px -30px 20px -30px;
    background: #2d3a2d;
    padding: 15px 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #4a7c4a;
    border-radius: 13px 13px 0 0;
    z-index: 10;
}

.settings-header h2 {
    margin: 0;
    color: #7dd87d;
}

.close-btn {
    background: none;
    border: none;
    color: #fff;
    font-size: 28px;
    cursor: pointer;
    line-height: 1;
    padding: 0;
    margin-left: auto;
}

.close-btn:hover {
    color: #7dd87d;
}

.settings-list {
    margin-bottom: 20px;
}

.setting-item {
    background: rgba(0, 0, 0, 0.3);
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 15px;
}

.setting-item label {
    display: block;
    font-weight: bold;
    margin-bottom: 5px;
    color: #7dd87d;
}

.setting-item .setting-desc {
    font-size: 12px;
    color: #aaa;
    margin-bottom: 10px;
}

.setting-item .setting-range {
    font-size: 11px;
    color: #888;
    margin-bottom: 8px;
}

.setting-item input[type="range"] {
    width: 100%;
    margin-bottom: 5px;
}

.setting-item .setting-value {
    text-align: right;
    font-weight: bold;
    color: #7dd87d;
}

.setting-item .setting-buttons {
    display: flex;
    gap: 10px;
    margin-top: 8px;
}

.setting-item button {
    background: #444;
    color: #fff;
    border: none;
    padding: 5px 10px;
    border-radius: 4px;
    font-size: 12px;
    cursor: pointer;
    flex: 1;
}

.setting-item button:hover {
    background: #555;
}

.settings-buttons {
    display: flex;
    gap: 10px;
    margin-top: 20px;
}

@media (max-width: 600px) {
    .settings-content {
        padding: 20px;
    }

    .settings-header {
        padding: 12px 20px;
        margin: -20px -20px 15px -20px;
    }

    .settings-header h2 {
        font-size: 18px;
    }

    .close-btn {
        font-size: 24px;
    }

    .setting-item {
        padding: 12px;
    }

    .setting-item label {
        font-size: 13px;
    }
}