:root {
  --bg:        #0d0d1a;
  --bg2:       #12122a;
  --card:      #181830;
  --card-h:    #1e1e3a;
  --accent:    #ff5a1f;
  --accent-h:  #ff7a45;
  --text:      #f0f0ff;
  --muted:     #8080a8;
  --border:    rgba(255,255,255,0.07);
  --green:     #22c55e;
  --yellow:    #eab308;
  --orange:    #f97316;
  --red:       #ef4444;
  --grey:      #3a3a5c;
  --shadow:    0 4px 24px rgba(0,0,0,0.5);
  --radius:    12px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
}

.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 16px;
}

/* ── Header ── */
header {
  background: linear-gradient(135deg, #0d0d1a 0%, #1a0828 100%);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 50;
}
.header-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.logo { display: flex; align-items: center; gap: 10px; }
.logo-icon { font-size: 1.9rem; line-height: 1; }
.logo h1 {
  font-size: 1.3rem;
  font-weight: 800;
  background: linear-gradient(90deg, #ff5a1f, #ffaa60);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  line-height: 1.2;
}
.tagline { font-size: 0.7rem; color: var(--muted); }

.status-badge {
  display: flex;
  align-items: center;
  gap: 7px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 5px 13px;
  font-size: 0.82rem;
  white-space: nowrap;
}
.status-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--grey);
  flex-shrink: 0;
}
.status-dot.open {
  background: var(--green);
  box-shadow: 0 0 7px var(--green);
  animation: blink 2s ease-in-out infinite;
}
@keyframes blink { 0%,100%{opacity:1} 50%{opacity:0.45} }

/* ── Ads ── */
.ad-strip {
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  text-align: center;
  padding: 10px 16px;
}
.ad-mid {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin: 28px 0;
  padding: 16px;
}
.ad-placeholder {
  color: var(--muted);
  font-size: 0.72rem;
  border: 1px dashed rgba(255,255,255,0.1);
  border-radius: 6px;
  padding: 14px 28px;
  display: inline-block;
}

/* ── Info bar ── */
.info-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  padding: 14px 0 10px;
  font-size: 0.83rem;
  color: var(--muted);
}
.refresh-row { display: flex; align-items: center; gap: 12px; }
.refresh-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 7px;
  padding: 6px 13px;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}
.refresh-btn:hover { background: var(--accent-h); }

/* ── States ── */
.hidden { display: none !important; }

.loading-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 70px 20px;
  color: var(--muted);
}
.spinner {
  width: 38px; height: 38px;
  border: 3px solid rgba(255,90,31,0.2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.error-state {
  text-align: center;
  padding: 50px 20px;
  color: var(--red);
}
.error-state button {
  margin-top: 14px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 7px;
  padding: 8px 22px;
  font-size: 0.9rem;
  cursor: pointer;
}

/* ── Land sections ── */
.land-section { margin-bottom: 30px; }

.land-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}
.land-title {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}
.land-count {
  font-size: 0.72rem;
  background: var(--card);
  border-radius: 10px;
  padding: 2px 8px;
  color: var(--muted);
}
.land-divider { flex: 1; height: 1px; background: var(--border); }

/* ── Ride grid ── */
.rides-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(175px, 1fr));
  gap: 10px;
}

/* ── Ride card ── */
.ride-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 15px;
  position: relative;
  overflow: hidden;
  transition: transform 0.13s, box-shadow 0.13s, border-color 0.13s;
}
.ride-card::after {
  content: '';
  position: absolute;
  inset: 0 0 auto 0;
  height: 3px;
  background: var(--bar-color, var(--grey));
  border-radius: var(--radius) var(--radius) 0 0;
}
.ride-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
  border-color: rgba(255,255,255,0.13);
}
.ride-card.closed { opacity: 0.5; }

.ride-name {
  font-size: 0.87rem;
  font-weight: 600;
  margin-bottom: 10px;
  line-height: 1.3;
}

.ride-wait {
  display: flex;
  align-items: baseline;
  gap: 3px;
  margin-bottom: 6px;
}
.wait-num {
  font-size: 2rem;
  font-weight: 800;
  line-height: 1;
}
.wait-unit { font-size: 0.8rem; color: var(--muted); }

.ride-status {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.st-open   { color: var(--green); }
.st-walkon { color: var(--green); }
.st-closed { color: var(--grey); }

/* wait-time colours */
.wt-low       { color: var(--green); }
.wt-medium    { color: var(--yellow); }
.wt-high      { color: var(--orange); }
.wt-very-high { color: var(--red); }

/* ── Stale banner ── */
.stale-banner {
  background: #7c3900;
  border-bottom: 1px solid #b85000;
  color: #ffd7a8;
  font-size: 0.82rem;
  text-align: center;
  padding: 8px 16px;
}

/* ── Skeleton cards (pre-populated for SEO) ── */
.ride-card.skeleton {
  opacity: 0.35;
  pointer-events: none;
}
.ride-card.skeleton::after { background: var(--grey); }

/* ── History chart ── */
.chart-section {
  margin-bottom: 4px;
}

.chart-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 14px;
}

