/* MicroCars viewer stylesheet: circa-2015 CSS 3, flat lean-paint, Tizen 2.4 / Mali-400 safe. */
* {
    -webkit-box-sizing: border-box;
    box-sizing: border-box;
}

html, body {
    width: 100%;
    height: 100%;
    margin: 0;
    padding: 0;
    overflow: hidden;
    background: #3d2c20;
    color: #f6f8fa;
    font-family: "Trebuchet MS", "Segoe UI", Arial, Helvetica, sans-serif;
    -webkit-user-select: none;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

#world, #world canvas {
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    display: block;
}

/* Top-left HUD bar */
#hud-top {
    position: fixed;
    top: 12px;
    left: 12px;
    right: 116px;
    z-index: 6;
    pointer-events: none;
}

.hud-pill {
    display: inline-block;
    vertical-align: top;
    margin: 0 8px 6px 0;
    padding: 8px 13px;
    border-radius: 9px;
    background: rgba(20, 25, 34, 0.86);
    border: 1px solid rgba(255, 255, 255, 0.28);
    font-size: 14px;
    line-height: 1.2;
    color: #f6f8fa;
}

.hud-tag {
    display: inline-block;
    padding: 2px 7px;
    margin-right: 7px;
    border-radius: 5px;
    background: #e53935;
    color: #ffffff;
    font-size: 11px;
    font-weight: bold;
    letter-spacing: 0.8px;
    vertical-align: middle;
}

.hud-title {
    font-weight: bold;
    letter-spacing: 0.4px;
    vertical-align: middle;
}

.hud-sub {
    margin-left: 8px;
    color: #ffd56b;
    font-size: 12px;
    font-weight: bold;
    text-transform: uppercase;
    vertical-align: middle;
}

.hud-race {
    font-family: monospace;
    font-size: 15px;
}

.stat-label {
    font-family: "Trebuchet MS", Arial, sans-serif;
    font-size: 10px;
    font-weight: bold;
    color: #a9bfd0;
    letter-spacing: 0.8px;
    margin-right: 4px;
}

.hud-divider {
    display: inline-block;
    width: 1px;
    height: 14px;
    margin: 0 10px;
    background: rgba(255, 255, 255, 0.25);
    vertical-align: middle;
}

.hud-btn {
    pointer-events: auto;
    display: inline-block;
    vertical-align: top;
    margin: 0 8px 6px 0;
    padding: 9px 14px;
    border-radius: 9px;
    border: 1px solid rgba(255, 255, 255, 0.36);
    background: rgba(22, 30, 42, 0.88);
    color: #ffffff;
    font-family: inherit;
    font-size: 13px;
    font-weight: bold;
    cursor: pointer;
}

.hud-btn-primary {
    background: #1e88e5;
    border-color: #6ab7ff;
}

.hud-btn:hover, .hud-btn:active {
    background: #2f435a;
}

.hud-btn-primary:hover, .hud-btn-primary:active {
    background: #1565c0;
}

/* Top-right utility controls */
#scene-controls {
    position: fixed;
    top: 12px;
    right: 12px;
    z-index: 7;
    white-space: nowrap;
}

.scene-button {
    display: inline-block;
    vertical-align: top;
    width: 44px;
    height: 44px;
    padding: 9px;
    margin: 0 0 0 6px;
    border: 1px solid rgba(255, 255, 255, 0.42);
    border-radius: 9px;
    background: rgba(20, 25, 34, 0.84);
    color: #ffffff;
    cursor: pointer;
}

