/* Create By Fuco, 2017/04/05, For 台北，每位各三列之顯示方式, 應用在 38 吋 LCD 上, 背景顏色加深(因 LCD 亮度不足的情況), 適用於亮 LCD,
       英文方向，太長則會跑馬顯示
 */

/* --- CSS 變數定義 --- */
:root {
  /* 桌面版使用原始設定 */
  --display-rows: 10;
  --font-size-base: clamp(20px, 2.8vw, 52px);
  --font-size-banner: clamp(18px, 2.1vw, 40px);
  --font-size-route: clamp(32px, 4vw, 80px);
  --font-size-route-with-en: clamp(28px, 3.2vw, 56px);
  --font-size-route-en: clamp(16px, 1.8vw, 28px);
  --font-size-dest: clamp(26px, 3vw, 42px);
  --font-size-dest-en: clamp(18px, 2.3vw, 36px);
  --font-size-est: clamp(30px, 4.2vw, 80px);
  --font-size-est-en: clamp(16px, 1.6vw, 28px);
  --font-size-est-special: clamp(24px, 3.2vw, 52px);
  --font-size-dest-to: clamp(14px, 1.4vw, 24px);
  --font-size-dest-zh: clamp(20px, 2.8vw, 42px);
  --font-size-est-unit: clamp(16px, 2vw, 30px);
  --font-size-est-min: clamp(14px, 1.8vw, 28px);
  --td-height: 128px;
  --border-spacing: 0px;
  --station-title-height: 120px;
  --font-size-station-name: clamp(30px, 3.6vw, 60px);
}

/* --- 響應式斷點 --- */

/* 大桌面斷點 (≤ 1600px) */
@media (max-width: 1600px) {
  :root {
    --display-rows: 10;
    /* 大桌面顯示10筆 */
    --td-height: 110px;
    /* 大桌面適中 */
    --border-spacing: 0px;
    /* 大桌面適中 */
    --station-title-height: 100px;
    --font-size-station-name: clamp(28px, 3.4vw, 52px);
  }
}

/* 新增：中等桌面斷點 (≤ 1200px) */
@media (max-width: 1200px) {
  :root {
    --display-rows: 10;
    --td-height: 100px;
    --border-spacing: 0px;
    --station-title-height: 90px;
    --font-size-station-name: clamp(26px, 3.2vw, 46px);
  }
}

/* 新增：平板斷點 (≤ 992px) */
@media (max-width: 992px) {
  :root {
    --display-rows: 8;
    --td-height: 90px;
    --border-spacing: 0px;
    --station-title-height: 85px;
    --font-size-station-name: clamp(24px, 3vw, 42px);
  }
}

/* 筆電螢幕斷點 (≤ 768px) */
@media (max-width: 768px) {
  :root {
    --display-rows: 8;
    --td-height: auto;
    --border-spacing: 0px;
    --station-title-height: 80px;
    --font-size-station-name: clamp(22px, 2.8vw, 38px);
    /* Increase special status font size for single column */
    --font-size-est-special: clamp(40px, 9vw, 80px);
    --font-size-est-en: clamp(24px, 5vw, 50px);
  }
}

/* 更小尺寸斷點 (≤ 480px) */
@media (max-width: 480px) {
  :root {
    --display-rows: 6;
    --td-height: auto;
    --border-spacing: 0px;
    --station-title-height: 60px;
    --font-size-station-name: clamp(18px, 2.4vw, 32px);
  }
}

/* --- 新增：直立式螢幕專用設定 (Portrait) --- */
/* 強制覆蓋上面的寬度設定，確保直立時字體夠大 */
@media (orientation: portrait) {
  :root {
    /* 直立時通常顯示較少筆數，或維持 8-10 筆但字體要大 */
    --display-rows: 10;

    /* 改用較大的 vw 比例 (因為 width 變窄了) 或直接用 vh/vmin */
    /* 這裡大幅增加 vw 係數，讓文字填滿寬度 */
    --font-size-base: clamp(24px, 4.5vw, 60px);
    --font-size-banner: clamp(20px, 4vw, 48px);

    /* 路線編號要很大 */
    --font-size-route: clamp(40px, 8vw, 100px);
    --font-size-route-with-en: clamp(32px, 6vw, 80px);
    --font-size-route-en: clamp(20px, 3.5vw, 40px);

    /* 目的地中文 */
    --font-size-dest: clamp(30px, 5.5vw, 70px);
    --font-size-dest-en: clamp(20px, 3.5vw, 40px);

    /* 預估時間 */
    --font-size-est: clamp(36px, 7vw, 90px);
    --font-size-est-en: clamp(18px, 3vw, 36px);
    --font-size-est-special: clamp(28px, 5vw, 60px);

    /* 其他細項 */
    --font-size-dest-to: clamp(16px, 2.5vw, 30px);
    --font-size-dest-zh: clamp(24px, 5vw, 60px);
    --font-size-est-unit: clamp(20px, 3.5vw, 40px);
    --font-size-est-min: clamp(18px, 3vw, 36px);

    /* 版面高度調整 */
    --td-height: auto;
    /* 讓內容撐開，或設一個較大的固定值 */
    --station-title-height: 100px;
    /* 標題區高度 */
    --font-size-station-name: clamp(32px, 6vw, 80px);
  }
}

