:root {
  color-scheme: light;
  --ink: #123047;
  --ink-soft: #496778;
  --sky: #72c7ef;
  --paper: #f7fbfd;
  --white: #ffffff;
  --red: #e94f45;
  --red-dark: #bd332f;
  --green: #217a58;
  --yellow: #ffd667;
  --line: #cfe1e8;
  --shadow: 0 16px 40px rgba(17, 48, 71, 0.14);
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

* {
  box-sizing: border-box;
}

[hidden] { display: none !important; }

html {
  scroll-behavior: smooth;
}

@media (display-mode: standalone) {
  html {
    scrollbar-width: none;
  }

  html::-webkit-scrollbar {
    width: 0;
    height: 0;
  }
}

body {
  margin: 0;
  color: var(--ink);
  background: var(--paper);
  font-family: -apple-system, BlinkMacSystemFont, "Noto Sans TC", "PingFang TC",
    "Microsoft JhengHei", sans-serif;
  font-size: 16px;
  line-height: 1.5;
  letter-spacing: 0;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

input:focus-visible, button:focus-visible { outline: 3px solid var(--yellow); outline-offset: 3px; }

a {
  color: inherit;
}

.skip-link {
  position: fixed;
  z-index: 100;
  top: 12px;
  left: 12px;
  padding: 10px 14px;
  color: var(--white);
  background: var(--ink);
  border-radius: 6px;
  transform: translateY(-160%);
}

.skip-link:focus {
  transform: translateY(0);
}

.hero {
  position: relative;
  min-height: min(820px, 86dvh);
  overflow: hidden;
  isolation: isolate;
  background-color: var(--sky);
}

.scene { position: absolute; inset: 0; z-index: -2; overflow: hidden; pointer-events: none; }
.scene-stage { position: absolute; width: 100%; height: 100%; }
.scene-backdrop { display: block; width: 100%; height: 100%; }
.cloud { position: absolute; height: auto; opacity: .82; animation: cloud-drift 44s linear infinite alternate; }
.cloud-one { width: 24%; left: 46%; top: 13%; animation-delay: -18s; }
.cloud-two { width: 17%; left: 14%; top: 26%; opacity: .58; animation-duration: 60s; animation-delay: -38s; }
.train-window { position: absolute; inset: 0; mask-image: linear-gradient(to right, transparent 57%, black 62%, black 96%, transparent 100%); }
.train-track { position: absolute; left: 58%; top: 71.2%; width: 42%; height: 0; transform: rotate(-3deg); transform-origin: left center; }
.train-runner { position: absolute; bottom: 0; width: 61%; transform: translateX(20%); animation: train-journey 80s linear infinite; animation-delay: -36s; }
.train-runner img { display: block; width: 100%; height: auto; }
.motion-paused * { animation-play-state: paused !important; }
.motion-disabled { scroll-behavior: auto; }
.motion-disabled .day-chip { animation: none; opacity: 1; }
.motion-disabled .countdown-lockup { animation: none; }
.topbar-status { display: flex; align-items: center; gap: 24px; }
.scene-controls { display: flex; align-items: center; gap: 14px; }
.music-controls { position: relative; display: flex; align-items: center; gap: 4px; }
.music-toggle { position: relative; display: grid; place-items: center; flex: 0 0 44px; width: 44px; height: 44px; padding: 0; border: 0; border-radius: 4px; color: var(--ink); background: transparent; cursor: pointer; }
.music-toggle:hover { background: rgba(255, 255, 255, .32); }
.music-toggle img { grid-area: 1 / 1; }
.music-icon-on { display: none; }
.music-toggle[data-state='playing']:not([data-silent='true']) .music-icon-on { display: block; }
.music-toggle[data-state='playing']:not([data-silent='true']) .music-icon-off { display: none; }
.music-toggle[data-state='blocked']::after { content: ''; position: absolute; right: 5px; top: 7px; width: 6px; height: 6px; border-radius: 50%; background: var(--red-dark); }
.music-toggle[data-state='loading']::after { content: ''; position: absolute; inset: 5px; border: 2px solid transparent; border-top-color: var(--ink); border-radius: 50%; animation: music-loading 1s linear infinite; }
#music-volume { width: 64px; min-width: 0; height: 44px; margin: 0; accent-color: var(--ink); cursor: pointer; }
.music-status { position: absolute; z-index: 5; top: 100%; right: 0; width: 216px; padding: 8px 10px; margin: 4px 0 0; background: var(--paper); color: var(--ink); border: 1px solid var(--line); border-radius: 4px; font-size: 12px; }
.music-credit { width: min(1180px, calc(100% - 48px)); margin: 12px auto 0; font-size: 12px; color: var(--ink-soft); }
.music-credit a { color: inherit; text-underline-offset: 3px; }
@keyframes music-loading { to { transform: rotate(360deg); } }
.holiday-now { min-height: 154px; padding-top: 20px; }
.holiday-now > strong { color: var(--red-dark); font-size: 76px; line-height: 1.1; }
.holiday-now p { margin: 8px 0 0; font-weight: 650; }
.day-chip[aria-current] { outline: 3px solid var(--ink); outline-offset: 3px; }
.preview-link, .preview-panel { width: min(1180px, calc(100% - 48px)); margin: 24px auto 0; }
.preview-link { display: block; font-size: 13px; }
.preview-panel { border-top: 1px solid var(--line); padding-top: 16px; }
.preview-panel h3 { font-size: 18px; }
.preview-panel form { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.preview-panel input, .preview-panel button { min-height: 44px; max-width: 100%; font: inherit; border: 1px solid var(--line); border-radius: 4px; padding: 6px 12px; }
.preview-panel button { background: var(--ink); color: white; cursor: pointer; }
.preview-panel p { font-size: 13px; }
.empty-state { grid-column: 1 / -1; color: var(--ink-soft); }

.hero-shade {
  position: absolute;
  z-index: -1;
  inset: 0;
  background: rgba(228, 246, 255, 0.18);
}

.topbar,
.hero-content,
.section-heading,
.holiday-list,
.source-note {
  width: min(1180px, calc(100% - 48px));
  margin-inline: auto;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 80px;
  border-bottom: 1px solid rgba(18, 48, 71, 0.16);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  color: var(--ink);
  font-weight: 750;
  text-decoration: none;
}

.brand-mark {
  display: block;
  flex: 0 0 32px;
  width: 32px;
  height: 32px;
  border-radius: 6px;
}

.today {
  font-size: 14px;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
}

.hero-content {
  display: flex;
  align-items: flex-start;
  flex-direction: column;
  padding-top: clamp(54px, 9vh, 96px);
  padding-bottom: 104px;
}

.live-line {
  display: flex;
  align-items: center;
  gap: 9px;
}

.live-dot {
  width: 9px;
  height: 9px;
  background: var(--red);
  border: 2px solid rgba(255, 255, 255, 0.86);
  border-radius: 50%;
  box-shadow: 0 0 0 2px var(--red);
  animation: live-pulse 1.8s ease-out infinite;
}

.overline,
.section-overline {
  margin: 0 0 8px;
  color: var(--red-dark);
  font-size: 14px;
  font-weight: 800;
}

.live-line .overline {
  margin-bottom: 0;
}

.countdown-lockup {
  display: grid;
  grid-template-columns: 188px minmax(0, 1fr);
  width: min(680px, 100%);
  min-height: 154px;
  margin-top: 18px;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  animation: timer-arrive 620ms var(--ease) both;
}

.days-ticket {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 7px;
  padding: 8px 18px 8px 0;
  color: var(--red-dark);
}

.days-ticket strong {
  display: block;
  font-size: 118px;
  font-weight: 850;
  line-height: 0.92;
  letter-spacing: 0;
  transform-origin: center bottom;
}

.days-ticket span {
  color: var(--red-dark);
  font-size: 18px;
  font-weight: 800;
}

.clock-face {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 20px minmax(0, 1fr) 20px minmax(0, 1fr);
  align-items: center;
  padding: 20px 0 20px 28px;
}

.time-part {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 4px;
  min-width: 0;
}

.time-part strong {
  display: block;
  font-size: 64px;
  font-weight: 820;
  line-height: 1;
  letter-spacing: 0;
  transform-origin: center bottom;
}

.time-part span {
  color: var(--ink-soft);
  font-size: 13px;
  font-weight: 800;
}

.time-part-seconds strong {
  color: var(--ink);
}

.time-divider {
  color: #87a0ad;
  font-size: 30px;
  font-weight: 800;
  text-align: center;
}

.time-part strong.is-ticking,
.days-ticket strong.is-ticking {
  animation: digit-tick 280ms var(--ease);
}

.holiday-copy {
  margin-top: 12px;
}

.holiday-copy h1 {
  max-width: 680px;
  margin: 0;
  font-size: 54px;
  line-height: 1.13;
  letter-spacing: 0;
}

.holiday-dates {
  margin: 12px 0 0;
  color: var(--ink);
  font-size: 21px;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
}

.day-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 30px;
}

.day-chip {
  display: grid;
  place-items: center;
  width: 58px;
  min-height: 66px;
  padding: 7px 4px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.84);
  border: 1px solid rgba(18, 48, 71, 0.18);
  border-radius: 8px;
  box-shadow: 0 7px 18px rgba(17, 48, 71, 0.1);
  opacity: 0;
  animation: chip-arrive 420ms var(--ease) forwards;
  animation-delay: calc(var(--index, 0) * 55ms + 160ms);
}

.day-chip.is-holiday {
  color: var(--white);
  background: var(--red);
  border-color: var(--red);
}

.day-chip span {
  font-size: 12px;
  font-weight: 700;
}

.day-chip strong {
  font-size: 22px;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}

.scroll-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  min-height: 48px;
  margin-top: 34px;
  padding: 0 18px;
  color: var(--white);
  background: var(--ink);
  border: 0;
  border-radius: 6px;
  font: inherit;
  font-weight: 750;
  cursor: pointer;
  transition: transform 180ms var(--ease), background-color 180ms ease;
  touch-action: manipulation;
}

