:root {
    --bg: #0d0d0d;
    --surface: #1a1a1a;
    --surface-2: #222222;
    --border: #2a2a2a;
    --text: #ffffff;
    --text-dim: #b8b8b8;
    --orange: #ff630f;
    --row-gap: 0.5vh;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    height: 100%;
    width: 100%;
    overflow: hidden;
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-weight: 500;
    -webkit-font-smoothing: antialiased;
}

.kiosk {
    height: 100vh;
    width: 100vw;
    display: grid;
    grid-template-rows: minmax(56px, 9vh) 1fr minmax(40px, 6vh);
    padding: 1vh 1.5vw;
    gap: 0.8vh;
}

/* ---------- TOPBAR ---------- */
.topbar {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    padding: 0 0.5vw;
    border-bottom: 2px solid var(--border);
    container-type: size;
    container-name: topbar;
}

.brand { display: flex; justify-content: flex-start; align-items: center; }
.provider { display: flex; justify-content: flex-end; align-items: center; }

.brand-logo { height: 75cqh; width: auto; }
.dvb-logo {
    height: 65cqh;
    width: auto;
}

.title {
    font-size: clamp(0.9rem, 35cqh, 2.4rem);
    font-weight: 700;
    letter-spacing: 0.25em;
    color: var(--text);
    white-space: nowrap;
}

.title::after {
    content: "";
    display: block;
    height: 3px;
    width: 30%;
    background: var(--orange);
    margin: 0.3vh auto 0;
}

/* ---------- DEPARTURES ---------- */
.departures {
    display: flex;
    flex-direction: column;
    gap: var(--row-gap);
    overflow: hidden;
    min-height: 0;
}

.row {
    flex: 1 1 0;
    min-height: 0;
    display: grid;
    grid-template-columns: minmax(60px, 9%) minmax(70px, 13%) 1fr minmax(340px, 36%) minmax(110px, 16%);
    align-items: center;
    background: var(--surface);
    border-left: 0.5cqh solid var(--orange);
    border-radius: 6px;
    padding: 0 1.5vw;
    gap: 1.5vw;
    overflow: hidden;
    container-type: size;
    container-name: row;
}

.row:nth-child(even) { background: var(--surface-2); }

.row.leaving { border-left-color: #ff3030; }
.row.leaving .mins-value { color: #ff5050; }

.row.cancelled { border-left-color: #ff3030; }
.row.cancelled .cell-dest,
.row.cancelled .cell-line {
    color: #ff5050;
    text-decoration: line-through;
    text-decoration-thickness: 0.08em;
}

.mins-cancelled {
    font-size: clamp(0.9rem, 38cqh, 4.5rem);
    font-weight: 800;
    color: #ff5050;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    white-space: nowrap;
}

.cell-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
}

.cell-icon img {
    max-height: 70cqh;
    max-width: 100%;
    width: auto;
    object-fit: contain;
}

.cell-line {
    font-size: clamp(1rem, 60cqh, 8rem);
    font-weight: 800;
    color: var(--orange);
    line-height: 1;
    letter-spacing: 0.02em;
    white-space: nowrap;
}

.cell-dest {
    font-size: clamp(0.9rem, 42cqh, 6rem);
    font-weight: 600;
    color: var(--text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    line-height: 1.05;
}

.cell-station {
    display: flex;
    align-items: baseline;
    gap: 0.4em;
    color: var(--text-dim);
    overflow: hidden;
    min-width: 0;
}

.cell-station .station-prefix {
    font-size: clamp(0.6rem, 22cqh, 2.6rem);
    font-weight: 500;
    text-transform: lowercase;
    letter-spacing: 0.05em;
    flex-shrink: 0;
}

.cell-station .station-name {
    font-size: clamp(0.9rem, 30cqh, 3.6rem);
    font-weight: 600;
    color: var(--text);
    line-height: 1.05;
    letter-spacing: 0.02em;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
}

.row.cancelled .cell-station .station-name { color: #ff5050; opacity: 0.85; }

.cell-time {
    display: flex;
    align-items: baseline;
    justify-content: flex-end;
    gap: 0.3vw;
    white-space: nowrap;
}

.mins-value {
    font-size: clamp(1.1rem, 65cqh, 8.5rem);
    font-weight: 800;
    color: var(--text);
    line-height: 1;
    font-variant-numeric: tabular-nums;
}

.mins-unit {
    font-size: clamp(0.7rem, 22cqh, 2.8rem);
    font-weight: 600;
    color: var(--text-dim);
    text-transform: lowercase;
}

.mins-now {
    font-size: clamp(1rem, 42cqh, 5rem);
    font-weight: 800;
    color: var(--orange);
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

/* ---------- BOTTOMBAR ---------- */
.bottombar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 0.5vw;
    border-top: 2px solid var(--border);
    container-type: size;
    container-name: bottom;
}

.status {
    font-size: clamp(0.7rem, 35cqh, 1.4rem);
    color: #4ade80;
    transition: color 0.3s;
}

.status.error { color: #ff5050; }

.clock {
    font-size: clamp(1.2rem, 80cqh, 4rem);
    font-weight: 700;
    color: var(--text);
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.05em;
    line-height: 1;
}

.clock .seconds {
    color: var(--orange);
    font-size: 0.75em;
}

/* ---------- EMPTY STATE ---------- */
.empty {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--text-dim);
    font-size: clamp(1.2rem, 5vh, 4vh);
    font-weight: 600;
}

/* ---------- NARROW SCREENS: hide station column ---------- */
@container row (max-width: 600px) {
    .cell-station { display: none; }
}

/* ---------- VERY NARROW TOPBAR: hide center title ---------- */
@container topbar (max-width: 500px) {
    .title { display: none; }
}

/* ---------- MOBILE (phones) -----------------------------------------
   Kiosk display (large landscape screen) keeps its sizing — these rules
   only fire below 720px viewport width, which catches portrait phones
   and small landscape phones. Goals: shrink fonts, drop the station
   column to free width, tighten paddings. */
@media (max-width: 720px) {
    .kiosk {
        padding: 0.6vh 2vw;
        gap: 0.6vh;
    }

    .row {
        /* 4-column layout on mobile: icon | line | dest | time */
        grid-template-columns: minmax(34px, 13%) minmax(46px, 16%) 1fr minmax(72px, 24%);
        padding: 0 2.5vw;
        gap: 2.5vw;
    }

    .cell-station { display: none; }

    .cell-line     { font-size: clamp(0.9rem, 52cqh, 2.2rem); }
    .cell-dest     { font-size: clamp(0.85rem, 38cqh, 1.6rem); }
    .mins-value    { font-size: clamp(1rem, 58cqh, 2.4rem); }
    .mins-unit     { font-size: clamp(0.6rem, 20cqh, 0.95rem); }
    .mins-now      { font-size: clamp(0.9rem, 38cqh, 1.6rem); }
    .mins-cancelled{ font-size: clamp(0.8rem, 34cqh, 1.4rem); }

    .title { font-size: clamp(0.8rem, 32cqh, 1.1rem); letter-spacing: 0.15em; }
    .clock { font-size: clamp(1rem, 70cqh, 1.8rem); }

    /* Keep brand left / DVB right on phones — hide title to give them room. */
    .topbar { grid-template-columns: auto 1fr auto; }
    .brand    { justify-self: start; }
    .provider { justify-self: end; }
    .title    { display: none; }
}