/* --- 基礎樣式 --- */
html,
body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

body {
  font-size: var(--font-size-base);
  font-family: Helvetica, 'Microsoft JhengHei';
  background: #0d0d0d;
  /* background-image: url(../images/bg_aptg_01.png); */
  overflow: hidden;
}

/* --- 頂部站名標題樣式 --- */
#station-name-title {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--station-title-height);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  font-family: 'Microsoft JhengHei', sans-serif;
  font-weight: bold;
  font-size: var(--font-size-station-name);
  text-align: center;
  color: white;
  background: rgb(0, 104, 183);
  gap: 20px;
}

/* 筆電螢幕斷點 (≤ 1600px) */
@media (max-width: 1600px) {
  #station-name-title {
    gap: 15px;
  }
}

/* 手機版斷點 (≤ 768px) */
@media (max-width: 768px) {
  #station-name-title {
    gap: 12px;
  }
}

/* 更小尺寸斷點 (≤ 480px) */
@media (max-width: 480px) {
  #station-name-title {
    gap: 10px;
  }
}

/* Logo 樣式 */
.station-logo {
  height: 80px;
  width: auto;
  object-fit: contain;
}

/* 筆電螢幕斷點 (≤ 1600px) */
@media (max-width: 1600px) {
  .station-logo {
    height: 60px;
  }
}

/* 手機版斷點 (≤ 768px) */
@media (max-width: 768px) {
  .station-logo {
    height: 40px;
  }
}

/* 更小尺寸斷點 (≤ 480px) */
@media (max-width: 480px) {
  .station-logo {
    height: 30px;
  }
}

/* 站名文字樣式 */
.station-name-text {
  display: inline-block;
}

/* --- 左上角隱藏熱區 --- */
#settingsHotspot {
  position: fixed;
  top: 0;
  left: 0;
  width: 100px;
  height: 100px;
  z-index: 9999;
  /* 讓它可點，但不顯眼 */
  background: transparent;
}

#settingsHotspot .settings-btn {
  position: absolute;
  top: 8px;
  left: 8px;
  padding: 20px 10px;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  font-size: 24px;
  line-height: 1;
  width: 110px;
  background: #222;
  color: #fff;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease;
}

#settingsHotspot:hover .settings-btn,
#settingsHotspot:focus-within .settings-btn {
  opacity: .9;
  pointer-events: auto;
}

#settingsHotspot .settings-btn:hover {
  opacity: 1;
}

/* --- Modal 遮罩與框 --- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .4);
  display: none;
  z-index: 10000;
}

.modal {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: min(1200px, 92vw);
  max-height: 90vh;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, .35);
  display: none;
  z-index: 10001;
  overflow: hidden;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans TC", Arial, sans-serif;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 16px;
  background: #4672d9;
  color: #fff;
}

.modal-title {
  font-size: 24px;
  font-weight: 600;
}

.modal-close {
  border: none;
  background: transparent;
  color: #fff;
  font-size: 26px;
  cursor: pointer;
}

.modal-body {
  padding: 8px;
  overflow-y: auto;
  max-height: calc(90vh - 120px);
  /* 減去 header 和 footer 的高度 */
}

.search-row {
  display: flex;
  gap: 8px;
}

.search-row input {
  flex: 1;
  padding: 10px 12px;
  font-size: 26px;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  outline: none;
}

.search-row button {
  padding: 10px 14px;
  border: none;
  border-radius: 8px;
  background: #2563eb;
  color: #fff;
  cursor: pointer;
  font-size: 20px;
}

