:root {
    --nmbs-bg: #0b61b3;
    --nmbs-header: #063a6f;
    --nmbs-yellow: #ffd200;
    --nmbs-orange: #f5a623;
    --nmbs-red: #E30613;
    --white: #ffffff;
    --gray-text: #d6e7ff;
    --nmbs-icon-bg: rgba(255,255,255,0.06);
    --nmbs-line: rgba(255,255,255,0.12);
    --bp-large: 1200px;
    --bp-medium: 900px;
    --bp-small: 600px;
    --bp-xsmall: 430px;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: var(--nmbs-bg);
    font-family: 'Roboto Condensed', 'Segoe UI', Roboto, sans-serif;
    color: var(--white);
    overflow: hidden;
    height: 100dvh;
}

.screen {
    display: flex;
    flex-direction: column;
    height: 100dvh;
    overflow: hidden;
}

.header {
    background: linear-gradient(180deg, var(--nmbs-header), #0a4f86);
    height: 78px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 28px;
    font-weight: 900;
    font-size: 22px;
}

.header-left {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

#station-heading {
    font-size: 34px;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: var(--white);
}

#station-name {
    font-size: 14px;
    color: var(--white);
    opacity: 0.9;
    text-transform: uppercase;
    font-weight: 700;
    margin-top: -6px;
}

.header-right #live-clock {
    background: var(--nmbs-icon-bg);
    padding: 6px 12px;
    border-radius: 6px;
    font-weight: 900;
    font-size: 20px;
    border: 1px solid rgba(255,255,255,0.06);
}

#board {
    flex-grow: 1;
    overflow: hidden;
    padding-bottom: 16px;
    padding-left: 8px;
    padding-right: 8px;
    padding-top: 6px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.screen.has-disturbance #board {
    padding-bottom: 176px;
}

.row {
    display: grid;
    grid-template-columns: 100px 120px minmax(180px,1.6fr) minmax(120px,1.1fr) 160px 110px 72px;
    padding: 12px 18px;
    border: 1px solid rgba(255,255,255,0.06);
    border-top: 6px solid rgba(255,255,255,0.06);
    border-radius: 6px;
    background: linear-gradient(90deg, rgba(255,255,255,0.03), rgba(255,255,255,0.01));
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.28);
    align-items: center;
    gap: 12px;
}

.col-time {
    font-size: 28px;
    font-weight: bold;
    letter-spacing: 0.5px;
}

/* fluid font scaling for key elements */
.dest-main { font-size: clamp(16px, 2.4vw, 28px); }
.col-time { font-size: clamp(14px, 2.6vw, 28px); }
.col-track { font-size: clamp(18px, 3.4vw, 34px); }

.canceled-row .col-time,
.canceled-row .dest-main {
    text-decoration: line-through;
    text-decoration-thickness: 3px;
    text-decoration-color: var(--white);
    opacity: 0.6;
}

.status-box {
    width: 100px;
    padding: 6px 8px;
    border-radius: 6px;
    font-weight: 900;
    font-size: 16px;
    text-align: center;
    box-shadow: inset 0 -2px 0 rgba(0,0,0,0.15);
}

.status-box.delay {
    background: var(--nmbs-red);
    color: white;
}

.status-box.platform {
    background: var(--nmbs-yellow);
    color: var(--nmbs-bg);
    animation: blink 1s infinite;
    font-size: 13px;
}

@keyframes blink {
    50% {
        opacity: 0.3;
    }
}

