/* ==========================================================================
   Tactics Board — sideline visual system
   Dark, outdoor-first. Chrome stays monochrome; colour is reserved for data
   (home, away, ball, ink). Volt marks only what is active.
   ========================================================================== */

/* Self-hosted, not Google Fonts: this is meant to work with zero signal at a
   pitch from the very first launch, not just after one lucky online load.
   Public Sans ships as a single variable file covering weights 400-700. */
@font-face {
  font-family: 'Public Sans';
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url('../fonts/public-sans-var.woff2') format('woff2');
}
@font-face {
  font-family: 'Bebas Neue';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('../fonts/bebas-neue-400.woff2') format('woff2');
}

:root {
  color-scheme: dark;

  /* chrome */
  --bg: #0b0e0d;
  --bar: #101514;
  --inset: #171e1c;
  --raised: #202826;
  --line: #232b29;
  --line-2: #2e3937;
  --text: #f1f5f3;
  --dim: #98a6a1;
  --dim-2: #7f8d88;

  /* data + state */
  --accent: #cdee4f;
  --accent-ink: #0b0e0d;
  --accent-tint: rgba(205, 238, 79, 0.14);
  --home: #3bb0ea;
  --home-ink: #04202e;
  --away: #ffa23a;
  --away-ink: #3a1c00;
  --danger: #f2564b;
  --danger-ink: #1a0605;
  --danger-line: #4a2724;
  --pitch: #17332a;

  --ui: 'Public Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;
  --display: 'Bebas Neue', 'Arial Narrow', Haettenschweiler, sans-serif;

  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  height: 100%;
  margin: 0;
  overscroll-behavior: none;
  background: var(--bg);
}

body {
  font-family: var(--ui);
  color: var(--text);
  user-select: none;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); }
a:hover { color: #e2fa8c; }

button, input { font-family: inherit; }

#app {
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ---------------------------------------------------------------- HEADER */
#app-header {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: calc(10px + var(--safe-top)) 10px 10px;
  background: var(--bar);
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}

.icon-btn {
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  border-radius: 12px;
  color: var(--text);
  flex-shrink: 0;
  transition: background 140ms ease-out;
}
.icon-btn:active { background: var(--raised); }
.icon-btn svg { width: 23px; height: 23px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.icon-btn[disabled] { color: var(--dim-2); opacity: 0.35; }
.icon-btn.hidden { display: none; }
#install-btn { color: var(--accent); }

.board-name {
  flex: 1;
  min-width: 0;
  height: 44px;
  display: flex;
  align-items: center;
  gap: 7px;
  justify-content: center;
  background: var(--inset);
  border: 1px solid var(--line);
  color: var(--text);
  font-size: 15.5px;
  font-weight: 600;
  letter-spacing: -0.01em;
  padding: 0 12px;
  border-radius: 12px;
}
.board-name:active { background: var(--raised); }
.board-name span#board-name-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.board-name .pencil { width: 14px; height: 14px; flex-shrink: 0; fill: none; stroke: var(--dim-2); stroke-width: 2; stroke-linecap: round; }

/* ----------------------------------------------------------------- PITCH */
#pitch-wrap {
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  position: relative;
  padding: 8px;
}

#pitch {
  width: 100%;
  height: 100%;
  background: transparent;
  touch-action: none;
  display: block;
}

.pitch-surface { fill: var(--pitch); }
.pitch-stripe { fill: #ffffff; fill-opacity: 0.022; }

/* live-recording frame — the board itself tells you it is capturing */
#pitch-wrap.recording::after {
  content: '';
  position: absolute;
  inset: 8px;
  border: 1.5px solid rgba(242, 86, 75, 0.55);
  border-radius: 6px;
  pointer-events: none;
}