.help-text {
  font-size: 20px;
  color: #6b7280;
  margin-top: 6px;
}

.results {
  margin-top: 12px;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  max-height: 200px;
  overflow: auto;
}

.result-item {
  padding: 10px 12px;
  cursor: pointer;
  display: flex;
  gap: 8px;
  align-items: baseline;
}

.result-item:hover {
  background: #f1f5f9;
}

.result-item .name {
  font-weight: 600;
  font-size: 20px;
}

.result-item .meta {
  font-size: 16px;
  color: #6b7280;
}

.empty,
.error {
  padding: 12px;
  color: #6b7280;
  font-size: 20px;
}

.loading {
  padding: 12px;
  color: #111827;
  font-size: 20px;
}

.kbd {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  background: #f3f4f6;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  padding: 1px 6px;
}

.lists-container {
  display: flex;
  gap: 16px;
  margin-top: 16px;
}

.list-block {
  flex: 1;
  border: 1px solid #ddd;
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
  display: flex;
  flex-direction: column;
}

.list-block .title {
  padding: 6px;
  font-weight: bold;
  background: #f9fafb;
  border-bottom: 1px solid #ddd;
  font-size: 20px;
}

.route-list {
  flex: 1;
  overflow-y: auto;
  max-height: 240px;
  padding: 6px;
}

.route-item {
  padding: 6px 8px;
  cursor: pointer;
  border-bottom: 1px solid #f1f5f9;
  font-size: 20px;
}

.route-item:hover {
  background: #f1f5f9;
}

#selectedItems {
  flex: 1;
  overflow-y: auto;
  max-height: 240px;
  padding: 6px;
  margin: 0;
  list-style: none;
}

#selectedItems li {
  padding: 6px 8px;
  border-bottom: 1px solid #f1f5f9;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 20px;
}

#selectedItems .remove-item {
  margin-left: 8px;
  padding: 2px 6px;
  border: none;
  background: #dc2626;
  color: #fff;
  border-radius: 4px;
  cursor: pointer;
}

.save-btn {
  margin-top: 12px;
  padding: 10px 14px;
  background: #16a34a;
  color: #fff;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  width: 100%;
  font-size: 20px;
}

.save-btn:hover {
  background: #15803d;
}

.modal-footer {
  display: flex;
  justify-content: space-between;
  /* 左右貼齊 */
  margin-top: 12px;
}

.modal-footer button {
  padding: 10px 14px;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-size: 20px;
}

#btnAddAll {
  background: #2563eb;
  color: #fff;
}

#btnAddAll:hover {
  background: #1d4ed8;
}

#btnSave {
  background: #16a34a;
  color: #fff;
}

#btnSave:hover {
  background: #15803d;
}

/* --- 響應式 Modal 優化 --- */
@media (max-width: 480px) {
  .modal {
    max-height: 95vh;
    top: 2.5vh;
    transform: translate(-50%, 0);
  }

  .modal-body {
    max-height: calc(95vh - 100px);
    overflow-y: auto;
  }
}



/* --- Banner 樣式 --- */
.banner {
  margin: 0 auto;
  display: inline;
  position: absolute;
  top: 0px;
  left: 0px;
  width: 100%;
  height: 114px;
  color: #FFFFFF;
  background: #CC4E00;
  border: 0px solid red;
}

.banner span {
  display: inline-block;
  line-height: 112px;
  /* 不加 span 不會垂直置中 */
  font-family: Helvetica, 'Microsoft JhengHei';
  font-size: var(--font-size-banner);
  vertical-align: middle;
  border: 0px solid blue;
}

.banner img {
  width: 100px;
}

.weather-location {
  font-weight: normal;
}

.weather-icon {
  text-align: center;
}

.weather-temp {
  width: 130px;
  font-weight: bold;
}

.timer {
  width: 400px;
  float: right;
  text-align: center;
}

/* --- 路線顯示區域 (Grid Layout) --- */
#route {
  width: 100%;
  height: calc(100% - var(--station-title-height));
  overflow: hidden;
  position: absolute;
  top: var(--station-title-height);
  left: 0;
  /* Use Flexbox to stack pages and pagination vertically */
  display: flex;
  flex-direction: column;
}

.route-pages-container {
  width: 100%;
  /* height: 100%; Removed to allow flex to control height */
  flex: 1;
  /* Take remaining space */
  position: relative;
  overflow: hidden;
  /* Keep content inside */
}

