body, html {
    margin: 0;
    padding: 0;
    overflow: hidden;
    height: 100%;
    width: 100%;
    background-color: #111;
    font-family: 'Inter', sans-serif;
    position: fixed;
    overscroll-behavior: none;
    touch-action: manipulation;
    -webkit-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
    /* Safe area bottom inset (set by JS for Android nav bar support) */
    --safe-bottom: 0px;
}

/* ===== Video Intro Overlay ===== */
.video-intro-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 999999;
    background: #000;
    display: flex;
    align-items: center;
    justify-content: center;
}

#introVideo {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Video Skip Button */
.video-skip {
    position: absolute;
    top: 20px;
    right: 20px;
    z-index: 1000000;
}

.skip-btn {
    background: rgba(0, 0, 0, 0.7);
    border: 2px solid #00BFFF;
    color: #00BFFF;
    padding: 10px 20px;
    border-radius: 25px;
    font-family: 'Consolas', monospace;
    font-size: 14px;
    font-weight: bold;
    cursor: pointer;
    letter-spacing: 1px;
    transition: all 0.3s ease;
    -webkit-tap-highlight-color: transparent;
}

.skip-btn:hover {
    background: rgba(0, 191, 255, 0.2);
    box-shadow: 0 0 20px rgba(0, 191, 255, 0.5);
    transform: scale(1.05);
}

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

/* ===== Home Screen / Cockpit View ===== */
#homeScreen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 9999;
    background: #000;
}

#cockpitImage {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
}

/* ===== Game Title & Version ===== */
.game-title-banner {
    position: absolute;
    top: 15px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10001;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    background: rgba(0, 0, 0, 0.6);
    padding: 12px 25px;
    border-radius: 0 0 12px 12px;
    backdrop-filter: blur(4px);
    border-bottom: 2px solid rgba(0, 191, 255, 0.5);
}

.game-icon {
    width: 60px;
    height: 60px;
    object-fit: contain;
    filter: drop-shadow(0 0 12px rgba(0, 191, 255, 1));
    animation: iconFloat 3s ease-in-out infinite;
}

@keyframes iconFloat {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-5px);
    }
}

.game-title {
    font-size: 38px;
    font-weight: 900;
    color: #ffffff;
    text-shadow: rgba(255, 255, 255, 0.9);
    letter-spacing: 5px;
    font-family: 'Consolas', monospace;
    text-transform: uppercase;
    margin: 0;
    background: linear-gradient(180deg, #ffffff 0%, #ffd700 50%, #ffaa00 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    filter: drop-shadow(0 0 15px rgba(255, 200, 50, 0.9));
}

.game-version {
    font-size: 11px;
    color: #ffd700;
    font-family: 'Consolas', monospace;
    letter-spacing: 1px;
    text-shadow: 0 0 8px rgba(255, 215, 0, 0.8);
    opacity: 1;
    font-weight: bold;
}

/* ===== How to Play Button ===== */
.howto-btn-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 10001;
    text-align: center;
    margin-top: -60px;
}

.howto-btn {
    background: linear-gradient(145deg, #10b981, #059669);
    border: 3px solid #34d399;
    border-radius: 50%;
    width: 65px;
    height: 65px;
    color: white;
    font-size: 11px;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    box-shadow: 0 0 12px rgba(16, 185, 129, 0.5), 0 4px 10px rgba(0, 0, 0, 0.4);
    transition: all 0.3s ease;
    -webkit-tap-highlight-color: transparent;
}

.howto-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 0 30px rgba(16, 185, 129, 0.7), 0 8px 20px rgba(0, 0, 0, 0.5);
}

.howto-btn .btn-icon {
    font-size: 24px;
    line-height: 1;
}

.howto-btn .btn-label {
    font-size: 9px;
    letter-spacing: 0.5px;
}

/* ===== How to Play Overlay ===== */
.howto-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10002;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow-y: auto;
    padding: 20px;
    box-sizing: border-box;
}

.howto-panel {
    background: linear-gradient(145deg, #1a1a2e, #16213e);
    border: 2px solid #00BFFF;
    border-radius: 15px;
    width: 90%;
    max-width: 700px;
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: 0 0 40px rgba(0, 191, 255, 0.4);
    -webkit-overflow-scrolling: touch;
}

.howto-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 25px;
    background: linear-gradient(90deg, #00BFFF, #0066cc);
    border-radius: 13px 13px 0 0;
}

.howto-header h2 {
    margin: 0;
    color: white;
    font-size: 24px;
    font-family: 'Consolas', monospace;
    letter-spacing: 2px;
}

.howto-close {
    background: transparent;
    border: 2px solid #fff;
    border-radius: 50%;
    width: 30px;
    height: 30px;
    color: white;
    font-size: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    -webkit-tap-highlight-color: transparent;
}

.howto-close:hover {
    background: #fff;
    color: #16213e;
    transform: scale(1.1);
}

.howto-content {
    padding: 20px 25px;
}

.howto-section {
    margin-bottom: 20px;
}

.howto-section h3 {
    color: #00BFFF;
    font-size: 16px;
    font-family: 'Consolas', monospace;
    margin-bottom: 10px;
    border-bottom: 1px solid rgba(0, 191, 255, 0.3);
    padding-bottom: 5px;
}

.howto-section p {
    color: #ccc;
    font-size: 13px;
    line-height: 1.5;
    margin-bottom: 10px;
}

/* ===== Controls Grid ===== */
.controls-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    margin-top: 10px;
}

