* { box-sizing: border-box; }
html, body { width: 100%; height: 100%; margin: 0; overflow: hidden; }
body { background: #142321; color: #fff; font-family: Arial, Helvetica, sans-serif; }
body { -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; }
input, textarea, [contenteditable="true"] { -webkit-touch-callout: default; -webkit-user-select: text; user-select: text; }
button, a { touch-action: manipulation; -webkit-user-drag: none; }
button, a { -webkit-tap-highlight-color: transparent; }
button { color: #fff; background: rgba(21, 42, 43, 0.76); border: 1px solid #70827d; border-radius: 3px; min-height: 42px; padding: 0 17px; font: bold 12px Arial, sans-serif; cursor: pointer; }
button:hover, button:focus { background: rgba(50, 72, 67, 0.8); }
button:focus, a:focus { outline: 2px solid #d9fd60; outline-offset: 3px; }
button[aria-pressed="true"] { background: #d9fd60; color: #152520; border-color: #d9fd60; }
[hidden] { display: none !important; }
button:disabled { opacity: 0.5; cursor: default; }
.car-marker { position: absolute; transform: translate(-50%, -50%); width: 18px; height: 18px; border: 2px solid; background: rgba(21, 42, 43, 0.76); color: #fff; font: bold 10px/14px Arial; border-radius: 50%; text-align: center; pointer-events: none; }
.car-marker.selected { background: #fff; color: #142321; z-index: 1; }
.marker-line { position: absolute; height: 1px; transform-origin: 0 50%; pointer-events: none; }
.race-panel { position: absolute; z-index: 4; top: 50%; left: 50%; transform: translate(-50%, -50%); width: 370px; max-width: 90%; max-height: 62%; overflow-y: auto; background: rgba(21, 42, 43, 0.76); padding: 24px; border-top: 4px solid #d9fd60; }
.race-panel h1 { font-size: 29px; line-height: 1.1; margin: 12px 0; letter-spacing: -1px; }
.race-panel p { font-size: 12px; color: #b7cbc3; line-height: 1.5; }
.race-panel label { display: block; font-size: 10px; font-weight: bold; letter-spacing: 1px; margin: 14px 0 6px; }
.race-panel input, .race-panel select { width: 100%; height: 38px; border: 1px solid #70827d; border-radius: 3px; background: rgba(36, 60, 57, 0.55); color: white; padding: 0 10px; font: 13px Arial; }
.settings-row { display: flex; } .settings-row label { width: 50%; } .settings-row label + label { margin-left: 12px; }
.settings-row select { margin-top: 6px; }
#settingsPanel { z-index: 7; }
#settingsTip { position: fixed; z-index: 20; width: 232px; max-width: calc(100% - 24px); padding: 11px 13px; border-radius: 8px; background: #d9fd60; color: #152520; box-shadow: 0 3px 0 rgba(0, 0, 0, 0.25); font: bold 12px/1.45 Arial, sans-serif; pointer-events: none; }
#settingsTipArrow { position: absolute; bottom: -8px; margin-left: -8px; width: 0; height: 0; border-left: 8px solid transparent; border-right: 8px solid transparent; border-top: 8px solid #d9fd60; }
#settingsTip.below #settingsTipArrow { top: -8px; bottom: auto; border-top: 0; border-bottom: 8px solid #d9fd60; }
#settingsPanel, #results { background: rgba(21, 42, 43, 0.96); }
.settings-actions { display: flex; margin-top: 14px; }
.settings-actions button + button { margin-left: 8px; }
#soundToggle { margin-top: 16px; }
#restartRace { margin-top: 16px; }
.race-panel small { display: block; color: #b7cbc3; font-size: 10px; line-height: 1.5; margin-top: 14px; }
#results { max-height: 73%; width: 430px; }
#resultList { list-style: none; padding: 0; margin: 15px 0; }
#resultList li { display: flex; align-items: center; min-height: 40px; font-size: 12px; border-left: 3px solid; padding: 7px 10px; margin-bottom: 3px; background: rgba(36, 60, 57, 0.55); }
#resultList .result-driver { flex: 1; min-width: 0; padding-right: 8px; overflow-wrap: break-word; }
#resultList .result-time { flex: none; margin-left: 10px; font: 11px Consolas, monospace; white-space: nowrap; }
#standings { margin-top: 12px; padding-top: 12px; border-top: 1px solid #415856; }
.standings-heading { display: flex; align-items: center; justify-content: space-between; font-size: 10px; letter-spacing: 1px; }
.standings-heading button { min-height: 26px; padding: 0 8px; }
#order { list-style: none; padding: 0; margin: 10px 0 0; }
#order li { display: flex; align-items: center; border-left: 3px solid; margin-bottom: 2px; background: rgba(36, 60, 57, 0.55); }
#order li.own-driver, #resultList li.own-driver { background: rgba(217, 253, 96, 0.25); color: #f1ffc4; font-weight: bold; outline: 1px solid #d9fd60; outline-offset: -1px; }
#order li > span { flex: 1; min-width: 0; padding: 0 7px; font-size: 10px; }
#order .follow-camera { flex: none; min-width: 44px; min-height: 44px; margin-left: 8px; padding: 8px; border: none; border-radius: 0; }
#order .follow-camera svg { display: block; margin: auto; }
#order .ai-badge, #resultList .ai-badge { flex: none; display: inline-block; margin: 0; background: #d9fd60; color: #152a2b; border-radius: 3px; padding: 3px 4px; font: bold 9px/1.2 Arial, sans-serif; }
.lobby .speed, .lobby .timing .metric, .lobby #surface { display: none; }
.lobby .session { z-index: 5; }
#trackView { position: absolute; top: 0; left: 0; right: 0; bottom: 0; }
#trackView canvas { display: block; width: 100%; height: 100%; }
.topbar { position: absolute; top: 24px; left: 30px; display: flex; flex-direction: column; align-items: flex-start; pointer-events: none; }
.brand { font-size: 32px; font-weight: 900; font-style: italic; letter-spacing: -2px; line-height: 0.95; }
.brand > span { color: #d9fd60; }
.brand small { display: block; font: bold 9px Arial, sans-serif; letter-spacing: 2.1px; padding-top: 8px; }
.race-hud { position: absolute; right: 30px; top: 24px; width: 370px; max-width: calc(100% - 60px); max-height: calc(100% - 48px); overflow-y: auto; padding: 0; background: transparent; }
.timing { display: flex; flex-wrap: wrap; justify-content: space-between; }
.timing .metric { margin-right: 10px; }
.timing .metric:last-child { margin-right: 0; }
.timing span { display: block; color: #b3c4bc; font-size: 9px; font-weight: bold; letter-spacing: 2px; margin-bottom: 5px; }
.timing strong { font: bold 20px Consolas, monospace; }
.timing strong.metric-flash { color: #d9fd60; }
.timing strong.metric-dim { opacity: 0.15; }
.finish-celebration { position: absolute; z-index: 6; top: 0; right: 0; bottom: 0; left: 0; pointer-events: none; overflow: hidden; }
#finishConfetti { position: absolute; width: 100%; height: 100%; }
.finish-medal { position: absolute; top: 48%; left: 50%; text-align: center; transform: translate(-50%, -50%); animation: podium-arrival 4.5s both; }
#finishNumber { display: block; color: #d9fd60; font: 900 220px/0.95 Arial, sans-serif; font-style: italic; transform: perspective(600px) rotateY(-16deg) rotateX(6deg); text-shadow: 1px 1px #9ebc3c, 2px 2px #9ebc3c, 3px 3px #8ba631, 4px 4px #8ba631, 5px 5px #71882a, 6px 6px #71882a, 7px 7px #526820, 8px 8px #526820, 9px 9px #34451b, 12px 15px 8px rgba(0, 0, 0, 0.6); }
.podium-2 #finishNumber { color: #e1ebf1; text-shadow: 1px 1px #a7bac7, 2px 2px #a7bac7, 3px 3px #899daa, 4px 4px #899daa, 5px 5px #6b7c89, 6px 6px #6b7c89, 7px 7px #4d5c68, 8px 8px #4d5c68, 9px 9px #303d48, 12px 15px 8px rgba(0, 0, 0, 0.6); }
.podium-3 #finishNumber { color: #e9ad79; text-shadow: 1px 1px #bd8051, 2px 2px #bd8051, 3px 3px #a56b40, 4px 4px #a56b40, 5px 5px #855331, 6px 6px #855331, 7px 7px #653d23, 8px 8px #653d23, 9px 9px #45291a, 12px 15px 8px rgba(0, 0, 0, 0.6); }
#finishCaption { display: block; margin-top: 20px; color: #fff; font: bold 14px Arial, sans-serif; letter-spacing: 4px; white-space: nowrap; text-shadow: 0 2px 4px #142321; }
.finish-announcement { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); }
@keyframes podium-arrival {
    0% { opacity: 0; transform: translate(-50%, -50%) scale(0.4) rotate(-10deg); }
    10% { opacity: 1; transform: translate(-50%, -50%) scale(1.08) rotate(2deg); }
    18%, 85% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
    100% { opacity: 0; transform: translate(-50%, -56%) scale(0.95); }
}
@media (max-height: 500px), (max-width: 500px) { #finishNumber { font-size: 150px; } #finishCaption { font-size: 11px; letter-spacing: 3px; margin-top: 14px; } }
@media (prefers-reduced-motion: reduce) { .finish-medal { animation: none; } #finishConfetti { display: none; } }
.hud-summary { padding: 12px 14px; background: rgba(21, 42, 43, 0.55); border: 1px solid #415856; border-top: 3px solid #d9fd60; border-radius: 6px 6px 0 0; }
.hud-details { display: flex; align-items: flex-start; }
.hud-status { flex: 1; min-width: 0; }
#connection { max-width: 110px; color: #dce6e1; font: bold 9px/1.5 Arial, sans-serif; letter-spacing: 0.5px; overflow-wrap: break-word; }
.course { flex: none; margin-top: 16px; padding: 0; background: transparent; text-align: center; }
.eyebrow { font-size: 10px; font-weight: bold; letter-spacing: 2px; }
.course canvas { display: block; width: 108px; height: 90px; margin: 0 auto; }
#courseLength { display: block; color: #afc2b6; font-size: 8px; }
#notice { color: #d9fd60; font-size: 13px; font-weight: bold; line-height: 1.45; margin-top: 9px; overflow-wrap: break-word; }
#notice:empty { display: none; }
.driver-heading { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 10px; }
#driverLabel { min-width: 0; color: #fff; font-size: 12px; font-weight: bold; line-height: 1.4; overflow-wrap: break-word; }
#driverCounts { flex: none; margin-left: 8px; color: #afc2b6; font-size: 10px; white-space: nowrap; }
#humanCount { color: #d9fd60; font-weight: bold; }
.speed { position: absolute; right: 30px; bottom: 24px; padding: 0; background: transparent; text-shadow: 0 2px 3px rgba(0, 0, 0, 0.9), 0 0 2px #142321; pointer-events: none; white-space: nowrap; }
.speed strong { font-size: 32px; font-weight: 900; font-style: italic; line-height: 1; letter-spacing: -1px; }
.speed > span { font-size: 10px; margin-left: 8px; }
#surface { font-size: 10px; letter-spacing: 1px; line-height: 1.5; margin-top: 7px; color: #b3c4bc; overflow-wrap: break-word; }
#statusCard { padding: 10px; background: rgba(21, 42, 43, 0.55); border-left: 2px solid #d9fd60; border-radius: 0 0 4px 4px; }
.hud-status #surface, .hud-status #notice { margin: 0; padding: 0; background: transparent; }
.hud-status #surface { font-size: 9px; font-weight: bold; letter-spacing: 0.7px; color: #dce6e1; }
.hud-status #surface:not(:empty) + #notice:not(:empty) { margin-top: 10px; padding-top: 8px; border-top: 1px solid rgba(175, 194, 182, 0.25); }
.status-caption { display: block; font-size: 9px; font-weight: normal; line-height: 1.4; color: #b7cbc3; }
.status-countdown { display: block; margin-top: 3px; font: bold 24px/1.1 Consolas, monospace; white-space: nowrap; }
.hud-status #surface:empty, .hud-status #notice:empty { display: none; }
#standings { padding: 12px; background: rgba(21, 42, 43, 0.76); }
#touchControls { display: none; position: absolute; bottom: 51px; left: 20px; right: 20px; justify-content: space-between; pointer-events: none; }
#touchControls > div { display: flex; position: relative; width: 46%; max-width: 192px; }
#touchControls button { pointer-events: auto; width: calc(50% - 4px); height: 64px; padding: 0; font-size: 11px; margin: 0; border-radius: 12px; box-shadow: 0 4px 0 rgba(0, 0, 0, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.22); touch-action: none; user-select: none; -webkit-user-select: none; }
#touchControls button + button { margin-left: 8px; }
#touchControls #mobileRecover { position: absolute; left: 0; bottom: 100%; width: 100%; height: 44px; margin: 0 0 12px; background: #d9fd60; color: #152520; border-color: #d9fd60; font-weight: bold; touch-action: manipulation; }
#touchControls button:active, #touchControls button.held { transform: translateY(2px); box-shadow: 0 2px 0 rgba(0, 0, 0, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.12); }
#touchControls button.held { background: #d9fd60; color: #152520; }
#touchControls .brake { background: #dc3434; border-color: #f46c6c; }
#touchControls .accelerator { background: #20ad50; border-color: #61d786; }
#touchControls .brake.held { background: #a61f1f; }
#touchControls .accelerator.held { background: #137b36; }
@media (max-width: 390px) { #touchControls { left: 10px; right: 10px; } }
.fatal { position: absolute; top: 40%; left: 15%; right: 15%; text-align: center; }
@media (pointer: coarse) { #touchControls { display: flex; } .speed { bottom: 127px; right: 23px; } }
@media (max-width: 650px) {
    .race-panel { padding: 18px; top: 45%; max-height: 55%; } .race-panel h1 { font-size: 25px; }
    .timing .best { display: none; }
    .topbar { top: 20px; left: 18px; right: 18px; } .brand { font-size: 27px; }
    .race-hud { top: 18px; right: 12px; width: 230px; max-width: calc(100% - 136px); max-height: calc(100% - 150px); padding: 0; }
    .timing { justify-content: space-between; }
    .timing .metric { margin: 0 10px 0 0; } .timing strong { font-size: 17px; }
    .timing span { font-size: 8px; letter-spacing: 1px; }
    .hud-summary { padding: 8px; }
    .course canvas { width: 95px; max-width: 100%; height: auto; } .eyebrow { font-size: 8px; letter-spacing: 1px; }
    .speed { right: 12px; bottom: 18px; } .speed strong { font-size: 26px; } .speed > span { font-size: 8px; margin-left: 5px; }
    #driverLabel { font-size: 11px; } .driver-heading { margin-bottom: 8px; }
    #surface { font-size: 9px; letter-spacing: 0; } #notice { font-size: 11px; }
    #touchControls { display: flex; }
    .speed { bottom: 127px; right: 23px; }
}
@media (max-width: 390px) { .speed { right: 12px; } }
@media (max-height: 600px) and (min-width: 651px) {
    .lobby .race-panel { top: 40%; max-height: 57%; }
    .race-panel { top: 44%; max-height: 61%; padding: 15px 22px; } .race-panel h1 { font-size: 24px; margin: 8px 0; }
    .topbar { top: 15px; } .brand { font-size: 26px; }
    .race-hud { top: 15px; width: 330px; max-height: calc(100% - 30px); padding: 0; }
    .hud-summary { padding: 12px; }
    .timing .metric { margin-right: 10px; } .timing strong { font-size: 19px; }
    .course canvas { width: 95px; height: 79px; }
}

/* Compact, consistently drawn icons; highlighted buttons show active toggles. */
.session { display: flex; justify-content: space-between; padding-bottom: 10px; margin-bottom: 12px; border-bottom: 1px solid #415856; }
.session button, .session a { display: flex; flex: none; align-items: center; justify-content: center; width: 36px; height: 36px; min-height: 0; padding: 0; color: #dce6e1; background: transparent; border: 0; border-radius: 3px; text-decoration: none; }
.session > * + * { margin-left: 4px; }
.session button:hover, .session button:focus, .session a:hover, .session a:focus { background: rgba(50, 72, 67, 0.8); }
.session button[aria-pressed="true"] { background: #d9fd60; color: #152520; }
.session svg { width: 21px; height: 21px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; pointer-events: none; }
#fullscreen .shrink-screen, #fullscreen[aria-pressed="true"] .expand-screen { display: none; }
#fullscreen[aria-pressed="true"] .shrink-screen { display: inline; }
.modal-backdrop { position: fixed; top: 0; right: 0; bottom: 0; left: 0; z-index: 20; background: rgba(8, 18, 18, 0.7); display: flex; align-items: center; justify-content: center; }
.leave-card { width: 330px; max-width: 90%; padding: 24px; border-top: 3px solid #d9fd60; background: rgba(21, 42, 43, 0.76); border-radius: 4px; }
.leave-card h2 { margin: 0 0 12px; font-size: 23px; }
.leave-card p { color: #b7cbc3; font-size: 13px; line-height: 1.5; }
#leaveConfirm { background: #d9fd60; color: #152520; border-color: #d9fd60; }
@media (max-width: 650px) {
    .session button, .session a { width: 28px; height: 30px; }
    .session > * + * { margin-left: 1px; }
    .session svg { width: 18px; height: 18px; }
}
@media (max-width: 400px) { .brand { font-size: 23px; } .brand small { font-size: 8px; letter-spacing: 1.4px; } }
@media (max-width: 359px) {
    .topbar { left: 12px; } .brand { font-size: 20px; } .brand small { font-size: 7px; letter-spacing: 1px; }
    .race-hud { right: 8px; max-width: calc(100% - 112px); }
    .session button, .session a { width: 26px; }
    .timing strong { font-size: 15px; } .timing .metric { margin-right: 6px; }
    .course canvas { width: 80px; height: auto; }
}

/* Shallow corner HUD and low controls leave the road clear on landscape phones. */
@media (orientation: landscape) and (max-height: 500px) and (max-width: 1000px) {
    .topbar { top: 10px; left: 14px; }
    .brand { font-size: 22px; }
    .brand small { padding-top: 5px; }
    .course { margin-top: 8px; }
    .course canvas { width: 70px; height: auto; }
    .course .eyebrow { font-size: 8px; letter-spacing: 1px; }
    #courseLength { display: none; }
    .race-hud { top: 8px; right: 10px; width: 236px; max-height: calc(100% - 90px); }
    .hud-summary { padding: 5px 8px 6px; }
    .session { padding-bottom: 4px; margin-bottom: 4px; }
    .session button, .session a { width: 28px; height: 30px; }
    .session > * + * { margin-left: 1px; }
    .session svg { width: 17px; height: 17px; }
    .driver-heading { margin-bottom: 4px; }
    #driverLabel { font-size: 10px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
    #driverCounts { font-size: 9px; }
    .timing .best { display: none; }
    .timing .metric { margin-right: 8px; }
    .timing span { font-size: 7px; letter-spacing: 1px; margin-bottom: 2px; }
    .timing strong { font-size: 16px; }
    #statusCard { padding: 3px 8px; background: transparent; border: 0; text-shadow: 0 1px 2px #142321; }
    .hud-status #surface, #notice { font-size: 9px; }
    .hud-status #surface:not(:empty) + #notice:not(:empty) { margin-top: 2px; padding-top: 0; border: 0; }
    .status-caption, .status-countdown { display: inline; font-size: 10px; }
    #touchControls { bottom: 12px; left: 14px; right: 14px; }
    #touchControls > div { max-width: 144px; }
    #touchControls button { height: 52px; }
    .speed { bottom: 73px; right: 16px; }
    .speed strong { font-size: 26px; }
    .speed > span { font-size: 8px; margin-left: 5px; }
}

/* Standard RCWeb invitation panel. */
.rcRoomQrCodeLink, .rcRoomQrCodeLink * { box-sizing: content-box; }
#joinPanel { position: relative; z-index: 6; width: 198px; margin: 12px 0 0 auto; padding: 12px 16px; border-radius: 4px; background: rgba(21, 42, 43, 0.76); }
.join-heading { display: flex; align-items: center; justify-content: space-between; font-size: 14px; font-weight: bold; line-height: 1.4; margin-bottom: 12px; }
.join-heading button { flex: none; min-height: 24px; padding: 0 6px; margin-left: 10px; }
#joinPanel p { font-size: 10px; line-height: 1.4; margin: 12px 0 0; color: #b7cbc3; }
@media (max-width: 650px) {
    #joinPanel { position: static; width: auto; padding: 12px; margin-top: 12px; border-top: 1px solid #415856; border-radius: 4px; max-height: none; overflow: visible; background: rgba(21, 42, 43, 0.76); }
}
.rcRoomQrCodeLink {
    display: block;
    width: 150px;
    margin-left: auto;
    margin-right: auto;
    border: solid 8px #fff;
    border-radius: 8px;
    color: #fff;
    background-color: #fff;
    box-shadow: 0 0 0 1px #fff;
    text-align: center;
    transition: opacity 1s ease;
    text-decoration: none;
    box-shadow: 0 0 32px #000;
    transform-origin: center;
    transform: scale(1);
    animation: pop-in 500ms ease-in-out forwards;
}

@keyframes pop-in {
    0% {
        transform: scale(0.5);
    }

    66% {
        transform: scale(1.1);
    }

    100% {
        transform: scale(1);
    }
}

.rcTechLabel {
    background-color: #000;
    color: #fff;
    font-family: monospace;
    font-size: 13px;
    font-weight: bold;
    margin: 0 0 8px 0;
    padding: 4px;
    letter-spacing: 0.2em;
    border-radius: 8px 8px 0 0;
}

.rcRoomQrCode {
    width: 150px;
    height: 150px;
}

.rcRoomId {
    background-color: #000;
    color: #fff;
    font-family: monospace;
    font-size: 16px;
    padding: 4px;
    margin: 8px 0 0 0;
    letter-spacing: 0.25em;
    border-radius: 0 0 8px 8px;
}