.scene-button svg {
    display: block;
    width: 24px;
    height: 24px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.scene-button:hover, .scene-button:active {
    background: #2d3b4e;
}

.sound-off, .is-muted .sound-on { display: none; }
.is-muted .sound-off { display: block; }
.fullscreen-exit, .is-fullscreen .fullscreen-enter { display: none; }
.is-fullscreen .fullscreen-exit { display: block; }

/* Live 6-car standings strip */
.leaderboard {
    position: fixed;
    top: 62px;
    left: 12px;
    z-index: 6;
    width: 218px;
    padding: 8px;
    border-radius: 10px;
    background: rgba(18, 22, 30, 0.82);
    border: 1px solid rgba(255, 255, 255, 0.22);
    pointer-events: none;
}

.lb-row {
    display: -webkit-flex;
    display: flex;
    -webkit-align-items: center;
    align-items: center;
    padding: 4px 6px;
    margin-bottom: 3px;
    border-radius: 6px;
    font-size: 13px;
    line-height: 1.2;
    background: rgba(255, 255, 255, 0.05);
}

.lb-row:last-child {
    margin-bottom: 0;
}

.lb-row.is-human {
    background: rgba(255, 255, 255, 0.14);
    border: 1px solid rgba(255, 255, 255, 0.28);
}

.lb-pos {
    width: 22px;
    font-weight: bold;
    color: #ffd56b;
    font-family: monospace;
}

.lb-dot {
    width: 11px;
    height: 11px;
    border-radius: 50%;
    margin-right: 7px;
    border: 1px solid rgba(255, 255, 255, 0.7);
    -webkit-flex-shrink: 0;
    flex-shrink: 0;
}

.lb-name {
    -webkit-flex: 1;
    flex: 1;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    font-weight: bold;
}

.lb-tag {
    margin-left: 6px;
    font-size: 10px;
    color: #b7c8d8;
    font-family: monospace;
}

/* Center countdown & event banner */
.center-banner {
    position: fixed;
    top: 24%;
    left: 50%;
    -webkit-transform: translateX(-50%);
    transform: translateX(-50%);
    z-index: 9;
    padding: 14px 30px;
    border-radius: 14px;
    background: rgba(20, 26, 36, 0.92);
    border: 3px solid #ffd56b;
    color: #ffffff;
    font-size: 40px;
    font-weight: bold;
    letter-spacing: 3px;
    text-transform: uppercase;
    white-space: nowrap;
    pointer-events: none;
}

.center-banner.is-go {
    background: #1b6e35;
    border-color: #8bf5a8;
}

.center-banner.is-info {
    font-size: 24px;
    padding: 10px 22px;
    border-color: #7cc4ff;
}

/* Lobby & Results modal card */
.overlay-card {
    position: fixed;
    top: 50%;
    left: 50%;
    -webkit-transform: translate(-50%, -50%);
    transform: translate(-50%, -50%);
    z-index: 8;
    width: 540px;
    max-width: 92%;
    max-height: 84%;
    overflow-y: auto;
    padding: 18px 20px;
    border-radius: 16px;
    background: rgba(20, 25, 35, 0.94);
    border: 2px solid rgba(255, 255, 255, 0.28);
    color: #f6f8fa;
}

.overlay-header {
    display: -webkit-flex;
    display: flex;
    -webkit-align-items: center;
    align-items: center;
    margin-bottom: 14px;
}

.overlay-icon {
    display: block;
    width: 60px;
    height: 60px;
    border-radius: 12px;
    margin-right: 14px;
    background: #ffffff;
    border: 2px solid rgba(255, 255, 255, 0.35);
    -webkit-flex-shrink: 0;
    flex-shrink: 0;
}

.overlay-eyebrow {
    font-size: 11px;
    font-weight: bold;
    letter-spacing: 1.6px;
    color: #ffd56b;
    text-transform: uppercase;
}

.overlay-title {
    margin: 2px 0 0 0;
    font-size: 30px;
    line-height: 1.05;
    letter-spacing: 0.5px;
}

.track-picker {
    display: -webkit-flex;
    display: flex;
    -webkit-align-items: center;
    align-items: center;
    padding: 10px;
    margin-bottom: 12px;
    border-radius: 11px;
    background: #1f2838;
    border: 1px solid rgba(255, 255, 255, 0.20);
}

.picker-arrow {
    width: 44px;
    height: 44px;
    border-radius: 9px;
    border: 1px solid rgba(255, 255, 255, 0.30);
    background: #2c394f;
    color: #ffffff;
    font-size: 28px;
    line-height: 1;
    cursor: pointer;
    -webkit-flex-shrink: 0;
    flex-shrink: 0;
}

.picker-arrow:hover, .picker-arrow:active {
    background: #3d506e;
}

.picker-info {
    -webkit-flex: 1;
    flex: 1;
    text-align: center;
    padding: 0 10px;
}

.picker-level {
    font-size: 11px;
    font-weight: bold;
    letter-spacing: 1.4px;
    color: #7cc4ff;
    text-transform: uppercase;
}

.picker-name {
    font-size: 22px;
    font-weight: bold;
    margin: 2px 0;
}

.picker-sub {
    font-size: 13px;
    color: #c7d5e2;
}

/* 6-slot roster grid (circa-2015 inline-block / flex) */
.roster-grid {
    margin: 0 -4px 12px -4px;
    font-size: 0;
}

.roster-slot {
    display: inline-block;
    vertical-align: top;
    width: 50%;
    padding: 4px;
    font-size: 13px;
}

.roster-card {
    display: -webkit-flex;
    display: flex;
    -webkit-align-items: center;
    align-items: center;
    padding: 7px 10px;
    border-radius: 8px;
    background: #232c3d;
    border: 1px solid rgba(255, 255, 255, 0.14);
}

.roster-card.is-human {
    background: #20392c;
    border-color: #66d98a;
}

.roster-swatch {
    width: 14px;
    height: 14px;
    border-radius: 4px;
    margin-right: 8px;
    border: 1px solid rgba(255, 255, 255, 0.75);
    -webkit-flex-shrink: 0;
    flex-shrink: 0;
}

.roster-name {
    -webkit-flex: 1;
    flex: 1;
    font-weight: bold;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.roster-role {
    font-size: 10px;
    font-weight: bold;
    letter-spacing: 0.6px;
    padding: 2px 6px;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.12);
    color: #d0dde8;
    text-transform: uppercase;
}

.roster-card.is-human .roster-role {
    background: #2e8b4e;
    color: #ffffff;
}

.overlay-actions {
    display: -webkit-flex;
    display: flex;
    -webkit-flex-wrap: wrap;
    flex-wrap: wrap;
    margin: 0 -5px;
}

.btn-big {
    -webkit-flex: 1;
    flex: 1;
    min-width: 130px;
    margin: 5px;
    padding: 13px 16px;
    border-radius: 10px;
    border: 2px solid transparent;
    font-family: inherit;
    font-size: 16px;
    font-weight: bold;
    letter-spacing: 0.4px;
    color: #ffffff;
    cursor: pointer;
}

.btn-start {
    background: #2e9d4f;
    border-color: #79e598;
}

.btn-start:hover, .btn-start:active {
    background: #24803f;
}

.btn-local {
    background: #1e7fd6;
    border-color: #77c0ff;
}

.btn-local:hover, .btn-local:active {
    background: #1665ad;
}

.btn-muted {
    background: #364154;
    border-color: #5b6b86;
}

.overlay-hint {
    margin: 10px 0 0 0;
    font-size: 13px;
    line-height: 1.35;
    color: #c2d1de;
    text-align: center;
}

/* Results table */
.results-badge {
    margin: 10px 0 12px 0;
    padding: 8px 12px;
    border-radius: 8px;
    background: #204c32;
    border: 1px solid #6be394;
    color: #e9fff0;
    font-size: 13px;
    font-weight: bold;
    letter-spacing: 0.8px;
    text-align: center;
}

.results-badge.is-retry {
    background: #54371c;
    border-color: #f0b050;
    color: #fff3db;
}

.results-list {
    margin-bottom: 12px;
}

.res-row {
    display: -webkit-flex;
    display: flex;
    -webkit-align-items: center;
    align-items: center;
    padding: 7px 10px;
    margin-bottom: 5px;
    border-radius: 8px;
    background: #222b3b;
    font-size: 14px;
}

.res-row.is-human {
    background: #213a2d;
    border: 1px solid #67da8b;
}

.res-place {
    width: 34px;
    font-weight: bold;
    color: #ffd56b;
    font-family: monospace;
}

.res-name {
    -webkit-flex: 1;
    flex: 1;
    font-weight: bold;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.res-time {
    width: 66px;
    text-align: right;
    font-family: monospace;
    color: #b7cadb;
}

.res-pts {
    width: 72px;
    text-align: right;
    font-family: monospace;
    font-weight: bold;
    color: #8bf5a8;
}

/* Local on-screen touch controls for playing directly on viewer */
.local-controls {
    position: fixed;
    left: 14px;
    right: 14px;
    bottom: 14px;
    z-index: 7;
    display: -webkit-flex;
    display: flex;
    -webkit-align-items: flex-end;
    align-items: flex-end;
    -webkit-justify-content: space-between;
    justify-content: space-between;
    pointer-events: none;
}

.local-pad-left, .local-pad-right {
    pointer-events: auto;
    white-space: nowrap;
}

.local-center-bar {
    pointer-events: auto;
    text-align: center;
    padding: 6px 12px;
    border-radius: 10px;
    background: rgba(18, 22, 30, 0.84);
    border: 1px solid rgba(255, 255, 255, 0.24);
}

.local-car-tag {
    display: block;
    font-size: 12px;
    font-weight: bold;
    letter-spacing: 0.8px;
    margin-bottom: 4px;
}

.local-boost-track {
    width: 120px;
    height: 8px;
    border-radius: 4px;
    background: #263142;
    overflow: hidden;
    margin: 0 auto 6px auto;
}

.local-boost-fill {
    width: 70%;
    height: 100%;
    background: #ff9800;
}

.local-exit-btn {
    padding: 5px 10px;
    border-radius: 6px;
    border: 1px solid rgba(255, 255, 255, 0.30);
    background: #333f52;
    color: #ffffff;
    font-size: 11px;
    font-weight: bold;
    cursor: pointer;
}

.drive-btn {
    display: inline-block;
    vertical-align: bottom;
    min-width: 74px;
    height: 74px;
    margin: 0 5px;
    border-radius: 16px;
    border: 2px solid rgba(255, 255, 255, 0.45);
    background: rgba(20, 26, 36, 0.84);
    color: #ffffff;
    font-family: inherit;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    touch-action: none;
}

.drive-steer {
    width: 82px;
    font-size: 38px;
    line-height: 1;
}

.drive-brake {
    width: 82px;
    background: rgba(168, 40, 36, 0.86);
    border-color: #ff9a94;
}

.drive-boost {
    width: 92px;
    background: rgba(224, 124, 12, 0.90);
    border-color: #ffe082;
}

.drive-btn.is-pressed {
    background: #ffffff;
    color: #141923;
}

/* Standard canonical RCWeb QR panel (content-box restored, uniform scale only) */
#qrPanel {
    position: fixed;
    bottom: 14px;
    right: 14px;
    z-index: 6;
    width: 166px;
    -webkit-transform-origin: bottom right;
    transform-origin: bottom right;
    -webkit-transform: scale(0.62);
    transform: scale(0.62);
}

#qrPanel.is-compact {
    bottom: 100px;
    -webkit-transform: scale(0.42);
    transform: scale(0.42);
    opacity: 0.72;
}