.dest-main {
    font-size: 28px;
    font-weight: bold;
    text-transform: uppercase;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.dest-ticker {
    height: 1.5em;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.dest-subline {
    font-size: 13px;
    font-weight: 700;
    color: var(--gray-text);
    text-transform: uppercase;
    line-height: 1.05;
    margin-top: 2px;
}

.ticker-item {
    font-size: 16px;
    font-weight: bold;
}

.text-warning {
    color: var(--nmbs-yellow) !important;
}

.text-gray,
.text-via {
    color: var(--gray-text);
}

.train-type-main {
    font-size: 20px;
    font-weight: 900;
    white-space: nowrap;
}

.mat-details {
    font-size: 13px;
    color: var(--gray-text);
    font-weight: bold;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.col-icons {
    display: flex;
    gap: 8px;
    align-items: center;
}

.icon-wrap {
    width: 34px;
    height: 34px;
    background: var(--nmbs-icon-bg);
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.icon-wrap svg {
    width: 20px;
    height: 20px;
}

.icon-wrap.unavailable {
    opacity: 0.2;
}

.occupancy-wrap {
    display: flex;
    gap: 4px;
}

.occupancy-wrap svg {
    width: 18px;
    height: 18px;
}

.occupancy-wrap.low .fill {
    color: #00ff88;
}

.occupancy-wrap.medium .fill {
    color: var(--nmbs-yellow);
}

.occupancy-wrap.high .fill {
    color: var(--nmbs-red);
}

.occupancy-wrap .empty {
    opacity: 0.2;
}

.col-seats {
    display: flex;
    gap: 8px;
    font-size: 16px;
    align-items: center;
}

.s-label-col {
    display: flex;
    flex-direction: column;
    color: var(--nmbs-yellow);
    font-weight: bold;
    text-align: right;
}

.s-value-col {
    display: flex;
    flex-direction: column;
    font-weight: bold;
    text-align: right;
    min-width: 40px;
}

.col-track {
    font-size: 34px;
    font-weight: bold;
    text-align: right;
    line-height: 1;
}

.track-mobile-meta {
    display: none;
    align-items: center;
    gap: 3px;
    margin-right: 6px;
}

.track-number {
    display: inline-block;
}

/* Compact helpers: hide less important columns on very small screens */
.compact .col-icons,
.compact .col-seats {
    display: none;
}

.compact .col-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

/* Emphasize time and destination on small screens */
.compact .col-time { font-size: 20px; }
.compact .dest-main { font-size: 18px; }
.compact .col-track { font-size: 26px; }

/* Desktop -> Mobile adjustments */
@media (max-width: 900px) {
    .header { height: 62px; padding: 6px 12px; }
    #station-heading { font-size: 20px; }
    #station-name { font-size: 12px; }
    .row { grid-template-columns: 72px 86px 1fr 0.9fr 110px 82px 52px; padding: 8px; gap: 8px; }
    .col-time { font-size: clamp(14px, 2.2vw, 20px); }
    .dest-main { font-size: clamp(14px, 2.2vw, 18px); }
    .col-track { font-size: clamp(16px, 3vw, 24px); }

    #board {
        padding-bottom: 12px;
    }

    .screen.has-disturbance #board {
        padding-bottom: 164px;
    }

    #disturbance-container {
        height: auto;
        min-height: 140px;
        max-height: 38dvh;
    }
}

@media (max-width: 430px) {
    .row { grid-template-columns: 64px 72px 1fr 0.9fr 96px 64px 44px; padding: 6px; gap: 6px; }
    .col-time { font-size: 16px; }
    .dest-main { font-size: 16px; }
    .train-type-main { font-size: 12px; }
    .mat-details { font-size: 10px; }
    .status-box { width: 64px; font-size: 12px; }

    #board {
        padding-bottom: 12px;
    }

    .screen.has-disturbance #board {
        padding-bottom: 180px;
    }

    #disturbance-container {
        height: auto;
        min-height: 156px;
        max-height: 46dvh;
    }
}

/* When .screen has .compact, show a condensed 3-column layout (time, destination, track) */
.screen.compact .row {
    grid-template-columns: 64px 1fr 52px;
    padding: 6px 8px;
    gap: 6px;
}
.screen.compact .col-status,
.screen.compact .col-info,
.screen.compact .col-icons,
.screen.compact .col-seats {
    display: none;
}
.screen.compact .col-dest {
    grid-column: 2 / 3;
}
.screen.compact .col-track {
    grid-column: 3 / 4;
}

/* Slight typographic tweaks for condensed display */
.dest-main { letter-spacing: 0.6px; }
.col-time { letter-spacing: 1px; }

.track-warning {
    color: var(--nmbs-yellow);
}

#disturbance-container {
    position: fixed;
    bottom: 16px;
    left: 16px;
    right: 16px;
    background: transparent;
    color: var(--white);
    display: flex;
    height: 140px;
    margin: 0;
    border-radius: 8px;
    z-index: 1000;
    overflow: visible;
}

.dist-container-inner {
    display: flex;
    width: 100%;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 6px 18px rgba(0,0,0,0.28);
}

.dist-left {
    background: var(--nmbs-yellow);
    color: #031427;
    padding: 18px 22px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 8px;
    min-width: 320px;
}

