/* Tour public pages: entry portal, squad lists (and the results page to come).
 * Mission Control palette on black with the Cornerpins purple, the same type
 * and weights as the streaming scoring overlay. Everything is prefixed tp- so
 * nothing else in the application can be restyled. Phone first at 360px:
 * facts sit four to a row, forms two to a row, nothing is clipped, the total
 * and the squad are on the first screen.
 */
:root {
  --tp-bg: #0a0a0d; --tp-panel: #111318; --tp-panel-2: #181c23; --tp-line: rgba(255, 255, 255, 0.10);
  --tp-text: #f4f4f6; --tp-muted: #9a9aa4; --tp-purple: #6d28d9; --tp-purple-light: #7c3aed; --tp-purple-muted: rgba(109, 40, 217, 0.22);
  --tp-red: #dc2626; --tp-green: #22c55e; --tp-amber: #f59e0b; --tp-radius: 10px; --tp-radius-sm: 6px;
}
body.tp-body { background: var(--tp-bg); color: var(--tp-text); font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; font-size: 15px; line-height: 1.5; }
.tp-header { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-bottom: 2px solid var(--tp-purple); background: var(--tp-panel); }
.tp-logo { height: 40px; width: auto; flex: 0 0 auto; }
.tp-header-text { min-width: 0; }
.tp-title { margin: 0; font-size: clamp(1.05rem, 4.5vw, 1.4rem); font-weight: 800; letter-spacing: 0.01em; overflow-wrap: anywhere; }
.tp-subtitle { margin: 0; font-size: 0.8rem; color: var(--tp-muted); overflow-wrap: anywhere; }
.tp-container { max-width: 760px; margin: 0 auto; padding: 10px; display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.tp-card { background: var(--tp-panel); border: 1px solid var(--tp-line); border-radius: var(--tp-radius); padding: 12px; display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.tp-h2 { margin: 0; font-size: 1rem; font-weight: 700; }
.tp-p { margin: 0; }
.tp-muted { color: var(--tp-muted); font-size: 0.85rem; }
.tp-ok { color: var(--tp-green); } .tp-bad { color: var(--tp-amber); font-size: 0.8rem; }
.tp-alert { padding: 10px 12px; border-radius: var(--tp-radius-sm); border: 1px solid var(--tp-amber); background: rgba(245, 158, 11, 0.12); font-size: 0.9rem; overflow-wrap: anywhere; }
.tp-alert-ok { border-color: var(--tp-green); background: rgba(34, 197, 94, 0.12); }

.tp-facts { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
.tp-fact { display: flex; flex-direction: column; gap: 1px; min-width: 0; padding: 8px; border-radius: var(--tp-radius-sm); background: var(--tp-panel-2); border-left: 3px solid var(--tp-purple); }
.tp-fact-label { font-size: 0.6rem; letter-spacing: 0.04em; text-transform: uppercase; color: var(--tp-muted); }
.tp-fact-value { font-size: clamp(0.95rem, 4vw, 1.2rem); font-weight: 800; line-height: 1.15; overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }
.tp-fact-big { color: var(--tp-purple-light); }
.tp-fact-sub { font-size: 0.7rem; font-weight: 500; color: var(--tp-muted); }

.tp-event-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.tp-event-name { font-weight: 800; font-size: 1.05rem; overflow-wrap: anywhere; }
.tp-pill { padding: 3px 8px; border-radius: 999px; font-size: 0.7rem; font-weight: 700; white-space: nowrap; border: 1px solid var(--tp-line); color: var(--tp-muted); }
.tp-pill-open { border-color: var(--tp-green); color: var(--tp-green); }
.tp-pill-upcoming { border-color: var(--tp-amber); color: var(--tp-amber); }

.tp-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.tp-btn { display: inline-flex; align-items: center; justify-content: center; min-height: 40px; padding: 8px 16px; border-radius: var(--tp-radius-sm); font-weight: 700; font-size: 0.9rem; text-decoration: none; border: 1px solid var(--tp-line); color: var(--tp-text); background: var(--tp-panel-2); cursor: pointer; flex: 1 1 auto; }
.tp-btn-primary { background: var(--tp-purple); border-color: var(--tp-purple); color: #fff; }
.tp-btn-primary:disabled { opacity: 0.45; cursor: not-allowed; }
.tp-btn-outline { background: transparent; border-color: var(--tp-purple-light); }
.tp-btn-ghost { background: transparent; color: var(--tp-muted); flex: 0 0 auto; }
.tp-btn-sm { min-height: 32px; padding: 4px 10px; font-size: 0.8rem; }
.tp-inline { display: inline-flex; gap: 6px; align-items: center; flex: 1 1 auto; }
.tp-addform .tp-input-sm { flex: 1 1 120px; }

.tp-form { gap: 10px; }
.tp-grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.tp-field { display: flex; flex-direction: column; gap: 3px; font-size: 0.75rem; color: var(--tp-muted); min-width: 0; }
.tp-input { width: 100%; min-width: 0; box-sizing: border-box; padding: 9px 10px; border-radius: var(--tp-radius-sm); border: 1px solid var(--tp-line); background: var(--tp-panel-2); color: var(--tp-text); font-size: 0.95rem; }
.tp-input:focus { outline: none; border-color: var(--tp-purple-light); box-shadow: 0 0 0 2px var(--tp-purple-muted); }
.tp-input-sm { padding: 7px 9px; font-size: 0.9rem; }

.tp-line { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 6px 10px; align-items: center; padding: 8px 0; border-top: 1px solid var(--tp-line); }
.tp-line:first-of-type { border-top: 0; }
.tp-line-main { display: flex; flex-direction: column; min-width: 0; overflow-wrap: anywhere; }
.tp-line-sub { font-size: 0.75rem; color: var(--tp-muted); }
.tp-line-money { display: flex; flex-direction: column; align-items: flex-end; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }

.tp-squads { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
.tp-squad { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 2px 8px; align-items: center; padding: 8px 10px; border: 1px solid var(--tp-line); border-radius: var(--tp-radius-sm); background: var(--tp-panel-2); cursor: pointer; min-height: 40px; }
.tp-squad input { grid-row: 1 / span 3; accent-color: var(--tp-purple-light); }
.tp-squad-label { font-weight: 700; }
.tp-squad-when, .tp-squad-places { font-size: 0.72rem; color: var(--tp-muted); overflow-wrap: anywhere; }
.tp-squad-full { opacity: 0.55; }
.tp-squad:has(input:checked) { border-color: var(--tp-purple-light); background: var(--tp-purple-muted); }

.tp-totals { display: flex; flex-direction: column; gap: 3px; font-size: 0.9rem; }
.tp-totals > div { display: flex; justify-content: space-between; gap: 10px; }
.tp-totals-total { font-weight: 800; font-size: 1.05rem; border-top: 1px solid var(--tp-line); padding-top: 4px; color: var(--tp-purple-light); }

.tp-fold > summary { cursor: pointer; font-weight: 700; list-style: none; min-height: 36px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.tp-fold > summary::-webkit-details-marker { display: none; }
.tp-fold > summary::after { content: '+'; margin-left: auto; color: var(--tp-muted); font-weight: 800; }
.tp-fold[open] > summary::after { content: '-'; }
.tp-list { margin: 0; padding-left: 22px; columns: 2; column-gap: 16px; font-size: 0.9rem; }
.tp-list li { break-inside: avoid; padding: 2px 0; overflow-wrap: anywhere; }

@media (max-width: 420px) {
  .tp-facts { gap: 4px; }
  .tp-fact { padding: 6px; }
  .tp-line { grid-template-columns: minmax(0, 1fr) auto; }
  .tp-line .tp-inline { grid-column: 1 / -1; justify-content: flex-end; }
  .tp-list { columns: 1; }
}

/* ---- Results ------------------------------------------------------------ */
.tp-line-link { text-decoration: none; color: inherit; }
.tp-line-link:hover .tp-line-main b { color: var(--tp-purple-light); }
.tp-tabs { display: flex; flex-wrap: wrap; gap: 6px; }
.tp-tab { flex: 1 1 auto; text-align: center; min-height: 34px; display: inline-flex; align-items: center; justify-content: center; padding: 4px 10px; border-radius: 999px; border: 1px solid var(--tp-purple-light); color: var(--tp-text); font-size: 0.8rem; font-weight: 700; text-decoration: none; }
.tp-tab:hover { background: var(--tp-purple-muted); }
.tp-table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.tp-table { width: 100%; border-collapse: collapse; font-size: 0.85rem; min-width: 300px; }
.tp-table th, .tp-table td { padding: 6px 6px; border-bottom: 1px solid var(--tp-line); text-align: left; white-space: nowrap; }
.tp-table th { font-size: 0.68rem; letter-spacing: 0.04em; text-transform: uppercase; color: var(--tp-muted); }
.tp-table td:nth-child(2) { white-space: normal; overflow-wrap: anywhere; min-width: 120px; }
.tp-table a { color: var(--tp-text); text-decoration: none; border-bottom: 1px dotted var(--tp-purple-light); }
.tp-num { text-align: right !important; font-variant-numeric: tabular-nums; }
.tp-cut-last td { border-bottom: 2px solid var(--tp-purple-light); }
.tp-row-out td { opacity: 0.55; }
.tp-match { display: grid; grid-template-columns: auto minmax(0, 1fr) auto minmax(0, 1fr); gap: 6px; align-items: center; padding: 6px 0; border-top: 1px solid var(--tp-line); font-size: 0.85rem; }
.tp-match-r { font-size: 0.7rem; color: var(--tp-muted); }
.tp-match-side { overflow-wrap: anywhere; }
.tp-match-side:last-child { text-align: right; }
.tp-match-win { color: var(--tp-green); }
.tp-match-v { color: var(--tp-muted); font-size: 0.75rem; }
.tp-frames { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 4px; }
.tp-frame { display: flex; flex-direction: column; align-items: center; gap: 1px; padding: 6px 2px; border: 1px solid var(--tp-line); border-radius: var(--tp-radius-sm); background: var(--tp-panel-2); min-width: 0; }
.tp-frame-n { font-size: 0.6rem; color: var(--tp-muted); }
.tp-frame-balls { font-weight: 800; font-size: 0.9rem; }
.tp-frame-total { font-size: 0.75rem; font-variant-numeric: tabular-nums; }
.tp-frame-speed { font-size: 0.6rem; color: var(--tp-purple-light); }
.tp-fold-inner { margin-top: 6px; }
.tp-fold-inner > summary { font-weight: 600; font-size: 0.85rem; color: var(--tp-muted); }