.rcRoomQrCodeLink, .rcRoomQrCodeLink * {
    -webkit-box-sizing: content-box;
    box-sizing: content-box;
}

.rcRoomQrCodeLink {
    display: block;
    width: 150px;
    margin-left: auto;
    margin-right: auto;
    border: solid 8px #fff;
    border-radius: 8px;
    color: #fff;
    background-color: #fff;
    text-align: center;
    -webkit-transition: opacity 1s ease;
    transition: opacity 1s ease;
    text-decoration: none;
    -webkit-transform-origin: center;
    transform-origin: center;
    -webkit-transform: scale(1);
    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;
}

.conn-status {
    position: fixed;
    left: 14px;
    bottom: 12px;
    z-index: 9;
    font-size: 13px;
    color: #ffe08a;
    pointer-events: none;
}

#diagnostics {
    position: fixed;
    left: 12px;
    bottom: 12px;
    z-index: 10;
    margin: 0;
    padding: 8px 10px;
    background: #141a24;
    color: #ffffff;
    font: 12px monospace;
    pointer-events: none;
}

.no-script {
    position: fixed;
    top: 40%;
    width: 100%;
    text-align: center;
}

/* Lean-paint mode for weak signage devices (Tizen 2.4 / Mali-400): solid flat backgrounds, zero alpha compositing over WebGL */
body.is-lean .hud-pill,
body.is-lean .hud-btn,
body.is-lean .scene-button,
body.is-lean .leaderboard,
body.is-lean .overlay-card,
body.is-lean .center-banner,
body.is-lean .local-center-bar,
body.is-lean .drive-btn {
    background: #141923;
}

