/* ==========================================================================
   Kyle's Dashboard — OLED-first, landscape-tablet tuned
   Themes switch via [data-theme]; background animations via [data-animation].
   ========================================================================== */

:root {
  --font: "Inter", "SF Pro Display", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: "SF Mono", ui-monospace, "JetBrains Mono", "Roboto Mono", Menlo, monospace;
  --radius-lg: 26px;
  --radius-md: 18px;
  --radius-sm: 12px;
  --ease: cubic-bezier(0.22, 0.85, 0.3, 1);

  --bg: #000000;
  --bg-soft: #050506;
  --surface: #0a0a0c;
  --surface-2: #111114;
  --surface-3: #17171b;
  --border: rgba(255, 255, 255, 0.075);
  --border-strong: rgba(255, 255, 255, 0.14);
  --text: #f6f6f8;
  --text-dim: #9b9ba6;
  --text-faint: #6b6b76;
  --accent: #ff7a18;
  --accent-soft: rgba(255, 122, 24, 0.14);
  --accent-ink: #0b0500;
  --blue: #1877f2;
  --orange: #ff6b00;
  --yellow: #facc15;
  --good: #38d39f;
  --warn: #ffb84d;
  --bad: #ff5d5d;
  --shadow: 0 24px 60px rgba(0, 0, 0, 0.55);
  --clock-glow: 0 0 90px rgba(255, 122, 24, 0.16);
}

[data-theme="midnight"] {
  --bg: #070a12;
  --bg-soft: #0a0f1a;
  --surface: #0f1624;
  --surface-2: #141d2e;
  --surface-3: #1b2536;
  --border: rgba(148, 173, 214, 0.14);
  --border-strong: rgba(148, 173, 214, 0.26);
  --text: #e8eefc;
  --text-dim: #93a3bd;
  --text-faint: #64748b;
  --accent: #6ea8fe;
  --accent-soft: rgba(110, 168, 254, 0.16);
  --accent-ink: #04101f;
  --clock-glow: 0 0 90px rgba(110, 168, 254, 0.2);
}

[data-theme="cyber"] {
  --bg: #04060a;
  --bg-soft: #060a10;
  --surface: #080d14;
  --surface-2: #0c131c;
  --surface-3: #101a25;
  --border: rgba(0, 229, 160, 0.16);
  --border-strong: rgba(0, 229, 160, 0.32);
  --text: #e6fff8;
  --text-dim: #84a8a0;
  --text-faint: #4f6b66;
  --accent: #00e5a0;
  --accent-soft: rgba(0, 229, 160, 0.14);
  --accent-ink: #00120c;
  --clock-glow: 0 0 100px rgba(0, 229, 160, 0.22);
}

[data-theme="papaya"] {
  --bg: #101114;
  --bg-soft: #141519;
  --surface: #17181d;
  --surface-2: #1e2026;
  --surface-3: #26282f;
  --border: rgba(255, 255, 255, 0.1);
  --border-strong: rgba(255, 128, 0, 0.34);
  --text: #f7f7f8;
  --text-dim: #a5a6ad;
  --text-faint: #73747c;
  --accent: #ff8000;
  --accent-soft: rgba(255, 128, 0, 0.16);
  --accent-ink: #150a00;
  --clock-glow: 0 0 100px rgba(255, 128, 0, 0.25);
}

[data-theme="mono"] {
  --bg: #0b0b0b;
  --bg-soft: #0f0f0f;
  --surface: #141414;
  --surface-2: #1a1a1a;
  --surface-3: #222222;
  --border: rgba(255, 255, 255, 0.11);
  --border-strong: rgba(255, 255, 255, 0.24);
  --text: #fafafa;
  --text-dim: #a0a0a0;
  --text-faint: #707070;
  --accent: #ffffff;
  --accent-soft: rgba(255, 255, 255, 0.1);
  --accent-ink: #0b0b0b;
  --clock-glow: 0 0 80px rgba(255, 255, 255, 0.12);
}

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

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

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overscroll-behavior: none;
}

button,
input,
select {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
}

[hidden] {
  display: none !important;
}

.bg-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;
  opacity: 0.9;
}

/* ---------------- PIN gate ---------------- */

.gate {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(120% 80% at 50% -10%, rgba(255, 122, 24, 0.1), transparent 60%),
    var(--bg);
}

