:root {
    color-scheme: dark;
    --bg: #050505;
    --text: #f8fafc;
    --muted: #a1a1aa;
    --green: #22c55e;
    --amber: #f59e0b;
    --red: #ef4444;
    --unknown: #3f3f46;
}

* {
    box-sizing: border-box;
}

html,
body {
    width: 100%;
    min-height: 100%;
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body {
    min-height: 100dvh;
    overflow: hidden;
}

.screen {
    position: relative;
    min-height: 100dvh;
    padding: max(18px, env(safe-area-inset-top)) 22px max(18px, env(safe-area-inset-bottom));
    display: grid;
    grid-template-rows: auto 1fr;
    gap: 20px;
}

.summary {
    text-align: center;
}

.place {
    min-height: 1.5em;
    color: var(--text);
    font-size: clamp(15px, 3.8vw, 20px);
    line-height: 1.35;
}

.speed {
    margin-top: 12px;
    font-size: clamp(52px, 18vw, 96px);
    font-weight: 800;
    line-height: 1;
}

.intersection {
    margin-top: 14px;
    color: #e5e7eb;
    font-size: clamp(19px, 5vw, 30px);
    font-weight: 650;
    line-height: 1.25;
}

.drive-view {
    position: relative;
    min-height: 0;
    display: block;
}

.route-panel {
    position: absolute;
    z-index: 2;
    left: 0;
    top: 50%;
    width: min(30vw, 210px);
    max-height: 92%;
    min-height: 0;
    overflow: hidden;
    display: flex;
    align-items: center;
    transform: translateY(-50%);
}

.route-line {
    position: relative;
    width: 100%;
    display: grid;
    gap: 14px;
    padding-left: 8px;
}

.route-line::before {
    content: "";
    position: absolute;
    top: 12px;
    bottom: 12px;
    left: 16px;
    width: 3px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.22);
}

.route-item {
    position: relative;
    min-width: 0;
    display: grid;
    grid-template-columns: 19px minmax(0, 1fr);
    gap: 8px;
    align-items: center;
}

.route-dot {
    width: 19px;
    height: 19px;
    border: 3px solid #6b7280;
    border-radius: 50%;
    background: var(--bg);
    z-index: 1;
}

.route-item.active .route-dot {
    border-color: #ffffff;
    background: var(--green);
    box-shadow: 0 0 18px rgba(34, 197, 94, 0.65);
}

.route-text {
    min-width: 0;
    display: grid;
    gap: 2px;
}

.route-name {
    overflow: hidden;
    color: #e5e7eb;
    font-size: clamp(13px, 3.2vw, 16px);
    font-weight: 800;
    line-height: 1.2;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.route-distance {
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
}

.transport {
    margin: 16px auto 0;
    display: grid;
    justify-items: center;
    gap: 8px;
}

.transport-label {
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
}

.transport-options {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 6px;
    width: min(100%, 420px);
}

.transport-button {
    appearance: none;
    min-width: 0;
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 12px;
    padding: 10px 8px;
    background: rgba(255, 255, 255, 0.08);
    color: var(--muted);
    font-size: 14px;
    font-weight: 800;
}

.transport-button.active {
    border-color: rgba(255, 255, 255, 0.72);
    background: rgba(255, 255, 255, 0.18);
    color: var(--text);
}

.signal-wrap {
    width: 100%;
    height: 100%;
    min-height: 0;
    display: flex;
    justify-content: center;
    align-items: stretch;
}

.signal-bars {
    width: min(94vw, 680px);
    min-height: 300px;
    max-height: 560px;
    display: flex;
    justify-content: center;
    align-items: stretch;
    gap: clamp(12px, 4vw, 28px);
}

.signal-column {
    min-width: 72px;
    max-width: 160px;
    flex: 1 1 0;
    display: grid;
    grid-template-rows: auto 1fr;
    gap: 10px;
}

@media (max-width: 700px) {
    .drive-view {
        display: grid;
        grid-template-columns: minmax(0, 1fr) auto;
        gap: 12px;
        align-items: stretch;
    }

    .route-panel {
        position: static;
        width: auto;
        max-height: none;
        transform: none;
    }

    .signal-wrap {
        justify-content: flex-end;
    }

    .signal-bars {
        width: auto;
        gap: 10px;
    }

    .signal-column {
        min-width: 36px;
        max-width: 80px;
    }
}

.signal-label {
    min-height: 1.4em;
    color: var(--muted);
    text-align: center;
    font-size: clamp(15px, 3.8vw, 19px);
    font-weight: 750;
    line-height: 1.2;
}

.signal-column.green .signal-label {
    color: #86efac;
}

.signal-column.amber .signal-label {
    color: #fcd34d;
}

.signal-column.red .signal-label {
    color: #fca5a5;
}

.signal-bar {
    position: relative;
    width: 100%;
    height: 100%;
    border-radius: 24px;
    background: #18181b;
    overflow: hidden;
    box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.08), 0 28px 80px rgba(0, 0, 0, 0.42);
}

.segment {
    width: 100%;
}

.segment.green {
    background: var(--green);
}

.segment.amber {
    background: var(--amber);
}

.segment.red {
    background: var(--red);
}

.segment.unknown {
    background: var(--unknown);
}

.arrival-line {
    position: absolute;
    left: -24px;
    right: -24px;
    top: 36.36%;
    height: 8px;
    background: #ffffff;
    transform: translateY(-50%);
    box-shadow: 0 0 18px rgba(255, 255, 255, 0.45);
}

.status {
    position: absolute;
    left: 22px;
    bottom: max(18px, env(safe-area-inset-bottom));
    z-index: 3;
    max-width: min(72vw, 560px);
    color: var(--red);
    font-size: 13px;
    font-weight: 650;
    line-height: 1.35;
    white-space: pre-line;
}

.status[hidden] {
    display: none;
}

.about-button {
    position: absolute;
    left: 22px;
    bottom: calc(max(18px, env(safe-area-inset-bottom)) + 34px);
    z-index: 3;
    width: 34px;
    height: 34px;
    border: 1px solid rgba(255, 255, 255, 0.22);
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.08);
    color: #e5e7eb;
    font-size: 18px;
    font-weight: 800;
    transition: bottom 160ms ease;
}

.has-error-status .about-button {
    bottom: calc(max(18px, env(safe-area-inset-bottom)) + 64px);
}

.about-button:active {
    background: rgba(255, 255, 255, 0.16);
}

.modal {
    position: fixed;
    inset: 0;
    z-index: 20;
    display: grid;
    place-items: center;
    padding: 22px;
}

.modal[hidden] {
    display: none;
}

.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.68);
}

.modal-panel {
    position: relative;
    z-index: 1;
    width: min(100%, 420px);
    border: 1px solid rgba(255, 255, 255, 0.16);
    border-radius: 16px;
    background: #111113;
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.48);
}

.modal-header {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 12px;
    align-items: center;
    padding: 18px 18px 10px;
}

.modal-header h2 {
    margin: 0;
    color: var(--text);
    font-size: 20px;
    line-height: 1.25;
}

.modal-close {
    appearance: none;
    width: 34px;
    height: 34px;
    border: 1px solid rgba(255, 255, 255, 0.16);
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.08);
    color: var(--text);
    font-size: 22px;
    line-height: 1;
}

.modal-body {
    display: grid;
    gap: 12px;
    padding: 0 18px 20px;
}

.modal-body p {
    margin: 0;
    color: #d4d4d8;
    font-size: 14px;
    line-height: 1.55;
}
