/* =========================================================
   高速あと何分 — 第一段階スタイル
   緑基調・高速道路標識風 / スマホ縦画面前提
   ========================================================= */

:root {
  --header-bg: #17613f;
  --header-bg-2: #134d31;
  --card-green-1: #1d6642;
  --card-green-2: #123f28;
  --badge-green: #1e7146;
  --num-green: #176b41;
  --accent-green: #2f8a5c;
  --bg: #ebeeec;
  --card-bg: #ffffff;
  --ink: #1f2422;
  --muted: #6f7d75;
  --line: #e6eae7;
  --note-bg: #e7f1ea;

  --radius-lg: 22px;
  --radius-md: 16px;
  --shadow-card: 0 6px 18px rgba(20, 60, 40, 0.10);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  background: #d7dcd8;
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans",
    "Hiragino Kaku Gothic ProN", "Noto Sans JP", "Yu Gothic", Meiryo, sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* ---- アプリ枠（スマホ幅・中央寄せ） ---- */
.app {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 480px;
  height: 100vh;
  height: 100dvh;
  margin: 0 auto;
  background: var(--bg);
  overflow: hidden;
  box-shadow: 0 0 40px rgba(0, 0, 0, 0.12);
}

/* =========================================================
   1. ヘッダー
   ========================================================= */
.header {
  flex: 0 0 auto;
  background: linear-gradient(160deg, var(--header-bg), var(--header-bg-2));
  color: #fff;
  padding: max(14px, env(safe-area-inset-top)) 20px 22px;
  border-radius: 0 0 26px 26px;
}

.header-main {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  flex: 0 0 auto;
  width: 46px;
  height: 54px;
  color: #fff;
  display: block;
}
.brand-mark svg { width: 100%; height: 100%; display: block; }

.brand-text { flex: 1 1 auto; min-width: 0; }

.brand-title {
  margin: 0;
  font-size: 34px;
  font-weight: 800;
  letter-spacing: 0.02em;
  line-height: 1.05;
}

.brand-sub {
  margin: 4px 0 0;
  font-size: 13px;
  font-weight: 600;
  opacity: 0.92;
}

.header-settings {
  flex: 0 0 auto;
  width: 38px;
  height: 38px;
  padding: 7px;
  border: none;
  background: transparent;
  color: #fff;
  cursor: pointer;
  opacity: 0.95;
}
.header-settings svg { width: 100%; height: 100%; display: block; }

/* =========================================================
   スクロール領域
   ========================================================= */
.scroll {
  flex: 1 1 auto;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 16px 16px 20px;
  margin-top: -10px;
}

.error-box {
  margin: 0 0 14px;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  background: #fdecea;
  color: #9b1c1c;
  font-size: 14px;
  font-weight: 600;
}

/* =========================================================
   2. 現在走行情報カード
   ========================================================= */
.info-card {
  background: var(--card-bg);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: 16px 18px;
  margin-bottom: 16px;
}

.info-top {
  display: flex;
  align-items: stretch;
  gap: 14px;
}

.info-left {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 10px;
  min-width: 0;
}

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

.route-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 46px;
  padding: 4px 8px;
  background: var(--badge-green);
  color: #fff;
  font-weight: 800;
  font-size: 18px;
  border-radius: 8px;
  border: 2px solid #fff;
  box-shadow: 0 0 0 2px var(--badge-green);
}

.route-name {
  font-size: 21px;
  font-weight: 800;
  color: var(--ink);
  white-space: nowrap;
}

.direction-row { display: flex; align-items: center; gap: 8px; }

.dir-arrow {
  width: 26px;
  height: 26px;
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--badge-green);
  border-radius: 50%;
  color: var(--badge-green);
  padding: 3px;
}
.dir-arrow svg { width: 100%; height: 100%; }

.direction-label {
  font-size: 18px;
  font-weight: 700;
  color: var(--ink);
}

.info-divider {
  flex: 0 0 auto;
  width: 1px;
  background: var(--line);
  align-self: stretch;
}

.info-right {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 9px;
}

.info-stat { display: flex; align-items: center; gap: 8px; }

.info-ic {
  width: 19px;
  height: 19px;
  flex: 0 0 auto;
  color: var(--badge-green);
  display: inline-flex;
}
.info-ic svg { width: 100%; height: 100%; }