.mode-hint {
  position: fixed;
  top: calc(16px + var(--safe-top));
  left: 50%;
  transform: translateX(-50%);
  max-width: calc(100% - 32px);
  background: var(--accent);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.45);
  padding: 12px 20px;
  border-radius: 100px;
  font-size: 14.5px;
  font-weight: 700;
  color: var(--accent-ink);
  text-align: center;
  pointer-events: none;
  z-index: 300;
}
.mode-hint.hidden { display: none; }

/* ---------------------------------------------------------- CONTEXT BARS */
.context-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--bar);
  border-top: 1px solid var(--line);
  flex-shrink: 0;
}
.context-bar.hidden { display: none; }

/* a coloured top edge names the active mode without being read */
#draw-bar { border-top-color: var(--accent); flex-direction: column; align-items: stretch; gap: 9px; }
#erase-bar { border-top-color: var(--danger); }
#add-bar { border-top-color: var(--home); }
#record-bar { border-top-color: var(--danger); }
#playback-bar { border-top-color: var(--accent); }

.bar-row { display: flex; align-items: center; justify-content: center; gap: 10px; }
.ink-row { gap: 13px; padding-right: 2px; }
.bar-label {
  font-family: var(--display);
  font-size: 15px;
  letter-spacing: 0.14em;
  color: var(--dim-2);
}

.seg-group {
  display: flex;
  gap: 3px;
  background: var(--bg);
  padding: 3px;
  border-radius: 12px;
  flex-shrink: 0;
}
.seg-btn {
  width: 44px;
  height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  border-radius: 9px;
  color: var(--dim);
  transition: background 140ms ease-out, color 140ms ease-out;
}
.seg-btn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.seg-btn.active { background: var(--accent); color: var(--accent-ink); }
#draw-style-group .seg-btn { width: 42px; }
#draw-style-group .seg-btn.active { background: var(--raised); color: var(--text); }

#draw-color-group { background: transparent; padding: 0; gap: 13px; }
.color-dot {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: none;
  background: var(--dot);
  flex-shrink: 0;
  transition: box-shadow 140ms ease-out;
}
.color-dot.active { box-shadow: 0 0 0 2px var(--bar), 0 0 0 4px var(--dot); }

.hint-text { color: #b9c6c1; font-size: 13px; font-weight: 500; flex: 1; min-width: 0; }

.record-dot {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: var(--danger);
  flex-shrink: 0;
  box-shadow: 0 0 12px rgba(242, 86, 75, 0.8);
  animation: record-pulse 1.1s ease-in-out infinite;
}
@keyframes record-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}
.rec-tag {
  font-family: var(--display);
  font-size: 20px;
  letter-spacing: 0.08em;
  color: var(--danger);
  flex-shrink: 0;
}
.rec-time {
  font-family: var(--display);
  font-size: 20px;
  letter-spacing: 0.06em;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}
.play-icon { width: 18px; height: 18px; fill: var(--accent); flex-shrink: 0; }
#playback-name { font-weight: 700; }

.text-btn {
  background: transparent;
  border: none;
  color: var(--accent);
  font-size: 14px;
  font-weight: 700;
  padding: 10px 4px;
  white-space: nowrap;
}
.text-btn.danger { color: var(--danger); }

.solid-btn {
  height: 44px;
  padding: 0 18px;
  border: none;
  border-radius: 12px;
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 14px;
  font-weight: 700;
  white-space: nowrap;
  flex-shrink: 0;
}
.solid-btn.danger { background: var(--danger); color: var(--danger-ink); }
.solid-btn:active { filter: brightness(1.12); }

.outline-btn {
  height: 44px;
  padding: 0 16px;
  border: 1px solid var(--line-2);
  border-radius: 12px;
  background: transparent;
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  flex-shrink: 0;
}
.outline-btn.danger { color: var(--danger); border-color: var(--danger-line); }