.gate-panel {
  width: min(460px, 100%);
  padding: clamp(22px, 3vw, 34px);
  border-radius: var(--radius-lg);
  background: linear-gradient(180deg, var(--surface-2), var(--surface));
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  text-align: center;
}

.gate-brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  color: var(--text-dim);
  font-size: 13px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.brand-mark {
  width: 10px;
  height: 10px;
  border-radius: 3px;
  background: var(--accent);
  box-shadow: 0 0 18px var(--accent);
}

.gate-title {
  margin: 18px 0 4px;
  font-size: clamp(26px, 3vw, 32px);
  letter-spacing: -0.02em;
}

.gate-sub {
  margin: 0 0 20px;
  color: var(--text-dim);
  font-size: 15px;
}

.pin-dots {
  display: flex;
  justify-content: center;
  gap: 12px;
  height: 18px;
  margin-bottom: 22px;
}

.pin-dots.compact {
  height: 14px;
  gap: 9px;
  margin: 12px 0 16px;
}

.pin-dots i {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 1px solid var(--border-strong);
  background: transparent;
  transition: transform 0.16s var(--ease), background 0.16s var(--ease), border-color 0.16s var(--ease);
}

.pin-dots.compact i {
  width: 9px;
  height: 9px;
}

.pin-dots i.filled {
  background: var(--accent);
  border-color: var(--accent);
  transform: scale(1.08);
}

.gate.shake .gate-panel,
.settings-auth.shake .pin-dots {
  animation: shake 0.42s var(--ease);
}

@keyframes shake {
  0%,
  100% {
    transform: translateX(0);
  }
  20% {
    transform: translateX(-9px);
  }
  40% {
    transform: translateX(8px);
  }
  60% {
    transform: translateX(-6px);
  }
  80% {
    transform: translateX(4px);
  }
}

.keypad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.keypad.compact {
  gap: 8px;
}

.key {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-height: 68px;
  padding: 8px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-size: 22px;
  font-weight: 600;
  transition: transform 0.12s var(--ease), background 0.16s var(--ease), border-color 0.16s var(--ease);
  touch-action: manipulation;
}

.keypad.compact .key {
  min-height: 52px;
  font-size: 18px;
  border-radius: var(--radius-sm);
}

.key em {
  font-style: normal;
  font-size: 9px;
  letter-spacing: 0.16em;
  color: var(--text-faint);
}

.key:hover {
  border-color: var(--border-strong);
}

.key:active,
.key.pressed {
  transform: scale(0.96);
  background: var(--accent-soft);
  border-color: var(--accent);
}

.key-ghost {
  font-size: 15px;
  font-weight: 500;
  color: var(--text-dim);
  background: transparent;
}

.gate-error {
  min-height: 20px;
  margin: 14px 0 0;
  color: var(--bad);
  font-size: 14px;
}

.gate-hint {
  margin: 10px 0 0;
  color: var(--text-faint);
  font-size: 12px;
}

/* ---------------- App shell ---------------- */

.app {
  position: relative;
  z-index: 1;
  height: 100dvh;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: clamp(10px, 1.4vh, 18px);
  padding: clamp(14px, 2vw, 30px) clamp(16px, 2.4vw, 34px);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 44px;
}

.topbar-left,
.topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.live-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-faint);
  transition: background 0.3s, box-shadow 0.3s;
}

.live-dot.ok {
  background: var(--good);
  box-shadow: 0 0 12px rgba(56, 211, 159, 0.6);
}

.live-dot.warn {
  background: var(--warn);
  box-shadow: 0 0 12px rgba(255, 184, 77, 0.5);
}

.live-dot.bad {
  background: var(--bad);
  box-shadow: 0 0 12px rgba(255, 93, 93, 0.5);
}

.topbar-label {
  font-size: 12px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-faint);
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-dim);
  font-size: 13px;
  transition: color 0.16s, border-color 0.16s, background 0.16s;
}

.icon-btn:hover {
  color: var(--text);
  border-color: var(--border-strong);
  background: var(--surface-2);
}

.mini-btn {
  padding: 6px 11px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-dim);
  font-size: 12px;
}

.mini-btn:hover {
  color: var(--text);
  border-color: var(--border-strong);
}

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1.58fr) minmax(330px, 0.82fr);
  gap: clamp(14px, 2vw, 30px);
  min-height: 0;
}

/* ---------------- Hero clock ---------------- */

.hero {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-width: 0;
  padding-left: clamp(0px, 1vw, 14px);
}