.info-text {
  font-size: 14px;
  color: var(--muted);
  font-weight: 600;
  white-space: nowrap;
}
.info-text b {
  font-size: 18px;
  color: var(--ink);
  font-weight: 800;
}
.info-unit { font-size: 12px; }

#infoGps { color: var(--badge-green); }

.info-note {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  margin-top: 14px;
  padding: 9px 12px;
  background: var(--note-bg);
  border-radius: 12px;
  color: #2c6045;
  font-size: 14px;
  font-weight: 700;
}
.note-ic { width: 18px; height: 18px; display: inline-flex; }
.note-ic svg { width: 100%; height: 100%; }

/* =========================================================
   3. 次の施設 大型カード
   ========================================================= */
.next-card {
  position: relative;
  overflow: hidden;
  background: linear-gradient(155deg, var(--card-green-1), var(--card-green-2));
  border-radius: var(--radius-lg);
  box-shadow: 0 8px 22px rgba(16, 56, 36, 0.28);
  padding: 16px 20px 20px;
  color: #fff;
  margin-bottom: 18px;
}

.next-tag {
  display: inline-block;
  padding: 5px 14px;
  background: rgba(255, 255, 255, 0.16);
  border-radius: 999px;
  font-size: 14px;
  font-weight: 700;
  margin-bottom: 12px;
}

.next-head {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  z-index: 1;
}

.next-icon {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 50px;
  height: 50px;
  padding: 0 10px;
  border: 3px solid #fff;
  border-radius: 12px;
  font-size: 26px;
  font-weight: 800;
}

.next-name {
  font-size: 44px;
  font-weight: 800;
  line-height: 1.0;
  letter-spacing: 0.01em;
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

.next-deco {
  position: absolute;
  top: -6px;
  right: -8px;
  width: 150px;
  height: 70px;
  z-index: 0;
  opacity: 0.9;
  pointer-events: none;
}

.next-line {
  height: 2px;
  background: rgba(255, 255, 255, 0.28);
  margin: 14px 0 12px;
  border-radius: 2px;
}

.next-stats {
  display: flex;
  align-items: flex-end;
}

.next-stat {
  flex: 1 1 0;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  min-width: 0;
}
.next-stat.time { padding-left: 18px; }

.next-stat .lbl {
  font-size: 18px;
  font-weight: 700;
  opacity: 0.92;
  margin-bottom: -2px;
}

.next-stat .big {
  font-size: 56px;
  font-weight: 800;
  line-height: 1.0;
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.18);
}
.next-stat .big .unit {
  font-size: 24px;
  font-weight: 700;
  margin-left: 2px;
}

.next-stat .arrive {
  margin-top: 6px;
  font-size: 17px;
  font-weight: 700;
  opacity: 0.95;
}

.next-vline {
  flex: 0 0 auto;
  width: 2px;
  align-self: stretch;
  background: rgba(255, 255, 255, 0.28);
  margin: 4px 0;
}

.next-empty {
  font-size: 16px;
  font-weight: 700;
  padding: 8px 0 4px;
}

/* =========================================================
   4. この先の施設一覧
   ========================================================= */
.list-heading {
  margin: 4px 4px 10px;
  font-size: 14px;
  font-weight: 700;
  color: var(--muted);
}

.facility-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.fac-item {
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr) auto auto 14px;
  align-items: center;
  gap: 12px;
  background: var(--card-bg);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-card);
  padding: 14px 14px;
}

.fac-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 46px;
  height: 46px;
  background: var(--badge-green);
  color: #fff;
  font-size: 15px;
  font-weight: 800;
  border-radius: 12px;
}