/* ------------------------------------------------------------ BOTTOM NAV */
#bottom-nav {
  display: flex;
  background: var(--bar);
  border-top: 1px solid var(--line);
  padding-bottom: var(--safe-bottom);
  flex-shrink: 0;
}
.nav-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: transparent;
  border: none;
  color: var(--dim);
  padding: 12px 2px 14px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  transition: color 140ms ease-out;
}
.nav-btn svg { width: 25px; height: 25px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.nav-btn.active { color: var(--accent); font-weight: 700; box-shadow: inset 0 2px 0 var(--accent); }
.nav-btn:active { background: var(--inset); }

/* ---------------------------------------------------------------- SHEETS */
.sheet-overlay {
  position: fixed;
  inset: 0;
  background: rgba(4, 6, 6, 0.62);
  display: flex;
  align-items: flex-end;
  z-index: 50;
}
.sheet-overlay.hidden { display: none; }

/* -------------------------------------------------------------- DIALOG
   Replaces confirm()/prompt() — same job (a yes/no or a short text entry
   before the app does something), styled like the rest of the app instead
   of however the OS happens to draw its own alert box. Centred, not a
   bottom sheet: this is a quick decision, not a panel to browse. */
.dialog-overlay {
  position: fixed;
  inset: 0;
  background: rgba(4, 6, 6, 0.62);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 60;
}
.dialog-overlay.hidden { display: none; }
.dialog-card {
  width: 100%;
  max-width: 340px;
  background: var(--raised);
  border: 1px solid var(--line-2);
  border-radius: 18px;
  padding: 22px 20px 18px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.5);
}
.dialog-message {
  margin: 0;
  font-size: 15px;
  font-weight: 500;
  line-height: 1.45;
  color: var(--text);
  text-wrap: pretty;
}
.dialog-input {
  width: 100%;
  height: 46px;
  margin-top: 14px;
  padding: 0 14px;
  background: var(--inset);
  border: 1.5px solid var(--line-2);
  border-radius: 12px;
  color: var(--text);
  font-family: inherit;
  font-size: 15px;
  outline: none;
}
.dialog-input:focus { border-color: var(--accent); }
.dialog-input.hidden { display: none; }
.dialog-actions { display: flex; gap: 10px; margin-top: 20px; }
.dialog-actions .outline-btn, .dialog-actions .solid-btn { flex: 1; }
.dialog-actions .solid-btn.hidden, .dialog-actions .outline-btn.hidden { display: none; }

.sheet {
  background: var(--bar);
  width: 100%;
  max-height: 86vh;
  overflow-y: auto;
  border-radius: 26px 26px 0 0;
  padding: 10px 18px calc(24px + var(--safe-bottom));
  border-top: 1px solid var(--line-2);
  box-shadow: 0 -18px 50px rgba(0, 0, 0, 0.6);
}
.sheet-handle {
  width: 44px;
  height: 4px;
  background: #3a4542;
  border-radius: 2px;
  margin: 5px auto 16px;
}
.sheet h2 {
  margin: 0 0 16px;
  font-family: var(--display);
  font-size: 30px;
  font-weight: 400;
  letter-spacing: 0.04em;
}
.sheet h3 {
  margin: 22px 0 10px;
  font-family: var(--display);
  font-size: 17px;
  font-weight: 400;
  color: var(--dim);
  letter-spacing: 0.12em;
}

.team-toggle {
  display: flex;
  gap: 6px;
  background: var(--bg);
  padding: 4px;
  border-radius: 13px;
}
.team-btn {
  flex: 1;
  height: 46px;
  border: none;
  border-radius: 10px;
  background: transparent;
  color: var(--dim);
  font-weight: 600;
  font-size: 14.5px;
  transition: background 140ms ease-out, color 140ms ease-out;
}
.team-btn.home.active { background: var(--home); color: var(--home-ink); font-weight: 700; }
.team-btn.away.active { background: var(--away); color: var(--away-ink); font-weight: 700; }

