/* The Traffico control room: asphalt, the game's yellow centre line, exit signs as the menu,
   a departure board, licence plates, traffic lights, kilometre stones. System fonts only (the
   CSP allows nothing external): DIN on macOS, a condensed sans elsewhere. */
:root {
  --asphalt: #1b1d20; --asphalt-2: #24272b; --asphalt-3: #2e3236; --kerb: #3b4045;
  --paint: #f2f0e8; --paint-dim: #a9aba5; --muted: #80858b;
  --yellow: #fabe14;           /* the game's centre line */
  --sign: #1f6b3d; --sign-ink: #ffffff;   /* motorway exit sign */
  --red: #e0443a; --amber: #ffb000; --green: #3ccf6e;
  --plate-blue: #1d4fa8;
  --sign-font: "DIN Alternate", "DIN Condensed", "Bahnschrift", "Arial Narrow", "Roboto Condensed", sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}
* { box-sizing: border-box; }
html { background: var(--asphalt); }
body {
  margin: 0; min-height: 100vh; color: var(--paint); font: 15px/1.45 -apple-system, system-ui, "Segoe UI", sans-serif;
  /* asphalt grain */
  background: var(--asphalt) radial-gradient(rgba(255,255,255,.035) 1px, transparent 1.2px) 0 0 / 5px 5px;
}
.hidden { display: none !important; }
.muted { color: var(--muted); }
code { font-family: var(--mono); font-size: .9em; color: var(--yellow); }
button { font: inherit; color: inherit; cursor: pointer; }
:focus-visible { outline: 3px solid var(--yellow); outline-offset: 2px; }

