:root {
  --color-primary: #1F4E79;
  --color-accent: #E65100;
  --color-good: #2E7D32;
  --color-warn: #F57F17;
  --color-danger: #C62828;
  --color-env: #4CAF50;
  --color-env-dark: #1B5E20;
  --bg-main: #F5F7FA;
  --bg-panel: #FFFFFF;
  --border-light: #E0E6ED;
  --text-dark: #1A1A1A;
  --text-gray: #666;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.1);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; overflow: hidden; font-family: 'Sarabun', 'Tahoma', system-ui, sans-serif; background: var(--bg-main); color: var(--text-dark); }

body { display: grid; grid-template-rows: 56px 42px 1fr 64px; height: 100vh; }

/* ====== TOP BAR — 3-column grid so brand sits in the CENTER ====== */
.top-bar {
  background: linear-gradient(135deg, var(--color-primary) 0%, #2C5F93 100%);
  color: white; padding: 0 20px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center; gap: 12px;
  box-shadow: var(--shadow-md);
}
.top-bar .brand {
  grid-column: 2;               /* centered in middle column */
  text-align: center;
  display: flex; align-items: center; gap: 10px; justify-content: center;
}
.top-bar .actions {
  grid-column: 3;
  justify-self: end;
}
.top-bar .brand > div { text-align: center; }
.top-bar .brand .title {
  font-size: 19px; font-weight: 800;
  text-shadow: 0 1px 3px rgba(0,0,0,0.3);
  letter-spacing: 0.3px;
}
.top-bar .brand .subtitle {
  font-size: 12px; opacity: 0.9;
}
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand .icon { font-size: 26px; flex-shrink: 0; }
.brand > div { min-width: 0; }
.brand .title { font-size: 16px; font-weight: 700; line-height: 1.2;
                white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand .title .badge {
  background: linear-gradient(135deg, rgba(255,213,79,0.25), rgba(255,255,255,0.15));
  border: 1px solid rgba(255,213,79,0.45);
  padding: 2px 9px; border-radius: 10px;
  font-size: 10.5px; margin-left: 6px; vertical-align: middle;
  font-weight: 600; letter-spacing: 0.2px;
  white-space: nowrap;
}
.brand .subtitle { font-size: 11px; opacity: 0.85; line-height: 1.25;
                   white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.actions { display: flex; gap: 6px; }

.btn-small {
  background: rgba(255,255,255,0.15); color: white; border: 1px solid rgba(255,255,255,0.2);
  padding: 5px 10px; border-radius: 6px; cursor: pointer; font-size: 13px;
  font-family: inherit;
  transition: background 0.2s;
}
.btn-small:hover { background: rgba(255,255,255,0.28); }
.btn-small.off { opacity: 0.5; }

/* ====== RECOMMENDATION BANNER ====== */
.reco-banner {
  background: linear-gradient(135deg, #FFF9C4 0%, #FFE082 100%);
  border-bottom: 2px solid #FFB300;
  padding: 6px 20px; display: flex; justify-content: space-between; align-items: center;
  gap: 20px;
}
.reco-left { display: flex; align-items: center; gap: 12px; }
.reco-trophy { font-size: 24px; }
.reco-title { font-size: 14px; font-weight: 700; color: #6D4C00; }
.reco-title strong { color: var(--color-accent); }
.reco-sub { font-size: 11px; color: #795548; margin-top: 1px; }
.reco-cta {
  background: var(--color-accent); color: white; border: none;
  padding: 8px 16px; border-radius: 20px; font-weight: 700; cursor: pointer;
  font-size: 13px; font-family: inherit;
  transition: all 0.2s;
}
.reco-cta:hover { background: #BF360C; transform: translateY(-1px); }

/* ====== MAIN LAYOUT ====== */
.main-layout {
  display: grid; grid-template-columns: 1fr 360px;
  grid-template-rows: 62px 1fr;
  grid-template-areas: "scenarios panel" "scene panel";
  overflow: hidden;
}

/* ====== SCENARIO BAR ====== */
.scenario-bar {
  grid-area: scenarios;
  display: flex; gap: 8px; padding: 10px 12px; background: var(--bg-panel);
  border-bottom: 1px solid var(--border-light);
}
.scenario-btn {
  flex: 1; background: #F8F9FA; border: 2px solid var(--border-light);
  border-radius: 8px; padding: 6px 10px; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 1px;
  transition: all 0.2s; font-family: inherit;
}
.scenario-btn:hover { background: #E8F4FD; border-color: var(--color-primary); }
.scenario-btn.active {
  background: var(--color-primary); color: white; border-color: var(--color-primary);
  box-shadow: var(--shadow-md);
}
.scenario-btn .s-label { font-size: 13px; font-weight: 700; }
.scenario-btn .s-desc { font-size: 10px; opacity: 0.85; line-height: 1.2; text-align: center; }

/* ====== 3D SCENE ====== */
.scene-container {
  grid-area: scene; position: relative; background: #9CC5E8; overflow: hidden;
}
#scene-3d { width: 100%; height: 100%; }

.scene-info {
  position: absolute; top: 12px; left: 12px; z-index: 10;
  background: rgba(0,0,0,0.65); color: white; padding: 8px 14px;
  border-radius: 8px; backdrop-filter: blur(8px);
  display: flex; flex-direction: column; gap: 4px;
}
.info-item { display: flex; gap: 12px; align-items: baseline; font-size: 12px; }
.info-label { opacity: 0.8; }
.info-val { font-weight: 700; font-size: 15px; color: #FFD54F; }

.legend {
  position: absolute; bottom: 12px; left: 12px; z-index: 10;
  background: rgba(0,0,0,0.65); color: white; padding: 8px 12px;
  border-radius: 8px; backdrop-filter: blur(8px);
  font-size: 11px; display: flex; flex-direction: column; gap: 3px;
}
.legend-item { display: flex; align-items: center; gap: 8px; }
.swatch { display: inline-block; width: 16px; height: 10px; border-radius: 3px; }
.swatch.car { background: #E53935; }
.swatch.moto { background: #43A047; }
.swatch.truck { background: #795548; }
.swatch.bus { background: #FFD54F; }

/* Heatmap mode selector — appears when heatmap is toggled on */
.hm-selector {
  position: absolute; top: 12px; right: 12px; z-index: 11;
  background: rgba(0,0,0,0.78); backdrop-filter: blur(12px);
  padding: 10px 12px; border-radius: 10px;
  border: 1px solid rgba(255, 213, 79, 0.35);
  display: none; flex-direction: column; gap: 4px;
  min-width: 210px; max-width: 260px;
  max-height: 70vh; overflow-y: auto;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
}
.hm-selector.show { display: flex; }
.hm-selector .hm-title {
  color: #FFD54F; font-size: 11px; font-weight: 700;
  letter-spacing: 0.3px;
  padding-bottom: 4px;
  border-bottom: 1px solid rgba(255, 213, 79, 0.25);
  margin-bottom: 2px;
}
.hm-group-label {
  font-size: 10px;
  font-weight: 700;
  color: rgba(255, 213, 79, 0.85);
  margin-top: 6px;
  margin-bottom: 2px;
  letter-spacing: 0.3px;
  text-transform: uppercase;
}
.hm-btns {
  display: flex; flex-direction: column; gap: 3px;
  margin-bottom: 2px;
}
.hm-mode-btn {
  background: rgba(255,255,255,0.08); color: #e6edf3;
  border: 1px solid rgba(255,255,255,0.12); border-radius: 6px;
  padding: 7px 10px; font-size: 11.5px; font-family: inherit;
  cursor: pointer; transition: all 0.12s;
  text-align: left;
  white-space: nowrap; text-overflow: ellipsis; overflow: hidden;
}
.hm-mode-btn:hover { background: rgba(255,255,255,0.18); transform: translateX(2px); }
.hm-mode-btn.active {
  background: linear-gradient(90deg, rgba(255, 213, 79, 0.35), rgba(255, 87, 34, 0.2));
  color: #FFF;
  border-color: rgba(255, 213, 79, 0.8);
  font-weight: 700;
  box-shadow: 0 0 8px rgba(255, 213, 79, 0.3);
}
.hm-info {
  color: #bcc8d3; font-size: 10px; font-style: italic;
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px solid rgba(255,255,255,0.08);
  line-height: 1.35;
}

.zoom-controls {
  position: absolute; top: 12px; right: 12px; z-index: 10;
  display: flex; flex-direction: column; gap: 4px;
}
/* Push zoom buttons down when heatmap selector is showing — approx 310px tall with 3 groups */
.hm-selector.show ~ .zoom-controls { top: 12px; right: 290px; }
.zoom-btn {
  width: 34px; height: 34px; border: none; border-radius: 6px;
  background: rgba(0,0,0,0.65); color: white; font-size: 18px; font-weight: 700;
  cursor: pointer; backdrop-filter: blur(8px);
  transition: background 0.15s;
}
.zoom-btn:hover { background: rgba(0,0,0,0.85); }

.attribution {
  position: absolute; bottom: 6px; right: 12px; z-index: 10;
  background: rgba(0,0,0,0.55); color: #ddd;
  padding: 4px 10px; border-radius: 4px;
  font-size: 10px; letter-spacing: 0.2px; line-height: 1.4;
  backdrop-filter: blur(6px);
  pointer-events: none;
  max-width: 60vw; text-align: right;
}
.attribution .dev-credit {
  font-size: 11px; color: #e6edf3; opacity: 0.95;
  margin-top: 2px;
}
.attribution .name-hl {
  color: #FFD54F;
  font-weight: 800;
  letter-spacing: 0.3px;
  text-shadow: 0 1px 2px rgba(0,0,0,0.6);
}

/* Survey credit — bottom-LEFT corner of 3D scene, above the legend */
.survey-credit {
  position: absolute; left: 12px; bottom: 108px; z-index: 10;
  background: rgba(0,0,0,0.65); color: #e6edf3;
  padding: 6px 12px; border-radius: 6px;
  font-size: 11px; line-height: 1.35;
  backdrop-filter: blur(8px);
  pointer-events: none;
  max-width: 60vw;
  border-left: 3px solid #FFD54F;
}
.survey-credit .survey-label {
  color: #FFD54F; font-weight: 700; display: block;
  font-size: 10.5px; letter-spacing: 0.3px; margin-bottom: 1px;
}
.survey-info-btn {
  display: block; margin-top: 4px;
  background: rgba(255, 213, 79, 0.2); color: #FFD54F;
  border: 1px solid rgba(255, 213, 79, 0.5); border-radius: 4px;
  font-size: 10px; padding: 3px 8px; cursor: pointer;
  font-family: inherit; pointer-events: auto;
  transition: all 0.15s;
}
.survey-info-btn:hover { background: rgba(255, 213, 79, 0.35); transform: translateX(1px); }

/* ----- RECO banner winner text — pulse blink for attention ----- */
.reco-winner {
  color: var(--color-accent);
  display: inline-block;
  animation: recoBlink 1.4s ease-in-out infinite;
}
@keyframes recoBlink {
  0%, 100% { opacity: 1; transform: scale(1); text-shadow: 0 0 0 rgba(230,81,0,0); }
  50%      { opacity: 0.7; transform: scale(1.02); text-shadow: 0 0 8px rgba(230,81,0,0.5); }
}

/* ====== LOADING ====== */
.loading-overlay {
  position: absolute; top: 0; left: 0; right: 0; bottom: 0; z-index: 100;
  background: rgba(31,78,121,0.92); color: white;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 20px;
}
.spinner {
  width: 50px; height: 50px; border: 5px solid rgba(255,255,255,0.25);
  border-top-color: #FFD54F; border-radius: 50%; animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-text { font-size: 16px; font-weight: 500; }

/* ====== SIDE PANEL ====== */
.side-panel {
  grid-area: panel; background: var(--bg-panel); overflow-y: auto;
  border-left: 1px solid var(--border-light); padding: 0;
  display: flex; flex-direction: column;
}

/* ====== TABS ====== */
.tab-bar {
  display: flex; border-bottom: 2px solid var(--border-light);
  background: #F8F9FA;
  position: sticky; top: 0; z-index: 5;
}
.tab-btn {
  flex: 1; background: transparent; border: none; padding: 12px 8px;
  font-family: inherit; font-size: 13px; font-weight: 600; cursor: pointer;
  color: var(--text-gray);
  border-bottom: 3px solid transparent;
  transition: all 0.15s;
}
.tab-btn:hover { background: rgba(31,78,121,0.08); color: var(--color-primary); }
.tab-btn.active {
  color: var(--color-primary); border-bottom-color: var(--color-primary);
  background: white;
}
.tab-panel { display: none; padding: 16px; }
.tab-panel.active { display: block; }
.tab-panel h3 { font-size: 14px; color: var(--color-primary); margin-bottom: 12px; font-weight: 700; }

/* ============ SUMMARY TAB (Winner) ============ */
.summary-hero {
  background: linear-gradient(135deg, #FFF9C4 0%, #FFE082 50%, #FFB300 100%);
  border: 2px solid #FFB300;
  border-radius: 14px;
  padding: 18px 16px; text-align: center;
  margin-bottom: 16px;
  box-shadow: 0 4px 16px rgba(255, 179, 0, 0.25);
}
.summary-trophy { font-size: 48px; line-height: 1; margin-bottom: 6px; animation: trophyBounce 2.5s ease-in-out infinite; }
@keyframes trophyBounce {
  0%, 100% { transform: translateY(0) rotate(-3deg); }
  50%      { transform: translateY(-4px) rotate(3deg); }
}
.summary-title-sm { font-size: 11px; color: #6D4C00; text-transform: uppercase; letter-spacing: 0.5px; font-weight: 700; }
.summary-winner-name {
  font-size: 22px; font-weight: 900;
  color: var(--color-accent);
  margin: 4px 0 2px;
  text-shadow: 0 2px 4px rgba(0,0,0,0.1);
  animation: recoBlink 1.4s ease-in-out infinite;
}
.summary-winner-sub { font-size: 14px; color: #6D4C00; font-weight: 600; }

.tab-panel h4 {
  font-size: 14px; color: var(--color-primary); font-weight: 700;
  margin: 14px 0 8px; padding-left: 4px;
  border-left: 3px solid var(--color-primary);
}

.summary-reason {
  display: flex; gap: 10px; align-items: flex-start;
  background: #F8F9FA; border-radius: 10px;
  padding: 10px 12px; margin-bottom: 8px;
  border-left: 4px solid var(--color-primary);
}
.summary-reason.ok   { background: #E8F5E9; border-left-color: var(--color-good); }
.summary-reason.warn { background: #FFF3E0; border-left-color: var(--color-accent); }
.summary-reason .sr-icon { font-size: 24px; flex-shrink: 0; }
.summary-reason .sr-title { font-size: 13.5px; font-weight: 700; color: var(--text-dark); margin-bottom: 2px; }
.summary-reason .sr-text  { font-size: 12px; line-height: 1.5; color: var(--text-dark); }
.summary-reason.ok .sr-title   { color: var(--color-good); }
.summary-reason.warn .sr-title { color: var(--color-accent); }
.summary-reason em { font-style: italic; color: var(--text-gray); font-size: 11.5px; }

.summary-vs {
  background: #F5F7FA; border-radius: 8px; padding: 12px;
  margin-bottom: 10px; font-size: 12.5px; line-height: 1.6;
}
.summary-vs p { margin-bottom: 6px; }
.summary-vs p:last-child { margin-bottom: 0; }
.summary-vs .ok     { color: var(--color-good); font-weight: 700; }
.summary-vs .danger { color: var(--color-danger); font-weight: 700; }
.scenario-ref {
  background: rgba(31,78,121,0.12); color: var(--color-primary);
  padding: 1px 6px; border-radius: 4px; font-weight: 700;
}

.summary-callout {
  background: linear-gradient(135deg, #E3F2FD 0%, #BBDEFB 100%);
  border: 1px solid #64B5F6; border-radius: 8px;
  padding: 10px 12px; font-size: 11px; color: #1565C0;
  text-align: center; line-height: 1.5;
  margin-top: 12px;
}
.tab-panel h4 { font-size: 13px; color: var(--color-primary); margin: 14px 0 8px; font-weight: 700; }
.footnote { font-size: 11px; color: var(--text-gray); margin-top: 8px; font-style: italic; }

/* ====== STAT CARDS & BARS ====== */
.compare-row { margin-bottom: 14px; }
.stat-card {
  background: #F8F9FA; border-radius: 8px; padding: 10px 12px;
  border-left: 3px solid var(--color-primary);
}
.stat-card.danger { border-left-color: var(--color-danger); background: #FFF3E0; }
.stat-h { font-size: 13px; font-weight: 700; color: var(--text-dark); }
.stat-unit { font-size: 10px; color: var(--text-gray); margin-bottom: 8px; }
.stat-note { font-size: 10px; color: var(--text-gray); margin-top: 6px; font-style: italic; line-height: 1.4; border-top: 1px dashed #D0D5DB; padding-top: 4px; }

.bars { display: flex; flex-direction: column; gap: 4px; }
.bar {
  position: relative; height: 22px; background: #E8ECF0; border-radius: 4px;
  overflow: hidden; display: flex; align-items: center;
}
.bar-lbl {
  position: absolute; left: 8px; top: 50%; transform: translateY(-50%);
  font-size: 11px; font-weight: 600; z-index: 2; color: var(--text-dark);
}
.bar-fill {
  position: absolute; left: 0; top: 0; bottom: 0;
  background: linear-gradient(90deg, #64B5F6, #1976D2);
  transition: width 0.4s ease-out;
}
.bar-val {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
  font-size: 11px; font-weight: 700; z-index: 2; color: var(--text-dark);
}
.bar.over .bar-fill { background: linear-gradient(90deg, #FFB74D, #C62828); }
.bar[data-scenario*="win"] .bar-fill,
.bar:has(.bar-lbl:first-child:nth-last-child(3)):last-child .bar-fill {
  background: linear-gradient(90deg, #81C784, #2E7D32);
}

/* ====== METRICS TABLE ====== */
.metrics-table { width: 100%; font-size: 12px; border-collapse: collapse; }
.metrics-table th, .metrics-table td {
  padding: 6px 4px; text-align: right; border-bottom: 1px solid var(--border-light);
}
.metrics-table th { background: var(--color-primary); color: white; font-weight: 600; }
.metrics-table td:first-child, .metrics-table th:first-child { text-align: left; font-weight: 600; }
.metrics-table td.win { color: var(--color-good); font-weight: 700; background: #E8F5E9; }
.metrics-table td.danger { color: var(--color-danger); font-weight: 700; background: #FFEBEE; }

/* ====== ENV PANEL ====== */
.env-summary {
  background: linear-gradient(135deg, #E8F5E9 0%, #F1F8E9 100%);
  border: 2px solid var(--color-env); border-radius: 10px;
  padding: 10px 12px; margin: 14px 0 10px;
}
.env-summary h4 {
  color: var(--color-env-dark); font-size: 13px; margin: 0 0 6px;
}
.env-points { list-style: none; padding: 0; margin: 0; }
.env-points li {
  font-size: 12px; line-height: 1.5; color: var(--text-dark);
  padding: 4px 0; border-bottom: 1px dashed rgba(46,125,50,0.15);
}
.env-points li:last-child { border-bottom: none; }
.env-points strong.ok   { color: var(--color-good); }
.env-points strong.warn { color: var(--color-accent); }
.env-points em { color: var(--color-env-dark); font-style: normal; font-weight: 600; }

.climate-equiv {
  background: #FFF; border: 1px solid var(--color-env);
  border-radius: 8px; padding: 12px; font-size: 12px;
}
.equiv-title { font-weight: 700; color: var(--color-env-dark); margin-bottom: 6px; }
.equiv-line { padding: 3px 0; color: var(--text-dark); }
.equiv-line span { font-weight: 700; color: var(--color-env-dark); }

/* Winner bar — green gradient (applies to any bar marked data-scenario="win") */
.bar[data-scenario="win"] .bar-fill {
  background: linear-gradient(90deg, #81C784, #2E7D32);
}

/* ====== ROADMAP ====== */
.roadmap-section {
  border-top: 1px solid var(--border-light); padding: 16px;
  background: #FAFBFC;
}
.roadmap-section h3 { font-size: 14px; color: var(--color-primary); margin-bottom: 10px; font-weight: 700; }
.timeline {
  list-style: none; padding-left: 16px; position: relative;
}
.timeline::before {
  content: ""; position: absolute; left: 6px; top: 6px; bottom: 6px;
  width: 2px; background: #CFD8DC;
}
.timeline li {
  position: relative; padding: 6px 0 10px 16px; font-size: 12px; color: var(--text-dark);
}
.timeline li::before {
  content: ""; position: absolute; left: -13px; top: 10px;
  width: 12px; height: 12px; border-radius: 50%;
  background: #CFD8DC; border: 2px solid white;
  box-shadow: 0 0 0 1px #CFD8DC;
}
.timeline li.done::before { background: var(--color-good); box-shadow: 0 0 0 1px var(--color-good); }
.timeline li.active::before {
  background: var(--color-accent); box-shadow: 0 0 0 1px var(--color-accent);
  animation: pulse 1.8s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 1px var(--color-accent); }
  50% { box-shadow: 0 0 0 5px rgba(230,81,0,0.3); }
}
.timeline .tl-title { font-weight: 700; color: var(--color-primary); }
.timeline .tl-date { font-size: 10px; color: var(--text-gray); margin-left: 6px; }
.timeline .tl-desc { font-size: 11px; color: var(--text-gray); line-height: 1.4; margin-top: 1px; }
.timeline li.done .tl-title { color: var(--color-good); }
.timeline li.active .tl-title { color: var(--color-accent); }

/* ====== CONTROLS BAR ====== */
.controls-bar {
  display: flex; gap: 16px; align-items: center; padding: 10px 20px;
  background: var(--bg-panel); border-top: 1px solid var(--border-light);
  box-shadow: 0 -2px 8px rgba(0,0,0,0.04);
}
.btn-play {
  width: 42px; height: 42px; border-radius: 50%; border: none;
  background: var(--color-primary); color: white; font-size: 18px; cursor: pointer;
  transition: all 0.2s;
  display: flex; align-items: center; justify-content: center;
}
.btn-play:hover { background: #2C5F93; transform: scale(1.05); }

.timeline-wrapper { flex: 1; display: flex; flex-direction: column; gap: 2px; }
#timeline { width: 100%; accent-color: var(--color-primary); cursor: pointer; }
.timeline-labels { font-size: 11px; color: var(--text-gray); display: flex; justify-content: space-between; }

.speed-control { display: flex; gap: 6px; align-items: center; font-size: 13px; }
.speed-control label { font-weight: 600; }
.speed-control select {
  padding: 4px 8px; border: 1px solid var(--border-light); border-radius: 4px;
  font-family: inherit; cursor: pointer;
}

/* ====== MODAL ====== */
.modal-overlay {
  position: fixed; top:0; left:0; right:0; bottom:0; z-index: 1000;
  background: rgba(0,0,0,0.6); display: flex; align-items: center; justify-content: center;
}
.modal {
  background: white; border-radius: 12px; padding: 24px;
  max-width: 500px; width: 90%; max-height: 85vh; overflow-y: auto;
  position: relative; box-shadow: var(--shadow-md);
}
.modal h2 { color: var(--color-primary); margin-bottom: 12px; }
.modal h3 { color: var(--color-primary); margin: 12px 0 6px; font-size: 14px; }
.modal ul { padding-left: 20px; margin-bottom: 8px; }
.modal li { margin: 4px 0; font-size: 14px; line-height: 1.5; }
.modal p { font-size: 14px; line-height: 1.6; margin-top: 6px; }
.modal-close {
  position: absolute; top: 10px; right: 14px; background: none; border: none;
  font-size: 28px; cursor: pointer; color: var(--text-gray);
}
.modal-close:hover { color: var(--color-accent); }

/* ============================================================ */
/* LANDING OVERLAY — device picker with blurred simulation background */
/* ============================================================ */
.landing-overlay {
  position: fixed; inset: 0; z-index: 9999;
  background: rgba(31, 78, 121, 0.55);
  backdrop-filter: blur(14px) saturate(1.1);
  -webkit-backdrop-filter: blur(14px) saturate(1.1);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  animation: landingFadeIn 0.5s ease-out;
  transition: opacity 0.5s ease-out;
}
.landing-overlay.hiding { opacity: 0; pointer-events: none; }
@keyframes landingFadeIn { from { opacity: 0; } to { opacity: 1; } }

.landing-card {
  background: rgba(255, 255, 255, 0.97);
  border-radius: 18px;
  padding: 32px 40px;
  max-width: 560px; width: 100%;
  box-shadow: 0 20px 60px rgba(0,0,0,0.25);
  text-align: center;
  border: 2px solid rgba(255, 213, 79, 0.6);
}
.landing-brand {
  display: flex; align-items: center; justify-content: center;
  gap: 16px; margin-bottom: 18px; text-align: left;
}
.landing-icon { font-size: 48px; flex-shrink: 0; }
.landing-card h1 {
  font-size: 22px; color: var(--color-primary); font-weight: 800;
  line-height: 1.2; margin: 0;
}
.landing-card h2 {
  font-size: 16px; color: var(--color-accent); font-weight: 600;
  margin: 2px 0 0 0;
}
.landing-card h2 .paren { color: var(--text-gray); font-weight: 400; }
.subtitle-line { font-size: 12px; color: var(--text-gray); margin-top: 4px; }

.landing-desc {
  font-size: 13px; color: var(--text-dark); line-height: 1.5;
  background: #F5F7FA; padding: 12px; border-radius: 8px;
  margin-bottom: 20px;
}

.landing-choices {
  display: grid; grid-template-columns: 1fr 1fr; gap: 12px;
  margin-bottom: 18px;
}
.landing-btn {
  background: white; border: 2px solid var(--border-light);
  border-radius: 12px; padding: 18px 12px; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  transition: all 0.18s; font-family: inherit;
}
.landing-btn:hover {
  border-color: var(--color-primary); background: #E8F4FD;
  transform: translateY(-2px); box-shadow: 0 6px 16px rgba(31,78,121,0.15);
}
.landing-btn .lbi { font-size: 32px; }
.landing-btn .lbl { font-size: 15px; font-weight: 700; color: var(--color-primary); }
.landing-btn .sub { font-size: 11px; color: var(--text-gray); line-height: 1.3; }

.landing-credit {
  font-size: 10px; color: var(--text-gray);
  border-top: 1px solid var(--border-light);
  padding-top: 12px; line-height: 1.5;
}

/* Layout class applied to <body> after choice — applies mobile rules even on wider screens */
body.layout-mobile, body.layout-mobile html {
  height: auto; min-height: 100%; overflow: auto;
}
body.layout-mobile {
  display: block;
  padding-top: 56px; padding-bottom: 72px;
}
body.layout-mobile .top-bar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 50; height: 56px;
}
body.layout-mobile .reco-banner {
  position: sticky; top: 56px; z-index: 40;
  flex-direction: row; padding: 6px 12px; gap: 8px; flex-wrap: wrap;
}
body.layout-mobile .main-layout { display: block; overflow: visible; }
body.layout-mobile .scenario-bar { position: sticky; top: 98px; z-index: 35; padding: 8px 10px; }
body.layout-mobile .scene-container { height: 58vh; min-height: 320px; max-height: 70vh; }
body.layout-mobile .side-panel {
  max-height: none; border-left: none;
  border-top: 1px solid var(--border-light);
}
body.layout-mobile .tab-bar { position: sticky; top: 160px; z-index: 30; }
body.layout-mobile .controls-bar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 50; height: 64px;
}
body.layout-mobile .brand .subtitle { display: none; }
body.layout-mobile .survey-credit { bottom: 88px; }

@media (max-width: 600px) {
  .landing-card { padding: 20px 16px; }
  .landing-brand { flex-direction: column; text-align: center; gap: 6px; }
  .landing-card h1 { font-size: 18px; }
  .landing-card h2 { font-size: 14px; }
  .landing-choices { grid-template-columns: 1fr; }
}

/* ----- VISSIM params table (Methodology) ----- */
.params-table {
  width: 100%; border-collapse: collapse; font-size: 12px;
  margin: 8px 0 10px;
}
.params-table td {
  padding: 5px 8px; border-bottom: 1px solid #EEE;
  vertical-align: top;
}
.params-table td:first-child {
  width: 55%; color: var(--text-gray);
}
.params-table td:last-child {
  color: var(--text-dark); font-weight: 500;
}
.params-table tr.section td {
  background: var(--color-primary); color: white;
  font-weight: 700; padding: 6px 8px;
  border: none; letter-spacing: 0.3px;
}
.params-table tr.highlight td {
  background: #FFF8E1;
}
.params-table em { color: var(--color-accent); font-style: normal; font-size: 11px; }
.params-footnote {
  font-size: 11px; color: var(--text-gray);
  background: #F5F7FA; padding: 8px 10px; border-radius: 6px;
  border-left: 3px solid var(--color-primary);
  margin-top: 8px; line-height: 1.5;
}

/* ====== RESPONSIVE ====== */
/* --- MOBILE: allow document-level scroll so the side panel is fully reachable --- */
@media (max-width: 900px) {
  html, body {
    height: auto; min-height: 100%;
    overflow: auto;                    /* enable vertical scroll on the page */
  }
  body {
    display: block;                     /* drop grid — let sections flow */
    padding-top: 56px;                  /* room for sticky top bar */
    padding-bottom: 72px;               /* room for sticky controls bar */
  }
  .top-bar {
    position: fixed; top: 0; left: 0; right: 0; z-index: 50;
    height: 56px;
    padding: 0 8px;
    grid-template-columns: 1fr auto;     /* mobile: brand fills, actions on right */
  }
  .top-bar .brand { grid-column: 1; justify-content: flex-start; text-align: left; }
  .top-bar .actions { grid-column: 2; }
  .top-bar .brand .title { font-size: 14px; }
  .reco-banner {
    position: sticky; top: 56px; z-index: 40;
    flex-direction: row; padding: 6px 12px; gap: 8px;
    flex-wrap: wrap;
  }
  .main-layout {
    display: block;                     /* stack scenarios / scene / panel vertically */
    overflow: visible;
  }
  .scenario-bar {
    position: sticky; top: 98px; z-index: 35;
    padding: 8px 10px;
  }
  .scene-container {
    height: 58vh;                       /* fixed visible area for 3D scene */
    min-height: 320px;
    max-height: 70vh;
  }
  .side-panel {
    max-height: none;                   /* no cap — page scrolls to show all */
    border-left: none;
    border-top: 1px solid var(--border-light);
  }
  .tab-bar {
    position: sticky; top: 160px; z-index: 30;
  }
  .controls-bar {
    position: fixed; bottom: 0; left: 0; right: 0; z-index: 50;
    height: 64px;
  }
  .brand .subtitle { display: none; }
  .brand .title { font-size: 15px; }
  .brand .icon { font-size: 24px; }
  .btn-small { padding: 4px 8px; font-size: 12px; }
  .actions { gap: 4px; }
  .survey-credit { bottom: 88px; font-size: 10px; padding: 5px 10px; }
  .attribution { font-size: 9px; padding: 3px 8px; }
}

@media (max-width: 600px) {
  body { padding-top: 50px; padding-bottom: 60px; }
  .top-bar { height: 50px; padding: 0 10px; }
  .brand .title { font-size: 13px; }
  .brand .title .badge { font-size: 9px; padding: 1px 6px; margin-left: 4px; }
  .reco-banner { top: 50px; padding: 4px 8px; gap: 6px; }
  .reco-title { font-size: 11px; }
  .reco-sub { display: none; }
  .reco-cta { padding: 5px 10px; font-size: 11px; }
  .scenario-bar { top: 92px; padding: 6px 8px; }
  .scenario-btn { padding: 4px 6px; }
  .scenario-btn .s-label { font-size: 11px; }
  .scenario-btn .s-desc { font-size: 9px; }
  .tab-bar { top: 150px; }
  .tab-btn { font-size: 11px; padding: 10px 4px; }
  .scene-info, .legend { font-size: 10px; padding: 6px 10px; }
  .controls-bar { padding: 6px 10px; gap: 6px; height: 56px; }
  .btn-play { width: 38px; height: 38px; font-size: 16px; }
  .speed-control label { display: none; }
  .zoom-controls .zoom-btn { width: 30px; height: 30px; font-size: 16px; }
  /* Heatmap selector on MOBILE — compact + positioned at bottom of scene */
  .hm-selector {
    top: auto; bottom: 8px; right: 8px; left: 8px;
    min-width: 0; max-width: none;
    padding: 6px 8px;
    max-height: 50vh;
    flex-direction: row; flex-wrap: wrap;
    align-items: center;
  }
  .hm-selector .hm-title { font-size: 10px; flex: 0 0 100%; padding-bottom: 2px; margin-bottom: 0; }
  .hm-selector #hm-mode-groups { display: flex; flex-wrap: wrap; gap: 3px; flex: 1; }
  .hm-group-label { font-size: 9px; margin: 3px 4px 1px 0; padding: 0; }
  .hm-btns { flex-direction: row; flex-wrap: wrap; gap: 3px; margin: 0; }
  .hm-mode-btn { font-size: 10px; padding: 4px 8px; }
  .hm-info { font-size: 9px; flex: 0 0 100%; margin-top: 4px; padding-top: 4px; }
  .survey-credit { font-size: 9px; padding: 4px 8px; bottom: 70px; }
  .attribution { font-size: 9px; line-height: 1.3; }
}
