:root {
  --color-italo: #e5a33e;
  --color-freccia: #f00624;
  --color-intercity: #218ccd;
  --color-trenord: #2b7f45;
  --color-trenitalia: #016969;
  --ritardo-verde: #2b7f45;
  --ritardo-rosso: #c51e05;
  --bg-app: #f5f5f7;
  --card-bg: #ffffff;
}

* { box-sizing: border-box; margin: 0; padding: 0; font-family: system-ui, -apple-system, sans-serif; }

body {
  background-color: var(--bg-app);
  color: #111;
  padding-bottom: 40px;
}

/* Header centrato */
.header {
  background: #ffffff;
  padding: 14px 20px;
  border-bottom: 1px solid #e5e5ea;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 10px rgba(0,0,0,0.03);
}

.header-center-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  margin-bottom: 12px;
}

/* Orologio digitale in alto al centro */
#live-clock {
  font-family: inherit;
  font-weight: 900;
  font-size: 1.4rem;
  color: #111;
  letter-spacing: 1px;
  margin-bottom: 2px;
}

/* Titolo / Input ricerca stazione */
.stazione-select-wrap {
  position: relative;
  width: 100%;
  max-width: 420px;
  text-align: center;
}

.stazione-input-title {
  width: 100%;
  border: none;
  background: transparent;
  font-family: inherit;
  font-size: 1.5rem;
  font-weight: 900;
  text-transform: uppercase;
  text-align: center;
  color: #000;
  cursor: pointer;
  outline: none;
  padding: 4px 8px;
  border-radius: 8px;
  transition: background 0.2s ease;
}

.stazione-input-title:focus {
  background: #f0f0f4;
}

/* Dropdown stazioni */
.stazioni-dropdown {
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 380px;
  background: #ffffff;
  border: 1px solid #ddd;
  border-radius: 14px;
  margin-top: 6px;
  max-height: 240px;
  overflow-y: auto;
  z-index: 1000;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
}

.stazione-item {
  padding: 12px 16px;
  font-size: 1rem;
  font-weight: 800;
  color: #222;
  text-align: center;
  border-bottom: 1px solid #eee;
  cursor: pointer;
  transition: background 0.15s ease;
}

.stazione-item:last-child {
  border-bottom: none;
}

.stazione-item:hover {
  background: #f4f4f8;
  color: #000;
}

.stazione-item.no-result {
  color: #888;
  font-weight: 500;
  cursor: default;
}

/* Tabs switcher */
.mode-tabs {
  display: flex;
  gap: 8px;
  background: #eee;
  padding: 4px;
  border-radius: 12px;
  max-width: 420px;
  margin: 0 auto;
}

.tab-btn {
  flex: 1;
  padding: 8px;
  border: none;
  background: none;
  font-weight: 800;
  color: #666;
  border-radius: 8px;
  cursor: pointer;
}

.tab-btn.active {
  background: #ffffff;
  color: #000;
  box-shadow: 0 2px 6px rgba(0,0,0,0.1);
}

/* Container principale */
.container {
  max-width: 540px;
  margin: 16px auto;
  padding: 0 12px;
}

.elenco-treni {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* SCHEDA TRENO STATICA (Stile pillola) */
.treno-card-nuova {
  background: var(--card-bg);
  border: 2.5px solid #ccc;
  border-radius: 38px;
  padding: 12px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 115px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.03);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.treno-card-nuova:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.06);
}

/* Colori vettori */
.treno-card-nuova.vettore-trenitalia { border-color: var(--color-trenitalia); color: var(--color-trenitalia); }
.treno-card-nuova.vettore-freccia { border-color: var(--color-freccia); color: var(--color-freccia); }
.treno-card-nuova.vettore-italo { border-color: var(--color-italo); color: var(--color-italo); }
.treno-card-nuova.vettore-intercity { border-color: var(--color-intercity); color: var(--color-intercity); }
.treno-card-nuova.vettore-trenord { border-color: var(--color-trenord); color: var(--color-trenord); }

/* SEZIONE SINISTRA: Logo Vettore + Numero Treno */
.card-left {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: space-between;
  width: 90px;
  flex-shrink: 0;
  height: 80px;
}

.card-left .logo-wrap {
  width: 100%;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: flex-start;
}

.card-left .logo-wrap img {
  max-width: 85px;
  max-height: 45px;
  object-fit: contain;
}

.card-left .numero-treno-label {
  font-size: 1.1rem;
  font-weight: 900;
  letter-spacing: -0.5px;
  line-height: 1;
}

/* SEZIONE CENTRALE: Destinazione + Orario + Ritardo */
.card-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
  text-align: center;
  gap: 4px;
  min-width: 0; /* Previene overflow del flex item */
}

.card-center .destinazione-label {
  font-size: 1.35rem;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
  line-height: 1.1;
}

.card-center .orario-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.card-center .orario-valore {
  font-size: 2.7rem;
  font-weight: 900;
  line-height: 1;
  letter-spacing: -1px;
}

/* Badge del ritardo tondo */
.badge-ritardo-tondo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background-color: var(--ritardo-rosso);
  color: #ffffff;
  font-size: 0.72rem;
  font-weight: 900;
  border-radius: 50%;
  width: 26px;
  height: 26px;
  flex-shrink: 0;
  line-height: 1;
}

.badge-ritardo-tondo.ritardo-ok {
  background-color: var(--ritardo-verde);
}

/* SEZIONE DESTRA: Binario Gigante + Specifica sotto (OVEST/EST) */
.card-right {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 80px;
  flex-shrink: 0;
  overflow: hidden;
}

.card-right .binario-gigante {
  font-size: 3.5rem;
  font-weight: 900;
  line-height: 0.85;
  letter-spacing: -2px;
  white-space: nowrap;
}

.card-right .binario-sub {
  font-size: 0.85rem;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-top: 2px;
  line-height: 1;
  white-space: nowrap;
}

/* Stato Cancellato */
.treno-card-nuova.cancellato {
  border-color: var(--ritardo-rosso) !important;
  opacity: 0.55;
}

.treno-card-nuova.cancellato .destinazione-label {
  text-decoration: line-through;
}

/* FOOTER BRANDING E LOGO */
.brand-copyright-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 14px;
  padding: 10px 8px 2px 8px;
  border-top: 1.5px solid #e0e5e8;
  width: 100%;
}

.brand-logo-wrap {
  display: flex;
  align-items: center;
  overflow: hidden;
}

/* Dimensione massima per evitare che l'immagine gigante rompa il layout */
.brand-logo-img {
  height: 36px;
  width: auto;
  max-width: 100px;
  border-radius: 6px; /* Arrotonda leggermente gli angoli dell'avatar */
  object-fit: cover;
}

.brand-copyright-footer .copyright-tag {
  font-size: 0.68rem;
  font-weight: 700;
  color: #666;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.hidden { display: none !important; }