.greeting {
  margin: 0 0 clamp(8px, 1.2vh, 18px);
  color: var(--text-dim);
  font-size: clamp(16px, 1.55vw, 24px);
  font-weight: 500;
  letter-spacing: -0.01em;
  min-height: 1.4em;
  transition: opacity 0.4s var(--ease);
}

.greeting.fade {
  opacity: 0;
}

.clock {
  display: flex;
  align-items: baseline;
  gap: clamp(6px, 0.8vw, 14px);
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
  line-height: 0.82;
  letter-spacing: -0.045em;
  text-shadow: var(--clock-glow);
}

.clock-main {
  font-size: clamp(5rem, min(15.5vw, 21vh), 15rem);
  font-weight: 700;
}

.clock-seconds {
  font-size: clamp(1.5rem, min(4vw, 6vh), 3.6rem);
  font-weight: 600;
  color: var(--accent);
  letter-spacing: -0.02em;
}

.clock-period {
  font-size: clamp(0.9rem, 1.4vw, 1.35rem);
  font-weight: 600;
  letter-spacing: 0.12em;
  color: var(--text-dim);
  text-transform: uppercase;
}

.date {
  margin-top: clamp(12px, 1.8vh, 26px);
  font-size: clamp(1.15rem, 2.1vw, 2rem);
  font-weight: 600;
  letter-spacing: -0.02em;
}

.day {
  margin-top: 4px;
  font-size: clamp(0.85rem, 1.25vw, 1.15rem);
  font-weight: 500;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--text-dim);
}

.hero-foot {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: clamp(16px, 2.4vh, 34px);
}

.hero-chip {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 9px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: color-mix(in srgb, var(--surface) 80%, transparent);
  font-size: 13px;
  color: var(--text-dim);
  max-width: 100%;
}

.chip-key {
  padding: 2px 7px;
  border-radius: 6px;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 700;
  font-size: 11px;
  letter-spacing: 0.06em;
}