.control-item {
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(0, 0, 0, 0.3);
    padding: 6px 10px;
    border-radius: 6px;
    border: 1px solid rgba(0, 191, 255, 0.2);
}

.key {
    background: linear-gradient(145deg, #475569, #334155);
    color: #fff;
    font-family: 'Consolas', monospace;
    font-size: 13px;
    font-weight: bold;
    min-width: 50px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 5px;
    border: 2px solid #475569;
    box-shadow: 0 0 8px rgba(0, 0, 0, 0.5);
}

.action {
    color: #ddd;
    font-size: 13px;
    flex: 1;
}

/* ===== Touch Controls List ===== */
.touch-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.touch-list li {
    color: #ccc;
    font-size: 13px;
    line-height: 1.6;
    padding: 4px 0;
    border-bottom: 1px dashed rgba(0, 191, 255, 0.1);
}

.touch-list li strong {
    color: #00BFFF;
}

/* ===== Dos and Don'ts Lists ===== */
.dos-list, .donts-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.dos-list li, .donts-list li {
    color: #ccc;
    font-size: 13px;
    line-height: 1.7;
    padding: 6px 0 6px 24px;
    position: relative;
    border-bottom: 1px dashed rgba(0, 191, 255, 0.1);
}

.dos-list li:before {
    content: "✓";
    position: absolute;
    left: 0;
    color: #32CD32;
    font-weight: bold;
}

.donts-list li:before {
    content: "✗";
    position: absolute;
    left: 0;
    color: #FF4136;
    font-weight: bold;
}

.dos-list li strong, .donts-list li strong {
    color: #fff;
}

/* ===== Game Elements Grid ===== */
.elements-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    margin-top: 10px;
}

.element-item {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(0, 0, 0, 0.3);
    padding: 8px 12px;
    border-radius: 6px;
    border: 1px solid rgba(0, 191, 255, 0.2);
}

.element-icon {
    font-size: 20px;
    min-width: 24px;
    text-align: center;
}

.element-label {
    color: #ccc;
    font-size: 12px;
    flex: 1;
}

/* ===== Engine Start Overlay ===== */
.engine-start-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 10000;
    text-align: center;
    margin-top: 50px;
}

.engine-start-btn {
    background: linear-gradient(145deg, #ff6b6b, #dc2626);
    border: 3px solid #ff8888;
    border-radius: 50%;
    width: 85px;
    height: 85px;
    color: white;
    font-size: 13px;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 5px;
    box-shadow: 0 0 20px rgba(220, 38, 38, 0.5), 0 5px 12px rgba(0, 0, 0, 0.5);
    transition: all 0.3s ease;
    animation: pulse 2s infinite;
    -webkit-tap-highlight-color: transparent;
}

.engine-start-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 0 60px rgba(220, 38, 38, 0.8), 0 15px 40px rgba(0, 0, 0, 0.6);
}

.engine-start-btn .btn-icon {
    font-size: 32px;
    line-height: 1;
}

.engine-start-btn .btn-label {
    font-size: 11px;
    letter-spacing: 0.5px;
}

@keyframes pulse {
    0%, 100% {
        box-shadow: 0 0 25px rgba(220, 38, 38, 0.5), 0 6px 15px rgba(0, 0, 0, 0.5);
    }
    50% {
        box-shadow: 0 0 40px rgba(220, 38, 38, 0.7), 0 10px 25px rgba(0, 0, 0, 0.6);
    }
}

/* ===== Game Screen ===== */
#gameScreen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
}

#gameCanvas {
    display: block;
    touch-action: none;
    width: 100%;
    height: 100%;
}

#minimapContainer {
    position: fixed;
    top: 10px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1000;
    width: 300px;
    height: 120px;
    border: 2px solid #333344;
    background-color: rgba(0, 0, 0, 0.7);
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 0 20px rgba(0, 191, 255, 0.3);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
}

#minimapContainer canvas {
    display: block;
    width: 100%;
    height: 100%;
}

.home-button {
    position: fixed;
    top: 30px;
    left: 18px;
    z-index: 1100;
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 84px;
    height: 38px;
    padding: 0 13px 0 9px;
    border: 1px solid rgba(245, 184, 74, 0.65);
    border-radius: 10px;
    background: rgba(10, 18, 23, 0.78);
    color: #f7f1e5;
    font: 700 10px/1 'Trebuchet MS', sans-serif;
    letter-spacing: 1.4px;
    cursor: pointer;
    box-shadow: 0 8px 22px rgba(0, 0, 0, 0.3), inset 0 1px rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(8px);
    -webkit-tap-highlight-color: transparent;
    transition: transform 0.2s ease, background 0.2s ease, border-color 0.2s ease;
}

.home-button:hover {
    transform: translateY(-2px);
    background: rgba(34, 52, 55, 0.92);
    border-color: #f5b84a;
}

.home-button:active { transform: translateY(0); }

.home-button-icon {
    color: #f5b84a;
    font-size: 20px;
    line-height: 1;
}

/* ===== Video Intro Overlay ===== */
.video-intro-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 999999;
    background: #000;
    display: flex;
    align-items: center;
    justify-content: center;
}

#introVideo {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.video-skip {
    position: absolute;
    top: 20px;
    right: 20px;
    z-index: 1000000;
}

.skip-btn {
    background: rgba(255, 255, 255, 0.2);
    border: 2px solid rgba(255, 255, 255, 0.5);
    color: white;
    padding: 10px 20px;
    border-radius: 25px;
    font-size: 14px;
    font-weight: bold;
    cursor: pointer;
    backdrop-filter: blur(10px);
    transition: all 0.3s ease;
}

