/* LegTracker — dark, big touch targets. Built for use during games. */
:root {
  --bg: #0b0f1a;
  --card: #151c2e;
  --card2: #1d2640;
  --text: #f2f5fb;
  --muted: #8b96b3;
  --green: #22c55e;
  --red: #ef4444;
  --amber: #f59e0b;
  --blue: #3b82f6;
  --radius: 16px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; padding: 0; background: var(--bg); color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", sans-serif;
  min-height: 100%;
  padding-bottom: env(safe-area-inset-bottom);
}
#topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: rgba(11,15,26,.92); backdrop-filter: blur(8px);
  border-bottom: 1px solid #1e2742;
}
#topbar h1 { font-size: 20px; margin: 0; }
.top-actions { display: flex; gap: 8px; }
.icon-btn {
  background: var(--card); color: var(--text); border: 1px solid #26304d;
  width: 44px; height: 44px; border-radius: 12px; font-size: 20px;
  display: flex; align-items: center; justify-content: center; cursor: pointer;
}
.icon-btn:active { background: var(--card2); }
.icon-btn.on { border-color: var(--green); }
.hidden { display: none !important; }

.conn {
  text-align: center; font-size: 13px; color: var(--amber);
  padding: 6px; background: #2a2111;
}

.sport-filter {
  display: flex; gap: 8px; padding: 8px 12px 0; max-width: 560px; margin: 0 auto;
  overflow-x: auto;
}
.sport-filter:empty { display: none; }
.sport-filter button {
  flex-shrink: 0; background: var(--card); color: var(--text);
  border: 1px solid #2a3352; border-radius: 999px; padding: 6px 12px;
  font-size: 13px; cursor: pointer;
}
.sport-filter button.sel { background: var(--blue); border-color: var(--blue); }

#dashboard { padding: 12px 12px 110px; max-width: 560px; margin: 0 auto; }
.empty { text-align: center; color: var(--muted); margin-top: 60px; }
.empty .sub { font-size: 14px; }