.chip-value {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---------------- Cards rail ---------------- */

.rail {
  display: grid;
  grid-template-rows: 1.06fr 0.94fr;
  gap: clamp(12px, 1.4vh, 18px);
  min-height: 0;
}

.card {
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: clamp(14px, 1.4vw, 20px);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  background: linear-gradient(180deg, var(--surface-2) 0%, var(--surface) 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03);
  overflow: hidden;
  transition: border-color 0.2s var(--ease), transform 0.2s var(--ease);
}

.card:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.card:hover {
  border-color: var(--border-strong);
}

.card:active {
  transform: scale(0.995);
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.card-head-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.bus-title {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.route-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 54px;
  padding: 6px 10px;
  border-radius: 10px;
  background: var(--yellow);
  color: #16130a;
  font-weight: 800;
  font-size: 18px;
  letter-spacing: -0.02em;
}

.bus-dest {
  font-size: clamp(15px, 1.25vw, 18px);
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.status-pill {
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-3);
  color: var(--text-dim);
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  white-space: nowrap;
}

.status-pill.live {
  border-color: rgba(56, 211, 159, 0.4);
  background: rgba(56, 211, 159, 0.12);
  color: var(--good);
}

.status-pill.warn {
  border-color: rgba(255, 184, 77, 0.4);
  background: rgba(255, 184, 77, 0.1);
  color: var(--warn);
}

.status-pill.bad {
  border-color: rgba(255, 93, 93, 0.4);
  background: rgba(255, 93, 93, 0.1);
  color: var(--bad);
}

.bus-stop-line {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  color: var(--text-faint);
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.muted-dot {
  opacity: 0.5;
}

.bus-next {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  margin-top: clamp(10px, 1.6vh, 20px);
}

.bus-next-main {
  display: flex;
  align-items: baseline;
  gap: 6px;
}

.bus-minutes {
  font-size: clamp(2.8rem, 4.6vw, 4rem);
  font-weight: 700;
  line-height: 0.9;
  letter-spacing: -0.04em;
  font-variant-numeric: tabular-nums;
}

.bus-minutes-unit {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-dim);
}

.bus-next-meta {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding-bottom: 6px;
  font-size: 12px;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
}

.bus-delay {
  color: var(--warn);
}

.bus-delay.early {
  color: var(--good);
}

.bus-distance {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  padding: 8px 11px;
  border-radius: var(--radius-sm);
  background: var(--surface-3);
  border: 1px solid var(--border);
  font-size: 12.5px;
  color: var(--text-dim);
}

.distance-icon {
  color: var(--yellow);
  font-size: 11px;
}

.bus-list {
  list-style: none;
  margin: 12px 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  overflow: hidden;
}

.bus-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 7px 10px;
  border-radius: 10px;
  background: color-mix(in srgb, var(--surface-3) 60%, transparent);
  font-size: 12.5px;
  color: var(--text-dim);
}

.bus-list li .bl-left {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.bus-list li .bl-line {
  font-weight: 700;
  color: var(--text);
}

.bus-list li .bl-dest {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bus-list li .bl-meta {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.bus-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: auto;
  padding-top: 10px;
  color: var(--text-faint);
  font-size: 11px;
}

.bus-source {
  text-align: right;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* search overlay */

.bus-search {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: clamp(14px, 1.4vw, 20px);
  background: color-mix(in srgb, var(--bg) 92%, var(--surface));
  backdrop-filter: blur(8px);
}

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

.bus-search-head input {
  flex: 1;
  min-width: 0;
  padding: 11px 13px;
  border-radius: 12px;
  border: 1px solid var(--border-strong);
  background: var(--surface-2);
  font-size: 14px;
}

.bus-search-head input:focus {
  outline: none;
  border-color: var(--accent);
}

.search-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chip {
  padding: 5px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-dim);
  font-size: 11.5px;
}

.chip:hover {
  color: var(--text);
  border-color: var(--accent);
}

.search-results {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-right: 4px;
}

.search-hint,
.search-empty {
  margin: 4px 0;
  color: var(--text-faint);
  font-size: 12px;
}

.search-group-title {
  margin: 8px 0 2px;
  color: var(--text-faint);
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.search-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  padding: 9px 11px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  text-align: left;
  font-size: 12.5px;
  color: var(--text);
}

.search-item:hover {
  border-color: var(--accent);
}

.search-item small {
  display: block;
  color: var(--text-faint);
  font-size: 11px;
  margin-top: 2px;
}

.search-item .si-meta {
  color: var(--text-dim);
  font-size: 11px;
  white-space: nowrap;
}

/* ---------------- Rocket League card ---------------- */

.card-rl {
  --team-a: var(--blue);
  --team-b: var(--orange);
}

.rl-title {
  display: flex;
  align-items: center;
  gap: 9px;
  font-weight: 600;
  font-size: clamp(14px, 1.15vw, 16px);
}

.rl-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 9px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.02em;
  color: #fff;
  background: linear-gradient(135deg, var(--blue), var(--orange));
}

.rl-score {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 8px;
  margin-top: clamp(8px, 1.4vh, 16px);
}

.rl-team {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.rl-blue {
  align-items: flex-start;
}

.rl-orange {
  align-items: flex-end;
}

.rl-team-name {
  font-size: 11.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-faint);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.rl-team-score {
  font-size: clamp(2.2rem, 3.6vw, 3.2rem);
  font-weight: 800;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.rl-blue .rl-team-score {
  color: var(--team-a);
  text-shadow: 0 0 26px color-mix(in srgb, var(--team-a) 45%, transparent);
}

.rl-orange .rl-team-score {
  color: var(--team-b);
  text-shadow: 0 0 26px color-mix(in srgb, var(--team-b) 45%, transparent);
}

.rl-clock-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.rl-clock {
  font-family: var(--mono);
  font-size: clamp(13px, 1.2vw, 16px);
  font-weight: 600;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
}

.rl-ot {
  padding: 1px 6px;
  border-radius: 4px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.1em;
}

.rl-meta {
  margin-top: 10px;
  font-size: 12px;
  color: var(--text-dim);
  overflow: hidden;
  text-overflow: ellipsis;
}

.rl-goalfeed {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 8px;
  overflow: hidden;
}

.rl-goalfeed .goal-row {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 11.5px;
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.goal-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex: 0 0 auto;
}

.goal-dot.blue {
  background: var(--team-a);
}

.goal-dot.orange {
  background: var(--team-b);
}

.rl-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: auto;
  padding-top: 10px;
  color: var(--text-faint);
  font-size: 11px;
}

.card-rl.is-live {
  border-color: color-mix(in srgb, var(--team-a) 30%, var(--border));
}

.card-rl.is-live::after {
  content: "";
  position: absolute;
  inset: -40% -10% auto;
  height: 70%;
  background: radial-gradient(60% 100% at 50% 0%, color-mix(in srgb, var(--team-a) 16%, transparent), transparent 70%);
  pointer-events: none;
  animation: rlPulse 5.5s ease-in-out infinite;
}

@keyframes rlPulse {
  0%,
  100% {
    opacity: 0.55;
    transform: translateY(0);
  }
  50% {
    opacity: 0.95;
    transform: translateY(6px);
  }
}

.card-rl.goal-flash::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background: radial-gradient(70% 90% at 50% 0%, color-mix(in srgb, var(--team-a) 55%, transparent), transparent 75%);
  animation: goalFlash 1.5s var(--ease);
}

@keyframes goalFlash {
  0% {
    opacity: 0.9;
  }
  100% {
    opacity: 0;
  }
}

/* ---------------- Status bar ---------------- */

.statusbar {
  display: flex;
  align-items: center;
  gap: 22px;
  padding-top: 2px;
  color: var(--text-faint);
  font-size: 11px;
  letter-spacing: 0.04em;
  overflow: hidden;
  white-space: nowrap;
}

.statusbar span {
  overflow: hidden;
  text-overflow: ellipsis;
}

.statusbar span:last-child {
  margin-left: auto;
  text-transform: uppercase;
  letter-spacing: 0.14em;
}

/* ---------------- Modals ---------------- */

.modal {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  padding: clamp(10px, 2vw, 26px);
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(10px);
  animation: modalIn 0.22s var(--ease);
}

@keyframes modalIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.modal-panel {
  width: min(1080px, 100%);
  max-height: 100%;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: clamp(16px, 1.8vw, 24px);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  background: linear-gradient(180deg, var(--surface-2), var(--surface));
  box-shadow: var(--shadow);
  overflow: hidden;
}

.modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.modal-head h2 {
  margin: 0;
  font-size: clamp(17px, 1.6vw, 22px);
  letter-spacing: -0.02em;
}

.modal-sub {
  margin: 3px 0 0;
  color: var(--text-faint);
  font-size: 12.5px;
}

/* map */

.map-panel {
  height: min(88dvh, 760px);
}

.map-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 290px;
  gap: 14px;
  min-height: 0;
  flex: 1;
}

.map-canvas {
  min-height: 260px;
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid var(--border);
  background: #0a0d12;
}

.map-side {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 0;
  overflow-y: auto;
}

.map-hint {
  font-size: 12px;
  line-height: 1.55;
  color: var(--text-dim);
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px dashed var(--border);
}

.map-hint a,
.settings-note a {
  color: var(--accent);
  text-decoration: underline;
}

.map-legend {
  display: flex;
  flex-direction: column;
  gap: 7px;
  padding: 11px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-2);
  font-size: 12px;
  color: var(--text-dim);
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
}