.skip-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.05);
}

/* ===== Cockpit buttons ===== */
.game-btn {
    position: fixed;
    z-index: 9999;
    border: 2px solid rgba(255, 255, 255, 0.18);
    border-radius: 10px;
    font-weight: bold;
    font-size: 18px;
    cursor: pointer;
    color: white;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    transition: transform 0.08s ease, box-shadow 0.08s ease, filter 0.08s ease, border-color 0.08s ease;
    user-select: none;
    -webkit-user-select: none;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}
.game-btn .btn-icon {
    font-size: 20px;
    line-height: 1;
    pointer-events: none;
    width: 24px;
    height: 24px;
    object-fit: contain;
}
.game-btn .btn-label {
    font-size: 8px;
    letter-spacing: 0.5px;
    opacity: 0.9;
    pointer-events: none;
}

/* Control wrapper for mobile label positioning */
.control-wrapper {
    position: fixed;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}
.control-label {
    font-size: 7px;
    color: #fff;
    letter-spacing: 0.5px;
    opacity: 0.9;
    text-align: center;
    pointer-events: none;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
}
.game-btn:active {
    transform: translateY(4px);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
    filter: brightness(1.15);
}

/* Active state (engaged gear / indicator on) */
.game-btn.active {
    border-color: #ffffff;
    box-shadow: 0 0 16px 5px rgba(255, 255, 255, 0.6);
    transform: scale(1.07);
}

/* ===== Pedals (bottom right, transparent overlays for canvas pedals) ===== */
.pedal {
    width: 50px;
    height: 80px;
    border-radius: 8px;
    font-size: 22px;
    background: transparent !important;
    border: 2px solid transparent !important;
    box-shadow: none !important;
    pointer-events: auto;
}
.pedal .btn-icon { font-size: 32px; }
.pedal .btn-label { font-size: 12px; letter-spacing: 1.5px; }
.pedal-gas {
    bottom: calc(16px + var(--safe-bottom, 0px));
    right: 16px;
}
.pedal-brake {
    bottom: calc(16px + var(--safe-bottom, 0px));
    right: 86px;
}
.pedal-horn {
    bottom: 16px;
    right: 236px;
    width: 50px;
    height: 80px;
    border-radius: 8px;
    font-size: 22px;
    background: transparent !important;
    border: 2px solid transparent !important;
    box-shadow: none !important;
}
.pedal-horn .btn-icon { font-size: 32px; }
.pedal-horn .btn-label { font-size: 12px; letter-spacing: 1.5px; }
/* Pressed down state - invisible but functional */
.pedal.pressed, .pedal:active {
    transform: translateY(0);
    box-shadow: none;
    filter: none;
}

/* ===== LED-style cockpit switches (bottom center, above pedals) ===== */
/* Row layout: ENG - HRN - STP - LFT - RGT */
#btnEngine { 
    bottom: 80px; 
    left: 50%; 
    transform: translateX(-260px); 
    width: 50px; 
    height: 50px; 
    border-radius: 50%; 
    background: radial-gradient(circle at 50% 30%, #ff6b6b, #dc2626 70%);
    box-shadow: 0 0 8px rgba(220, 38, 38, 0.4);
    z-index: 10000;
    opacity: 0.7;
    transition: all 0.3s ease;
}
#btnEngine .btn-icon { 
    width: 26px;
    height: 26px;
    object-fit: contain;
}
#btnEngine .btn-label { font-size: 8px; letter-spacing: 0.3px; font-weight: bold; }
#btnEngine.active {
    opacity: 1;
    box-shadow: 0 0 20px rgba(220, 38, 38, 0.9);
}

#hornBtn {
    bottom: 80px;
    left: 50%;
    transform: translateX(-170px);
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: radial-gradient(circle at 50% 30%, #fbbf24, #d97706 70%);
    box-shadow: 0 0 8px rgba(251, 191, 36, 0.4);
    z-index: 10000;
    opacity: 0.7;
    transition: all 0.3s ease;
}
#hornBtn .btn-icon { 
    width: 26px;
    height: 26px;
    object-fit: contain;
}
#hornBtn .btn-label { font-size: 8px; letter-spacing: 0.3px; font-weight: bold; }
#hornBtn:active, #hornBtn.active {
    opacity: 1;
    box-shadow: 0 0 20px rgba(251, 191, 36, 0.9);
}

#btnGear  { 
    bottom: 80px; 
    left: 50%; 
    transform: translateX(-80px); 
    width: 50px; 
    height: 50px; 
    border-radius: 50%; 
    background: radial-gradient(circle at 50% 30%, #94a3b8, #475569 70%);
    box-shadow: 0 0 8px rgba(71, 85, 105, 0.4);
    z-index: 10000;
    opacity: 0.7;
    transition: all 0.3s ease;
}
#btnGear .btn-icon { 
    width: 26px;
    height: 26px;
    object-fit: contain;
}
#btnGear .btn-label { font-size: 8px; letter-spacing: 0.3px; font-weight: bold; }
#btnGear.active {
    opacity: 1;
    box-shadow: 0 0 20px rgba(71, 85, 105, 0.9);
}