body.is-lean .hud-btn-primary { background: #1e88e5; }
body.is-lean .drive-brake { background: #a82824; }
body.is-lean .drive-boost { background: #e07c0c; }
body.is-lean .rcRoomQrCodeLink {
    -webkit-transition: none;
    transition: none;
}

/* Short landscape (960x540) */
@media (max-width: 1024px), (max-height: 620px) {
    .overlay-card {
        width: 470px;
        padding: 13px 16px;
        left: 44%;
    }
    .overlay-icon { width: 46px; height: 46px; }
    .overlay-title { font-size: 24px; }
    .picker-name { font-size: 18px; }
    .picker-arrow { width: 38px; height: 38px; font-size: 24px; }
    .roster-card { padding: 5px 8px; }
    .btn-big { padding: 10px 12px; font-size: 14px; }
    .overlay-hint { font-size: 12px; margin-top: 7px; }
    #qrPanel {
        bottom: 10px;
        right: 10px;
        -webkit-transform: scale(0.52);
        transform: scale(0.52);
    }
    .leaderboard { width: 192px; }
}

/* Portrait & narrow displays (1080x1920, 450x960) */
@media (orientation: portrait) {
    .overlay-card {
        left: 50%;
        top: 43%;
        width: 416px;
        max-width: 92%;
    }
    #qrPanel {
        bottom: 12px;
        right: 12px;
        -webkit-transform: scale(0.56);
        transform: scale(0.56);
    }
}

/* Compact top bar on medium-narrow & short landscape displays (e.g. phones in landscape) */
@media (max-width: 760px), (max-height: 460px) {
    #hud-top { top: 8px; left: 8px; right: 92px; }
    #scene-controls { top: 8px; right: 8px; }
    .scene-button { width: 36px; height: 36px; padding: 7px; margin-left: 4px; }
    .scene-button svg { width: 20px; height: 20px; }
    .hud-pill { font-size: 12px; padding: 6px 9px; margin: 0 5px 4px 0; }
    .hud-sub { display: none; }
    .hud-btn { font-size: 12px; padding: 6px 10px; margin: 0 5px 4px 0; }
    .leaderboard { top: 50px; left: 8px; width: 158px; padding: 5px; }
    .lb-row { font-size: 11px; padding: 3px 5px; }
}

/* Narrow smartphones: single-row ultra-compact HUD, no overlap, hide QR panel */
@media (max-width: 520px) {
    #hud-top {
        top: 6px;
        left: 6px;
        right: 78px;
        display: -webkit-flex;
        display: flex;
        -webkit-flex-wrap: nowrap;
        flex-wrap: nowrap;
        -webkit-align-items: center;
        align-items: center;
    }
    #scene-controls { top: 6px; right: 6px; }
    .scene-button { width: 32px; height: 32px; padding: 6px; margin-left: 4px; border-radius: 7px; }
    .scene-button svg { width: 18px; height: 18px; }
    .hud-pill {
        font-size: 11px;
        padding: 5px 7px;
        margin: 0 4px 0 0;
        border-radius: 7px;
        white-space: nowrap;
        -webkit-flex-shrink: 0;
        flex-shrink: 0;
    }
    .hud-tag { padding: 1px 5px; margin-right: 0; font-size: 10px; }
    .hud-title, .hud-sub { display: none; }
    .hud-race { font-size: 11px; }
    .stat-label { font-size: 9px; margin-right: 2px; }
    .hud-divider { height: 11px; margin: 0 5px; }
    .hud-btn {
        font-size: 11px;
        padding: 5px 8px;
        margin: 0 4px 0 0;
        border-radius: 7px;
        white-space: nowrap;
        -webkit-flex-shrink: 0;
        flex-shrink: 0;
    }
    .leaderboard {
        top: 42px;
        left: 6px;
        width: 130px;
        padding: 4px;
        border-radius: 8px;
    }
    .lb-row { font-size: 10px; padding: 2px 4px; margin-bottom: 2px; }
    .lb-pos { width: 16px; }
    .lb-dot { width: 8px; height: 8px; margin-right: 4px; }
    .lb-tag { font-size: 9px; margin-left: 3px; }
    .overlay-card {
        top: 50%;
        left: 50%;
        padding: 12px 13px;
        max-height: 82%;
    }
    .overlay-icon { width: 42px; height: 42px; margin-right: 10px; }
    .overlay-title { font-size: 22px; }
    .roster-slot { width: 50%; padding: 3px; font-size: 12px; }
    .btn-big { min-width: 110px; padding: 10px 10px; font-size: 14px; }
    .drive-btn { min-width: 60px; height: 64px; font-size: 13px; margin: 0 3px; }
    .drive-steer { width: 66px; font-size: 30px; }
    .drive-brake { width: 68px; }
    .drive-boost { width: 74px; }
    .local-center-bar { display: none; }
    #qrPanel { display: none; }
}