.fac-name {
  font-size: 21px;
  font-weight: 800;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.fac-dist, .fac-time {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  line-height: 1.05;
}
.fac-time { align-items: flex-end; }

.fac-dist .lbl, .fac-time .lbl {
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
}

.fac-dist .val, .fac-time .val {
  font-size: 26px;
  font-weight: 800;
  color: var(--num-green);
}
.fac-dist .val .unit, .fac-time .val .unit {
  font-size: 14px;
  font-weight: 700;
  margin-left: 1px;
}

.fac-time .arrive {
  margin-top: 3px;
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
}

.fac-chevron {
  width: 14px;
  height: 22px;
  color: #b9c2bc;
  display: inline-flex;
}
.fac-chevron svg { width: 100%; height: 100%; }

.list-empty {
  padding: 18px;
  text-align: center;
  color: var(--muted);
  font-weight: 700;
}

.list-end {
  margin: 6px 2px 2px;
  text-align: center;
  font-size: 12px;
  font-weight: 600;
  color: #9aa8a0;
  letter-spacing: 0.02em;
}

/* =========================================================
   5. 速度モード切替
   ========================================================= */
.speed-bar {
  flex: 0 0 auto;
  background: var(--card-bg);
  border-top: 1px solid var(--line);
  padding: 10px 14px calc(10px + env(safe-area-inset-bottom));
  box-shadow: 0 -4px 16px rgba(20, 60, 40, 0.06);
}

.speed-label {
  margin: 0 0 8px 2px;
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
}

.speed-tabs {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  padding-bottom: 2px;
}
.speed-tabs::-webkit-scrollbar { display: none; }

.speed-tab {
  flex: 1 0 auto;
  min-width: 60px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 9px 8px;
  border: none;
  border-radius: 12px;
  background: #f1f4f2;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: background-color 0.15s, color 0.15s;
}

.speed-tab .tab-ic { width: 20px; height: 20px; display: inline-flex; }
.speed-tab .tab-ic svg { width: 100%; height: 100%; }

.speed-tab[aria-selected="true"] {
  background: linear-gradient(160deg, var(--badge-green), var(--card-green-2));
  color: #fff;
  box-shadow: 0 3px 10px rgba(20, 80, 50, 0.3);
}

/* =========================================================
   表示範囲モード
   ========================================================= */
.range-bar { margin: 2px 0 16px; }

.range-label {
  margin: 0 0 8px 2px;
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
}

.range-tabs {
  display: flex;
  gap: 6px;
  padding: 4px;
  background: #e2e7e3;
  border-radius: 14px;
}

.range-tab {
  flex: 1 1 0;
  padding: 10px 6px;
  border: none;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: background-color 0.15s, color 0.15s;
}

.range-tab[aria-selected="true"] {
  background: linear-gradient(160deg, var(--badge-green), var(--card-green-2));
  color: #fff;
  box-shadow: 0 2px 8px rgba(20, 80, 50, 0.25);
}

.range-tab:disabled { opacity: 0.4; cursor: not-allowed; }

/* =========================================================
   長距離見通しカード
   ========================================================= */
.overview-card {
  background: var(--card-bg);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  border-left: 6px solid var(--badge-green);
  padding: 15px 18px;
  margin-bottom: 18px;
}
.overview-card[hidden] { display: none; }

.ov-tag {
  font-size: 13px;
  font-weight: 700;
  color: var(--badge-green);
  margin-bottom: 4px;
}

.ov-name {
  font-size: 24px;
  font-weight: 800;
  color: var(--ink);
  margin-bottom: 12px;
}

.ov-stats {
  display: flex;
  align-items: flex-end;
  gap: 18px;
}

.ov-stat {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  line-height: 1.05;
}

.ov-stat .lbl {
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
}

.ov-stat .val {
  font-size: 26px;
  font-weight: 800;
  color: var(--num-green);
}
.ov-stat .val .unit {
  font-size: 14px;
  font-weight: 700;
  margin-left: 1px;
}
.ov-stat .val.arrive {
  font-size: 18px;
  color: var(--ink);
}

.ov-pending,
.ov-passed {
  margin: 2px 0;
  font-size: 15px;
  font-weight: 700;
  color: var(--muted);
}

@media (max-width: 360px) {
  .brand-title { font-size: 30px; }
  .next-name { font-size: 38px; }
  .next-stat .big { font-size: 48px; }
  .fac-name { font-size: 19px; }
  .ov-stats { gap: 12px; }
  .ov-stat .val { font-size: 22px; }
}

/* 給油ブランド 小チップ（SA/PAのfuelBrands表示） */
.fac-main {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}
.fac-fuels {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
.fuel-chip {
  display: inline-flex;
  align-items: center;
  padding: 1px 6px;
  font-size: 11px;
  font-weight: 700;
  line-height: 1.4;
  color: var(--badge-green);
  background: #eaf3ee;
  border: 1px solid #cfe3d8;
  border-radius: 6px;
  white-space: nowrap;
}
.next-head .fac-fuels {
  margin-left: 6px;
}