#btnLeft  { 
    bottom: 80px; 
    left: 50%; 
    transform: translateX(-5px); 
    width: 50px; 
    height: 50px; 
    border-radius: 50%; 
    background: radial-gradient(circle at 50% 30%, #4ade80, #059669 70%);
    box-shadow: 0 0 8px rgba(5, 150, 105, 0.4);
    z-index: 10000;
    opacity: 0.7;
    transition: all 0.3s ease;
}
#btnLeft .btn-icon { 
    width: 26px;
    height: 26px;
    object-fit: contain;
}
#btnLeft .btn-label { font-size: 8px; letter-spacing: 0.3px; font-weight: bold; }
#btnLeft.active {
    opacity: 1;
    box-shadow: 0 0 20px rgba(5, 150, 105, 0.9);
}

#btnRight { 
    bottom: 80px; 
    left: 50%; 
    transform: translateX(65px); 
    width: 50px; 
    height: 50px; 
    border-radius: 50%; 
    background: radial-gradient(circle at 50% 30%, #4ade80, #059669 70%);
    box-shadow: 0 0 8px rgba(5, 150, 105, 0.4);
    z-index: 10000;
    opacity: 0.7;
    transition: all 0.3s ease;
}
#btnRight .btn-icon { 
    width: 26px;
    height: 26px;
    object-fit: contain;
}
#btnRight .btn-label { font-size: 8px; letter-spacing: 0.3px; font-weight: bold; }
#btnRight.active {
    opacity: 1;
    box-shadow: 0 0 20px rgba(5, 150, 105, 0.9);
}

#btnHeadlights { 
    bottom: 80px; 
    left: 50%; 
    transform: translateX(150px); 
    width: 50px; 
    height: 50px; 
    border-radius: 50%; 
    background: radial-gradient(circle at 50% 30%, #fbbf24, #d97706 70%);
    box-shadow: 0 0 8px rgba(251, 191, 36, 0.4);
    z-index: 10000;
    opacity: 0.7;
    transition: all 0.3s ease;
}
#btnHeadlights .btn-icon { 
    width: 26px;
    height: 26px;
    object-fit: contain;
}
#btnHeadlights .btn-label { font-size: 8px; letter-spacing: 0.3px; font-weight: bold; }
#btnHeadlights.active {
    opacity: 1;
    box-shadow: 0 0 20px rgba(251, 191, 36, 0.9);
}

#btnRefuel { 
    bottom: 80px; 
    left: 50%; 
    transform: translateX(220px); 
    width: 50px; 
    height: 50px; 
    border-radius: 50%; 
    background: radial-gradient(circle at 50% 30%, #f43f5e, #be123c 70%);
    box-shadow: 0 0 8px rgba(244, 63, 94, 0.4);
    z-index: 10000;
    opacity: 0.7;
    transition: all 0.3s ease;
}
#btnRefuel .btn-icon { 
    width: 26px;
    height: 26px;
    object-fit: contain;
}
#btnRefuel .btn-label { font-size: 7px; letter-spacing: 0.3px; font-weight: bold; }
#btnRefuel.active {
    opacity: 1;
    box-shadow: 0 0 20px rgba(244, 63, 94, 0.9);
}

#btnDrive { 
    bottom: calc(16px + var(--safe-bottom, 0px)); 
    left: 78px; 
    width: 50px; 
    height: 50px; 
    border-radius: 50%; 
    background: radial-gradient(circle at 50% 30%, #38bdf8, #0ea5e9 70%);
    box-shadow: 0 0 15px rgba(14, 165, 233, 0.6);
}
#btnDrive .btn-icon { 
    width: 26px;
    height: 26px;
    object-fit: contain;
}
#btnDrive .btn-label { font-size: 7px; letter-spacing: 0.3px; }

#neutralBtn { 
    bottom: calc(16px + env(safe-area-inset-bottom, 0px) + var(--safe-bottom, 0px)); 
    left: 12px; 
    width: 50px; 
    height: 50px; 
    border-radius: 50%; 
    background: radial-gradient(circle at 50% 30%, #a78bfa, #7c3aed 70%);
    box-shadow: 0 0 15px rgba(124, 58, 237, 0.6);
}
#neutralBtn .btn-icon { 
    width: 26px;
    height: 26px;
    object-fit: contain;
}
#neutralBtn .btn-label { font-size: 7px; letter-spacing: 0.3px; }

/* ===== Small desktop/tablet screens (non-landscape) ===== */
@media (max-width: 800px) {
    #btnEngine { left: 50%; transform: translateX(-220px); bottom: 80px; }
    #hornBtn   { left: 50%; transform: translateX(-138px); bottom: 80px; }
    #btnGear   { left: 50%; transform: translateX(-62px); bottom: 80px; }
    #btnLeft   { left: 50%; transform: translateX(-35px); bottom: 80px; }
    #btnRight  { left: 50%; transform: translateX(20px); bottom: 80px; }
    #btnHeadlights { left: 50%; transform: translateX(80px); bottom: 80px; }
    #btnRefuel { left: 50%; transform: translateX(140px); bottom: 80px; }
}