.dist-left.red { background: var(--nmbs-red); color: #ffffff; }
.dist-left.red .dist-mini-icon { color: #ffffff; }
.dist-left.orange { background: var(--nmbs-orange); color: #031427; }
.dist-left.orange .dist-mini-icon { color: #031427; }

.dist-left .dist-title-wrap { color: #031427; font-size: 20px; font-weight:900; }

.dist-right { flex: 1; background: #ffffff; padding: 12px 18px; color: #031427; }

.dist-right #dist-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(0,0,0,0.06);
    padding-bottom: 6px;
    margin-bottom: 6px;
}

.dist-right .dist-title-wrap {
    display: flex;
    align-items: center;
    gap: 10px;
    color: #031427;
    font-size: 16px;
    font-weight: 800;
    text-transform: uppercase;
}

.dist-mini-icon { width: 22px; height: 22px; color: #031427; }

#dist-desc {
    line-height: 1.2;
    font-weight: 700;
    color: #031427;
    flex-grow: 1;
    overflow: hidden;
    display: block;
}

#dist-page {
    background: rgba(0,0,0,0.04);
    color: #031427;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 900;
    border: 1px solid rgba(0,0,0,0.04);
}

@media (max-width: 900px) {
    .header {
        height: 56px;
        padding: 0 12px;
        font-size: 18px;
    }

    #board {
        padding-bottom: 132px;
        padding-left: 6px;
        padding-right: 6px;
        gap: 5px;
    }

    .row {
        grid-template-columns: 64px 80px 1.35fr 0.95fr 132px 82px 44px;
        padding: 7px 8px;
        gap: 8px;
        border-radius: 6px;
    }

    .col-time {
        font-size: 18px;
    }

    .status-box {
        width: 74px;
        padding: 5px 4px;
        font-size: 14px;
    }

    .status-box.platform {
        font-size: 9px;
    }

    .dest-main {
        font-size: 18px;
    }

    .dest-subline {
        font-size: 10px;
    }

    .ticker-item {
        font-size: 12px;
    }

    .train-type-main {
        font-size: 14px;
    }

    .mat-details {
        font-size: 10px;
    }

    .col-icons {
        gap: 5px;
    }

    .icon-wrap {
        width: 24px;
        height: 24px;
    }

    .icon-wrap svg {
        width: 14px;
        height: 14px;
    }

    .occupancy-wrap {
        gap: 2px;
    }

    .occupancy-wrap svg {
        width: 12px;
        height: 12px;
    }

    .col-seats {
        gap: 4px;
        font-size: 11px;
    }

    .s-value-col {
        min-width: 28px;
    }

    .col-track {
        font-size: 24px;
    }

    #disturbance-container {
        margin: 6px;
        border-radius: 6px;
    }

    .dist-body {
        padding: 8px 10px;
    }

    #dist-header {
        padding-bottom: 4px;
        margin-bottom: 4px;
    }

    .dist-title-wrap {
        gap: 6px;
        font-size: 13px;
    }

    .dist-mini-icon {
        width: 16px;
        height: 16px;
    }

    #dist-page {
        padding: 3px 8px;
        font-size: 10px;
    }

    #dist-desc {
        line-height: 1.25;
    }
}

@media (max-width: 430px) {
    .header {
        height: 52px;
        padding: 0 10px;
        font-size: 16px;
    }

    #station-name {
        max-width: 66%;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    #live-clock {
        font-size: 22px;
        letter-spacing: 0.5px;
    }

    #board {
        padding: 4px;
        gap: 4px;
    }

    .row {
        grid-template-columns: 50px 58px 1.4fr 0.95fr 84px 56px 30px;
        align-items: center;
        padding: 7px;
        gap: 6px;
        border-width: 1px;
        border-top-width: 3px;
        border-radius: 6px;
        box-shadow: 0 3px 10px rgba(0, 0, 0, 0.28);
    }

    .col-time {
        font-size: 16px;
        line-height: 1;
    }

    .col-status {
        min-width: 0;
    }

    .status-box {
        width: 100%;
        min-width: 54px;
        max-width: 58px;
        padding: 4px 2px;
        font-size: 9px;
        line-height: 1;
    }

    .status-box.platform {
        font-size: 6px;
    }

    .col-track {
        font-size: 22px;
    }

    .dest-main {
        font-size: 16px;
    }

    .dest-subline {
        font-size: 9px;
    }

    .dest-ticker {
        height: 1.2em;
    }

    .ticker-item {
        font-size: 10px;
    }

    .train-type-main {
        font-size: 12px;
        line-height: 1;
    }

    .mat-details {
        font-size: 9px;
        line-height: 1.1;
    }

    .col-icons {
        gap: 3px;
    }

    .icon-wrap {
        width: 19px;
        height: 19px;
        border-radius: 4px;
    }

    .icon-wrap svg {
        width: 11px;
        height: 11px;
    }

    .occupancy-wrap svg {
        width: 9px;
        height: 9px;
    }

    .col-seats {
        gap: 3px;
        font-size: 9px;
    }

    .s-value-col {
        min-width: 20px;
    }

    #disturbance-container {
        margin: 5px;
        border-radius: 6px;
    }

    .dist-body {
        padding: 7px 9px;
    }

    .dist-title-wrap {
        font-size: 12px;
    }

    .dist-mini-icon {
        width: 14px;
        height: 14px;
    }

    #dist-page {
        padding: 2px 6px;
        font-size: 9px;
    }

    #dist-desc {
        line-height: 1.2;
    }
}