.team-toggle.mini { padding: 3px; border-radius: 10px; flex-shrink: 0; }
.team-toggle.mini .team-btn { height: auto; padding: 8px 12px; font-size: 12.5px; border-radius: 7px; }
.pane-head .team-toggle.mini { padding: 4px; border-radius: 12px; }
.pane-head .team-toggle.mini .team-btn { height: 42px; padding: 0 12px; font-size: 13.5px; border-radius: 9px; }

.row-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
  flex-wrap: wrap;
}
.pill-btn {
  flex: 1;
  min-width: 140px;
  min-height: 54px;
  padding: 10px 14px;
  border-radius: 13px;
  border: 1px solid var(--line-2);
  background: var(--raised);
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.pill-btn svg { width: 19px; height: 19px; flex-shrink: 0; }
.pill-btn .plus { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linecap: round; }
.pill-btn .ball-mark { fill: #ffffff; }
.pill-btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 700; }
.pill-btn.record { background: var(--danger); color: var(--danger-ink); border-color: var(--danger); font-weight: 700; }
.pill-btn.record .rec-bullet { width: 11px; height: 11px; border-radius: 50%; background: var(--danger-ink); flex-shrink: 0; }
.pill-btn:active { filter: brightness(1.12); }

.formation-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.formation-btn {
  height: 66px;
  padding: 6px;
  border-radius: 12px;
  border: 1px solid var(--line-2);
  background: var(--raised);
  color: var(--text);
  font-size: 13px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.formation-btn:active { background: var(--line-2); }
.formation-glyph { width: 34px; height: 24px; display: block; fill: var(--home); }
.formation-btn.away-shape .formation-glyph { fill: var(--away); }

#clear-team-btn { margin-top: 22px; }

.save-row { display: flex; gap: 8px; }
.save-row input {
  flex: 1;
  min-width: 0;
  height: 54px;
  padding: 0 14px;
  border-radius: 13px;
  border: 1px solid var(--line-2);
  background: var(--inset);
  color: var(--text);
  font-size: 14.5px;
  font-weight: 500;
}
.save-row input::placeholder { color: var(--dim-2); }
.save-row .pill-btn { flex: 0 0 96px; min-width: 96px; }

#new-board-btn { margin-top: 14px; }

.saved-list { display: flex; flex-direction: column; gap: 8px; }
.empty-hint { color: var(--dim-2); font-size: 12.5px; font-weight: 500; line-height: 1.5; text-wrap: pretty; margin: 0 0 10px; }

.saved-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 11px 12px;
  border-radius: 13px;
  background: var(--inset);
  border: 1px solid var(--line);
}
.saved-item .meta { flex: 1; min-width: 0; }
.saved-item .name { font-weight: 600; font-size: 14.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.saved-item .date { font-size: 11.5px; font-weight: 500; color: var(--dim-2); margin-top: 3px; }
.saved-item .duration { font-variant-numeric: tabular-nums; }
.saved-item button {
  width: 42px;
  height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 11px;
  border: none;
  background: var(--raised);
  color: var(--dim);
  flex-shrink: 0;
}
.saved-item button svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.saved-item button.load-btn { color: var(--accent); }
.saved-item button.load-btn svg.solid { fill: currentColor; stroke: none; }
.saved-item button.delete-btn { color: var(--danger); }
.saved-item button.respond-btn { color: var(--away); }

.lineup-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 280px;
  overflow-y: auto;
  margin-bottom: 8px;
}
.lineup-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px;
  border-radius: 13px;
  background: var(--inset);
  border: 1px solid var(--line);
}
.lineup-num {
  width: 50px;
  height: 42px;
  flex-shrink: 0;
  text-align: center;
  padding: 0 4px;
  border-radius: 9px;
  border: 1px solid var(--line-2);
  background: var(--raised);
  color: var(--text);
  font-weight: 700;
  font-size: 15px;
  font-variant-numeric: tabular-nums;
}
.lineup-name {
  flex: 1;
  min-width: 0;
  height: 42px;
  padding: 0 11px;
  border-radius: 9px;
  border: 1px solid var(--line-2);
  background: var(--raised);
  color: var(--text);
  font-size: 14px;
  font-weight: 500;
}
.lineup-name::placeholder { color: var(--dim-2); }
.lineup-delete {
  width: 42px;
  height: 42px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 9px;
  border: none;
  background: transparent;
  color: var(--danger);
}
.lineup-delete svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* -------------------------------------------------------------- POPOVER */
/* Fixed 232px at every position: clamped inside the pitch frame, with the
   caret sliding to stay on the token, and flipping below near the top. */