.leg-card {
  background: var(--card); border-radius: var(--radius);
  padding: 14px; margin-bottom: 12px; border: 1px solid #202a49;
  position: relative;
}
.leg-card.hit { border-color: #f59e0b;
  box-shadow: 0 0 0 1px #f59e0b44, 0 0 22px #f59e0b33; }
.leg-card.hit .bar > div { background: linear-gradient(90deg, #b45309, #fbbf24); }
.leg-card.miss { border-color: var(--red); opacity: .75; }
.hit-chip {
  display: inline-block; margin-top: 6px; font-size: 11px; font-weight: 800;
  letter-spacing: .08em; color: #fde68a;
  background: #78350f66; border: 1px solid #f59e0b99;
  border-radius: 999px; padding: 2px 10px;
}
/* one-shot celebration when a leg hits live */
@keyframes hitPop {
  0% { transform: scale(1); box-shadow: 0 0 0 0 #fbbf2455; }
  25% { transform: scale(1.025); box-shadow: 0 0 0 4px #fbbf2466, 0 0 34px #fbbf24aa; }
  100% { transform: scale(1); box-shadow: 0 0 0 1px #f59e0b44, 0 0 22px #f59e0b33; }
}
.leg-card.just-hit { animation: hitPop 1.4s ease-out; }
/* dead-leg troll: shake + a rotating roast line */
.troll-line {
  margin-top: 8px; font-size: 12.5px; font-style: italic; color: var(--muted);
}
@keyframes missShake {
  0%, 100% { transform: translateX(0); }
  15% { transform: translateX(-7px); }
  30% { transform: translateX(6px); }
  45% { transform: translateX(-4px); }
  60% { transform: translateX(3px); }
  75% { transform: translateX(-2px); }
}
.leg-card.just-missed { animation: missShake 1.1s ease-out; }
/* possession highlight: glowing blue top bar + chip, only on live open legs */
.leg-card.has-possession { border-color: #3b82f6;
  box-shadow: 0 0 0 1px #3b82f655, 0 0 18px #3b82f633; }
.leg-card.has-possession::before {
  content: ""; position: absolute; top: 0; left: 14px; right: 14px; height: 3px;
  border-radius: 0 0 4px 4px;
  background: linear-gradient(90deg, #2563eb, #60a5fa, #2563eb);
  box-shadow: 0 0 12px #60a5fa;
}
.poss-chip {
  display: inline-block; margin-top: 6px; font-size: 11px; font-weight: 700;
  letter-spacing: .06em; color: #93c5fd;
  background: #1e3a8a55; border: 1px solid #3b82f688;
  border-radius: 999px; padding: 2px 8px;
}
.leg-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.leg-label { font-weight: 700; font-size: 16px; line-height: 1.3; }
.leg-sub { color: var(--muted); font-size: 13px; margin-top: 4px; }
.leg-badge {
  font-size: 22px; flex-shrink: 0;
}
.bar {
  height: 12px; background: #0d1322; border-radius: 8px; margin-top: 12px;
  overflow: hidden;
}
.bar > div {
  height: 100%; border-radius: 8px;
  background: linear-gradient(90deg, var(--blue), #60a5fa);
  transition: width .4s ease;
}
.leg-card.hit .bar > div { background: linear-gradient(90deg, #16a34a, var(--green)); }
.leg-card.miss .bar > div { background: linear-gradient(90deg, #b91c1c, var(--red)); }
.leg-progress { display: flex; justify-content: space-between; margin-top: 6px; font-size: 13px; color: var(--muted); }
.leg-progress b { color: var(--text); font-size: 15px; }
.leg-del {
  position: absolute; top: 8px; right: 8px; background: none; border: none;
  color: var(--muted); font-size: 16px; padding: 8px; cursor: pointer;
}

.fab {
  position: fixed; right: 20px; bottom: calc(24px + env(safe-area-inset-bottom));
  width: 64px; height: 64px; border-radius: 50%;
  background: var(--green); color: #06210f; font-size: 32px; border: none;
  box-shadow: 0 6px 20px rgba(34,197,94,.4); cursor: pointer;
}
.fab:active { transform: scale(.94); }

/* bottom sheet */
.sheet {
  position: fixed; inset: 0; z-index: 50; background: rgba(0,0,0,.6);
  display: flex; align-items: flex-end; justify-content: center;
}
.sheet-card {
  background: var(--card); width: 100%; max-width: 560px;
  max-height: 82vh; border-radius: 20px 20px 0 0;
  display: flex; flex-direction: column;
  padding-bottom: env(safe-area-inset-bottom);
}
.sheet-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 16px 6px; }
.sheet-head h2 { margin: 0; font-size: 18px; }
#sheet-body { overflow-y: auto; padding: 6px 12px 20px; }

.row-item {
  width: 100%; text-align: left; background: var(--card2); color: var(--text);
  border: 1px solid #26304d; border-radius: 12px; padding: 14px; margin: 8px 0;
  font-size: 16px; cursor: pointer; display: flex; justify-content: space-between; align-items: center;
}
.row-item:active { background: #27335a; }
.row-item .tag { color: var(--muted); font-size: 13px; }
.search {
  width: 100%; padding: 14px; font-size: 16px; border-radius: 12px;
  border: 1px solid #26304d; background: #0d1322; color: var(--text); margin: 8px 0;
}
.seg { display: flex; gap: 8px; margin: 10px 0; flex-wrap: wrap; }
.seg button {
  flex: 1; padding: 14px 4px; border-radius: 12px; font-size: 15px; font-weight: 600;
  background: var(--card2); color: var(--text); border: 1px solid #26304d; cursor: pointer;
}
.seg button.sel { background: var(--blue); border-color: var(--blue); }
.stepper { display: flex; align-items: center; gap: 12px; margin: 10px 0; }
.stepper button {
  width: 52px; height: 52px; border-radius: 14px; font-size: 24px;
  background: var(--card2); color: var(--text); border: 1px solid #26304d; cursor: pointer;
}
.stepper .val { font-size: 28px; font-weight: 800; min-width: 90px; text-align: center; }
.big-btn {
  width: 100%; padding: 16px; margin-top: 14px; border-radius: 14px; border: none;
  background: var(--green); color: #06210f; font-size: 18px; font-weight: 800; cursor: pointer;
}
.big-btn:active { transform: scale(.98); }
.field-label { color: var(--muted); font-size: 13px; margin: 14px 0 2px; text-transform: uppercase; letter-spacing: .5px; }
.back-link { background: none; border: none; color: var(--blue); font-size: 15px; padding: 10px 0; cursor: pointer; }

.install-steps { padding: 6px 18px 24px; font-size: 16px; line-height: 1.5; }
.install-steps ol { padding-left: 22px; }
.install-steps li { margin: 10px 0; }
.glyph { border: 1px solid var(--muted); border-radius: 6px; padding: 1px 7px; }
.sub { color: var(--muted); font-size: 14px; }

/* bottom banner (config-driven, dismissible) */
#banner {
  margin: 18px 4px 8px; padding: 14px 40px 14px 16px; text-align: center;
  background: var(--card); border: 1px dashed #2b3a66; border-radius: var(--radius);
  font-size: 17px; font-weight: 700; position: relative;
}
#banner a {
  color: inherit; text-decoration: underline;
  text-decoration-color: var(--amber); text-underline-offset: 3px;
}
#banner img { max-width: 100%; max-height: 90px; border-radius: 8px; display: block; margin: 0 auto; }
.banner-x {
  position: absolute; top: 6px; right: 6px; background: none; border: none;
  color: var(--muted); font-size: 15px; padding: 10px; cursor: pointer;
}

/* slip import */
.slip-text {
  width: 100%; padding: 14px; font-size: 15px; border-radius: 12px;
  border: 1px solid #26304d; background: #0d1322; color: var(--text);
  margin: 8px 0; font-family: inherit; resize: vertical;
}
.file-inp { width: 100%; margin: 4px 0 8px; font-size: 15px; color: var(--muted); }
.err {
  background: #3a1414; border: 1px solid var(--red); color: #ffb4b4;
  border-radius: 12px; padding: 12px; margin-top: 12px; font-size: 14px;
}
.warn {
  background: #2a2111; border: 1px solid var(--amber); color: #ffd88a;
  border-radius: 12px; padding: 10px 12px; margin: 8px 0; font-size: 14px;
}
.imp-row {
  background: var(--card2); border: 1px solid #26304d; border-radius: 12px;
  padding: 12px; margin: 10px 0;
}
.imp-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.imp-head-btns { display: flex; gap: 6px; flex-shrink: 0; }
.mini-btn {
  background: var(--card); color: var(--text); border: 1px solid #26304d;
  border-radius: 10px; padding: 10px 12px; font-size: 14px; cursor: pointer;
}
.mini-btn.danger { color: var(--red); }
.conf { font-size: 13px; font-weight: 700; }
.conf.ok { color: var(--green); }
.conf.low { color: var(--amber); }
.warn-t { color: var(--amber); }
.imp-line { display: flex; gap: 10px; align-items: center; }
.imp-line .seg { flex: 1; }
.stepper.sm button { width: 44px; height: 44px; font-size: 20px; }
.stepper.sm .val { font-size: 20px; min-width: 52px; }