.route-page {
  width: 100%;
  height: 100%;
  display: none;
  position: absolute;
  top: 0;
  left: 0;
}

.grid-container {
  display: grid;
  width: 100%;
  grid-template-columns: 1fr 1fr;
  /* Desktop: Double Column */
  column-gap: 0;
  /* Removed gap, using border instead */
  padding: 0;
  box-sizing: border-box;
  align-content: start;
}

.grid-row {
  display: grid;
  grid-template-columns: 3fr 4fr 3fr;
  /* Route | Dest | Est */
  align-items: center;
  border-bottom: 2px solid #323333;
  height: var(--td-height);
  color: #fff;
  box-sizing: border-box;
}

/* Add divider for left column items in double-column layout */
.grid-container .grid-row:nth-child(odd) {
  border-right: 10px solid #323333;
}

/* Grid Cell Styles */
.cell-route {
  text-align: center;
  font-size: var(--font-size-route);
  border-right: 4px solid white;
  padding: 0 5px;
  /* Reduced vertical padding, added horizontal */
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  overflow: hidden;
  /* Prevent overflow */
  line-height: 1.2;
  /* Tighter line height */
}

.cell-dest {
  text-align: left;
  font-size: var(--font-size-dest);
  padding-left: 12px;
  overflow: hidden;
  white-space: nowrap;
  height: 100%;
  display: flex;
  align-items: center;
  position: relative;
  /* For z-index */
  z-index: 1;
  /* Lower than est */
}

.cell-est {
  text-align: center;
  font-size: var(--font-size-est);
  font-weight: bold;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: row;
  /* Changed to row to put number and units side-by-side */
  overflow: hidden;
  /* Prevent overflow */
  position: relative;
  /* For z-index */
  z-index: 2;
  /* Higher than dest to cover marquee if it overlaps */
}

/* Mobile / Single Column Layout */
@media (max-width: 768px) {
  .grid-container {
    grid-template-columns: 1fr;
    column-gap: 0;
  }

  .grid-row {
    grid-template-columns: 25% 50% 25%;
    border-bottom: 1px solid #323333;
  }

  /* Remove divider for mobile */
  .grid-container .grid-row:nth-child(odd) {
    border-right: none;
  }

  .cell-route {
    border-right: none;
    width: 100%;
  }

  .cell-dest {
    width: 100%;
  }

  .cell-est {
    width: 100%;
  }
}

/* Small Screen Scrolling Support */
@media (max-width: 480px) {
  .route-pages-container {
    overflow-y: auto;
    overflow-x: hidden;
  }

  .route-page {
    position: static;
    display: block !important;
    height: auto;
  }

  #routePaging {
    display: none;
  }
}

/* --- 分頁元件 --- */
#routePaging {
  margin: 20px auto 0;
  /* 上方間距 20px，水平置中 */
  display: block;
  /* 改為 block 顯示 */
  position: relative;
  /* 改為相對定位 */
  width: 100%;
  height: 30px;
  text-align: center;
  border: 0px solid red;
  z-index: 10;
  /* Ensure it's above other elements */
}

/* --- 不同斷點的分頁點點樣式調整 --- */
@media (max-width: 1600px) {
  #routePaging {
    margin: 18px auto 0;
    /* 大桌面版間距適中 */
  }
}

@media (max-width: 1200px) {
  #routePaging {
    margin: 16px auto 0;
    /* 中等桌面版間距適中 */
  }
}

@media (max-width: 992px) {
  #routePaging {
    margin: 15px auto 0;
    /* 平板版間距適中 */
  }
}

@media (max-width: 768px) {
  #routePaging {
    margin: 15px auto 0;
    /* 手機版間距稍小 */
  }
}

#routePaging span {
  display: inline-block;
  line-height: 20px;
  /* 不加 span 不會垂直置中 */
  vertical-align: middle;
  width: 25px;
  height: 25px;
  margin: 2px 8px 0 8px;
  border-radius: 99em;
  box-shadow: 0 2px 3px #000 inset;
}

.gray {
  background-color: #323333;
  /* Paging 預設顏色 #616161 */
}

.white {
  background-color: #FFFFFF;
}

/* Removed obsolete table styles */

/* 預估時間的有分離數字 */
.divTable {
  display: inline-table;
  vertical-align: middle;
}

.divRow {
  display: table-row;
  line-height: normal;
  /* Allow natural height */
}

