:root {
      --panel-bg: rgba(18, 18, 18, 0.84);
      --panel-border: rgba(255,255,255,0.08);
      --text-main: #ffffff;
      --text-sub: #d1d5db;
      --accent: #38bdf8;
      --accent-2: #22c55e;
      --danger: #ef4444;
      --warning: #f59e0b;
      --shadow: 0 10px 28px rgba(0,0,0,0.32);
      --pin-blue: #1ea0ff;
    }

    html, body {
      margin: 0;
      padding: 0;
      width: 100%;
      height: 100%;
      overflow: hidden;
      font-family: Arial, sans-serif;
      background: #111827;
      overscroll-behavior: none;
      -webkit-tap-highlight-color: transparent;
    }

    #map {
      width: 100%;
      height: 100%;
      touch-action: pan-x pan-y pinch-zoom;
    }

    .floating-panel {
      position: absolute;
      z-index: 1000;
      background: var(--panel-bg);
      color: var(--text-main);
      border: 1px solid var(--panel-border);
      border-radius: 16px;
      box-shadow: var(--shadow);
      backdrop-filter: blur(8px);
      user-select: none;
    }

    .left-panel {
      top: 14px;
      left: 14px;
      width: 360px;
      padding: 14px;
      max-height: calc(100vh - 28px);
      overflow: auto;
    }

    .left-panel h1 {
      margin: 0 0 10px 0;
      font-size: 18px;
    }

    .hint {
      font-size: 13px;
      line-height: 1.5;
      color: var(--text-sub);
      margin-bottom: 4px;
    }

    .section-title {
      margin-top: 14px;
      padding-top: 12px;
      border-top: 1px solid rgba(255,255,255,0.08);
      font-size: 13px;
      font-weight: 700;
      color: #fff;
    }

    .control-group {
      display: grid;
      grid-template-columns: 1fr 1fr;
      gap: 8px;
      margin-top: 10px;
    }

    .span-2 {
      grid-column: 1 / -1;
    }

    .btn {
      border: 0;
      border-radius: 12px;
      padding: 10px 12px;
      font-size: 13px;
      font-weight: bold;
      cursor: pointer;
      transition: transform 0.12s ease, opacity 0.12s ease, background 0.12s ease;
      touch-action: manipulation;
    }

    .btn:hover { transform: translateY(-1px); }
    .btn:active { transform: translateY(0); }
    .btn:disabled {
      cursor: not-allowed;
      opacity: 0.45;
      transform: none;
    }

    .btn-primary { background: var(--accent); color: #062033; }
    .btn-success { background: var(--accent-2); color: #052e16; }
    .btn-dark { background: #374151; color: #fff; }
    .btn-danger { background: var(--danger); color: #fff; }
    .btn-warning { background: var(--warning); color: #3f2500; }

    .status-grid {
      margin-top: 10px;
      display: grid;
      grid-template-columns: 1fr 1fr;
      gap: 6px 10px;
      font-size: 13px;
      color: var(--text-sub);
    }

    .status-grid strong {
      color: #fff;
      font-weight: 700;
    }

    .gauge-wrap {
      position: absolute;
      top: 10px;
      right: 10px;
      z-index: 1000;
      pointer-events: none;
      background: transparent;
      border: 0;
      box-shadow: none;
    }

    #speedGauge {
      width: 190px;
      height: 190px;
      display: block;
      filter: drop-shadow(0 8px 18px rgba(0,0,0,0.26));
    }

    .hud-info-panel {
      top: 192px;
      right: 14px;
      width: 220px;
      padding: 12px;
      text-align: left;
      background: rgba(18, 18, 18, 0.5);
    }

    .hud-row {
      display: flex;
      justify-content: space-between;
      gap: 8px;
      font-size: 13px;
      color: var(--text-sub);
      margin-top: 6px;
    }

    .hud-row:first-child {
      margin-top: 0;
    }

    .hud-row strong {
      color: var(--text-main);
      font-weight: 700;
    }

    .turn-hint-box {
      margin-top: 10px;
      padding: 10px 12px;
      border-radius: 12px;
      border: 1px solid rgba(255,255,255,0.12);
      text-align: left;
      transition: background 0.12s ease, border-color 0.12s ease;
    }

    .turn-hint-box.straight {
      background: rgba(56, 189, 248, 0.12);
      border-color: rgba(56, 189, 248, 0.26);
    }

    .turn-hint-box.left,
    .turn-hint-box.right {
      background: rgba(250, 204, 21, 0.12);
      border-color: rgba(250, 204, 21, 0.28);
    }

    .turn-hint-label {
      font-size: 11px;
      color: #cbd5e1;
      letter-spacing: 0.02em;
    }

    .turn-hint-value {
      margin-top: 4px;
      font-size: 15px;
      font-weight: 700;
      color: #fff;
      line-height: 1.25;
    }

    .mini-wrap {
      position: absolute;
      right: 14px;
      bottom: 14px;
      z-index: 1000;
      width: 220px;
      background: var(--panel-bg);
      border: 1px solid var(--panel-border);
      border-radius: 16px;
      box-shadow: var(--shadow);
      overflow: hidden;
      backdrop-filter: blur(8px);
    }

    .mini-title {
      padding: 10px 12px;
      color: #fff;
      font-size: 13px;
      font-weight: bold;
      border-bottom: 1px solid rgba(255,255,255,0.08);
      background: rgba(255,255,255,0.03);
    }

    #minimap {
      width: 100%;
      height: 168px;
    }

    .toast {
      position: absolute;
      left: 50%;
      bottom: 18px;
      transform: translateX(-50%);
      z-index: 1000;
      background: rgba(17, 24, 39, 0.86);
      color: #fff;
      padding: 10px 14px;
      border-radius: 999px;
      font-size: 13px;
      box-shadow: var(--shadow);
      transition: opacity 0.2s ease;
      pointer-events: none;
      max-width: calc(100vw - 40px);
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
    }

    .fixed-car {
      position: absolute;
      left: 50%;
      top: 72%;
      width: 42px;
      height: 62px;
      transform: translate(-50%, -50%);
      transform-origin: center center;
      z-index: 950;
      pointer-events: none;
      filter: drop-shadow(0 10px 14px rgba(0,0,0,0.28));
      opacity: 0;
      transition: opacity 0.18s ease;
    }

    .fixed-car.active {
      opacity: 1;
    }

    .car-wrap {
      width: 42px;
      height: 62px;
      position: relative;
      transform-origin: center center;
    }

    .pin-tip {
      position: absolute;
      top: 0;
      left: 50%;
      transform: translateX(-50%);
      width: 18px;
      height: 16px;
      background: var(--pin-blue);
      clip-path: polygon(50% 0%, 0% 100%, 100% 100%);
      border-radius: 3px 3px 5px 5px;
    }

    .pin-body {
      position: absolute;
      left: 50%;
      top: 14px;
      transform: translateX(-50%);
      width: 28px;
      height: 28px;
      border-radius: 50%;
      background: var(--pin-blue);
    }

    .pin-shadow {
      position: absolute;
      left: 50%;
      bottom: 8px;
      transform: translateX(-50%);
      width: 20px;
      height: 7px;
      border-radius: 999px;
      background: rgba(0,0,0,0.18);
      filter: blur(2px);
    }

    .legend {
      margin-top: 10px;
      display: flex;
      flex-wrap: wrap;
      gap: 8px 12px;
      font-size: 12px;
      color: var(--text-sub);
    }

    .legend-item {
      display: inline-flex;
      align-items: center;
      gap: 6px;
    }

    .legend-line {
      width: 18px;
      height: 0;
      border-top: 4px solid #fff;
      border-radius: 999px;
    }

    .lg-red { border-color: #ef4444; }
    .lg-green { border-color: #22c55e; }
    .lg-cyan { border-color: #60a5fa; }

    .record-controls {
      margin-top: 10px;
      display: flex;
      align-items: flex-end;
      gap: 14px;
      flex-wrap: wrap;
    }

    .icon-stack {
      display: flex;
      flex-direction: column;
      align-items: center;
      gap: 6px;
      min-width: 74px;
    }

    .round-icon-btn {
      width: 64px;
      height: 64px;
      border-radius: 50%;
      border: 2px solid rgba(255,255,255,0.18);
      background: linear-gradient(180deg, #2b2b2b 0%, #151515 100%);
      box-shadow: inset 0 2px 8px rgba(255,255,255,0.08), 0 4px 14px rgba(0,0,0,0.28);
      display: flex;
      align-items: center;
      justify-content: center;
      cursor: pointer;
      transition: transform 0.12s ease, opacity 0.12s ease, border-color 0.12s ease;
      padding: 0;
      touch-action: manipulation;
    }

    .round-icon-btn:hover { transform: translateY(-1px); }
    .round-icon-btn:active { transform: translateY(0); }
    .round-icon-btn:disabled {
      opacity: 0.45;
      cursor: not-allowed;
      transform: none;
    }

    .round-icon-btn.active {
      border-color: rgba(255,255,255,0.32);
      box-shadow: inset 0 2px 8px rgba(255,255,255,0.12), 0 0 0 2px rgba(56, 189, 248, 0.16), 0 6px 16px rgba(0,0,0,0.32);
    }

    .icon-label {
      font-size: 12px;
      color: var(--text-sub);
      text-align: center;
      line-height: 1.2;
    }

    .icon-shape {
      display: inline-block;
      position: relative;
    }

    .play-shape {
      width: 0;
      height: 0;
      border-top: 14px solid transparent;
      border-bottom: 14px solid transparent;
      border-left: 22px solid #ffffff;
      margin-left: 5px;
    }

    .pause-shape {
      width: 24px;
      height: 28px;
    }

    .pause-shape::before,
    .pause-shape::after {
      content: "";
      position: absolute;
      top: 0;
      width: 8px;
      height: 28px;
      background: #ffffff;
      border-radius: 2px;
    }

    .pause-shape::before { left: 0; }
    .pause-shape::after { right: 0; }

    .stop-shape {
      width: 20px;
      height: 20px;
      background: #ffffff;
      border-radius: 3px;
    }

    .record-side-actions {
      display: flex;
      flex-direction: column;
      gap: 8px;
      min-width: 100px;
    }

    .confirm-overlay {
      position: absolute;
      inset: 0;
      z-index: 2000;
      background: rgba(0,0,0,0.46);
      display: none;
      align-items: center;
      justify-content: center;
      padding: 20px;
      backdrop-filter: blur(3px);
    }

    .confirm-overlay.show {
      display: flex;
    }

    .confirm-dialog {
      width: min(360px, calc(100vw - 40px));
      background: rgba(20,20,20,0.95);
      border: 1px solid rgba(255,255,255,0.08);
      border-radius: 18px;
      box-shadow: 0 16px 42px rgba(0,0,0,0.35);
      padding: 18px;
      color: #fff;
    }

    .confirm-title {
      font-size: 16px;
      font-weight: 700;
      margin-bottom: 8px;
    }

    .confirm-message {
      font-size: 14px;
      line-height: 1.55;
      color: var(--text-sub);
    }

    .confirm-actions {
      margin-top: 16px;
      display: flex;
      justify-content: flex-end;
      gap: 8px;
    }

    .mobile-fab {
      position: absolute;
      top: calc(env(safe-area-inset-top, 0px) + 10px);
      right: 10px;
      z-index: 1300;
      width: 48px;
      height: 48px;
      border: 0;
      border-radius: 14px;
      background: rgba(17, 24, 39, 0.88);
      color: #fff;
      font-size: 20px;
      font-weight: 700;
      display: none;
      align-items: center;
      justify-content: center;
      box-shadow: var(--shadow);
      backdrop-filter: blur(8px);
      touch-action: manipulation;
    }

    .leaflet-container {
      background: #dbeafe;
    }

    .locate-control a {
      width: 34px;
      height: 34px;
      display: flex;
      align-items: center;
      justify-content: center;
      background: #ffffff;
      text-decoration: none;
    }

    .locate-control a:hover {
      background: #f8fafc;
    }

    .locate-control a svg {
      display: block;
    }

    input[type="file"] { display: none; }

    @media (max-width: 900px) {
      .mobile-fab {
        display: flex;
      }

      .left-panel {
        top: calc(env(safe-area-inset-top, 0px) + 8px);
        left: 8px;
        right: 64px;
        width: auto;
        max-width: none;
        max-height: min(52vh, 460px);
        padding: 12px;
        border-radius: 18px;
      }

      .left-panel.collapsed-mobile {
        transform: translateY(calc(-100% - 12px));
        opacity: 0.2;
        pointer-events: none;
      }

      .left-panel h1 {
        font-size: 16px;
      }

      .hint,
      .status-grid,
      .icon-label,
      .legend {
        font-size: 12px;
      }

      .btn {
        min-height: 46px;
        font-size: 14px;
      }

      .gauge-wrap {
        top: calc(env(safe-area-inset-top, 0px) + 8px);
        right: 6px;
      }

      #speedGauge {
        width: 128px;
        height: 128px;
      }

      .hud-info-panel {
        top: calc(env(safe-area-inset-top, 0px) + 130px);
        right: 8px;
        width: 150px;
        padding: 10px;
      }

      .hud-row {
        font-size: 12px;
      }

      .turn-hint-value {
        font-size: 13px;
      }

      .mini-wrap {
        right: 8px;
        bottom: calc(env(safe-area-inset-bottom, 0px) + 8px);
        width: 152px;
        border-radius: 14px;
      }

      .mini-title {
        padding: 8px 10px;
        font-size: 12px;
      }

      #minimap {
        height: 112px;
      }

      .toast {
        bottom: calc(env(safe-area-inset-bottom, 0px) + 12px);
        max-width: calc(100vw - 24px);
        font-size: 12px;
        padding: 10px 12px;
      }

      .fixed-car {
        top: 63%;
        width: 36px;
        height: 54px;
      }

      .car-wrap {
        width: 36px;
        height: 54px;
      }

      .pin-tip {
        width: 16px;
        height: 14px;
      }

      .pin-body {
        top: 12px;
        width: 24px;
        height: 24px;
      }

      .round-icon-btn {
        width: 68px;
        height: 68px;
      }

      .record-controls {
        gap: 12px;
      }
    }