.legend-item i {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.dot-yellow {
  background: var(--yellow);
  box-shadow: 0 0 10px rgba(250, 204, 21, 0.7);
}

.dot-route {
  background: var(--accent);
  border-radius: 2px !important;
  height: 3px !important;
  width: 14px !important;
}

.dot-stop {
  background: var(--text-faint);
}

.map-next {
  padding: 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-2);
  font-size: 12.5px;
  color: var(--text-dim);
  line-height: 1.55;
}

.map-next strong {
  color: var(--text);
  font-size: 15px;
}

.map-search-detail {
  padding: 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-2);
  font-size: 12.5px;
  color: var(--text-dim);
  line-height: 1.55;
}

.map-search-detail ul {
  list-style: none;
  margin: 8px 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.map-search-detail li {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 12px;
}

.leaflet-container {
  background: #0a0d12;
  font-family: var(--font);
}

.leaflet-popup-content-wrapper,
.leaflet-popup-tip {
  background: #14161b;
  color: #f2f2f4;
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.6);
}

.leaflet-popup-content {
  margin: 10px 12px;
  font-size: 12.5px;
  line-height: 1.5;
}

.leaflet-popup-content b {
  color: #fff;
}

.bus-marker {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--yellow);
  color: #17130a;
  font-size: 10px;
  font-weight: 800;
  border: 2px solid #fff8dc;
  box-shadow: 0 0 0 4px rgba(250, 204, 21, 0.22), 0 0 22px rgba(250, 204, 21, 0.5);
  animation: busPulse 2.4s ease-in-out infinite;
}