/* 預估時間的"分" */
.divTd1 {
  display: table-cell;
  text-align: left;
  padding-left: 10px;
  font-size: var(--font-size-est-unit);
}

/* 預估時間的"min" font-family: Verdana  */
.divTd2 {
  display: table-cell;
  text-align: left;
  padding-left: 10px;
  font-size: var(--font-size-est-min);
  font-family: Arial;
}

/* --- 新增：取代 inline-style 的 class 樣式 --- */
/* 特殊狀態時間樣式 */
.est-special {
  display: inline-block;
  font-size: var(--font-size-est-special);
  font-weight: normal;
  max-width: 100%;
  white-space: nowrap;
  /* Prevent wrapping like "即將進" "站" */
}

/* Container for special status to stack text vertically */
.est-status-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
}

/* 英文時間樣式 */
.est-en {
  display: inline-block;
  font-size: var(--font-size-est-en);
  max-width: 100%;
}

/* 時間間距 */
.est-spacer {
  height: 10px;
  width: 1px;
}

/* 發車時間樣式 */
.est-time {
  font-size: clamp(24px, 3.5vw, var(--font-size-est));
  font-weight: bold;
  line-height: 68px;
}

/* 路線中文樣式 */
.route-zh {
  font-size: var(--font-size-route-with-en);
}

/* 路線英文樣式 */
.route-en {
  font-size: var(--font-size-route-en);
}

.divRowDest {
  display: table-row;
}

/* 方向的 "往" 及 "To" */
.divTdTo {
  display: table-cell;
  vertical-align: middle;
  padding-right: 8px;
  font-size: var(--font-size-dest-to);
}

/* 中文方向 */
.divTdDestZh {
  display: table-cell;
  vertical-align: middle;
  font-size: var(--font-size-dest-zh);
}

/* 英文方向 */
.divTdDestEn {
  display: table-cell;
  font-size: var(--font-size-dest-en);
}

/* 英文方向跑馬燈 */
.divTdDestEnScrollBoundary {
  display: table-cell;
  padding-left: 0px;
  width: 100%;
  max-width: 100%;
  overflow: hidden;
  vertical-align: middle;
}

.divTdDestEnScroll {
  display: inline-block;
  font-size: var(--font-size-dest-en);
  white-space: nowrap;
  padding-right: 50px;
  will-change: transform;
  animation: scroll-left 10s linear 1s infinite;
}

/* 中文方向跑馬燈 */
.divTdDestZhScrollBoundary {
  display: table-cell;
  padding-left: 0px;
  width: 100%;
  max-width: 100%;
  overflow: hidden;
  vertical-align: middle;
}

.divTdDestZhScroll {
  display: inline-block;
  font-size: var(--font-size-dest-zh);
  white-space: nowrap;
  padding-right: 50px;
  will-change: transform;
  animation: scroll-left 12s linear 1s infinite;
}

/* --- 長英文目的地換行/縮小邏輯 --- */
/* 小螢幕時，調整跑馬燈速度 */
@media (max-width: 1200px) {
  .divTdDestEnScroll {
    animation-duration: 8s;
  }
}

@media (max-width: 992px) {
  .divTdDestEnScroll {
    animation-duration: 7s;
  }
}

@media (max-width: 768px) {
  .divTdDestEnScroll.mobile {
    display: inline-block;
    animation: scroll-left 6s linear 1s infinite;
    white-space: nowrap;
    will-change: transform;
  }

  .divTdDestZhScroll.mobile {
    display: inline-block;
    animation: scroll-left 6s linear 1s infinite;
    white-space: nowrap;
    will-change: transform;
  }
}

@media (max-width: 480px) {
  .divTdDestEnScroll.mobile {
    animation-duration: 5s;
  }

  .divTdDestZhScroll.mobile {
    animation-duration: 5s;
  }
}

/* --- 動畫定義 --- */
@keyframes scroll-left {
  0% {
    transform: translateX(0%);
    -moz-transform: translateX(0%);
    -webkit-transform: translateX(0%);
  }

  100% {
    transform: translateX(-60%);
    -moz-transform: translateX(-60%);
    -webkit-transform: translateX(-60%);
  }
}

@-moz-keyframes scroll-left {
  0% {
    transform: translateX(0%);
    -moz-transform: translateX(0%);
    -webkit-transform: translateX(0%);
  }

  100% {
    -moz-transform: translateX(-60%);
  }
}