/* ===== Mobile Landscape Optimization (phones in landscape) ===== */
@media (orientation: landscape) and (max-height: 500px) {
    /* Home screen adjustments for landscape mobile */
    .game-title-banner {
        top: 5px;
        padding: 6px 15px;
        gap: 3px;
    }
    .game-icon {
        width: 32px;
        height: 32px;
    }
    .game-title {
        font-size: 20px;
        letter-spacing: 3px;
    }
    .game-version {
        font-size: 8px;
    }
    
    .howto-btn-overlay {
        margin-top: -50px;
    }
    .howto-btn {
        width: 50px;
        height: 50px;
    }
    .howto-btn .btn-icon {
        font-size: 18px;
    }
    .howto-btn .btn-label {
        font-size: 8px;
    }
    
    .engine-start-overlay {
        margin-top: 35px;
    }
    .engine-start-btn {
        width: 65px;
        height: 65px;
    }
    .engine-start-btn .btn-icon {
        font-size: 24px;
    }
    .engine-start-btn .btn-label {
        font-size: 9px;
    }
    
    /* How-to panel fits landscape */
    .howto-panel {
        max-height: 90vh;
        width: 85%;
    }
    .howto-panel .howto-content {
        padding: 12px 20px;
    }
    
    /* Hide labels inside buttons on mobile - show external labels instead */
    .game-btn .btn-label {
        display: none;
    }
    
    /* Show external control labels */
    .control-label {
        display: block;
    }
    
    /* Position control labels below top-row buttons with small gap */
    #btnEngine + .control-label {
        position: fixed;
        bottom: 8px;
        left: 50%;
        transform: translateX(-155px);
        width: 42px;
        text-align: center;
    }
    #btnGear + .control-label {
        position: fixed;
        bottom: 8px;
        left: 50%;
        transform: translateX(-55px);
        width: 42px;
        text-align: center;
    }
    #btnLeft + .control-label {
        position: fixed;
        bottom: 8px;
        left: 50%;
        transform: translateX(-5px);
        width: 42px;
        text-align: center;
    }
    #btnRight + .control-label {
        position: fixed;
        bottom: 8px;
        left: 50%;
        transform: translateX(45px);
        width: 42px;
        text-align: center;
    }
    #btnHeadlights + .control-label {
        position: fixed;
        bottom: 8px;
        left: 50%;
        transform: translateX(95px);
        width: 42px;
        text-align: center;
    }
    #btnRefuel + .control-label {
        position: fixed;
        bottom: 8px;
        left: 50%;
        transform: translateX(-105px);
        width: 42px;
        text-align: center;
    }
    /* Left-column labels positioned to the RIGHT of their buttons (vertically centered) */
    #hornBtn + .control-label {
        position: fixed;
        bottom: 104px;
        left: 56px;
        width: 44px;
        text-align: center;
    }
    #btnDrive + .control-label {
        position: fixed;
        bottom: 154px;
        left: 46px;
        width: 34px;
        text-align: center;
    }
    #neutralBtn + .control-label {
        position: fixed;
        bottom: 196px;
        left: 46px;
        width: 34px;
        text-align: center;
    }
    
    /* Controls row - compact for landscape, positioned inside the cockpit */
    #btnEngine { 
        bottom: 20px; 
        left: 50%; 
        transform: translateX(-155px); 
        width: 42px; 
        height: 42px; 
    }
    #hornBtn   { 
        bottom: 104px; 
        left: 8px; 
        transform: translateX(0); 
        width: 44px; 
        height: 44px; 
        border-radius: 50%; 
    }
    #btnGear   { 
        bottom: 20px; 
        left: 50%; 
        transform: translateX(-55px); 
        width: 42px; 
        height: 42px; 
    }
    #btnLeft   { 
        bottom: 20px; 
        left: 50%; 
        transform: translateX(-5px); 
        width: 42px; 
        height: 42px; 
    }
    #btnRight  { 
        bottom: 20px; 
        left: 50%; 
        transform: translateX(45px); 
        width: 42px; 
        height: 42px; 
    }
    #btnHeadlights { 
        bottom: 20px; 
        left: 50%; 
        transform: translateX(95px); 
        width: 42px; 
        height: 42px; 
    }
    
    /* NEU / DRV / REFUEL stacked vertically on the left */
    #neutralBtn { 
        bottom: 196px; 
        left: 8px; 
        width: 34px; 
        height: 34px; 
    }
    #btnDrive { 
        bottom: 154px; 
        left: 8px; 
        width: 34px; 
        height: 34px; 
    }
    #btnRefuel { 
        bottom: 20px; 
        left: 50%; 
        transform: translateX(-105px); 
        width: 42px; 
        height: 42px; 
    }
    
    #btnDrive .btn-icon,
    #neutralBtn .btn-icon,
    #btnRefuel .btn-icon {
        font-size: 14px;
    }
    
    .pedal {
        height: 65px;
        width: 45px;
    }
    .pedal-gas {
        bottom: 10px;
        right: 10px;
    }
    .pedal-brake {
        bottom: 10px;
        right: 83px;
    }
    
    /* Minimap smaller in landscape mobile */
    #minimapContainer {
        top: 5px;
        width: 220px;
        height: 90px;
    }
    
    /* Adjust button icon sizes */
    #btnEngine .btn-icon,
    #hornBtn .btn-icon,
    #btnGear .btn-icon,
    #btnLeft .btn-icon,
    #btnRight .btn-icon,
    #btnHeadlights .btn-icon,
    #btnRefuel .btn-icon {
        font-size: 16px;
    }
}

