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

html, body { height: 100%; overflow: hidden; }

body {
  font-family: 'Segoe UI', 'Helvetica Neue', Arial, sans-serif;
  background: #070f1c;
  color: #e8edf5;
  display: flex;
  flex-direction: column;
}

.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 2rem;
  background: linear-gradient(135deg, #12305a, #0a1c36);
  border-bottom: 4px solid #f97316;
  flex-shrink: 0;
}

.header-left { display: flex; align-items: center; gap: 1rem; }
.logo { width: 3.5rem; height: 3.5rem; border-radius: 50%; object-fit: cover; }
.header h1 { font-size: clamp(1.6rem, 3.2vw, 2.8rem); letter-spacing: 0.04em; }
.subtitle { color: #94a3b8; font-size: 0.95rem; margin-top: 0.2rem; }
.header-right { text-align: right; }
.clock { font-size: clamp(1.8rem, 3vw, 2.6rem); color: #f97316; font-weight: 700; }
.clock-date { color: #94a3b8; font-size: 0.95rem; }
.lang {
  display: inline-block;
  margin-top: 0.35rem;
  color: #f97316;
  font-weight: 700;
  letter-spacing: 0.08em;
}

.board {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  padding: 1rem 1.5rem;
  overflow: hidden;
}

.loading, .idle {
  margin: auto;
  text-align: center;
  color: #94a3b8;
  font-size: 1.6rem;
}

.platform-strip {
  flex: 1;
  min-height: 0;
  background: #0d1f38;
  border: 1px solid #1e3a5f;
  border-radius: 12px;
  padding: 0.9rem 1.1rem 0.7rem;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  overflow: hidden;
}

.platform-strip.single { flex: 1; }

.strip-header {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  font-size: clamp(1.1rem, 1.8vw, 1.5rem);
}

.strip-header strong { color: #f97316; }
.strip-header .route-hint {
  display: inline-block;
  margin-left: 0.55rem;
  color: #94a3b8;
  font-size: 0.72em;
  font-weight: 500;
}

.heading-banner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  padding: 0.45rem 1rem;
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(249, 115, 22, 0.12), rgba(56, 189, 248, 0.18), rgba(249, 115, 22, 0.12));
  border: 1px solid rgba(56, 189, 248, 0.35);
  font-size: clamp(0.95rem, 1.6vw, 1.25rem);
  letter-spacing: 0.04em;
}

.heading-banner .towards-label {
  color: #7dd3fc;
  text-transform: uppercase;
  font-weight: 700;
  font-size: 0.78em;
}

.heading-banner .dest {
  color: #f8fafc;
  font-size: 1.05em;
  text-transform: uppercase;
}

.heading-banner .motion {
  color: #38bdf8;
  font-weight: 800;
  letter-spacing: 0.12em;
  animation: pulseArrow 1.1s ease-in-out infinite;
}

.heading-banner .motion.trail {
  opacity: 0.45;
  animation-delay: 0.35s;
}

.heading-banner.heading-left {
  background: linear-gradient(90deg, rgba(56, 189, 248, 0.28), rgba(15, 23, 42, 0.2) 55%, transparent);
}

.heading-banner.heading-right {
  background: linear-gradient(270deg, rgba(56, 189, 248, 0.28), rgba(15, 23, 42, 0.2) 55%, transparent);
}

@keyframes pulseArrow {
  0%, 100% { opacity: 0.35; transform: translateX(0); }
  50% { opacity: 1; transform: translateX(0); }
}

.heading-left .motion { animation-name: nudgeLeft; }
.heading-right .motion { animation-name: nudgeRight; }

@keyframes nudgeLeft {
  0%, 100% { opacity: 0.4; transform: translateX(0); }
  50% { opacity: 1; transform: translateX(-6px); }
}

@keyframes nudgeRight {
  0%, 100% { opacity: 0.4; transform: translateX(0); }
  50% { opacity: 1; transform: translateX(6px); }
}

.rake-wrap {
  position: relative;
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 0;
  overflow: hidden;
}

.rake-stage {
  position: relative;
  width: 100%;
  min-height: 0;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  --coach-count: 12;
  --coach-gap: clamp(0.08rem, 0.35vw, 0.28rem);
}

.rake {
  display: flex;
  width: 100%;
  gap: var(--coach-gap);
  overflow: hidden;
  padding: 0.35rem 0 0;
  animation: rakeIn 0.7s ease-out;
  z-index: 2;
  position: relative;
}

.rake.engine-right {
  animation-name: rakeInRight;
}

.rake.engine-right .coach-art {
  transform: scaleX(-1);
}

@keyframes rakeIn {
  from { transform: translateX(-1.2rem); opacity: 0.2; }
  to { transform: translateX(0); opacity: 1; }
}

@keyframes rakeInRight {
  from { transform: translateX(1.2rem); opacity: 0.2; }
  to { transform: translateX(0); opacity: 1; }
}

.coach {
  flex: 1 1 0;
  min-width: 0;
  width: auto;
  min-height: 0;
  border-radius: clamp(4px, 0.45vw, 10px);
  border: 2px solid rgba(255,255,255,0.08);
  background: rgba(8, 16, 32, 0.55);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  gap: 0.1rem;
  font-weight: 700;
  position: relative;
  padding: 0.3rem 0.15rem 0.35rem;
  overflow: hidden;
  /* shrink labels with longer rakes */
  --tile-fs: clamp(0.5rem, calc(78vw / var(--coach-count) / 7.2), 1.05rem);
}

.coach .num {
  position: absolute;
  top: 0.22rem;
  left: 0.22rem;
  min-width: clamp(0.9rem, calc(55vw / var(--coach-count) / 8), 1.35rem);
  height: clamp(0.9rem, calc(55vw / var(--coach-count) / 8), 1.35rem);
  padding: 0 0.2rem;
  border-radius: 999px;
  background: #f97316;
  color: #0b1220;
  font-size: clamp(0.55rem, calc(55vw / var(--coach-count) / 10), 0.75rem);
  font-weight: 800;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1;
}

.coach-art {
  width: 100%;
  height: auto;
  max-height: clamp(2.2rem, calc(52vh / 2.6), calc(90vw / var(--coach-count) * 0.72));
  object-fit: contain;
  display: block;
  pointer-events: none;
}

.coach .code {
  font-size: var(--tile-fs);
  line-height: 1.1;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.coach .kind {
  font-size: clamp(0.4rem, calc(var(--tile-fs) * 0.62), 0.65rem);
  opacity: 0.85;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: #94a3b8;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.coach.pin-aligned {
  box-shadow: 0 0 0 3px #fbbf24, 0 0 18px rgba(251, 191, 36, 0.45);
  border-color: #fbbf24;
}

/* —— Track / rails —— */
.track {
  position: relative;
  height: clamp(1.35rem, 2.4vh, 1.9rem);
  margin-top: -0.15rem;
  z-index: 1;
  overflow: hidden;
  border-radius: 0 0 6px 6px;
}

.track .ballast {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 20% 40%, rgba(148, 163, 184, 0.18) 0 1px, transparent 2px) 0 0 / 10px 8px,
    radial-gradient(circle at 70% 60%, rgba(100, 116, 139, 0.22) 0 1px, transparent 2px) 3px 2px / 12px 9px,
    linear-gradient(180deg, #1a2438 0%, #121a2a 45%, #0c1422 100%);
  box-shadow: inset 0 6px 10px rgba(0, 0, 0, 0.35);
}

.track .sleepers {
  position: absolute;
  left: 0;
  right: 0;
  top: 28%;
  height: 44%;
  background: repeating-linear-gradient(
    90deg,
    transparent 0,
    transparent 10px,
    #5b3a1e 10px,
    #5b3a1e 22px,
    #3f2814 22px,
    #3f2814 24px,
    transparent 24px,
    transparent 34px
  );
  opacity: 0.92;
  filter: drop-shadow(0 1px 0 rgba(0, 0, 0, 0.45));
}

.track .rail {
  position: absolute;
  left: 0;
  right: 0;
  height: 3px;
  border-radius: 2px;
  background: linear-gradient(
    90deg,
    #64748b 0%,
    #e2e8f0 18%,
    #94a3b8 36%,
    #f1f5f9 52%,
    #94a3b8 68%,
    #cbd5e1 84%,
    #64748b 100%
  );
  box-shadow:
    0 1px 0 rgba(15, 23, 42, 0.85),
    0 0 8px rgba(148, 163, 184, 0.35);
}

.track .rail::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(255, 255, 255, 0.55) 45%,
    transparent 70%
  );
  background-size: 40% 100%;
  animation: railShine 4.5s linear infinite;
  opacity: 0.55;
}

.track .rail-far { top: 32%; }
.track .rail-near { top: 58%; }

.track .rail-glow {
  position: absolute;
  left: 0;
  right: 0;
  top: 20%;
  height: 60%;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(56, 189, 248, 0.08),
    transparent
  );
  pointer-events: none;
  animation: trackPulse 3.2s ease-in-out infinite;
}