@-webkit-keyframes scroll-left {
  0% {
    transform: translateX(0%);
    -moz-transform: translateX(0%);
    -webkit-transform: translateX(0%);
  }

  100% {
    transform: translateX(-60%);
    -moz-transform: translateX(-60%);
    -webkit-transform: translateX(-60%);
  }
}

@keyframes glow {
  0% {
    border-color: #393;
    box-shadow: 0 0 5px rgba(0, 255, 0, .2), inset 0 0 5px rgba(0, 255, 0, .1), 0 2px 0 #000;
  }

  100% {
    border-color: #6f6;
    box-shadow: 0 0 20px rgba(0, 255, 0, .6), inset 0 0 10px rgba(0, 255, 0, .4), 0 2px 0 #000;
  }
}

/* --- State-Driven Layout Overrides (Added by Senior Engineer) --- */
/* 這些樣式由 JS 的 body class 強制驅動，不再依賴 Media Query 猜測 */

/* 1. 單欄模式 (手機 / 直立看板 / 窄螢幕) */
body.layout-single-col {
  /* 強制單欄變數設定 */
  --display-rows: 8;
  /* 直立通常顯示 8 筆 */

  /* 字體放大 (因為只有一欄，空間很大) */
  --font-size-base: clamp(24px, 4.5vw, 60px);
  --font-size-route: clamp(40px, 9vw, 110px);
  /* 路線編號特大 */
  --font-size-route-with-en: clamp(32px, 5.5vw, 90px);
  --font-size-route-en: clamp(20px, 4vw, 50px);

  --font-size-dest: clamp(30px, 6vw, 80px);
  /* 目的地大 */
  --font-size-dest-en: clamp(20px, 4vw, 50px);

  --font-size-est: clamp(36px, 8vw, 100px);
  /* 時間大 */
  --font-size-est-special: clamp(24px, 4.5vw, 60px);
  --font-size-est-en: clamp(18px, 3.5vw, 40px);
}

body.layout-single-col .grid-container {
  grid-template-columns: 1fr;
  /* 強制單欄 */
}

body.layout-single-col .grid-row {
  grid-template-columns: 25% 50% 25%;
  /* 調整單欄比例 */
}

body.layout-single-col .grid-container .grid-row:nth-child(odd) {
  border-right: none;
  /* 移除中間分隔線 */
}

body.layout-single-col .cell-route {
  border-right: none;
}

/* 2. 雙欄模式 (寬螢幕 / 電視牆) */
body.layout-double-col {
  /* 強制雙欄變數設定 */
  --display-rows: 12;
  /* 雙欄顯示 12 筆 */

  /* 字體縮小 (適應半寬欄位) */
  --font-size-base: clamp(16px, 1.5vw, 32px);
  --font-size-route: clamp(24px, 3vw, 60px);
  /* 路線編號適中 */
  --font-size-route-with-en: clamp(20px, 2.5vw, 48px);
  --font-size-route-en: clamp(14px, 1.5vw, 24px);

  --font-size-dest: clamp(20px, 2.2vw, 40px);
  /* 目的地適中 */
  --font-size-dest-en: clamp(14px, 1.6vw, 28px);

  --font-size-est: clamp(24px, 3vw, 60px);
  /* 時間適中 */
  --font-size-est-special: clamp(20px, 2.5vw, 40px);
  --font-size-est-en: clamp(12px, 1.2vw, 24px);
}

body.layout-double-col .grid-container {
  grid-template-columns: 1fr 1fr;
  /* 強制雙欄 */
}

body.layout-double-col .grid-row {
  grid-template-columns: 3fr 4fr 3fr;
  /* 恢復雙欄比例 */
}

body.layout-double-col .grid-container .grid-row:nth-child(odd) {
  border-right: 10px solid #323333;
  /* 恢復分隔線 */
}

body.layout-double-col .cell-route {
  border-right: 4px solid white;
}

/* 3. 跑馬燈 RWD 優化 (綁定單欄模式) */
/* 無論螢幕寬度多少，只要是單欄模式，就使用較快的跑馬燈速度與正確的顯示方式 */
body.layout-single-col .divTdDestEnScroll,
body.layout-single-col .divTdDestZhScroll {
  display: inline-block;
  white-space: nowrap;
  will-change: transform;
  animation: scroll-left 6s linear 1s infinite;
  /* 確保覆蓋原本的設定 */
  animation-duration: 6s;
}