.scroll-button:hover {
  background: #071d2b;
  transform: translateY(-2px);
}

.scroll-button:active {
  transform: translateY(0) scale(0.98);
}

.scroll-button:focus-visible,
a:focus-visible {
  outline: 3px solid var(--yellow);
  outline-offset: 3px;
}

.image-credit {
  position: absolute;
  right: 24px;
  bottom: 20px;
  margin: 0;
  padding: 7px 10px;
  color: var(--white);
  background: rgba(18, 48, 71, 0.74);
  border-radius: 4px;
  font-size: 13px;
}

.upcoming {
  padding: 64px 0 40px;
  background: #edf3eb;
  border-top: 6px solid #d4e3cc;
}

.section-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  padding-bottom: 12px;
}

.section-heading h2 {
  margin: 0;
  font-size: 38px;
  line-height: 1.15;
  letter-spacing: 0;
}

.year-badge {
  color: #526958;
  font-size: 15px;
  font-weight: 650;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.holiday-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 38px 0;
  padding: 28px 0 0;
  list-style: none;
}

.holiday-station { --station-color: #b34037; min-width: 0; }
.holiday-station:nth-child(3n + 2) { --station-color: #246c62; }
.holiday-station:nth-child(3n) { --station-color: #85621d; }
.station-stop { position: relative; display: flex; align-items: center; height: 30px; gap: 10px; }
.station-stop::before { content: ''; position: absolute; left: 0; right: 0; height: 3px; background: #b6cbbb; }
.station-dot { z-index: 1; width: 19px; height: 19px; flex: 0 0 19px; border: 4px solid var(--station-color); background: #edf3eb; border-radius: 50%; transition: background .2s, transform .2s; }
.station-number { position: relative; padding: 0 8px 0 2px; font-size: 12px; font-weight: 750; color: #526958; background: #edf3eb; }
.holiday-station:nth-child(3n) .station-stop::before, .holiday-station:last-child .station-stop::before { right: 32px; }
.station-details { margin-right: 32px; }
.station-summary {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 72px;
  align-items: start;
  gap: 0 12px;
  padding: 20px 0 16px;
  cursor: pointer;
  list-style: none;
  border-bottom: 1px solid #c8d8c9;
}
.station-summary::-webkit-details-marker { display: none; }
.station-summary:focus-visible { outline: 3px solid var(--station-color); outline-offset: 6px; border-radius: 2px; }
.station-date { display: block; font-variant-numeric: tabular-nums; }
.station-year { display: block; color: #526958; font-size: 12px; font-weight: 650; }
.station-date > strong { font-size: 44px; line-height: 1.2; font-weight: 780; }
.station-length { display: flex; flex-direction: column; align-items: center; justify-content: center; width: 72px; height: 72px; border: 1px solid var(--station-color); border-radius: 50%; color: var(--station-color); transform: rotate(7deg); transition: transform .25s; }
.station-length strong { font-size: 30px; line-height: 1.05; }
.station-length > span { font-size: 11px; margin-top: 3px; }
.station-name { grid-column: 1 / -1; font-size: 23px; line-height: 1.4; margin: 20px 0 6px; overflow-wrap: anywhere; }
.station-range { grid-column: 1 / -1; margin: 0; font-size: 13px; color: #526958; min-height: 39px; }
.station-status { margin-top: 16px; font-size: 13px; color: var(--station-color); font-weight: 750; }
.station-chevron { justify-self: end; align-self: end; width: 9px; height: 9px; margin: 0 5px 6px; border-right: 2px solid var(--ink); border-bottom: 2px solid var(--ink); transform: rotate(45deg); transition: transform .2s; }
.station-details[open] .station-chevron { transform: rotate(225deg); }
.station-details[open] .station-length { transform: rotate(0); }
.station-expanded { padding: 16px 0 8px; }
.station-fullname { margin: 0 0 12px; font-size: 13px; color: #526958; }
.station-days { display: flex; flex-wrap: wrap; gap: 6px; }
.station-day { display: grid; gap: 3px; min-width: 48px; padding: 6px 3px; text-align: center; border-top: 2px solid var(--station-color); }
.station-day span { font-size: 11px; color: #526958; }
.station-day strong { font-size: 14px; font-variant-numeric: tabular-nums; }
.station-arriving .station-details { animation: station-arrive .55s var(--ease) both; animation-delay: calc(var(--station-index) * 80ms); }
.motion-disabled .station-arriving .station-details { animation: none; }
@media (hover: hover) {
  .holiday-station:hover .station-dot { background: var(--station-color); transform: scale(1.15); }
  .station-summary:hover .station-length { transform: rotate(0) translateY(-3px); }
  .station-summary:hover .station-name { color: var(--station-color); }
}
@keyframes station-arrive { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: translateY(0); } }

.source-note {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-top: 32px;
  padding-top: 24px;
  color: var(--ink-soft);
  border-top: 1px solid var(--line);
  font-size: 13px;
}

.source-note p {
  margin: 0;
}

.source-note a {
  color: var(--ink);
  font-weight: 700;
  text-underline-offset: 3px;
}

.source-dot {
  flex: 0 0 auto;
  width: 9px;
  height: 9px;
  margin-top: 5px;
  background: var(--green);
  border-radius: 50%;
}

@media (max-width: 820px) {
  .hero {
    min-height: 760px;
    background-position: 62% center;
  }

  .hero-shade {
    background: rgba(218, 242, 252, 0.22);
  }

  .topbar-status { gap: 8px; align-items: flex-end; flex-direction: column; padding-block: 10px; }
  .holiday-copy h1 { font-size: 42px; }
  .section-heading h2 { font-size: 32px; }

  .topbar,
  .hero-content,
  .section-heading,
  .holiday-list,
  .source-note {
    width: min(100% - 32px, 680px);
  }

  .music-credit { width: min(100% - 32px, 680px); }
  .scene-controls { gap: 4px; }

  .holiday-list {
    grid-template-columns: 1fr;
    gap: 0;
  }

  .holiday-station { position: relative; padding-left: 44px; padding-bottom: 24px; }
  .holiday-station::before { content: ''; position: absolute; width: 3px; top: 20px; bottom: 0; left: 8px; background: #b6cbbb; }
  .holiday-station:last-child::before { bottom: 28px; }
  .station-stop { position: absolute; left: 0; top: 20px; flex-direction: column; gap: 4px; }
  .station-stop::before { display: none; }
  .station-number { padding: 3px 0; font-size: 10px; }
  .station-details { margin-right: 0; }
  .station-summary { padding-top: 12px; }
  .station-range { min-height: 0; }
  .station-name { margin-top: 12px; }
  .station-arriving .station-details { animation-delay: 0ms; }

  .countdown-lockup {
    grid-template-columns: 164px minmax(0, 1fr);
  }

  .clock-face {
    grid-template-columns: minmax(0, 1fr) 16px minmax(0, 1fr) 16px minmax(0, 1fr);
    padding: 18px 0 18px 20px;
  }

  .time-part strong {
    font-size: 52px;
  }

  .days-ticket strong {
    font-size: 96px;
  }

  .image-credit {
    display: none;
  }
}

@media (max-width: 520px) {
  .hero {
    min-height: 700px;
  }

  .topbar {
    min-height: 68px;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    column-gap: 12px;
  }

  .topbar-status { display: contents; }
  .topbar .today { grid-column: 1 / -1; grid-row: 2; text-align: left; padding-bottom: 10px; }
  .scene-controls { grid-column: 2; grid-row: 1; justify-content: flex-end; }
  #music-volume { width: 48px; }

  .today {
    font-size: 11px;
  }

  .hero-content {
    padding-top: 42px;
    padding-bottom: 72px;
  }

  .countdown-lockup {
    grid-template-columns: 122px minmax(0, 1fr);
    min-height: 104px;
    width: 100%;
  }

  .days-ticket {
    gap: 4px;
    padding: 8px 8px 8px 0;
  }

  .days-ticket strong {
    font-size: 86px;
  }

  .days-ticket span {
    font-size: 13px;
  }

  .clock-face {
    grid-template-columns: minmax(0, 1fr) 9px minmax(0, 1fr) 9px minmax(0, 1fr);
    padding: 12px 0 12px 10px;
  }

  .time-part {
    gap: 2px;
  }

  .time-part strong {
    font-size: 30px;
  }

  .time-part span {
    font-size: 11px;
  }

  .time-divider {
    font-size: 20px;
  }

  .day-strip {
    width: 100%;
  }

  .day-chip {
    flex: 0 0 44px;
    min-width: 44px;
    min-height: 66px;
  }

  .scroll-button {
    margin-top: 26px;
  }

  .holiday-copy h1 { font-size: 34px; }
  .holiday-dates { font-size: 16px; }
  .holiday-now > strong { font-size: 62px; }
  .holiday-now { min-height: 124px; }
  .section-heading h2 { font-size: 26px; }

  .upcoming {
    padding-top: 54px;
  }

  .section-heading {
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 12px;
  }

  .station-date > strong { font-size: 38px; }
  .station-length { width: 62px; height: 62px; }
  .station-summary { grid-template-columns: minmax(0, 1fr) 62px; }
  .station-name { font-size: 22px; }
  .year-badge { font-size: 13px; }
}

@media (max-width: 370px) {
  .countdown-lockup { grid-template-columns: 106px minmax(0, 1fr); }
  .days-ticket strong { font-size: 72px; }
  .time-part strong { font-size: 24px; }
  .clock-face { padding-left: 5px; }
  .holiday-copy h1 { font-size: 30px; }
  .brand { font-size: 14px; gap: 8px; }
}

@keyframes cloud-drift { from { transform: translateX(-40%); } to { transform: translateX(40%); } }
@keyframes train-journey { from { transform: translateX(-110%); } to { transform: translateX(170%); } }

@keyframes digit-tick {
  0% {
    opacity: 0.35;
    transform: translateY(-8px) scale(1.06);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes timer-arrive {
  0% {
    opacity: 0;
    transform: translateY(18px) scale(0.98);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes chip-arrive {
  0% {
    opacity: 0;
    transform: translateY(14px) rotate(2deg);
  }
  100% {
    opacity: 1;
    transform: translateY(0) rotate(0);
  }
}

@keyframes live-pulse {
  0%,
  45% {
    box-shadow: 0 0 0 2px var(--red);
  }
  100% {
    box-shadow: 0 0 0 9px rgba(233, 79, 69, 0);
  }
}

@keyframes landscape-drift {
  from {
    background-position: 49% center;
  }
  to {
    background-position: 53% center;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

  .holiday-card,
  .day-chip {
    opacity: 1;
    transform: none;
  }

  .train-runner { animation: none; transform: translateX(20%); }
  .cloud { animation: none; }
}
