/* FeenyFlight — retro Lite-Brite / LED billboard styling */

:root {
  --bg: #060608;
  --bg-2: #0d0e12;
  --panel: #14151b;
  --panel-2: #1b1d25;
  --line: #2a2d38;
  --ink: #e9edf4;
  --muted: #8b93a7;
  --amber: #ffb000;
  --amber-dim: #7a5600;
  --accent: #ff2e6d;
  --good: #2bff88;
  --frame: #1a1206;
  --frame-2: #2c1f0a;
  --shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
  --mono: 'Courier New', ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

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

body {
  font-family: var(--sans);
  color: var(--ink);
  background:
    radial-gradient(1200px 800px at 50% -10%, #10131c 0%, var(--bg) 60%),
    var(--bg);
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* Starfield backdrop */
.stars {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background-image:
    radial-gradient(1px 1px at 20% 30%, rgba(255, 255, 255, 0.7), transparent),
    radial-gradient(1px 1px at 70% 20%, rgba(255, 255, 255, 0.5), transparent),
    radial-gradient(1px 1px at 40% 70%, rgba(255, 255, 255, 0.6), transparent),
    radial-gradient(1px 1px at 85% 60%, rgba(255, 255, 255, 0.4), transparent),
    radial-gradient(1.5px 1.5px at 15% 85%, rgba(255, 255, 255, 0.5), transparent),
    radial-gradient(1px 1px at 60% 90%, rgba(255, 255, 255, 0.35), transparent);
  opacity: 0.5;
}

a { color: var(--amber); }

/* ============================ LOGO ============================ */
.logo {
  font-family: var(--mono);
  font-weight: 700;
  letter-spacing: 0.14em;
  font-size: clamp(1.9rem, 6vw, 3.1rem);
  margin: 0 0 0.4rem;
  color: var(--amber);
  text-shadow: 0 0 6px rgba(255, 176, 0, 0.7), 0 0 22px rgba(255, 176, 0, 0.45);
}
.logo-accent { color: #fff; text-shadow: 0 0 6px rgba(255, 255, 255, 0.7), 0 0 22px rgba(255, 255, 255, 0.35); }
.logo-plane { color: #fff; text-shadow: 0 0 10px rgba(255, 255, 255, 0.8); }

/* ======================= INTRO OVERLAY ======================= */
.intro {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.4rem;
  padding: 1.5rem;
  background:
    radial-gradient(900px 600px at 50% 20%, rgba(20, 24, 36, 0.9), rgba(6, 6, 8, 0.97));
  backdrop-filter: blur(2px);
}
.intro.hide { opacity: 0; visibility: hidden; transition: opacity 0.5s ease, visibility 0.5s; }

.intro-card {
  width: min(440px, 100%);
  background: linear-gradient(180deg, var(--panel), var(--bg-2));
  border: 1px solid var(--line);
  border-radius: 0;
  box-shadow: var(--shadow), inset 0 1px 0 rgba(255, 255, 255, 0.04);
  padding: 2rem 1.6rem 1.7rem;
  text-align: center;
}
.tagline { color: var(--muted); margin: 0 0 1.5rem; font-size: 0.98rem; line-height: 1.5; }

.btn {
  font-family: var(--sans);
  font-size: 1rem;
  font-weight: 600;
  border: 1px solid var(--line);
  border-radius: 0;
  padding: 0.85rem 1.1rem;
  cursor: pointer;
  color: var(--ink);
  background: var(--panel-2);
  transition: transform 0.08s ease, box-shadow 0.2s ease, background 0.2s;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn-primary {
  width: 100%;
  color: #1a1206;
  background: linear-gradient(180deg, #ffc63f, var(--amber));
  border-color: #ffd873;
  box-shadow: 0 6px 20px rgba(255, 176, 0, 0.35), 0 0 0 1px rgba(255, 176, 0, 0.2) inset;
  letter-spacing: 0.06em;
}
.btn-primary:hover { box-shadow: 0 10px 28px rgba(255, 176, 0, 0.5); }
.btn-icon { margin-right: 0.4rem; }

.intro-or {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  color: var(--muted);
  margin: 1.2rem 0;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}
.intro-or::before, .intro-or::after {
  content: "";
  height: 1px;
  flex: 1;
  background: var(--line);
}

.place-form { display: flex; gap: 0.5rem; }
.input {
  flex: 1;
  min-width: 0;
  font-size: 1rem;
  padding: 0.8rem 0.9rem;
  border-radius: 0;
  border: 1px solid var(--line);
  background: #0a0b0f;
  color: var(--ink);
}
.input:focus { outline: none; border-color: var(--amber); box-shadow: 0 0 0 3px rgba(255, 176, 0, 0.15); }
.btn-go { background: var(--panel-2); padding-inline: 1.3rem; }

.radius-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
  margin-top: 1.3rem;
  color: var(--muted);
  font-size: 0.92rem;
}
.select {
  font-family: var(--sans);
  font-size: 0.92rem;
  padding: 0.5rem 0.7rem;
  border-radius: 0;
  border: 1px solid var(--line);
  background: #0a0b0f;
  color: var(--ink);
  cursor: pointer;
}
.select:focus { outline: none; border-color: var(--amber); }

.intro-msg { min-height: 1.2em; margin: 1rem 0 0; font-size: 0.9rem; color: var(--accent); }
.intro-msg.busy { color: var(--amber); }

/* ========================== APP SHELL ========================== */
.app {
  position: relative;
  z-index: 1;
  max-width: 1100px;
  margin: 0 auto;
  /* Honour iOS safe areas since the viewport is viewport-fit=cover. */
  padding: max(1rem, env(safe-area-inset-top)) max(1rem, env(safe-area-inset-right))
           2rem max(1rem, env(safe-area-inset-left));
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding-top: 0.4rem;
}
.brand {
  font-family: var(--mono);
  font-weight: 700;
  letter-spacing: 0.12em;
  font-size: clamp(1rem, 3.5vw, 1.4rem);
  color: var(--amber);
  text-shadow: 0 0 6px rgba(255, 176, 0, 0.6);
}
.brand .logo-accent { color: #fff; }

.chip {
  font-family: var(--mono);
  font-size: 0.85rem;
  color: var(--ink);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 0;
  padding: 0.45rem 0.9rem;
  cursor: pointer;
  max-width: 60vw;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}
.chip:hover { border-color: var(--amber); }
.chip-edit { color: var(--muted); }

/* ========================= BILLBOARD ========================= */
.billboard { display: flex; justify-content: center; }
.billboard-frame {
  width: 100%;
  border-radius: 0;
  padding: 18px 18px 10px;
  background:
    linear-gradient(180deg, #3a2a0d, #1a1206 40%, #120c04);
  border: 1px solid #4a380f;
  box-shadow:
    var(--shadow),
    inset 0 2px 3px rgba(255, 210, 120, 0.18),
    inset 0 -3px 8px rgba(0, 0, 0, 0.7);
}
.billboard-screen {
  position: relative;
  border-radius: 0;
  overflow: hidden;
  background: #050505;
  border: 2px solid #000;
  box-shadow: inset 0 0 40px rgba(0, 0, 0, 0.9), inset 0 0 3px rgba(255, 255, 255, 0.06);
  aspect-ratio: 16 / 4.2;
  min-height: 130px;
}
.led {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}
.scanlines {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: repeating-linear-gradient(
    to bottom,
    rgba(0, 0, 0, 0) 0,
    rgba(0, 0, 0, 0) 2px,
    rgba(0, 0, 0, 0.16) 3px,
    rgba(0, 0, 0, 0.16) 3px
  );
  mix-blend-mode: multiply;
}
.vignette {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(120% 120% at 50% 50%, rgba(0, 0, 0, 0) 55%, rgba(0, 0, 0, 0.55) 100%);
}
.glass {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(160deg, rgba(255, 255, 255, 0.06) 0%, rgba(255, 255, 255, 0) 30%);
}
.billboard-brand {
  text-align: center;
  font-family: var(--mono);
  font-size: 0.7rem;
  letter-spacing: 0.35em;
  color: #6b5320;
  padding-top: 8px;
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.6);
}

/* ========================= STATUS BAR ========================= */
.statusbar {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.7rem;
}
.stat {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 0;
  padding: 0.7rem 0.6rem;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}
.stat-num {
  font-family: var(--mono);
  font-size: clamp(1.1rem, 4vw, 1.6rem);
  font-weight: 700;
  color: var(--amber);
  text-shadow: 0 0 8px rgba(255, 176, 0, 0.4);
}
.stat-lbl {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}
.stat-src { justify-content: center; }
.dot {
  width: 9px;
  height: 9px;
  border-radius: 0;
  background: var(--muted);
  margin: 0 auto 0.2rem;
  box-shadow: 0 0 8px currentColor;
  color: var(--muted);
}
.dot.live { background: var(--good); color: var(--good); animation: pulse 2s infinite; }
.dot.stale { background: var(--amber); color: var(--amber); }
.dot.error { background: var(--accent); color: var(--accent); }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }

/* ========================= CONTROLS ========================= */
.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.7rem;
  align-items: flex-end;
}
.ctrl {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}
.btn-ghost {
  background: var(--panel);
  padding: 0.55rem 1rem;
  font-size: 0.9rem;
}
.btn-ghost.paused { color: var(--amber); border-color: var(--amber); }

/* Ticker-speed slider */
.ctrl-speed { flex: 1 1 190px; min-width: 170px; }
.readout {
  font-style: normal;
  font-weight: 700;
  color: var(--amber);
  text-shadow: 0 0 6px rgba(255, 176, 0, 0.4);
}
.range {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  margin: 0.55rem 0 0.15rem;
  border-radius: 0;
  background: linear-gradient(90deg, var(--amber-dim), var(--amber));
  outline: none;
  cursor: pointer;
}
.range:focus { box-shadow: 0 0 0 3px rgba(255, 176, 0, 0.18); }
.range::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 0;
  background: radial-gradient(circle at 35% 30%, #ffe6a8, var(--amber));
  border: 1px solid #ffd873;
  box-shadow: 0 0 8px rgba(255, 176, 0, 0.7);
}
.range::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 0;
  background: radial-gradient(circle at 35% 30%, #ffe6a8, var(--amber));
  border: 1px solid #ffd873;
  box-shadow: 0 0 8px rgba(255, 176, 0, 0.7);
}

/* ========================== ROSTER ========================== */
.roster {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 0;
  padding: 1rem 1.1rem 1.2rem;
}
.roster-title {
  font-family: var(--mono);
  font-size: 0.8rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 0.8rem;
}
.roster-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 0.6rem;
}
.roster-item {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 0.7rem;
  padding: 0.6rem 0.75rem;
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  border: 1px solid var(--line);
  border-radius: 0;
}
.ri-plane {
  font-size: 1.1rem;
  color: var(--amber);
  display: inline-block;
  transition: transform 0.3s ease;
}
.ri-main { min-width: 0; }
.ri-flight {
  font-family: var(--mono);
  font-weight: 700;
  font-size: 1rem;
  color: var(--ink);
}
.ri-airline {
  font-size: 0.78rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ri-meta {
  text-align: right;
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--amber);
  line-height: 1.5;
  white-space: nowrap;
}
.ri-meta .sub { color: var(--muted); }
.roster-empty { color: var(--muted); font-size: 0.9rem; margin: 0.4rem 0 0; }

/* ======================= ATTRIBUTION ======================= */
.attribution {
  position: relative;
  z-index: 1;
  max-width: 1100px;
  margin: 0 auto;
  padding: 1.4rem max(1rem, env(safe-area-inset-right))
           max(2.4rem, env(safe-area-inset-bottom)) max(1rem, env(safe-area-inset-left));
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 1.4rem;
  justify-content: center;
  text-align: center;
  color: var(--muted);
  font-size: 0.76rem;
}
.attribution a { text-decoration: none; }
.attribution a:hover { text-decoration: underline; }

/* ========================= RESPONSIVE ========================= */
@media (max-width: 560px) {
  .statusbar { grid-template-columns: repeat(2, 1fr); }
  .billboard-screen { aspect-ratio: 16 / 6; }
  .controls { justify-content: space-between; }
  .ctrl { flex: 1 1 40%; }
  .btn-pause, #btn-pause { flex: 1 1 100%; }
}

@media (prefers-reduced-motion: reduce) {
  .dot.live { animation: none; }
}