/* ===== Very small landscape phones (e.g., iPhone SE landscape) ===== */
@media (orientation: landscape) and (max-height: 380px) {
    .game-title-banner {
        top: 3px;
        padding: 4px 10px;
    }
    .game-icon {
        width: 24px;
        height: 24px;
    }
    .game-title {
        font-size: 16px;
        letter-spacing: 2px;
    }
    .game-version {
        font-size: 7px;
    }
    
    .howto-btn-overlay {
        margin-top: -40px;
    }
    .howto-btn {
        width: 42px;
        height: 42px;
    }
    .howto-btn .btn-icon {
        font-size: 16px;
    }
    
    .engine-start-overlay {
        margin-top: 30px;
    }
    .engine-start-btn {
        width: 55px;
        height: 55px;
    }
    .engine-start-btn .btn-icon {
        font-size: 20px;
    }
    
    /* Even more compact controls */
    #btnEngine, #btnGear, #btnLeft, #btnRight, #btnHeadlights {
        width: 36px;
        height: 36px;
        bottom: 15px;
    }
    
    #btnEngine { transform: translateX(-155px); }
    #btnGear   { transform: translateX(-55px); }
    #btnLeft   { transform: translateX(-5px); }
    #btnRight  { transform: translateX(45px); }
    #btnHeadlights { transform: translateX(95px); }
    
    /* NEU / DRV / REFUEL stacked vertically on the left */
    #neutralBtn {
        width: 30px;
        height: 30px;
        bottom: 176px;
        left: 8px;
    }
    #btnDrive {
        width: 30px;
        height: 30px;
        bottom: 138px;
        left: 8px;
    }
    #btnRefuel {
        transform: translateX(-105px);
        width: 36px;
        height: 36px;
        border-radius: 50%;
        bottom: 15px;
        left: 50%;
    }
    
    #hornBtn {
        transform: translateX(0);
        width: 36px;
        height: 36px;
        border-radius: 50%;
        bottom: 96px;
        left: 8px;
    }
    
    #btnDrive .btn-icon,
    #neutralBtn .btn-icon,
    #btnRefuel .btn-icon {
        font-size: 12px;
    }
    #btnDrive .btn-label,
    #neutralBtn .btn-label,
    #btnRefuel .btn-label {
        font-size: 5px;
    }
    
    /* Very small landscape: position labels to the right of left-column buttons */
    #hornBtn + .control-label {
        position: fixed;
        bottom: 96px;
        left: 50px;
        width: 36px;
        text-align: center;
    }
    #btnDrive + .control-label {
        position: fixed;
        bottom: 138px;
        left: 42px;
        width: 30px;
        text-align: center;
    }
    #neutralBtn + .control-label {
        position: fixed;
        bottom: 176px;
        left: 42px;
        width: 30px;
        text-align: center;
    }
    /* Top-row labels below buttons */
    #btnEngine + .control-label,
    #btnGear + .control-label,
    #btnLeft + .control-label,
    #btnRight + .control-label,
    #btnHeadlights + .control-label,
    #btnRefuel + .control-label {
        position: fixed;
        bottom: 8px;
        text-align: center;
    }
    #btnEngine + .control-label { transform: translateX(-155px); left: 50%; }
    #btnGear + .control-label   { transform: translateX(-55px); left: 50%; }
    #btnLeft + .control-label   { transform: translateX(-5px); left: 50%; }
    #btnRight + .control-label  { transform: translateX(45px); left: 50%; }
    #btnHeadlights + .control-label { transform: translateX(95px); left: 50%; }
    #btnRefuel + .control-label { transform: translateX(-105px); left: 50%; }
    
    #minimapContainer {
        width: 180px;
        height: 75px;
    }
}

/* ===== Tablets (iPad landscape, larger screens) ===== */
@media (orientation: landscape) and (min-width: 900px) and (max-width: 1250px) {
    #btnEngine { transform: translateX(-240px); }
    #hornBtn   { transform: translateX(-160px); }
    #btnGear   { transform: translateX(-80px); }
    #btnLeft   { transform: translateX(0px); }
    #btnRight  { transform: translateX(80px); }
    #btnHeadlights { transform: translateX(160px); }
    #btnRefuel { transform: translateX(240px); }
    
    #minimapContainer {
        width: 250px;
        height: 100px;
    }
}

/* ===== Safe area support for notched devices ===== */
/* Uses env() for iOS safe areas and --safe-bottom (set by JS) for Android nav bar */
@supports (padding: env(safe-area-inset-bottom)) {
    .pedal-gas {
        bottom: calc(16px + env(safe-area-inset-bottom) + var(--safe-bottom, 0px));
    }
    .pedal-brake {
        bottom: calc(16px + env(safe-area-inset-bottom) + var(--safe-bottom, 0px));
    }
    #btnDrive, #neutralBtn {
        bottom: calc(16px + env(safe-area-inset-bottom) + var(--safe-bottom, 0px));
    }
    #btnEngine, #hornBtn, #btnGear, #btnLeft, #btnRight, #btnHeadlights, #btnRefuel {
        bottom: calc(80px + env(safe-area-inset-bottom) + var(--safe-bottom, 0px));
    }
    
    @media (orientation: landscape) and (max-height: 500px) {
        #btnEngine, #btnGear, #btnLeft, #btnRight, #btnHeadlights {
            bottom: calc(20px + env(safe-area-inset-bottom) + var(--safe-bottom, 0px));
        }
        .pedal-gas {
            bottom: calc(10px + env(safe-area-inset-bottom) + var(--safe-bottom, 0px));
        }
        .pedal-brake {
            bottom: calc(10px + env(safe-area-inset-bottom) + var(--safe-bottom, 0px));
        }
        #neutralBtn {
            bottom: calc(196px + env(safe-area-inset-bottom) + var(--safe-bottom, 0px));
        }
        #btnDrive {
            bottom: calc(154px + env(safe-area-inset-bottom) + var(--safe-bottom, 0px));
        }
        #btnRefuel {
            bottom: calc(20px + env(safe-area-inset-bottom) + var(--safe-bottom, 0px));
        }
        #hornBtn {
            bottom: calc(104px + env(safe-area-inset-bottom) + var(--safe-bottom, 0px));
        }
    }
    
    /* Very small landscape phones - safe area adjustments */
    @media (orientation: landscape) and (max-height: 380px) {
        #btnEngine, #btnGear, #btnLeft, #btnRight, #btnHeadlights {
            bottom: calc(15px + env(safe-area-inset-bottom) + var(--safe-bottom, 0px));
        }
        .pedal-gas {
            bottom: calc(10px + env(safe-area-inset-bottom) + var(--safe-bottom, 0px));
        }
        .pedal-brake {
            bottom: calc(10px + env(safe-area-inset-bottom) + var(--safe-bottom, 0px));
        }
        #neutralBtn {
            bottom: calc(176px + env(safe-area-inset-bottom) + var(--safe-bottom, 0px));
        }
        #btnDrive {
            bottom: calc(138px + env(safe-area-inset-bottom) + var(--safe-bottom, 0px));
        }
        #btnRefuel {
            bottom: calc(15px + env(safe-area-inset-bottom) + var(--safe-bottom, 0px));
        }
        #hornBtn {
            bottom: calc(96px + env(safe-area-inset-bottom) + var(--safe-bottom, 0px));
        }
    }
}

