@import url('https://fonts.googleapis.com/css2?family=Space+Mono:wght@400;700&family=Noto+Sans+JP:wght@300;400;500&display=swap');

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

:root {
  --bg: #0a0a0f;
  --bg-card: #111118;
  --bg-card2: #18181f;
  --accent: #e8ff47;
  --accent-dim: rgba(232, 255, 71, 0.15);
  --accent-dim2: rgba(232, 255, 71, 0.06);
  --text-primary: #f0f0f0;
  --text-secondary: #888899;
  --text-muted: #44445a;
  --border: rgba(255,255,255,0.07);
  --border-accent: rgba(232, 255, 71, 0.3);
  --red: #ff4d4d;
  --orange: #ff9f40;
  --green: #47ffb0;
  --radius: 16px;
  --radius-sm: 10px;
}

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

body {
  font-family: 'Noto Sans JP', sans-serif;
  background: var(--bg);
  color: var(--text-primary);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  min-height: 100dvh;
  padding: env(safe-area-inset-top, 0) 0 0;
  user-select: none;
  -webkit-user-select: none;
}

#app {
  width: 100%;
  max-width: 430px;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: 0 20px 20px;
  overflow: hidden;
}

/* ── Header ── */
header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 0 16px;
  flex-shrink: 0;
}

.header-left {
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.logo {
  font-family: 'Space Mono', monospace;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.15em;
  color: var(--text-primary);
  text-transform: uppercase;
}

.station-name {
  font-size: 13px;
  font-weight: 300;
  color: var(--text-primary);
  letter-spacing: 0.05em;
}

#current-time {
  font-family: 'Space Mono', monospace;
  font-size: 13px;
  color: var(--text-primary);
  letter-spacing: 0.08em;
}

/* ── Direction Toggle ── */
.direction-toggle {
  display: flex;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 4px;
  gap: 4px;
  flex-shrink: 0;
  margin-bottom: 12px;
}

.dir-btn {
  flex: 1;
  padding: 10px 8px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-family: 'Noto Sans JP', sans-serif;
  font-size: 14px;
  font-weight: 400;
  border-radius: 7px;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.dir-btn .arrow {
  font-family: 'Space Mono', monospace;
  font-size: 12px;
}

.dir-btn.active {
  background: var(--accent-dim);
  color: var(--accent);
  font-weight: 500;
}

/* ── Day Type Toggle ── */
.day-toggle {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
  margin-bottom: 20px;
}

.day-btn {
  flex: 1;
  padding: 8px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  font-family: 'Noto Sans JP', sans-serif;
  font-size: 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s ease;
  letter-spacing: 0.05em;
}

.day-btn.active {
  border-color: var(--border-accent);
  color: var(--accent);
  background: var(--accent-dim2);
}

/* ── Next Train Hero ── */
.next-train-hero {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px 24px 20px;
  flex-shrink: 0;
  margin-bottom: 12px;
  position: relative;
  overflow: hidden;
}

.next-train-hero::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: var(--accent);
  opacity: 0;
  transition: opacity 0.3s;
}

.next-train-hero.urgent::before {
  opacity: 1;
  background: var(--red);
}

.next-train-hero.soon::before {
  opacity: 1;
  background: var(--orange);
}

.next-train-hero.ok::before {
  opacity: 1;
  background: var(--green);
}

.hero-label {
  font-size: 11px;
  font-weight: 400;
  color: var(--text-primary);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-family: 'Space Mono', monospace;
  margin-bottom: 8px;
}

.hero-row {
  display: flex;
  align-items: baseline;
  gap: 0;
  margin-bottom: 4px;
}

.hero-minutes {
  font-family: 'Space Mono', monospace;
  font-size: 72px;
  line-height: 1;
  font-weight: 700;
  color: var(--text-primary);
  transition: color 0.3s;
  letter-spacing: -0.03em;
}

.next-train-hero.urgent .hero-minutes { color: var(--red); }
.next-train-hero.soon .hero-minutes { color: var(--orange); }
.next-train-hero.ok .hero-minutes { color: var(--accent); }

.hero-unit {
  font-size: 18px;
  font-weight: 300;
  color: var(--text-primary);
  align-self: flex-end;
  padding-bottom: 8px;
  padding-left: 6px;
}

.hero-sub {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.hero-departure {
  font-family: 'Space Mono', monospace;
  font-size: 22px;
  font-weight: 700;
  color: var(--text-primary);
}

.hero-advice {
  font-size: 13px;
  font-weight: 500;
  padding: 5px 12px;
  border-radius: 100px;
  letter-spacing: 0.02em;
}

.advice-urgent { background: rgba(255,77,77,0.15); color: var(--red); }
.advice-soon   { background: rgba(255,159,64,0.15); color: var(--orange); }
.advice-ok     { background: rgba(71,255,176,0.15); color: var(--green); }

/* ── Upcoming Trains ── */
.upcoming-label {
  font-size: 11px;
  font-weight: 400;
  color: var(--text-primary);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-family: 'Space Mono', monospace;
  margin-bottom: 10px;
  flex-shrink: 0;
}

.train-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
  overflow: hidden;
}

.train-item {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  transition: opacity 0.2s;
}

.train-item:not(.first) {
  opacity: 0.7;
}

.train-index {
  font-family: 'Space Mono', monospace;
  font-size: 10px;
  color: var(--text-muted);
  width: 20px;
  flex-shrink: 0;
}

.train-time {
  font-family: 'Space Mono', monospace;
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
  flex: 1;
  padding-left: 12px;
}

.train-wait {
  font-family: 'Space Mono', monospace;
  font-size: 14px;
  color: var(--text-secondary);
}

.train-wait span {
  font-size: 11px;
  color: var(--text-muted);
}

/* ── No Train ── */
.no-train {
  text-align: center;
  padding: 40px 0;
  color: var(--text-muted);
  font-size: 14px;
  letter-spacing: 0.05em;
}

/* ── Refresh indicator ── */
.refresh-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 0 0;
  flex-shrink: 0;
}

.refresh-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--text-muted);
  animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 0.3; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.3); }
}

.refresh-text {
  font-family: 'Space Mono', monospace;
  font-size: 10px;
  color: var(--text-muted);
  letter-spacing: 0.08em;
}

/* ── Animations ── */
@keyframes slideUp {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.train-item {
  animation: slideUp 0.25s ease both;
}

.train-item:nth-child(1) { animation-delay: 0.00s; }
.train-item:nth-child(2) { animation-delay: 0.05s; }
.train-item:nth-child(3) { animation-delay: 0.10s; }
.train-item:nth-child(4) { animation-delay: 0.15s; }

/* ── Midnight notice ── */
.midnight-notice {
  text-align: center;
  padding: 16px;
  color: var(--text-muted);
  font-size: 12px;
  letter-spacing: 0.05em;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  margin-top: auto;
}

/* ── Train tag (始発マーク等) ── */
.train-tag {
  font-size: 10px;
  font-weight: 700;
  color: var(--accent);
  border: 1px solid var(--border-accent);
  border-radius: 4px;
  padding: 1px 5px;
  margin-left: 6px;
  font-family: 'Space Mono', monospace;
  letter-spacing: 0.05em;
  vertical-align: middle;
}