/* ---- Fields ------------------------------------------------------------------------- */
.field { display: block; margin: 0 0 14px; }
.field > span { display: block; font: 600 12px/1 var(--sign-font); letter-spacing: .12em; text-transform: uppercase; color: var(--paint-dim); margin-bottom: 6px; }
.field input, .field select, .field textarea {
  width: 100%; padding: 10px 12px; font: inherit; color: var(--paint);
  background: var(--asphalt); border: 0; border-bottom: 2px solid var(--kerb); border-radius: 4px 4px 0 0;
}
.field input:focus, .field select:focus, .field textarea:focus { outline: none; border-bottom-color: var(--yellow); background: #15171a; }
.field input[type=file] { padding: 8px; }
.go {
  display: inline-flex; align-items: center; gap: 10px; padding: 12px 22px; border: 0; border-radius: 6px;
  background: var(--yellow); color: #1b1d20; font: 700 16px/1 var(--sign-font); letter-spacing: .06em; text-transform: uppercase;
  box-shadow: 0 3px 0 #b88a00;
}
.go:hover { transform: translateY(-1px); box-shadow: 0 4px 0 #b88a00; }
.go:active { transform: translateY(2px); box-shadow: 0 1px 0 #b88a00; }
.go:disabled { opacity: .5; cursor: progress; }
.ghost { background: none; border: 1px dashed var(--kerb); border-radius: 6px; padding: 7px 12px; color: var(--paint-dim); }
.ghost:hover { border-color: var(--yellow); color: var(--paint); }

/* ---- Login: a road with a stop sign ------------------------------------------------- */
.gate { min-height: 100vh; display: grid; place-items: center; padding: 16px; position: relative; overflow: hidden; }
.gate-road { position: absolute; inset: 0 auto 0 50%; width: 220px; transform: translateX(-50%); background: var(--asphalt-2); border-left: 6px solid var(--paint); border-right: 6px solid var(--paint); opacity: .55; }
.gate-road span { position: absolute; inset: 0 auto 0 50%; width: 6px; margin-left: -3px;
  background: repeating-linear-gradient(to bottom, var(--yellow) 0 40px, transparent 40px 80px); animation: flow 1.6s linear infinite; }
@keyframes flow { to { background-position: 0 80px; } }
@media (prefers-reduced-motion: reduce) { .gate-road span { animation: none; } }
.gate-box { position: relative; width: 100%; max-width: 380px; background: var(--asphalt-3); padding: 72px 28px 24px; border-radius: 10px; box-shadow: 0 20px 60px rgba(0,0,0,.55); }
.stop { position: absolute; top: -46px; left: 50%; width: 92px; height: 92px; margin-left: -46px; background: var(--red);
  clip-path: polygon(30% 0, 70% 0, 100% 30%, 100% 70%, 70% 100%, 30% 100%, 0 70%, 0 30%); display: grid; place-items: center; }
.stop::before { content: ""; position: absolute; inset: 5px; background: var(--red); border: 0;
  clip-path: inherit; box-shadow: inset 0 0 0 3px var(--paint); }
.stop span { position: relative; font: 700 24px/1 var(--sign-font); letter-spacing: .04em; color: var(--paint); }
.gate-kicker { margin: 0; text-align: center; font: 600 12px/1 var(--sign-font); letter-spacing: .16em; text-transform: uppercase; color: var(--yellow); }
.gate-box h1 { text-align: center; font: 700 24px/1.15 var(--sign-font); margin: 8px 0 22px; }
.gate-box .go { width: 100%; justify-content: center; }
.gate-error { min-height: 1.3em; margin: 12px 0 0; color: #ff8a80; text-align: center; }

/* ---- The panel: road + board ---------------------------------------------------------- */
.shell { display: grid; grid-template-columns: 260px 1fr; min-height: 100vh; }
.road {
  position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 24px; padding: 22px 18px;
  background: var(--asphalt-2); border-right: 6px solid var(--paint);
  /* the centre line runs down the road */
  background-image: repeating-linear-gradient(to bottom, var(--yellow) 0 26px, transparent 26px 52px);
  background-size: 4px 100%; background-repeat: no-repeat; background-position: 26px 0;
}
.brand { display: flex; align-items: center; gap: 12px; padding-left: 26px; }
.brand-light { display: grid; gap: 3px; padding: 5px; background: #0d0e10; border-radius: 6px; }
.brand-light i { width: 10px; height: 10px; border-radius: 50%; background: #3a2a28; }
.brand-light i:nth-child(1) { background: var(--red); box-shadow: 0 0 8px var(--red); }
.brand-light i:nth-child(2) { background: #3a3424; }
.brand-light i:nth-child(3) { background: #233a2b; }
.brand-name { font: 700 24px/1 var(--sign-font); }
.brand-name small { display: block; font-size: 11px; letter-spacing: .2em; text-transform: uppercase; color: var(--yellow); margin-top: 3px; }
.exits { display: grid; gap: 12px; padding-left: 26px; }
.exit {
  display: flex; align-items: center; gap: 10px; text-align: left; padding: 10px 12px; border: 0; border-radius: 8px;
  background: #19442a; color: rgba(255,255,255,.7); box-shadow: inset 0 0 0 2px rgba(255,255,255,.35);
  font: 600 17px/1 var(--sign-font); transition: transform .12s, background .12s;
}
.exit b { display: grid; place-items: center; min-width: 30px; height: 26px; padding: 0 6px; border-radius: 4px; background: var(--paint); color: var(--sign); font-size: 15px; }
.exit:hover { transform: translateX(3px); color: #fff; }
.exit.active { background: var(--sign); color: var(--sign-ink); box-shadow: inset 0 0 0 2px #fff, 0 4px 14px rgba(0,0,0,.4); transform: translateX(6px); }
.exit.active::after { content: "↗"; margin-left: auto; font-size: 18px; }
.driver { margin-top: auto; padding: 14px; padding-left: 40px; display: grid; gap: 4px; font-size: 13px; }
.driver strong { font: 700 18px/1.2 var(--sign-font); }
.driver .ghost { margin-top: 8px; justify-self: start; }

.board { padding: 28px clamp(16px, 4vw, 48px) 64px; min-width: 0; }
.page { max-width: 1040px; }
.page-head { display: flex; align-items: baseline; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; padding-bottom: 14px;
  border-bottom: 4px dashed var(--kerb); }
.page-head h2 { margin: 0; font: 700 34px/1 var(--sign-font); letter-spacing: .01em; }
.page-head p { margin: 0; color: var(--muted); }

/* ---- Overview: a departure board ------------------------------------------------------ */
.departures { background: #0c0d0e; border-radius: 10px; padding: 8px 0; box-shadow: inset 0 0 0 2px #2a2d31, 0 12px 40px rgba(0,0,0,.4); font-family: var(--mono); }
.dep-head, .dep-row { display: grid; grid-template-columns: 1fr auto; gap: 16px; padding: 12px 22px; align-items: center; }
.dep-head { font-size: 11px; letter-spacing: .2em; text-transform: uppercase; color: var(--muted); border-bottom: 1px solid #222; }
.dep-row { border-bottom: 1px solid #1a1b1d; color: var(--amber); font-size: 18px; text-transform: uppercase; letter-spacing: .06em; }
.dep-row:last-child { border-bottom: 0; }
.dep-row .flap { display: inline-flex; gap: 3px; }
.dep-row .flap i { font-style: normal; display: inline-grid; place-items: center; min-width: 22px; height: 30px; padding: 0 2px;
  background: #1c1d20; border-radius: 3px; color: #ffd36b; font-size: 18px; position: relative; }
.dep-row .flap i::after { content: ""; position: absolute; left: 0; right: 0; top: 50%; height: 1px; background: #000; }
.dep-row.warn { color: #ff8a80; }
.dep-row.warn .flap i { color: #ff8a80; }

/* ---- Users: licence plates ------------------------------------------------------------- */
.search { display: flex; align-items: center; gap: 10px; max-width: 420px; margin-bottom: 18px; padding: 0 14px; background: var(--asphalt-2); border-radius: 30px; border: 2px solid var(--kerb); }
.search:focus-within { border-color: var(--yellow); }
.search span { color: var(--muted); font-size: 18px; }
.search input { flex: 1; min-width: 0; padding: 11px 0; border: 0; background: none; color: var(--paint); font: inherit; }
.search input:focus { outline: none; }
.plates { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.car { display: grid; grid-template-columns: auto 1fr auto; gap: 18px; align-items: center; padding: 12px 16px; background: var(--asphalt-2); border-radius: 10px; border-left: 6px solid var(--kerb); }
.car.off { border-left-color: var(--red); }
.plate { display: inline-flex; align-items: stretch; border: 2px solid #111; border-radius: 6px; background: #f6f6f0; color: #111; overflow: hidden; box-shadow: 0 2px 0 #000; }
.plate::before { content: "T"; display: grid; place-items: center; width: 20px; padding-top: 10px; background: var(--plate-blue); color: #fff; font: 700 11px/1 var(--sign-font); }
.plate span { padding: 4px 12px; font: 700 21px/1.2 var(--sign-font); letter-spacing: .08em; text-transform: uppercase; white-space: nowrap; }
.car-info { display: flex; flex-wrap: wrap; gap: 4px 18px; color: var(--paint-dim); font-size: 13px; min-width: 0; }
.car-info b { color: var(--paint); font-weight: 600; }
.car-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.light { display: inline-flex; gap: 4px; padding: 4px 6px; background: #0d0e10; border-radius: 12px; }
.light i { width: 10px; height: 10px; border-radius: 50%; background: #2c2f33; }
.light.ok i:nth-child(3) { background: var(--green); box-shadow: 0 0 8px var(--green); }
.light.off i:nth-child(1) { background: var(--red); box-shadow: 0 0 8px var(--red); }
.sign-btn { padding: 6px 11px; border: 2px solid var(--kerb); border-radius: 6px; background: var(--asphalt-3); font: 600 14px/1 var(--sign-font); letter-spacing: .03em; }
.sign-btn:hover { border-color: var(--paint); }
.sign-btn.danger { border-color: #6a2b27; color: #ff9d94; }
.sign-btn.danger:hover { background: var(--red); border-color: var(--red); color: #fff; }
.empty { padding: 28px; text-align: center; color: var(--muted); border: 2px dashed var(--kerb); border-radius: 10px; }

/* The user's saves: a garage */
.garage { margin-top: 22px; padding: 18px; border-radius: 10px; background: var(--asphalt-2);
  border-top: 8px solid; border-image: repeating-linear-gradient(45deg, var(--yellow) 0 14px, #1b1d20 14px 28px) 8; }
.garage h3 { margin: 0 0 12px; font: 700 20px/1 var(--sign-font); }
.bays { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; }
.bay { padding: 12px 14px; border: 2px solid var(--paint); border-top: 0; border-radius: 0 0 6px 6px; display: grid; gap: 6px; }
.bay b { font: 700 17px/1.1 var(--sign-font); word-break: break-all; }
.bay small { color: var(--paint-dim); }
.bay div { display: flex; gap: 8px; margin-top: 4px; }
.bay a { text-decoration: none; color: var(--paint); display: inline-block; }

/* ---- Releases: road works + kilometre stones ----------------------------------------- */
.works { position: relative; padding: 22px; margin-bottom: 30px; background: var(--asphalt-2); border-radius: 10px;
  border: 8px solid; border-image: repeating-linear-gradient(-45deg, #ff6a13 0 14px, #f4f4f0 14px 28px) 8; }
.works h3 { margin: 0 0 16px; font: 700 20px/1 var(--sign-font); }
.works-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 0 16px; }
.works-grid .wide { grid-column: 1 / -1; }
.works-msg { min-height: 1.3em; margin: 12px 0 0; color: var(--paint-dim); }
.toggle { display: inline-flex; align-items: center; gap: 10px; margin: 2px 0 16px; cursor: pointer; color: var(--paint-dim); }
.toggle input { position: absolute; opacity: 0; }
.toggle i { width: 42px; height: 22px; border-radius: 12px; background: var(--kerb); position: relative; transition: background .15s; }
.toggle i::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: var(--paint); transition: left .15s; }
.toggle input:checked + i { background: var(--green); }
.toggle input:checked + i::after { left: 23px; }
.toggle input:focus-visible + i { outline: 3px solid var(--yellow); outline-offset: 2px; }

.milestones { list-style: none; margin: 0; padding: 0 0 0 62px; position: relative; display: grid; gap: 16px; }
.milestones::before { content: ""; position: absolute; left: 14px; top: 0; bottom: 0; width: 34px; background: var(--asphalt-2);
  border-left: 3px solid var(--paint); border-right: 3px solid var(--paint); }
.milestones::after { content: ""; position: absolute; left: 30px; top: 0; bottom: 0; width: 3px;
  background: repeating-linear-gradient(to bottom, var(--yellow) 0 16px, transparent 16px 32px); }
.stone { position: relative; display: grid; grid-template-columns: auto 1fr auto; gap: 16px; align-items: center; padding: 12px 16px; background: var(--asphalt-2); border-radius: 10px; }
.km { display: grid; place-items: center; min-width: 74px; padding: 10px 8px 8px; border-radius: 22px 22px 4px 4px; background: #eceae2; color: #111; box-shadow: 0 3px 0 #000; }
.km small { font: 600 10px/1 var(--sign-font); letter-spacing: .14em; text-transform: uppercase; color: #555; }
.km b { font: 700 20px/1.1 var(--sign-font); }
.stone.live .km { background: var(--sign); color: #fff; box-shadow: inset 0 0 0 2px #fff, 0 3px 0 #000; }
.stone.live .km small { color: #cfe8d7; }
.stone-info { display: grid; gap: 3px; min-width: 0; }
.stone-info span { color: var(--paint-dim); font-size: 13px; }
.stone-info p { margin: 0; color: var(--paint); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---- Toast: a variable message sign ------------------------------------------------------ */
.vms { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); max-width: calc(100% - 32px);
  padding: 12px 20px; background: #0a0a0a; border: 3px solid #333; border-radius: 4px;
  color: var(--amber); font: 700 15px/1.3 var(--mono); letter-spacing: .08em; text-transform: uppercase;
  text-shadow: 0 0 6px rgba(255,176,0,.6); box-shadow: 0 10px 30px rgba(0,0,0,.6); }

/* ---- Small screens: the road turns sideways ----------------------------------------- */
@media (max-width: 820px) {
  .shell { grid-template-columns: 1fr; }
  .road { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 12px; padding: 14px 16px 16px;
    border-right: 0; border-bottom: 6px solid var(--paint);
    background-image: repeating-linear-gradient(to right, var(--yellow) 0 26px, transparent 26px 52px);
    background-size: 100% 4px; background-position: 0 calc(100% - 8px); }
  .brand, .exits { padding-left: 0; }
  .exits { display: flex; flex-wrap: wrap; gap: 8px; order: 3; width: 100%; padding-bottom: 12px; }
  .exit { padding: 8px 10px; font-size: 15px; }
  .exit.active { transform: none; }
  .exit.active::after { display: none; }
  .driver { margin: 0 0 0 auto; padding: 0; grid-template-columns: auto auto; align-items: center; gap: 4px 10px; }
  .driver .ghost { margin: 0; }
  .driver > .muted { display: none; }
  .board { padding: 20px 16px 48px; }
  .page-head h2 { font-size: 28px; }
  .car { grid-template-columns: 1fr; gap: 10px; }
  .car .plate { justify-self: start; }
  .car-actions { justify-content: flex-start; }
  .stone { grid-template-columns: auto 1fr; }
  .stone .car-actions { grid-column: 1 / -1; }
  .milestones { padding-left: 0; }
  .milestones::before, .milestones::after { display: none; }
  .dep-head, .dep-row { padding: 10px 14px; }
  .dep-row { font-size: 14px; }
  .dep-row .flap i { min-width: 17px; height: 25px; font-size: 15px; }
}
