@import url("https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@300;400;500;700&family=Barlow+Condensed:wght@300;400;500;600;700&display=swap");
      * {
        box-sizing: border-box;
        margin: 0;
        padding: 0;
      }
      :root {
        --bg: #07080b;
        --panel: #0c0f14;
        --panel2: #0f1218;
        --border: #191e28;
        --border2: #222a38;
        --cyan: #00e5ff;
        --red: #ff3d5a;
        --green: #39ff7a;
        --amber: #ffb800;
        --purple: #b388ff;
        --orange: #ff7043;
        --blue: #448aff;
        --text: #bcc8d8;
        --muted: #3a4555;
        --dim: #0d1017;
        --mono: "JetBrains Mono", monospace;
        --ui: "Barlow Condensed", sans-serif;
        --brand-red: #cc2222;
      }
      html,
      body {
        height: 100%;
        overflow: hidden;
        background: var(--bg);
        color: var(--text);
        font-family: var(--ui);
      }
      #connect-screen {
        position: fixed;
        inset: 0;
        display: flex;
        align-items: center;
        justify-content: center;
        background: var(--bg);
        z-index: 100;
        flex-direction: column;
        gap: 20px;
      }
      .connect-card {
        background: var(--panel);
        border: 1px solid var(--border2);
        border-radius: 12px;
        padding: 32px 40px;
        width: 420px;
      }
      .connect-logo-row {
        display: flex;
        align-items: center;
        gap: 12px;
        margin-bottom: 6px;
      }
      .connect-logo-img {
        width: 44px;
        height: 44px;
        object-fit: contain;
        background: #fff;
        border-radius: 6px;
        padding: 4px;
      }
      .connect-brand {
        font-size: 20px;
        font-weight: 700;
        letter-spacing: 0.12em;
        color: var(--brand-red);
        text-transform: uppercase;
      }
      .connect-sub {
        font-size: 12px;
        color: var(--muted);
        letter-spacing: 0.06em;
        margin-bottom: 22px;
      }
      .connect-label {
        font-size: 11px;
        letter-spacing: 0.12em;
        text-transform: uppercase;
        color: var(--muted);
        margin-bottom: 6px;
      }
      .connect-input {
        width: 100%;
        background: var(--bg);
        border: 1px solid var(--border2);
        border-radius: 6px;
        padding: 10px 14px;
        font-family: var(--mono);
        font-size: 13px;
        color: var(--text);
        outline: none;
        transition: border-color 0.15s;
      }
      .connect-input:focus {
        border-color: var(--cyan);
      }
      .connect-btn {
        width: 100%;
        margin-top: 14px;
        padding: 11px;
        font-family: var(--ui);
        font-size: 14px;
        font-weight: 600;
        letter-spacing: 0.1em;
        text-transform: uppercase;
        background: rgba(0, 229, 255, 0.1);
        border: 1px solid rgba(0, 229, 255, 0.35);
        color: var(--cyan);
        border-radius: 6px;
        cursor: pointer;
        transition: all 0.15s;
      }
      .connect-btn:hover {
        background: rgba(0, 229, 255, 0.18);
      }
      .connect-status {
        font-family: var(--mono);
        font-size: 11px;
        text-align: center;
        height: 16px;
        margin-top: 10px;
      }
      .cs-ok {
        color: var(--green);
      }
      .cs-err {
        color: var(--red);
      }
      .cs-wait {
        color: var(--amber);
      }
      .connect-hint {
        font-size: 11px;
        color: var(--muted);
        font-family: var(--mono);
        text-align: center;
        line-height: 1.6;
      }
      #app {
        display: none;
        height: 100vh;
        flex-direction: column;
        overflow: hidden;
      }
      #app.visible {
        display: flex;
      }
      .topbar {
        height: 36px;
        background: var(--panel);
        border-bottom: 1px solid var(--border);
        display: flex;
        align-items: center;
        flex-shrink: 0;
      }
      .tb-brand {
        padding: 0 12px;
        border-right: 1px solid var(--border);
        height: 100%;
        display: flex;
        align-items: center;
        gap: 8px;
        min-width: 176px;
      }
      .tb-brand-logo {
        width: 26px;
        height: 26px;
        object-fit: contain;
        background: #fff;
        border-radius: 3px;
        padding: 2px;
      }
      .tb-brand-name {
        font-size: 12px;
        font-weight: 700;
        letter-spacing: 0.1em;
        color: var(--brand-red);
        text-transform: uppercase;
        line-height: 1;
      }
      .tb-brand-sub {
        font-size: 9px;
        color: var(--muted);
        letter-spacing: 0.06em;
        margin-top: 1px;
      }
      .tb-center {
        flex: 1;
        display: flex;
        align-items: center;
        height: 100%;
        overflow: hidden;
      }
      .tb-metric {
        padding: 0 10px;
        height: 100%;
        display: flex;
        flex-direction: column;
        justify-content: center;
        border-right: 1px solid var(--border);
      }
      .tb-metric:first-child {
        border-left: 1px solid var(--border);
      }
      .tb-k {
        font-size: 8px;
        letter-spacing: 0.1em;
        text-transform: uppercase;
        color: var(--muted);
      }
      .tb-v {
        font-family: var(--mono);
        font-size: 12px;
        font-weight: 700;
        line-height: 1.1;
      }
      .tb-right {
        padding: 0 10px;
        display: flex;
        align-items: center;
        gap: 10px;
        border-left: 1px solid var(--border);
        height: 100%;
        flex-shrink: 0;
      }
      .status-dot {
        width: 7px;
        height: 7px;
        border-radius: 50%;
      }
      .dot-live {
        background: var(--green);
        animation: blink 1.4s ease-in-out infinite;
      }
      .dot-off {
        background: var(--muted);
      }
      @keyframes blink {
        0%,
        100% {
          opacity: 1;
        }
        50% {
          opacity: 0.2;
        }
      }
      .tb-disconnect {
        cursor: pointer;
        font-size: 11px;
        color: var(--muted);
        transition: color 0.12s;
        padding: 0 4px;
      }
      .tb-disconnect:hover {
        color: var(--red);
      }
      .focus-select {
        background: var(--dim);
        border: 1px solid var(--border2);
        color: var(--cyan);
        font-family: var(--mono);
        font-size: 10px;
        padding: 3px 7px;
        border-radius: 3px;
        cursor: pointer;
        outline: none;
        max-width: 150px;
      }
      .focus-select option {
        background: var(--panel);
        color: var(--text);
      }
      .body {
        flex: 1;
        display: flex;
        overflow: hidden;
        min-height: 0;
      }
      .sidebar {
        width: 172px;
        flex-shrink: 0;
        background: var(--panel);
        border-right: 1px solid var(--border);
        display: flex;
        flex-direction: column;
        overflow: hidden;
      }
      .sb-sect {
        padding: 5px 9px;
        border-bottom: 1px solid var(--border);
        flex-shrink: 0;
      }
      .sb-lbl {
        font-size: 8px;
        letter-spacing: 0.12em;
        text-transform: uppercase;
        color: var(--muted);
        margin-bottom: 2px;
      }
      .sb-big {
        font-family: var(--mono);
        font-size: 28px;
        font-weight: 700;
        line-height: 1;
        letter-spacing: -0.02em;
      }
      .sb-unit {
        font-family: var(--mono);
        font-size: 9px;
        color: var(--muted);
      }
      .sb-gear {
        font-family: var(--ui);
        font-weight: 700;
        font-size: 44px;
        line-height: 1;
        text-align: center;
      }
      .rpmbar {
        height: 4px;
        background: var(--dim);
        border-radius: 1px;
        overflow: hidden;
        margin: 3px 0 2px;
      }
      .rpmbar-fill {
        height: 100%;
        border-radius: 1px;
        transition: width 0.06s linear;
      }
      .pedal-row {
        display: flex;
        gap: 5px;
        height: 46px;
        align-items: flex-end;
      }
      .pedal-col {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 2px;
        flex: 1;
      }
      .pedal-track {
        flex: 1;
        width: 100%;
        background: var(--dim);
        border-radius: 1px;
        position: relative;
        overflow: hidden;
      }
      .pedal-fill {
        position: absolute;
        bottom: 0;
        left: 0;
        right: 0;
        border-radius: 1px;
        transition: height 0.05s linear;
      }
      .p-thr {
        background: var(--green);
      }
      .p-brk {
        background: var(--red);
      }
      .p-clt {
        background: var(--muted);
      }
      .pedal-lbl {
        font-family: var(--mono);
        font-size: 7px;
        color: var(--muted);
      }
      .pedal-pct {
        font-family: var(--mono);
        font-size: 8px;
      }
      .mini-r {
        display: flex;
        justify-content: space-between;
        align-items: center;
        margin-bottom: 2px;
      }
      .mini-k {
        font-size: 10px;
        color: var(--muted);
      }
      .mini-v {
        font-family: var(--mono);
        font-size: 10px;
        font-weight: 500;
      }
      .fuel-bar {
        height: 4px;
        background: var(--dim);
        border-radius: 1px;
        overflow: hidden;
        margin: 2px 0 1px;
      }
      .fuel-fill {
        height: 100%;
        border-radius: 1px;
        transition: width 0.5s;
      }
      .tyre-grid {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 3px;
      }
      .tyre-cell {
        background: var(--dim);
        border-radius: 3px;
        padding: 3px 4px;
      }
      .tc-pos {
        font-size: 7px;
        color: var(--muted);
        margin-bottom: 2px;
        letter-spacing: 0.06em;
      }
      .tc-bars {
        display: flex;
        gap: 2px;
        justify-content: center;
        margin-bottom: 2px;
      }
      .tc-bar {
        width: 9px;
        height: 18px;
        border-radius: 1px;
        transition: background 0.3s;
      }
      .tc-temp {
        font-family: var(--mono);
        font-size: 8px;
        text-align: center;
        color: var(--muted);
      }
      .tc-psi {
        font-family: var(--mono);
        font-size: 8px;
        text-align: center;
        margin-top: 1px;
      }
      .gf-canvas {
        display: block;
        width: 100%;
      }
      .col-mid {
        flex: 1;
        display: flex;
        flex-direction: column;
        overflow: hidden;
        min-width: 0;
        border-right: 1px solid var(--border);
      }
      .map-panel {
        flex: 0 0 42%;
        border-bottom: 1px solid var(--border);
        display: flex;
        flex-direction: column;
        overflow: hidden;
        min-height: 0;
      }
      .telem-panel {
        flex: 1;
        display: flex;
        flex-direction: column;
        overflow: hidden;
        min-height: 0;
      }
      .panel-hdr {
        height: 26px;
        background: var(--panel);
        border-bottom: 1px solid var(--border);
        display: flex;
        align-items: center;
        padding: 0 10px;
        gap: 6px;
        flex-shrink: 0;
      }
      .ph-title {
        font-size: 9px;
        font-weight: 600;
        letter-spacing: 0.14em;
        text-transform: uppercase;
        color: var(--muted);
      }
      .ph-right {
        margin-left: auto;
        font-family: var(--mono);
        font-size: 9px;
      }
      .tab-row {
        height: 26px;
        background: var(--panel);
        border-bottom: 1px solid var(--border);
        display: flex;
        flex-shrink: 0;
      }
      .tab {
        padding: 0 14px;
        display: flex;
        align-items: center;
        font-size: 11px;
        font-weight: 600;
        letter-spacing: 0.08em;
        text-transform: uppercase;
        color: var(--muted);
        cursor: pointer;
        border-bottom: 2px solid transparent;
        transition: all 0.12s;
      }
      .tab:hover {
        color: var(--text);
      }
      .tab.active {
        color: var(--cyan);
        border-bottom-color: var(--cyan);
      }
      .tab-content {
        flex: 1;
        display: none;
        flex-direction: column;
        overflow-y: auto;
        overflow-x: hidden;
        padding: 6px 8px;
        min-height: 0;
      }
      .tab-content.active {
        display: flex;
      }
      #map-container {
        flex: 1;
        position: relative;
        display: flex;
        align-items: center;
        justify-content: center;
        overflow: hidden;
      }
      #map-canvas {
        display: block;
        max-width: 100%;
        max-height: 100%;
      }
      #map-no-track {
        position: absolute;
        inset: 0;
        display: flex;
        align-items: center;
        justify-content: center;
        flex-direction: column;
        gap: 5px;
        pointer-events: none;
      }
      .ch-bar {
        display: flex;
        gap: 4px;
        flex-wrap: wrap;
        margin-bottom: 5px;
        flex-shrink: 0;
      }
      .ch-tog {
        display: flex;
        align-items: center;
        gap: 3px;
        padding: 2px 7px;
        border-radius: 3px;
        border: 1px solid var(--border);
        font-size: 9px;
        font-family: var(--mono);
        cursor: pointer;
        user-select: none;
        transition: all 0.12s;
      }
      .ch-tog.on {
        background: rgba(255, 255, 255, 0.03);
        border-color: rgba(255, 255, 255, 0.12);
      }
      .ch-dot {
        width: 6px;
        height: 6px;
        border-radius: 50%;
        flex-shrink: 0;
      }
      .lap-tags {
        display: flex;
        gap: 4px;
        flex-wrap: wrap;
        margin-bottom: 5px;
        flex-shrink: 0;
      }
      .lap-tag {
        display: flex;
        align-items: center;
        gap: 3px;
        padding: 2px 8px;
        border-radius: 3px;
        border: 1px solid var(--border);
        font-size: 9px;
        font-family: var(--mono);
        cursor: pointer;
        user-select: none;
      }
      .lap-tag.on {
        background: rgba(255, 255, 255, 0.03);
        border-color: rgba(255, 255, 255, 0.12);
      }
      .lt-dot {
        width: 6px;
        height: 6px;
        border-radius: 2px;
        flex-shrink: 0;
      }
      .lt-best {
        color: var(--amber);
      }
      .chart-rows {
        display: flex;
        flex-direction: column;
        gap: 1px;
        background: var(--border);
      }
      .chart-row {
        background: var(--panel2);
        padding: 4px 8px 6px;
      }
      .cr-hdr {
        display: flex;
        align-items: center;
        justify-content: space-between;
        margin-bottom: 3px;
      }
      .cr-title {
        font-size: 8px;
        font-weight: 600;
        letter-spacing: 0.14em;
        text-transform: uppercase;
      }
      .cr-vals {
        display: flex;
        gap: 6px;
      }
      .cr-val {
        font-family: var(--mono);
        font-size: 10px;
        font-weight: 700;
      }
      .stream-rows {
        display: flex;
        flex-direction: column;
        gap: 1px;
        background: var(--border);
      }
      .stream-row {
        background: var(--panel2);
        padding: 4px 8px 6px;
      }
      .sr-hdr {
        display: flex;
        justify-content: space-between;
        align-items: center;
        margin-bottom: 2px;
      }
      .sr-title {
        font-size: 8px;
        font-weight: 600;
        letter-spacing: 0.12em;
        text-transform: uppercase;
      }
      .sr-live {
        font-family: var(--mono);
        font-size: 10px;
        font-weight: 700;
      }
      .col-right {
        width: 310px;
        flex-shrink: 0;
        display: flex;
        flex-direction: column;
        overflow: hidden;
        min-width: 0;
      }
      .driver-panel {
        flex: 0 0 25%;
        max-height: 25%;
        border-bottom: 1px solid var(--border);
        display: flex;
        flex-direction: column;
        overflow: hidden;
      }
      .dp-body {
        padding: 5px 8px;
        flex: 1;
        overflow: hidden;
        display: flex;
        flex-direction: column;
        gap: 3px;
      }
      .dp-name {
        font-size: 11px;
        font-weight: 700;
        color: var(--text);
        line-height: 1.2;
      }
      .dp-car {
        font-size: 9px;
        color: var(--muted);
      }
      .dp-grid {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 2px;
      }
      .dp-grid3 {
        display: grid;
        grid-template-columns: 1fr 1fr 1fr;
        gap: 2px;
      }
      .dp-grid4 {
        display: grid;
        grid-template-columns: 1fr 1fr 1fr 1fr;
        gap: 2px;
      }
      .dp-cell {
        background: var(--dim);
        border-radius: 3px;
        padding: 3px 5px;
      }
      .dp-k {
        font-size: 7px;
        letter-spacing: 0.08em;
        text-transform: uppercase;
        color: var(--muted);
      }
      .dp-v {
        font-family: var(--mono);
        font-size: 10px;
        font-weight: 600;
        line-height: 1.2;
      }
      .standings-panel {
        flex: 1;
        display: flex;
        flex-direction: column;
        overflow: hidden;
      }
      .standings-body {
        flex: 1;
        overflow-y: auto;
        overflow-x: hidden;
      }
      .st-head {
        display: grid;
        font-size: 8px;
        color: var(--muted);
        padding: 3px 6px;
        border-bottom: 1px solid var(--border);
        background: var(--panel);
        position: sticky;
        top: 0;
        z-index: 1;
        letter-spacing: 0.06em;
        text-transform: uppercase;
        grid-template-columns: 24px 1fr 62px 62px 62px 44px;
        gap: 0;
      }
      .st-row {
        display: grid;
        grid-template-columns: 24px 1fr 62px 62px 62px 44px;
        gap: 0;
        font-size: 9px;
        padding: 3px 6px;
        border-bottom: 1px solid #111520;
        font-family: var(--mono);
        cursor: pointer;
        transition: background 0.1s;
      }
      .st-row:hover {
        background: rgba(255, 255, 255, 0.03);
      }
      .st-row.focused {
        background: rgba(0, 229, 255, 0.05);
        border-left: 2px solid var(--cyan);
      }
      .st-pos {
        color: var(--muted);
        font-weight: 700;
      }
      .st-name {
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        color: var(--text);
      }
      .st-best {
        color: var(--amber);
      }
      .st-cur {
        color: var(--cyan);
      }
      .st-last {
        color: var(--text);
      }
      .st-gap {
        color: var(--muted);
        font-size: 8px;
      }
      .statusbar {
        height: 20px;
        background: var(--panel);
        border-top: 1px solid var(--border);
        display: flex;
        align-items: center;
        padding: 0 12px;
        gap: 20px;
        flex-shrink: 0;
      }
      .sb2 {
        font-size: 9px;
        color: var(--muted);
        font-family: var(--mono);
      }
      .sb2 span {
        color: var(--text);
      }
      .alerts {
        position: fixed;
        bottom: 28px;
        right: 12px;
        display: flex;
        flex-direction: column;
        gap: 4px;
        z-index: 200;
        pointer-events: none;
      }
      .alert {
        padding: 5px 10px;
        border-radius: 4px;
        font-family: var(--mono);
        font-size: 10px;
        border-left: 2px solid;
        animation: slideIn 0.2s ease;
      }
      @keyframes slideIn {
        from {
          opacity: 0;
          transform: translateX(16px);
        }
        to {
          opacity: 1;
          transform: none;
        }
      }
      .al-info {
        background: rgba(0, 229, 255, 0.07);
        border-color: var(--cyan);
        color: var(--cyan);
      }
      .al-warn {
        background: rgba(255, 184, 0, 0.07);
        border-color: var(--amber);
        color: var(--amber);
      }
      .al-danger {
        background: rgba(255, 61, 90, 0.07);
        border-color: var(--red);
        color: var(--red);
      }
      /* Flag display */
      @keyframes flagpulse {
        0%,
        100% {
          opacity: 1;
        }
        50% {
          opacity: 0.45;
        }
      }
      .flag-active {
        opacity: 1 !important;
        animation: flagpulse 0.8s ease-in-out infinite;
      }
      .flag-active-solid {
        opacity: 1 !important;
      }
      /* Chequered flag pattern */
      #flag-rect.chequered {
        background: repeating-conic-gradient(#fff 0% 25%, #111 0% 50%) 0 0/8px
          8px;
      }
      .dmg-row {
        display: flex;
        align-items: center;
        gap: 4px;
      }
      .dmg-lbl {
        font-size: 8px;
        color: var(--muted);
        font-family: var(--mono);
        min-width: 48px;
        flex-shrink: 0;
      }
      .dmg-bar-bg {
        flex: 1;
        height: 5px;
        background: var(--dim);
        border-radius: 1px;
        overflow: hidden;
      }
      .dmg-bar-fill {
        height: 100%;
        border-radius: 1px;
        background: var(--green);
        transition:
          width 0.4s,
          background 0.3s;
      }
      .dmg-pct {
        font-size: 8px;
        font-family: var(--mono);
        color: var(--muted);
        min-width: 26px;
        text-align: right;
      }
      /* Record indicator */
      @keyframes recblink {
        0%,
        100% {
          opacity: 1;
        }
        50% {
          opacity: 0.3;
        }
      }
      .recording {
        background: rgba(255, 61, 90, 0.12) !important;
        border-color: rgba(255, 61, 90, 0.5) !important;
        color: var(--red) !important;
        animation: recblink 1s ease-in-out infinite;
      }
      /* Light mode */
      body.light {
        --bg: #f0f2f5;
        --panel: #ffffff;
        --panel2: #f7f8fa;
        --border: #d8dde6;
        --border2: #c8cdd8;
        --text: #1a2035;
        --muted: #7a8299;
        --dim: #e8eaf0;
      }
      body.light .topbar,
      body.light .sidebar,
      body.light .panel-hdr,
      body.light .tab-row,
      body.light .statusbar {
        background: #ffffff;
        border-color: #d8dde6;
      }
      body.light .chart-row,
      body.light .stream-row {
        background: #f7f8fa;
      }
      body.light .st-row {
        border-bottom-color: #eaecf2;
      }
      body.light .st-row:hover {
        background: rgba(0, 0, 0, 0.03);
      }
      body.light .st-row.focused {
        background: rgba(0, 100, 200, 0.05);
      }
      body.light .connect-card {
        background: #ffffff;
        border-color: #c8cdd8;
      }
      body.light .connect-input {
        background: #f7f8fa;
        border-color: #c8cdd8;
        color: #1a2035;
      }
      body.light #damage-panel {
        border-right-color: #d8dde6;
      }
      body.light #damage-svg rect {
        fill: #e8eaf0;
        stroke: #c8cdd8;
      }
      body.light .sb2 {
        color: #7a8299;
      }
      body.light .sb2 span {
        color: #1a2035;
      }