/* ===== Premium home screen ===== */
#homeScreen::after {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 1;
    pointer-events: none;
    background: linear-gradient(180deg, rgba(7, 13, 18, 0.72) 0%, rgba(7, 13, 18, 0.04) 34%, rgba(7, 13, 18, 0.62) 100%);
}

.game-title-banner {
    top: 24px;
    gap: 5px;
    padding: 16px 34px 14px;
    border: 1px solid rgba(245, 184, 74, 0.45);
    border-top: 0;
    border-radius: 0 0 18px 18px;
    background: rgba(11, 20, 26, 0.72);
    box-shadow: 0 18px 45px rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(12px);
}

.game-icon {
    width: 72px;
    height: 72px;
    margin-bottom: 3px;
    filter: drop-shadow(0 0 18px rgba(245, 184, 74, 0.72));
}

.game-kicker, .panel-eyebrow {
    color: #f5b84a;
    font: 700 10px/1 'Trebuchet MS', sans-serif;
    letter-spacing: 3px;
}

.game-title {
    color: #f7f1e5;
    font-family: 'Trebuchet MS', sans-serif;
    font-size: clamp(30px, 4vw, 48px);
    letter-spacing: 8px;
    line-height: 1;
    background: none;
    -webkit-text-fill-color: initial;
    filter: none;
    text-shadow: 0 4px 18px rgba(0, 0, 0, 0.75);
}

.game-subtitle {
    color: #b4c8c9;
    font: 700 11px/1 'Trebuchet MS', sans-serif;
    letter-spacing: 5px;
}

.game-version {
    color: rgba(247, 241, 229, 0.62);
    font: 10px/1.2 'Trebuchet MS', sans-serif;
    letter-spacing: 1px;
    text-shadow: none;
    margin-top: 6px;
}

.howto-btn-overlay, .engine-start-overlay {
    top: auto;
    bottom: 13%;
    margin: 0;
    transform: none;
}

.howto-btn-overlay { left: 50%; margin-left: -220px; }
.engine-start-overlay { left: 50%; margin-left: 8px; }

.howto-btn, .engine-start-btn {
    width: 190px;
    height: 64px;
    border-radius: 14px;
    flex-direction: row;
    gap: 12px;
    padding: 0 22px;
    box-sizing: border-box;
    font-family: 'Trebuchet MS', sans-serif;
    letter-spacing: 1px;
}

.howto-btn {
    background: rgba(11, 20, 26, 0.78);
    border: 1px solid rgba(180, 200, 201, 0.65);
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.35), inset 0 1px rgba(255, 255, 255, 0.12);
}

.howto-btn:hover { background: rgba(27, 43, 47, 0.9); transform: translateY(-3px); }
.howto-btn .btn-icon {
    display: grid;
    place-items: center;
    width: 28px;
    height: 28px;
    border: 1px solid #f5b84a;
    border-radius: 50%;
    color: #f5b84a;
    font: 700 17px/1 'Trebuchet MS', sans-serif;
}