@keyframes railShine {
  from { background-position: -40% 0; }
  to { background-position: 140% 0; }
}

@keyframes trackPulse {
  0%, 100% { opacity: 0.35; }
  50% { opacity: 0.85; }
}

.pin-row {
  position: relative;
  height: 3.1rem;
  flex-shrink: 0;
}

.you-pin {
  position: absolute;
  top: 0;
  transform: translateX(-50%);
  text-align: center;
  color: #fbbf24;
  font-weight: 700;
  animation: bob 1.4s ease-in-out infinite;
  max-width: min(90vw, 28rem);
}

.you-pin .arrow { font-size: 1.2rem; line-height: 1; }

.pin-cluster {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.55rem;
  white-space: nowrap;
  margin-top: 0.1rem;
}

.pin-cluster .label {
  font-size: 0.9rem;
  color: #fbbf24;
}

.pin-cluster .walk {
  color: #94a3b8;
  font-size: 0.78rem;
  font-weight: 600;
}

@keyframes bob {
  0%, 100% { transform: translateX(-50%) translateY(0); }
  50% { transform: translateX(-50%) translateY(-4px); }
}

.unavailable {
  color: #f87171;
  font-size: 1.3rem;
  padding: 1.5rem;
  text-align: center;
}

.footer {
  flex-shrink: 0;
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.55rem 1.5rem;
  background: #0a1628;
  border-top: 1px solid #1e3a5f;
  color: #64748b;
  font-size: 0.9rem;
}

.admin-link { color: #f97316; text-decoration: none; }
