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

:root {
  --bg: #1a1a2e;
  --card: #16213e;
  --text: #eee;
  --muted: #888;
  --green: #4ade80;
  --yellow: #fbbf24;
  --red: #f87171;
}

html, body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  min-height: 100dvh;
}

header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: var(--card);
  border-bottom: 1px solid #333;
  position: sticky;
  top: 0;
  z-index: 100;
}

header h1 {
  font-size: 1.25rem;
  font-weight: 600;
}

.status {
  display: flex;
  align-items: center;
  gap: 10px;
}

#clock {
  font-variant-numeric: tabular-nums;
  font-size: 1.1rem;
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  transition: background 0.3s;
}

.dot.connected { background: var(--green); }
.dot.disconnected { background: var(--red); }

main {
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.loading {
  text-align: center;
  padding: 40px;
  color: var(--muted);
}

/* Train row */
.train {
  display: grid;
  grid-template-columns: 60px 1fr auto;
  gap: 10px;
  padding: 12px;
  background: var(--card);
  border-radius: 8px;
  border-left: 4px solid #666;
  transition: opacity 0.3s, transform 0.3s;
}

.train.fade-in {
  animation: fadeIn 0.3s ease;
}

.train.fade-out {
  opacity: 0;
  transform: translateX(-20px);
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.train-time {
  font-size: 1.3rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.train-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.train-dest {
  font-size: 1.1rem;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.train-line {
  font-size: 0.85rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.train-number {
  color: var(--text);
  font-weight: 600;
  margin-right: 6px;
}

.train-meta {
  text-align: right;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
}

.train-track {
  font-size: 1.4rem;
  font-weight: 700;
  min-width: 40px;
  text-align: center;
}

.train-track.assigned {
  background: var(--green);
  color: #000;
  padding: 2px 8px;
  border-radius: 4px;
}

/* Predicted track styles */
.train-track.predicted {
  padding: 2px 8px;
  border-radius: 4px;
  border: 2px dashed var(--muted);
  color: var(--muted);
  font-size: 1.2rem;
}

.train-track.predicted.confidence-high {
  border-color: var(--green);
  color: var(--green);
  opacity: 0.8;
}

.train-track.predicted.confidence-medium {
  border-color: var(--yellow);
  color: var(--yellow);
  opacity: 0.7;
}

.train-track.predicted.confidence-low {
  border-color: var(--muted);
  color: var(--muted);
  opacity: 0.6;
}

.train-status {
  font-size: 0.8rem;
  font-weight: 500;
}

.train-status.on-time { color: var(--green); }
.train-status.delayed { color: var(--yellow); }
.train-status.late { color: var(--red); }
.train-status.boarding { color: #60a5fa; }
.train-status.departed { color: var(--muted); }

.train-id {
  font-size: 0.75rem;
  color: var(--muted);
}

footer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 8px 16px;
  background: var(--card);
  border-top: 1px solid #333;
  text-align: center;
  font-size: 0.8rem;
  color: var(--muted);
}

/* Tablets and larger */
@media (min-width: 600px) {
  main {
    padding: 16px;
    max-width: 800px;
    margin: 0 auto;
  }

  .train {
    grid-template-columns: 80px 1fr 100px;
    padding: 16px;
  }

  .train-time {
    font-size: 1.5rem;
  }

  .train-dest {
    font-size: 1.25rem;
  }
}