.engine-start-btn {
    background: linear-gradient(135deg, #f6c35e, #d17b2e);
    border: 1px solid #ffe2a0;
    color: #172126;
    box-shadow: 0 14px 32px rgba(209, 123, 46, 0.38), inset 0 1px rgba(255, 255, 255, 0.55);
    animation: premiumPulse 2.8s ease-in-out infinite;
}

.engine-start-btn:hover { transform: translateY(-3px); filter: brightness(1.08); }
.engine-start-btn .btn-icon { font-size: 22px; }
.howto-btn .btn-label, .engine-start-btn .btn-label { font-size: 12px; letter-spacing: 1.6px; }

@keyframes premiumPulse {
    0%, 100% { box-shadow: 0 14px 32px rgba(209, 123, 46, 0.32), inset 0 1px rgba(255, 255, 255, 0.55); }
    50% { box-shadow: 0 18px 42px rgba(245, 184, 74, 0.55), inset 0 1px rgba(255, 255, 255, 0.55); }
}

.howto-overlay { background: rgba(4, 10, 14, 0.82); backdrop-filter: blur(8px); }
.howto-panel {
    width: min(820px, 94vw);
    max-height: 88vh;
    border: 1px solid rgba(245, 184, 74, 0.55);
    border-radius: 18px;
    background: #101b21;
    box-shadow: 0 24px 70px rgba(0, 0, 0, 0.58);
}
.howto-header { padding: 22px 26px; background: linear-gradient(110deg, #182d34, #263e3f); border-radius: 17px 17px 0 0; border-bottom: 1px solid rgba(245, 184, 74, 0.35); }
.howto-header h2 { margin-top: 7px; font: 700 25px/1 'Trebuchet MS', sans-serif; letter-spacing: 3px; }
.howto-close { width: 34px; height: 34px; border: 1px solid rgba(255, 255, 255, 0.5); border-radius: 10px; }
.howto-content { padding: 24px 26px 26px; }
.howto-intro { display: flex; gap: 16px; align-items: flex-start; padding-bottom: 20px; border-bottom: 1px solid rgba(180, 200, 201, 0.14); }
.intro-mark, .howto-section h3 span { color: #f5b84a; font: 700 12px/1 'Trebuchet MS', sans-serif; letter-spacing: 1px; }
.intro-mark { padding-top: 4px; }
.howto-intro h3, .howto-section h3 { color: #f7f1e5; font-family: 'Trebuchet MS', sans-serif; letter-spacing: 1px; }
.howto-intro h3 { margin: 0 0 7px; font-size: 18px; }
.howto-intro p { color: #b9c7c8; line-height: 1.6; margin: 0; }
.howto-section { margin: 22px 0 0; }
.howto-section h3 { display: flex; gap: 10px; align-items: baseline; margin: 0 0 12px; padding: 0; border: 0; font-size: 15px; }
.howto-section p, .action, .dos-list li, .donts-list li { color: #b9c7c8; }
.howto-section p { line-height: 1.6; margin: 0; }
.controls-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; margin: 0; }
.control-item { padding: 9px 11px; border: 1px solid rgba(180, 200, 201, 0.14); border-radius: 9px; background: rgba(255, 255, 255, 0.04); }
.control-icon { display: grid; place-items: center; width: 24px; height: 27px; color: #f5b84a; font-size: 18px; line-height: 1; }
.control-icon img { width: 24px; height: 24px; object-fit: contain; filter: drop-shadow(0 0 5px rgba(245, 184, 74, 0.28)); }
.control-icon-dual { display: flex; gap: 1px; width: 38px; }
.control-icon-dual img { width: 18px; height: 18px; }
.key { min-width: 54px; height: 27px; border: 1px solid rgba(245, 184, 74, 0.5); border-radius: 6px; background: #26373b; color: #f7f1e5; font-family: 'Trebuchet MS', sans-serif; }
.briefing-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.dos-list li, .donts-list li { padding: 5px 0 5px 20px; border: 0; line-height: 1.45; }
.dos-list li:before { color: #82c59b; }
.donts-list li:before { color: #e88e6b; }
.howto-footer { margin-top: 24px; padding-top: 15px; border-top: 1px solid rgba(180, 200, 201, 0.14); color: rgba(245, 184, 74, 0.85); font: 700 10px/1.4 'Trebuchet MS', sans-serif; letter-spacing: 1.5px; text-align: center; }
.howto-reference { display: none; }
.howto-reference ~ .howto-section { display: none; }

@media (max-width: 620px) {
    .game-title-banner { top: 8px; padding: 10px 18px 11px; }
    .game-icon { width: 48px; height: 48px; }
    .game-kicker { font-size: 8px; letter-spacing: 2px; }
    .game-title { font-size: 27px; letter-spacing: 5px; }
    .game-subtitle { font-size: 9px; letter-spacing: 3px; }
    .game-version { font-size: 8px; margin-top: 3px; }
    .howto-btn-overlay, .engine-start-overlay { bottom: 8%; margin-left: 0; }
    .howto-btn-overlay { left: 7%; }
    .engine-start-overlay { right: 7%; left: auto; }
    .howto-btn, .engine-start-btn { width: 42vw; min-width: 145px; height: 55px; padding: 0 13px; gap: 8px; }
    .howto-btn .btn-label, .engine-start-btn .btn-label { font-size: 10px; letter-spacing: 1px; }
    .howto-panel { width: 92vw; max-height: 90vh; }
    .howto-header { padding: 17px 18px; }
    .howto-content { padding: 18px; }
    .controls-grid, .briefing-grid { grid-template-columns: 1fr; }
    .home-button { top: 22px; left: 10px; min-width: 74px; height: 34px; padding-right: 10px; font-size: 9px; }
}

@media (orientation: landscape) and (max-height: 500px) {
    .game-title-banner { top: 5px; padding: 7px 17px 8px; gap: 3px; }
    .game-icon { width: 34px; height: 34px; }
    .game-title { font-size: 21px; letter-spacing: 4px; }
    .game-subtitle { font-size: 8px; }
    .game-version { font-size: 7px; margin-top: 2px; }
    .howto-btn-overlay, .engine-start-overlay { bottom: 8%; }
    .howto-btn-overlay { margin-left: -175px; }
    .engine-start-overlay { margin-left: 0; }
    .howto-btn, .engine-start-btn { width: 150px; height: 48px; }
    .howto-panel { max-height: 92vh; }
    .home-button { top: 18px; left: 8px; height: 32px; }
}