.player-popover {
  position: absolute;
  width: 232px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: var(--raised);
  border: 1px solid var(--line-2);
  border-radius: 16px;
  padding: 10px;
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.55);
  z-index: 40;
  transform: translate(-50%, calc(-100% - 9px));
}
.player-popover.flipped { transform: translate(-50%, 9px); }
.player-popover.hidden { display: none; }
.player-popover::after {
  content: '';
  position: absolute;
  left: var(--caret-x, 50%);
  bottom: -7px;
  width: 13px;
  height: 13px;
  margin-left: -6.5px;
  background: var(--raised);
  border-right: 1px solid var(--line-2);
  border-bottom: 1px solid var(--line-2);
  transform: rotate(45deg);
}
.player-popover.flipped::after {
  bottom: auto;
  top: -7px;
  border-right: none;
  border-bottom: none;
  border-left: 1px solid var(--line-2);
  border-top: 1px solid var(--line-2);
}
.pop-name-input {
  width: 100%;
  height: 46px;
  padding: 0 12px;
  border-radius: 11px;
  border: 1px solid var(--line);
  background: #151b19;
  color: var(--text);
  font-size: 14px;
  font-weight: 500;
}
.pop-name-input::placeholder { color: var(--dim-2); }
.pop-controls-row { display: flex; align-items: center; gap: 8px; }
.pop-number-input {
  flex: 1;
  min-width: 0;
  height: 48px;
  text-align: center;
  padding: 0 4px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #151b19;
  color: var(--text);
  font-weight: 700;
  font-size: 18px;
  font-variant-numeric: tabular-nums;
}
.pop-btn {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  border: none;
  background: #151b19;
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.pop-btn.danger { color: var(--danger); }
.pop-btn.danger svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ------------------------------------------------------- PITCH ELEMENTS */
.token-circle { cursor: grab; }
.token-home { fill: var(--home); }
.token-away { fill: var(--away); }
.token-ball { fill: #ffffff; }
.token-hit { fill: transparent; }
.token-label {
  font-family: var(--ui);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  pointer-events: none;
  user-select: none;
}
.label-home { fill: var(--home-ink); }
.label-away { fill: var(--away-ink); }

/* movement trail — a ghost of the drag, never a drawing */
.trail {
  fill: none;
  stroke-width: 0.6;
  stroke-linecap: round;
  stroke-linejoin: round;
  pointer-events: none;
}
.trail-home { stroke: var(--home); }
.trail-away { stroke: var(--away); }
.trail-ball { stroke: #ffffff; }

/* ============================================================ FIRST RUN GATE */
.gate { display: none; }
html.locked .gate {
  display: flex;
  position: fixed;
  inset: 0;
  z-index: 200;
  background: var(--bg);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.gate-inner {
  width: 100%;
  min-height: 100%;
  display: flex;
  flex-direction: column;
  padding: calc(40px + var(--safe-top)) 24px calc(26px + var(--safe-bottom));
}
.gate-mark { width: 64px; height: 64px; display: block; border-radius: 16px; flex-shrink: 0; }
.gate-title {
  margin: 20px 0 0;
  font-family: var(--display);
  font-size: 42px;
  line-height: 0.92;
  font-weight: 400;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}
.gate-sub { margin: 10px 0 0; font-size: 14.5px; font-weight: 500; line-height: 1.5; color: var(--dim); text-wrap: pretty; }
.gate-label {
  display: block;
  margin: 26px 0 10px;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  color: var(--dim-2);
}
.gate-code {
  width: 100%;
  height: 64px;
  padding: 0 18px;
  background: var(--inset);
  border: 1.5px solid var(--line-2);
  border-radius: 14px;
  color: var(--text);
  font-family: var(--display);
  font-size: 30px;
  letter-spacing: 0.22em;
  font-variant-numeric: tabular-nums;
  text-transform: uppercase;
  outline: none;
  user-select: text;
}
.gate-code:focus { border-color: var(--accent); }
.gate-code::placeholder { color: #3a4542; letter-spacing: 0.22em; }
.gate.bad .gate-code { border-color: var(--danger-line); }
.gate-help { margin: 9px 0 0; font-size: 12.5px; font-weight: 500; line-height: 1.5; color: var(--dim-2); text-wrap: pretty; }
.gate.bad .gate-help { color: var(--danger); font-weight: 600; }
.gate-btn {
  width: 100%;
  height: 58px;
  margin-top: 16px;
  background: var(--accent);
  color: var(--accent-ink);
  border: none;
  border-radius: 14px;
  font-size: 16px;
  font-weight: 700;
  flex-shrink: 0;
}
.gate-btn:active { filter: brightness(1.12); }

.gate-install {
  margin-top: auto;
  padding: 16px;
  background: var(--bar);
  border: 1px solid var(--line);
  border-radius: 16px;
}
.gate-install.row { display: flex; align-items: center; gap: 14px; }
.gate-install.hidden { display: none; }
.gi-head { display: flex; align-items: center; gap: 9px; font-size: 13px; font-weight: 700; letter-spacing: 0.02em; }
.gi-head svg { width: 18px; height: 18px; flex-shrink: 0; fill: none; stroke: var(--accent); stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.gi-copy { margin: 9px 0 0; font-size: 12.5px; font-weight: 500; line-height: 1.55; color: var(--dim); text-wrap: pretty; }
.gate-install.row .gi-copy { margin-top: 6px; }
.gi-text { flex: 1; min-width: 0; }
.gi-title { font-size: 13px; font-weight: 700; }
.gi-btn {
  flex-shrink: 0;
  height: 48px;
  padding: 0 18px;
  background: var(--raised);
  border: 1px solid #3a4542;
  border-radius: 12px;
  color: var(--accent);
  font-size: 14px;
  font-weight: 700;
}
.gi-steps { list-style: none; margin: 13px 0 0; padding: 0; display: flex; flex-direction: column; gap: 9px; }
.gi-steps li { display: flex; align-items: center; gap: 10px; font-size: 13px; font-weight: 500; line-height: 1.35; color: #b9c6c1; }
.gi-num {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--raised);
  color: #b9c6c1;
  font-size: 10.5px;
  font-weight: 700;
  line-height: 20px;
  text-align: center;
}
.gi-steps b { color: var(--text); font-weight: 700; }
.gi-inline { width: 14px; height: 14px; vertical-align: -2px; fill: none; stroke: var(--accent); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ====================================================== PLAYERS SHEET: TABS */
.sheet-tabs { display: flex; gap: 5px; padding: 4px; background: var(--bg); border-radius: 13px; }
.sheet-tab {
  flex: 1;
  height: 46px;
  border: none;
  border-radius: 10px;
  background: transparent;
  color: var(--dim);
  font-size: 14.5px;
  font-weight: 600;
}
.sheet-tab.active {
  background: var(--raised);
  color: var(--text);
  font-weight: 700;
  box-shadow: inset 0 0 0 1px #3a4542;
}
.pane.hidden { display: none; }

.pane-head { display: flex; align-items: center; gap: 10px; margin-top: 16px; }
.pane-head .team-toggle { flex: 1; }
.head-meta { font-size: 12.5px; font-weight: 600; color: var(--dim-2); white-space: nowrap; }

.icon-sq {
  flex-shrink: 0;
  width: 42px;
  height: 42px;
  border-radius: 11px;
  background: var(--raised);
  border: 1px solid var(--line-2);
  color: #b9c6c1;
  display: flex;
  align-items: center;
  justify-content: center;
}
.icon-sq svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.icon-sq svg.dots { fill: currentColor; stroke: none; }
.icon-sq.accent { color: var(--accent); }
.icon-sq:active { background: var(--line-2); }

/* ⋯ menus: everything rare or destructive lives here, never under a thumb */
.more-wrap { position: relative; flex-shrink: 0; }
.menu {
  position: absolute;
  right: 0;
  top: 50px;
  z-index: 20;
  width: 252px;
  background: var(--raised);
  border: 1px solid #303b38;
  border-radius: 16px;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.65);
  overflow: hidden;
}
.menu.hidden { display: none; }
.menu button {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 14px 16px;
  background: transparent;
  border: none;
  border-bottom: 1px solid #2a3331;
  color: var(--text);
  font-size: 14.5px;
  font-weight: 600;
  text-align: left;
}
.menu button:last-child { border-bottom: none; }
.menu button:active { background: var(--line-2); }
.menu button svg { width: 18px; height: 18px; flex-shrink: 0; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.menu button.danger { color: var(--danger); }
.menu button.danger svg { stroke: var(--danger); }

/* ------------------------------------------------- LINEUPS: the tab is the list */
.lineups-list { display: flex; flex-direction: column; gap: 8px; margin-top: 16px; }
.lineup-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 12px 12px 17px;
  background: var(--inset);
  border: 1px solid #262f2c;
  border-radius: 14px;
  overflow: hidden;
}
.lineup-item.on-pitch { padding-left: 14px; }
.lineup-item.on-pitch::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--accent);
}
.lineup-item .meta { flex: 1; min-width: 0; }
.lineup-item .name { font-size: 15.5px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lineup-item .sub { margin-top: 3px; font-size: 11.5px; font-weight: 500; color: var(--dim-2); }
.lineup-item.on-pitch .sub { color: var(--accent); }
.lineup-item button {
  flex-shrink: 0;
  width: 42px;
  height: 42px;
  border-radius: 11px;
  background: var(--raised);
  border: none;
  color: var(--dim);
  display: flex;
  align-items: center;
  justify-content: center;
}
.lineup-item button svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.lineup-item button.apply-btn { color: var(--accent); }
.lineup-item button.open-btn svg { stroke-width: 2.2; }
.lineup-item button:active { background: var(--line-2); }

.ghost-row {
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  height: 54px;
  margin-top: 8px;
  padding: 0 16px;
  background: transparent;
  border: 1px dashed var(--line-2);
  border-radius: 14px;
  color: #b9c6c1;
  font-size: 15px;
  font-weight: 600;
}
.ghost-row svg { width: 18px; height: 18px; flex-shrink: 0; }
.ghost-row .plus { fill: none; stroke: var(--accent); stroke-width: 2.2; stroke-linecap: round; }

/* --------------------------------------------------- LINEUPS: one lineup open */
.detail-head { display: flex; align-items: center; gap: 10px; margin-top: 16px; }
.detail-title {
  flex: 1;
  min-width: 0;
  background: transparent;
  border: none;
  padding: 0;
  text-align: left;
  color: var(--text);
}
.dt-name { display: flex; align-items: center; gap: 7px; font-size: 16px; font-weight: 600; }
.dt-name > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dt-name .pencil { width: 14px; height: 14px; flex-shrink: 0; fill: none; stroke: var(--dim-2); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.dt-meta { display: block; margin-top: 3px; font-size: 11.5px; font-weight: 500; color: var(--dim-2); }

/* bottom room so the last row can scroll clear of the sticky footer */
.squad-rows { margin-top: 18px; padding-bottom: 84px; touch-action: pan-y; }
.group-block + .group-block { margin-top: 18px; }
.group-head { display: flex; align-items: center; gap: 9px; margin: 0 0 2px; min-height: 28px; }
.group-head span {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  color: var(--accent);
}
.group-head i { flex: 1; height: 1px; background: var(--raised); }
.group-head.bench span { color: var(--dim-2); }
/* every group carries its own + so a player can be filed straight into it */
.group-add {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  padding: 0;
  display: grid;
  place-items: center;
  background: var(--inset);
  border: none;
  border-radius: 50%;
  cursor: pointer;
}
.group-add:active { background: var(--raised); }
.group-add svg { width: 15px; height: 15px; fill: none; stroke: var(--accent); stroke-width: 2.4; stroke-linecap: round; }
.group-head.bench .group-add svg { stroke: var(--dim-2); }
/* an empty group still needs to exist on screen: it is the drop target */
.group-slot {
  width: 100%;
  height: 40px;
  display: flex;
  align-items: center;
  padding-left: 42px;
  border: 1px dashed var(--raised);
  border-radius: 8px;
  background: transparent;
  font-family: inherit;
  font-size: 12px;
  color: var(--dim-2);
  text-align: left;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
}
.group-slot:active { background: var(--inset); border-color: var(--line-2); color: var(--dim); }

.squad-row {
  display: flex;
  align-items: center;
  gap: 12px;
  height: 52px;
  border-bottom: 1px solid #1b2220;
  background: var(--bar);
}
.squad-row.dragging { background: var(--inset); border-radius: 8px; border-bottom-color: transparent; }
.row-handle {
  flex-shrink: 0;
  width: 30px;
  height: 44px;
  padding: 0;
  background: transparent;
  border: none;
  display: flex;
  align-items: center;
  touch-action: none;
  cursor: grab;
}
.row-handle svg { width: 15px; height: 15px; fill: #4b5754; }
.row-num {
  width: 46px;
  flex-shrink: 0;
  padding: 0;
  background: transparent;
  border: none;
  color: var(--home);
  font-size: 17px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  outline: none;
  -moz-appearance: textfield;
}
.row-num::-webkit-outer-spin-button, .row-num::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.away-side .row-num { color: var(--away); }
.row-name {
  flex: 1;
  min-width: 0;
  padding: 0;
  background: transparent;
  border: none;
  color: var(--text);
  font-size: 15.5px;
  font-weight: 500;
  outline: none;
}
.row-name::placeholder { color: var(--dim-2); }
.row-num:focus, .row-name:focus { color: var(--accent); }
.row-remove {
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  background: transparent;
  border: none;
  color: #4b5754;
  display: flex;
  align-items: center;
  justify-content: center;
}
.row-remove svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.row-remove:active { color: var(--danger); }

/* Sticky pins to the scroll container's PADDING box, and .sheet does not clip
   content in its 24px bottom padding — so bottom:0 leaves a strip of scrolling
   rows visible under the button. Pull the footer down over that inset and pay
   it back as internal padding, so the footer's edge is the sheet's edge. */
.detail-foot {
  position: sticky;
  bottom: -24px;
  z-index: 5;
  display: flex;
  gap: 8px;
  margin: 0 -18px;
  padding: 12px 18px calc(28px + var(--safe-bottom));
  background: var(--bar);
  border-top: 1px solid var(--raised);
}
.detail-foot .pill-btn { height: 56px; border-radius: 14px; font-size: 15.5px; }
.detail-foot .icon-sq { width: 56px; height: 56px; border-radius: 14px; }
.detail-foot .icon-sq svg { width: 21px; height: 21px; }

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