@keyframes busPulse {
  0%,
  100% {
    box-shadow: 0 0 0 4px rgba(250, 204, 21, 0.2), 0 0 18px rgba(250, 204, 21, 0.4);
  }
  50% {
    box-shadow: 0 0 0 9px rgba(250, 204, 21, 0.06), 0 0 26px rgba(250, 204, 21, 0.65);
  }
}

.pin-marker {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid #fff;
  box-shadow: 0 0 14px color-mix(in srgb, var(--accent) 60%, transparent);
}

.pin-marker.interchange {
  background: #8b5cf6;
}

/* settings */

.settings-panel {
  width: min(680px, 100%);
  max-height: min(92dvh, 900px);
  overflow-y: auto;
}

.settings-auth {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 6px 0 4px;
}

.settings-auth-label {
  margin: 0;
  color: var(--text-dim);
  font-size: 13px;
}

.settings-auth .keypad {
  width: min(340px, 100%);
}

.settings-body {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.settings-body fieldset {
  margin: 0;
  padding: 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--surface-2);
}

.settings-body legend {
  padding: 0 6px;
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-faint);
}

.option-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 8px;
}

.option {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-3);
  text-align: left;
  font-size: 12.5px;
  color: var(--text-dim);
  transition: border-color 0.16s, color 0.16s;
}

.option:hover {
  border-color: var(--border-strong);
  color: var(--text);
}

.option.selected {
  border-color: var(--accent);
  color: var(--text);
  box-shadow: inset 0 0 0 1px var(--accent);
}

.option-swatches {
  display: flex;
  gap: 4px;
}

.option-swatches i {
  width: 16px;
  height: 16px;
  border-radius: 5px;
  border: 1px solid rgba(255, 255, 255, 0.14);
}

.option-name {
  font-weight: 600;
}

.toggle-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 0;
  font-size: 13px;
  color: var(--text-dim);
  cursor: pointer;
}

.toggle-row input {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}

.range-row {
  display: grid;
  grid-template-columns: 1fr 1.4fr auto;
  align-items: center;
  gap: 10px;
  padding: 7px 0;
  font-size: 13px;
  color: var(--text-dim);
}

.range-row input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
}

.range-row output {
  min-width: 42px;
  text-align: right;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  font-size: 12px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  color: var(--text-dim);
}

.field input {
  padding: 11px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--bg-soft);
  font-size: 13px;
  color: var(--text);
  font-family: var(--mono);
}

.field input:focus {
  outline: none;
  border-color: var(--accent);
}

.key-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.settings-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.btn {
  padding: 11px 18px;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: var(--surface-3);
  color: var(--text);
  font-size: 13.5px;
  font-weight: 600;
  min-height: 44px;
}

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}

.btn-ghost {
  background: transparent;
  color: var(--text-dim);
}

.btn:hover {
  filter: brightness(1.08);
}

.settings-note {
  margin: 0;
  font-size: 12px;
  color: var(--text-faint);
  min-height: 1.2em;
}

.settings-note.ok {
  color: var(--good);
}

.settings-note.bad {
  color: var(--bad);
}

/* ---------------- Rocket League fullscreen ---------------- */

.rl-full {
  padding: 0;
  background: #05060a;
  display: flex;
  flex-direction: column;
  gap: clamp(10px, 1.4vh, 18px);
  padding: clamp(14px, 1.6vw, 26px) clamp(16px, 2vw, 34px);
  overflow-y: auto;
  z-index: 70;
}

.rl-full-bg {
  position: absolute;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(60% 70% at 8% 0%, color-mix(in srgb, var(--team-a) 34%, transparent), transparent 70%),
    radial-gradient(60% 70% at 92% 100%, color-mix(in srgb, var(--team-b) 30%, transparent), transparent 70%),
    #05060a;
  transition: background 0.6s var(--ease);
}

.rl-full.rl-goal .rl-full-bg {
  animation: rlGoalFlash 1.8s var(--ease);
}

@keyframes rlGoalFlash {
  0% {
    filter: brightness(1.9) saturate(1.3);
  }
  100% {
    filter: brightness(1) saturate(1);
  }
}

.rl-full-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.rl-full-head h2 {
  margin: 0;
  font-size: clamp(16px, 1.6vw, 22px);
  letter-spacing: -0.02em;
}

.rl-full-score {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: clamp(10px, 2vw, 30px);
  padding: clamp(8px, 1.4vh, 18px) 0;
}