.chart-header h2 {
  font-size: 1rem;
  font-weight: 700;
}

.range-btns {
  display: flex;
  gap: 4px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 3px;
}

.range-btn {
  background: transparent;
  color: var(--muted);
  border: none;
  border-radius: 5px;
  padding: 4px 12px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.range-btn.active,
.range-btn:hover {
  background: var(--accent);
  color: #fff;
}

.land-tabs {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.land-tab {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 20px;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 600;
  padding: 5px 14px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.land-tab.active,
.land-tab:hover {
  background: var(--card-h);
  color: var(--text);
  border-color: rgba(255,255,255,0.15);
}

.land-tab.active {
  border-color: var(--accent);
  color: var(--accent);
}

.chart-wrap {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  position: relative;
  min-height: 260px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.chart-loading {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 0.85rem;
}

.chart-empty {
  color: var(--muted);
  font-size: 0.85rem;
  text-align: center;
  padding: 20px;
}

#queueChart {
  width: 100% !important;
  max-height: 320px;
}

/* ── Best time to visit ── */
.best-time-section {
  margin-bottom: 4px;
}
.best-time-section h2 { font-size: 1rem; font-weight: 700; margin-bottom: 4px; }
.best-time-sub { font-size: 0.78rem; color: var(--muted); margin-bottom: 14px; }

.best-time-land-tabs {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.heatmap-wrap {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow-x: auto;
}

.heatmap-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.75rem;
  min-width: 560px;
}
.heatmap-table th {
  padding: 8px 4px;
  color: var(--muted);
  font-weight: 600;
  text-align: center;
  white-space: nowrap;
  border-bottom: 1px solid var(--border);
}
.heatmap-table th.ride-col { text-align: left; padding-left: 14px; min-width: 160px; }
.heatmap-table td {
  padding: 6px 4px;
  text-align: center;
  border-bottom: 1px solid rgba(255,255,255,0.03);
}
.heatmap-table td.ride-col {
  text-align: left;
  padding-left: 14px;
  color: var(--text);
  font-weight: 500;
  white-space: nowrap;
}
.heatmap-table tr:last-child td { border-bottom: none; }

.hm-cell {
  display: inline-block;
  min-width: 30px;
  padding: 3px 2px;
  border-radius: 4px;
  font-size: 0.7rem;
  font-weight: 600;
  color: rgba(0,0,0,0.75);
}
.hm-cell.hm-none  { background: transparent; color: var(--muted); font-weight: 400; }
.hm-cell.hm-0     { background: #22c55e; }
.hm-cell.hm-1     { background: #84cc16; }
.hm-cell.hm-2     { background: #eab308; }
.hm-cell.hm-3     { background: #f97316; }
.hm-cell.hm-4     { background: #ef4444; color: #fff; }

/* ── Ride detail modal ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  backdrop-filter: blur(4px);
}

.modal {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 16px;
  width: 100%;
  max-width: 680px;
  max-height: 90vh;
  overflow-y: auto;
  padding: 24px;
}

.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 20px;
}
.modal-header h3 { font-size: 1.3rem; font-weight: 800; }
.modal-wait { font-size: 0.85rem; color: var(--muted); margin-top: 2px; }

.modal-close {
  background: var(--card);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 50%;
  width: 32px;
  height: 32px;
  font-size: 1.2rem;
  line-height: 1;
  cursor: pointer;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
}
.modal-close:hover { background: var(--card-h); }

.modal-section { margin-bottom: 20px; }
.modal-section h4 {
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
  margin-bottom: 12px;
}

.modal-chart-wrap {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  min-height: 200px;
  display: flex;
  align-items: center;
  justify-content: center;
}
#modalChart { width: 100% !important; max-height: 220px; }

.modal-heatmap-row {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
.modal-hm-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}
.modal-hm-item .hm-hour {
  font-size: 0.62rem;
  color: var(--muted);
}

/* ── Footer ── */
footer {
  background: var(--bg2);
  border-top: 1px solid var(--border);
  padding: 24px 0;
  text-align: center;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 2;
}
footer a { color: var(--accent); text-decoration: none; }
footer a:hover { text-decoration: underline; }

/* ── Responsive ── */
@media (max-width: 560px) {
  .logo h1  { font-size: 1.05rem; }
  .tagline  { display: none; }
  .rides-grid { grid-template-columns: repeat(auto-fill, minmax(145px, 1fr)); gap: 8px; }
  .wait-num { font-size: 1.65rem; }
}