@media (max-width: 600px) {
    /* tablet -> small phone: simplify the grid and hide non-essential columns */
    .row {
        grid-template-columns: 64px 1fr 56px;
        padding: 8px 10px;
        gap: 8px;
        align-items: center;
    }
    .row > .col-status,
    .row > .col-info,
    .row > .col-icons,
    .row > .col-seats {
        display: none;
    }
    .row > .col-time { grid-column: 1 / 2; }
    .row > .col-dest { grid-column: 2 / 3; }
    .row > .col-track { grid-column: 3 / 4; }

    /* disturbance: stack left (yellow) above right (white) */
    .dist-container-inner {
        flex-direction: column;
        height: 100%;
    }
    .dist-left {
        min-width: 100%;
        width: 100%;
        padding: 8px 10px 6px;
        gap: 2px;
    }
    .dist-left .dist-title-wrap {
        font-size: 15px;
        gap: 6px;
    }
    .dist-left .dist-title-wrap #dist-title {
        font-size: 1.05em;
    }
    .dist-right {
        width: 100%;
        padding: 7px 10px 8px;
        display: flex;
        flex-direction: column;
        min-height: 0;
    }
    .dist-right #dist-header {
        align-items: flex-start;
        gap: 4px;
        flex-wrap: wrap;
    }
    .dist-right .dist-title-wrap {
        font-size: 9px;
        gap: 6px;
    }
    #dist-desc {
        font-size: 8px;
        line-height: 1.15;
        overflow-y: auto;
        overflow-x: hidden;
        max-height: 14dvh;
        padding-right: 2px;
    }
    #dist-page {
        padding: 2px 6px;
        font-size: 7px;
        flex: 0 0 auto;
    }
    #disturbance-container {
        left: 8px;
        right: 8px;
        bottom: 8px;
        height: auto;
        min-height: 112px;
        max-height: 34dvh;
    }

    .occupancy-label { display: none; }
    .track-mobile-meta { display: inline-flex; }
}

@media (max-width: 320px) {
    /* very small phones: reduce paddings and font sizes */
    .header { padding: 6px 10px; }
    .dist-left { padding: 7px 9px 5px; }
    .dist-left .dist-title-wrap { font-size: 14px; }
    .dist-left .dist-title-wrap #dist-title { font-size: 1.05em; }
    .dist-right { padding: 6px 9px 8px; }
    .dist-right .dist-title-wrap { font-size: 8px; }
    #dist-desc { font-size: 7px; max-height: 16dvh; line-height: 1.15; }
    #dist-page { padding: 2px 5px; font-size: 7px; }
    #disturbance-container { min-height: 104px; max-height: 30dvh; }
    .row { padding: 6px 8px; gap: 6px; }
}

/* Ensure station name fully visible on small screens */
@media (max-width: 600px) {
    .header {
        flex-direction: row;
        align-items: flex-start;
        gap: 8px;
        height: auto;
        padding: 7px 10px;
    }
    .header-left { flex: 1 1 auto; min-width: 0; }
    .header-right { flex: 0 0 auto; align-self: flex-start; }
    #station-heading { font-size: 18px; }
    #station-name { font-size: 14px; white-space: normal; max-width: 100%; opacity: 1; line-height: 1.05; }
    .header-right #live-clock { font-size: 16px; }
}

/* Occupancy label: visible on compact (mobile) and small as a badge */
.occupancy-label {
    display: none;
    margin-left: 8px;
    padding: 2px 6px;
    border-radius: 12px;
    font-weight: 900;
    font-size: 12px;
    color: var(--white);
    background: rgba(0,0,0,0.18);
}
.occupancy-label.low { background: rgba(0,200,120,0.9); color: #032a1f; }
.occupancy-label.medium { background: var(--nmbs-yellow); color: #031427; }
.occupancy-label.high { background: var(--nmbs-red); color: #fff; }

/* show occupancy label in compact/mobile */
.screen.compact .occupancy-label { display: none; }
@media (max-width: 600px) {
    .occupancy-label { display: none; }
    .track-mobile-meta { display: inline-flex; }
}

.screen.compact .dest-main { white-space: normal; display: inline-block; }

.screen.compact .col-track {
    display: inline-flex;
    align-items: center;
    justify-content: flex-end;
    gap: 4px;
}

.screen.compact .track-number {
    font-size: 22px;
    line-height: 1;
}

.track-mobile-meta .occupancy-wrap { gap: 2px; }
.track-mobile-meta .occupancy-wrap svg { width: 10px; height: 10px; }