.rl-full-team {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.rl-full-team.rl-blue {
  align-items: flex-start;
}

.rl-full-team.rl-orange {
  align-items: flex-end;
}

.rl-full-team-name {
  font-size: clamp(11px, 1vw, 13px);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--text-dim);
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rl-full-score-value {
  font-size: clamp(4rem, 9vw, 8rem);
  font-weight: 800;
  line-height: 0.86;
  letter-spacing: -0.05em;
  font-variant-numeric: tabular-nums;
}

.rl-blue .rl-full-score-value {
  color: var(--team-a);
  text-shadow: 0 0 60px color-mix(in srgb, var(--team-a) 55%, transparent);
}

.rl-orange .rl-full-score-value {
  color: var(--team-b);
  text-shadow: 0 0 60px color-mix(in srgb, var(--team-b) 55%, transparent);
}

.rl-full-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.rl-full-clock {
  font-family: var(--mono);
  font-size: clamp(16px, 1.8vw, 24px);
  font-weight: 600;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.rl-full-ot {
  padding: 2px 8px;
  border-radius: 5px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.14em;
}

.rl-full-arena {
  color: var(--text-faint);
  font-size: 11.5px;
}

.rl-full-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(96px, 1fr));
  gap: 8px;
}

.stat-chip {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 9px 11px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(10, 12, 18, 0.55);
  font-size: 11px;
  color: var(--text-dim);
}

.stat-chip strong {
  font-size: 16px;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.rl-boards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: clamp(10px, 1.4vw, 18px);
}

.rl-board {
  padding: 12px;
  border-radius: var(--radius-md);
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(10, 12, 18, 0.6);
  min-width: 0;
}

.rl-board h3,
.rl-events h3 {
  margin: 0 0 8px;
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--text-dim);
}

.rl-board.rl-blue {
  border-top: 2px solid var(--team-a);
}

.rl-board.rl-orange {
  border-top: 2px solid var(--team-b);
}

.score-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
  font-variant-numeric: tabular-nums;
}

.score-table th {
  padding: 5px 6px;
  text-align: right;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-faint);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.score-table th:first-child,
.score-table td:first-child {
  text-align: left;
}

.score-table td {
  padding: 6px;
  text-align: right;
  color: var(--text-dim);
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.score-table tr:last-child td {
  border-bottom: none;
}

.score-table td:first-child {
  color: var(--text);
  font-weight: 500;
  max-width: 160px;
}

.score-table td.player-score {
  color: var(--text);
  font-weight: 600;
}

.rl-events {
  padding: 12px;
  border-radius: var(--radius-md);
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(10, 12, 18, 0.6);
}

.rl-events ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.rl-events li {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 11px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.05);
  font-size: 12px;
  color: var(--text-dim);
}

.rl-events li.muted {
  background: none;
  color: var(--text-faint);
}

/* ---------------- Toast ---------------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  z-index: 90;
  transform: translateX(-50%);
  padding: 11px 18px;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: var(--surface-2);
  box-shadow: var(--shadow);
  font-size: 13px;
  color: var(--text);
  animation: toastIn 0.24s var(--ease);
}

.toast.bad {
  border-color: rgba(255, 93, 93, 0.5);
  color: var(--bad);
}

@keyframes toastIn {
  from {
    opacity: 0;
    transform: translate(-50%, 10px);
  }
  to {
    opacity: 1;
    transform: translate(-50%, 0);
  }
}

/* ---------------- Responsive ---------------- */

@media (max-width: 1024px) {
  .layout {
    grid-template-columns: minmax(0, 1.35fr) minmax(300px, 0.9fr);
  }

  .clock-main {
    font-size: clamp(4rem, 14vw, 10rem);
  }

  .map-body {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: minmax(200px, 1fr) auto;
  }
}

@media (max-width: 900px), (orientation: portrait) {
  body {
    overflow-y: auto;
  }

  .app {
    height: auto;
    min-height: 100dvh;
  }

  .layout {
    grid-template-columns: minmax(0, 1fr);
  }

  .hero {
    padding-left: 0;
    align-items: flex-start;
  }

  .rail {
    grid-template-rows: auto auto;
  }

  .card {
    min-height: 230px;
  }

  .clock-main {
    font-size: clamp(4.2rem, 21vw, 9rem);
  }

  .rl-boards {
    grid-template-columns: 1fr;
  }

  .rl-full-score {
    grid-template-columns: 1fr auto 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}
