/* ============================================================
   TeamMaker · v3 design pass
   Mobile-first, Telegram theme variables, dark by default.
   ============================================================ */

:root {
  /* Telegram theme integration */
  --bg:           var(--tg-theme-bg-color, #0f1115);
  --surface:      var(--tg-theme-secondary-bg-color, #1a1d23);
  --surface-2:    var(--tg-theme-section-bg-color, #1a1d23);
  --text:         var(--tg-theme-text-color, #ffffff);
  --hint:         var(--tg-theme-hint-color, #8a8f97);
  --link:         var(--tg-theme-link-color, #5eb3ff);
  --accent:       var(--tg-theme-button-color, #3390ec);
  --accent-text:  var(--tg-theme-button-text-color, #ffffff);
  --destructive:  var(--tg-theme-destructive-text-color, #ef5b5b);
  --header-bg:    var(--tg-theme-header-bg-color, #15171c);
  --separator:    var(--tg-theme-section-separator-color, rgba(255,255,255,0.07));

  /* Tier palette */
  --tier-s: #ff5c5c;
  --tier-a: #ffb13a;
  --tier-b: #4aa9ff;
  --tier-c: #9aa4b1;
  --success: #34c759;

  /* Spacing scale */
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 20px;
  --sp-6: 24px;
  --sp-8: 32px;

  /* Radii */
  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 16px;
  --r-pill: 999px;

  /* Heights */
  --h-input: 44px;
  --h-btn: 42px;
  --h-btn-sm: 32px;
  --nav-h: 60px;

  /* Surfaces */
  --surface-elev: rgba(255,255,255,0.04);
  --surface-press: rgba(255,255,255,0.08);
}

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

/* HTML5 [hidden] attribute is set with default display:none in UA stylesheet,
   but any author rule with display:flex / inline-flex / etc. overrides it.
   Force [hidden] to actually hide. Critical for our modals. */
[hidden] { display: none !important; }

html, body {
  margin: 0; padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.4;
  overscroll-behavior-y: contain;
  -webkit-font-smoothing: antialiased;
}

body {
  padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 12px);
  min-height: 100vh;
}

button { font-family: inherit; }

/* =================== HEADER =================== */
.app-header {
  background: var(--header-bg);
  position: sticky; top: 0; z-index: 10;
  border-bottom: 1px solid var(--separator);
  padding: 10px var(--sp-4) 10px;
  padding-top: calc(10px + env(safe-area-inset-top));
}
.header-row {
  display: flex; align-items: center; gap: var(--sp-3);
}
.header-title { flex: 1; min-width: 0; }
.header-title .title {
  font-size: 17px; font-weight: 700;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  text-align: left;
}
.header-title .subtitle {
  font-size: 12px; color: var(--hint); margin-top: 1px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  min-width: 0;
}
button.chat-switcher {
  appearance: none; background: none; border: none;
  padding: 0; margin: 0; font: inherit; color: inherit;
  text-align: left; cursor: default;
  display: block;
}
.chat-switcher .subtitle-row {
  display: flex; align-items: center; gap: 4px;
  min-width: 0;
}
.chat-switcher .chevron {
  display: none;
  font-size: 11px; color: var(--hint);
  line-height: 1; flex-shrink: 0;
  transition: transform .15s;
}
.chat-switcher.has-chats { cursor: pointer; }
.chat-switcher.has-chats .chevron { display: inline; }
.chat-switcher.has-chats:active .subtitle,
.chat-switcher.has-chats:active .chevron { opacity: 0.6; }

.chat-switch-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--sp-3);
  padding: 12px var(--sp-3);
  background: var(--surface);
  border: 1px solid var(--separator);
  border-radius: var(--r-md);
  cursor: pointer;
  transition: background .12s;
}
.chat-switch-row:active { background: var(--surface-press); }
.chat-switch-row .name {
  flex: 1; min-width: 0;
  font-size: 15px; font-weight: 500;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.chat-switch-row .arrow { color: var(--hint); font-size: 18px; flex-shrink: 0; }
.chat-switch-row.current {
  cursor: default;
  border-color: var(--accent);
}
.chat-switch-row.current .name { color: var(--accent); }
.chat-switch-row.current .badge {
  font-size: 11px; color: var(--accent);
  background: transparent; border: 1px solid var(--accent);
  border-radius: 10px; padding: 2px 8px;
  flex-shrink: 0;
}

/* =================== VIEWS =================== */
main { padding: var(--sp-3) var(--sp-4) var(--sp-4); }
.view { display: none; }
.view.active { display: block; animation: fadeIn .18s ease; }
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: none; }
}

.section-row {
  display: flex; align-items: center; justify-content: space-between;
  margin: var(--sp-3) 0 var(--sp-2);
  gap: var(--sp-2);
}
.section-row:first-child { margin-top: 0; }

.section-title {
  font-size: 13px; color: var(--hint);
  font-weight: 600; letter-spacing: 0.2px;
}
.section-title.plain { text-transform: none; letter-spacing: 0; font-weight: 600; color: var(--text); font-size: 14px; }

.stats-bar { color: var(--hint); font-size: 12px; margin-bottom: var(--sp-3); }

.hint {
  font-size: 11px; color: var(--hint);
  text-align: center; margin: var(--sp-2) 0 var(--sp-4);
}

/* =================== CARD LIST =================== */
.card-list { display: flex; flex-direction: column; gap: 6px; margin-bottom: var(--sp-3); }

/* =================== BUTTONS =================== */
.btn {
  border: none; outline: none;
  border-radius: var(--r-md);
  padding: 0 var(--sp-4);
  height: var(--h-btn);
  font-size: 14px; font-weight: 600;
  cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  transition: opacity .12s, transform .08s, background .12s;
  text-decoration: none;
  white-space: nowrap;
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn.primary { background: var(--accent); color: var(--accent-text); }
.btn.primary:active { background: var(--accent); filter: brightness(0.9); }

.btn.ghost {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--separator);
}
.btn.ghost:active { background: var(--surface-press); }

.btn.small {
  height: var(--h-btn-sm);
  padding: 0 var(--sp-3);
  font-size: 13px;
  border-radius: var(--r-sm);
}
.btn.block { display: flex; width: 100%; margin-top: var(--sp-2); }
.btn.square { width: var(--h-btn); padding: 0; font-size: 20px; flex-shrink: 0; }

.btn.danger { background: var(--destructive); color: white; }

/* Icon button */
.icon-btn {
  background: transparent; border: none;
  width: 36px; height: 36px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: var(--r-sm);
  color: var(--text); font-size: 18px;
  cursor: pointer;
  transition: background .12s;
  flex-shrink: 0;
}
.icon-btn:active { background: var(--surface-press); }
.icon-btn.del { color: var(--destructive); }

/* =================== INPUT =================== */
.input {
  display: block;
  width: 100%;
  height: var(--h-input);
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--separator);
  border-radius: var(--r-md);
  padding: 0 var(--sp-3);
  font-size: 15px; font-family: inherit;
  outline: none;
  transition: border-color .12s;
}
.input::placeholder { color: var(--hint); }
.input:focus { border-color: var(--accent); }

textarea.input {
  height: auto;
  min-height: 64px;
  padding: 10px var(--sp-3);
  resize: vertical;
  line-height: 1.4;
}

/* =================== TIER BADGES + PICKER =================== */
.tier-badge {
  min-width: 26px; height: 26px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: var(--r-sm);
  font-weight: 700; font-size: 12px;
  flex-shrink: 0;
}
.tier-S { background: var(--tier-s); color: #fff; }
.tier-A { background: var(--tier-a); color: #1a1100; }
.tier-B { background: var(--tier-b); color: #fff; }
.tier-C { background: var(--tier-c); color: #1a1a1a; }

.tier-picker {
  display: inline-flex; gap: 4px;
  background: var(--surface-elev);
  padding: 3px;
  border-radius: var(--r-sm);
}
.tier-btn {
  width: 30px; height: 30px;
  border: none; background: transparent;
  color: var(--hint);
  border-radius: 6px;
  font-weight: 700; font-size: 13px;
  cursor: pointer;
  transition: all .12s;
}
.tier-picker.mini .tier-btn { width: 28px; height: 28px; font-size: 12px; }
.tier-btn[data-tier="S"].active { background: var(--tier-s); color: #fff; }
.tier-btn[data-tier="A"].active { background: var(--tier-a); color: #1a1100; }
.tier-btn[data-tier="B"].active { background: var(--tier-b); color: #fff; }
.tier-btn[data-tier="C"].active { background: var(--tier-c); color: #1a1a1a; }

/* =================== PLAYERS — ROSTER ROW =================== */
.player {
  display: flex; align-items: center; gap: var(--sp-3);
  padding: 10px var(--sp-3);
  background: var(--surface);
  border-radius: var(--r-md);
}
.player .name {
  flex: 1; min-width: 0;
  font-weight: 500;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.player .name .badge-tg {
  font-size: 10px; color: var(--hint); margin-left: 4px;
  opacity: 0.7;
}

/* Suggested users */
.suggested-row {
  display: flex; align-items: center; gap: var(--sp-3);
  padding: 10px var(--sp-3);
  background: var(--surface);
  border-radius: var(--r-md);
  border-left: 3px solid var(--accent);
}
.suggested-row .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.suggested-row .name .un { color: var(--hint); font-size: 12px; margin-left: 4px; }

/* =================== COMPOSER (add player) =================== */
.composer {
  background: var(--surface);
  border-radius: var(--r-md);
  padding: var(--sp-2);
  display: flex; flex-direction: column; gap: var(--sp-2);
  margin-top: var(--sp-3);
  position: sticky; bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 8px);
  border: 1px solid var(--separator);
  backdrop-filter: blur(6px);
}
.composer input {
  width: 100%;
  height: 36px;
  background: transparent;
  border: none;
  color: var(--text); font-size: 15px;
  padding: 0 var(--sp-2);
  outline: none;
}
.composer-actions {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--sp-2);
}

/* =================== MATCH =================== */
.quick-actions { display: flex; gap: 6px; margin-bottom: var(--sp-3); }
.quick-actions .btn { flex: 1; }

.vote-row {
  display: flex; align-items: center; gap: var(--sp-3);
  padding: 10px var(--sp-3);
  background: var(--surface);
  border-radius: var(--r-md);
}
.vote-row .name { flex: 1; font-size: 14px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.toggle {
  position: relative;
  width: 44px; height: 26px;
  background: var(--surface-press);
  border-radius: 13px; cursor: pointer;
  transition: background .15s;
  flex-shrink: 0;
}
.toggle::after {
  content: ""; position: absolute;
  top: 3px; left: 3px;
  width: 20px; height: 20px;
  background: #fff; border-radius: 50%;
  transition: left .15s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.25);
}
.vote-row.voted .toggle { background: var(--success); }
.vote-row.voted .toggle::after { left: 21px; }
.vote-row.voted .name { font-weight: 600; }

/* =================== PANEL (draft controls) =================== */
.panel {
  background: var(--surface);
  border-radius: var(--r-md);
  padding: var(--sp-3);
  margin-top: var(--sp-3);
  display: flex; flex-direction: column; gap: var(--sp-2);
}
.panel .section-title { margin: 0; }

/* Segmented control */
.seg {
  display: flex; gap: 4px;
  background: var(--bg);
  padding: 3px;
  border-radius: var(--r-md);
}
.seg-btn {
  flex: 1; height: 32px;
  border: none; background: transparent;
  color: var(--hint); font-weight: 600;
  border-radius: 8px; cursor: pointer; font-size: 14px;
  transition: background .12s, color .12s;
}
.seg-btn.active { background: var(--accent); color: var(--accent-text); }

/* =================== TEAMS RESULT =================== */
.teams-result { display: flex; flex-direction: column; gap: var(--sp-3); margin-top: var(--sp-3); }
.team-card {
  background: var(--surface);
  border-radius: var(--r-md);
  padding: var(--sp-3);
  animation: pop .25s ease;
}
@keyframes pop {
  from { opacity: 0; transform: translateY(4px) scale(0.99); }
  to   { opacity: 1; transform: none; }
}
.team-card .team-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: var(--sp-2);
}
.team-card h3 { margin: 0; font-size: 15px; font-weight: 700; }
.team-card .strength {
  font-size: 12px; color: var(--hint);
  background: var(--surface-elev);
  padding: 3px var(--sp-2); border-radius: 6px;
}
.team-card .members { display: flex; flex-direction: column; gap: 4px; }
.team-card .member {
  display: flex; align-items: center; gap: var(--sp-2); padding: 3px 4px;
  border-radius: 6px;
  touch-action: none;          /* required for Pointer Events on touch */
  -webkit-user-select: none; user-select: none;
  cursor: grab;
  transition: background .15s ease, transform .15s ease, opacity .15s ease;
}
.team-card .member:active { cursor: grabbing; }
.team-card .member .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* DnD states */
.team-card .member.dnd-source { opacity: .35; }
.team-card.dnd-target {
  outline: 2px dashed var(--accent, #4a9eff);
  outline-offset: -2px;
  background: rgba(74, 158, 255, 0.06);
}
.dnd-ghost {
  position: fixed; z-index: 9999; pointer-events: none;
  background: var(--surface-elev, #2a2a2a);
  border-radius: 8px;
  padding: 6px 10px;
  display: flex; align-items: center; gap: var(--sp-2);
  box-shadow: 0 8px 24px rgba(0,0,0,.35);
  transform: scale(1.04);
  opacity: .96;
}

.teams-actions { display: flex; gap: var(--sp-2); margin-top: var(--sp-2); }
.teams-actions .btn { flex: 1; }

/* =================== HISTORY =================== */
.game-card {
  background: var(--surface);
  border-radius: var(--r-md);
  padding: var(--sp-3);
  cursor: pointer;
  display: flex; align-items: center; gap: var(--sp-3);
  transition: background .12s;
}
.game-card:active { background: var(--surface-elev); }
.game-card .icon { font-size: 24px; flex-shrink: 0; }
.game-card .meta { flex: 1; min-width: 0; }
.game-card .meta .row1 {
  display: flex; align-items: center; gap: var(--sp-2);
  flex-wrap: wrap;
}
.game-card .meta .score { font-size: 18px; font-weight: 700; }
.game-card .meta .loc {
  font-size: 12px; color: var(--hint);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.game-card .meta .date { font-size: 11px; color: var(--hint); margin-top: 3px; }
.game-card .pending {
  font-size: 10px; font-weight: 700;
  background: var(--accent); color: var(--accent-text);
  padding: 2px 7px; border-radius: 5px;
  text-transform: uppercase; letter-spacing: 0.4px;
}

.game-detail {
  background: var(--surface);
  border-radius: var(--r-md);
  padding: var(--sp-3);
  margin-top: -2px;
  animation: fadeIn .18s ease;
  border-top: 1px solid var(--separator);
}
.game-detail .team-block { margin-bottom: var(--sp-3); }
.game-detail .team-block h4 {
  margin: 0 0 6px; font-size: 13px; font-weight: 600;
  display: flex; align-items: center; gap: 6px;
}
.game-detail .team-block.win h4::after { content: "🏆"; font-size: 12px; }
.game-detail .player-chip {
  display: inline-block;
  padding: 3px 10px;
  background: var(--surface-elev);
  border-radius: var(--r-pill);
  margin: 3px 4px 3px 0;
  font-size: 12px;
}
.game-detail-actions { display: flex; gap: 6px; margin-top: var(--sp-2); }

/* =================== STATS =================== */
.stat-row {
  display: flex; align-items: center; gap: var(--sp-3);
  padding: 10px var(--sp-3);
  background: var(--surface);
  border-radius: var(--r-md);
}
.stat-row .name { flex: 1; min-width: 0; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stat-row .nums {
  display: flex; gap: 6px; font-size: 12px; color: var(--hint);
  align-items: baseline;
}
.stat-row .nums .w { color: var(--success); font-weight: 700; }
.stat-row .nums .l { color: var(--destructive); }
.stat-row .pct {
  font-size: 14px; font-weight: 700;
  min-width: 48px; text-align: right;
}

/* =================== EVENTS =================== */
.event-card {
  background: var(--surface);
  border-radius: var(--r-md);
  padding: var(--sp-3);
  cursor: pointer;
  transition: background .12s;
}
.event-card:active { background: var(--surface-elev); }
.event-card .ev-head {
  display: flex; align-items: center; gap: var(--sp-2);
  font-weight: 600; font-size: 15px;
}
.event-card .ev-head .title-text {
  flex: 1; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.ev-status {
  font-size: 10px; padding: 3px 8px;
  border-radius: var(--r-pill);
  font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.4px;
  flex-shrink: 0;
}
.ev-status.voting    { background: rgba(255, 178, 66, 0.18); color: #ffb142; }
.ev-status.confirmed { background: rgba(52, 199, 89, 0.18);  color: var(--success); }
.ev-status.cancelled { background: rgba(239, 91, 91, 0.18);  color: var(--destructive); }
.ev-status.completed { background: var(--surface-elev);      color: var(--hint); }

.event-card .ev-when { font-size: 13px; color: var(--text); margin-top: 6px; }
.event-card .ev-loc {
  font-size: 12px; color: var(--hint); margin-top: 2px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.event-card .ev-meta {
  display: flex; gap: var(--sp-3); margin-top: 6px;
  font-size: 11px; color: var(--hint);
}

/* Event detail (inside modal) */
#eventBody .ev-desc {
  background: var(--surface);
  padding: var(--sp-3); border-radius: var(--r-sm);
  margin-bottom: var(--sp-3);
  font-size: 14px; line-height: 1.45;
}
#eventBody .ev-section { margin-bottom: var(--sp-4); }
#eventBody .ev-section:last-child { margin-bottom: 0; }
#eventBody .ev-section-title {
  font-size: 12px; color: var(--hint);
  text-transform: uppercase; letter-spacing: 0.5px;
  margin-bottom: 6px; font-weight: 600;
}
#eventBody .slot-row {
  display: flex; align-items: center; gap: var(--sp-3);
  padding: 10px var(--sp-3);
  background: var(--surface);
  border-radius: var(--r-md);
  margin-bottom: 6px;
  cursor: pointer;
  border: 1.5px solid transparent;
  transition: border-color .12s;
}
#eventBody .slot-row.voted { border-color: var(--accent); }
#eventBody .slot-row.confirmed { background: rgba(52, 199, 89, 0.12); }
#eventBody .slot-row .when { flex: 1; font-weight: 500; font-size: 14px; }
#eventBody .slot-row .count {
  font-size: 12px; color: var(--hint);
  background: var(--surface-elev);
  padding: 3px 8px; border-radius: var(--r-pill);
  font-weight: 600;
}
#eventBody .signup-buttons {
  display: flex; gap: 6px;
}
#eventBody .signup-buttons .btn { flex: 1; height: 38px; font-size: 13px; }
#eventBody .signup-buttons .btn.active.in    { background: var(--success); color: white; border-color: transparent; }
#eventBody .signup-buttons .btn.active.maybe { background: #ffb142; color: #1a1100; border-color: transparent; }
#eventBody .signup-buttons .btn.active.out   { background: var(--destructive); color: white; border-color: transparent; }
#eventBody .signup-list { display: flex; flex-wrap: wrap; gap: 4px; }
#eventBody .signup-chip {
  font-size: 12px;
  background: var(--surface);
  padding: 5px 10px;
  border-radius: var(--r-pill);
}
#eventBody .signup-chip.maybe { opacity: 0.6; }
#eventBody .map-link { margin-top: 8px; }

/* =================== MODAL =================== */
.modal {
  position: fixed; inset: 0; z-index: 50;
  display: flex; align-items: flex-end; justify-content: center;
  animation: fadeIn .15s ease;
}
.modal-bg {
  position: absolute; inset: 0;
  background: rgba(0,0,0,0.6);
}
.modal-sheet {
  position: relative; z-index: 1;
  background: var(--bg);
  width: 100%; max-width: 480px;
  max-height: 92vh;
  border-radius: var(--r-lg) var(--r-lg) 0 0;
  display: flex; flex-direction: column;
  animation: slideUp .22s cubic-bezier(0.2, 0.9, 0.3, 1);
  overflow: hidden;
}
@keyframes slideUp { from { transform: translateY(100%); } to { transform: none; } }

.modal-grab {
  width: 36px; height: 4px;
  background: var(--surface-press);
  border-radius: 2px;
  margin: 8px auto 0;
  flex-shrink: 0;
}

.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: var(--sp-3) var(--sp-4) var(--sp-2);
  flex-shrink: 0;
}
.modal-head h3 {
  margin: 0;
  font-size: 17px; font-weight: 700;
  flex: 1; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.modal-content {
  padding: 0 var(--sp-4) var(--sp-4);
  overflow-y: auto;
  overscroll-behavior: contain;
  flex: 1;
  -webkit-overflow-scrolling: touch;
}

.modal-foot {
  display: flex; gap: var(--sp-2);
  padding: var(--sp-3) var(--sp-4) calc(var(--sp-3) + env(safe-area-inset-bottom));
  background: var(--bg);
  border-top: 1px solid var(--separator);
  flex-shrink: 0;
}
.modal-foot .btn { flex: 1; }

/* =================== FORM =================== */
.form-row {
  margin-bottom: var(--sp-4);
}
.form-row:last-child { margin-bottom: 0; }
.form-label {
  font-size: 12px; color: var(--hint);
  text-transform: uppercase; letter-spacing: 0.4px;
  margin-bottom: var(--sp-2);
  font-weight: 600;
  display: flex; justify-content: space-between; align-items: baseline;
}
.form-label .label-hint {
  font-weight: 500; text-transform: none; letter-spacing: 0;
  opacity: 0.75;
}
.form-inline {
  display: flex; align-items: center; gap: var(--sp-2);
  margin-top: var(--sp-2);
  flex-wrap: wrap;
}
.form-hint { font-size: 11px; color: var(--hint); margin-top: var(--sp-2); }

/* Game type grid */
.type-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--sp-2);
}
.type-card {
  background: var(--surface);
  border-radius: var(--r-md);
  border: 1.5px solid transparent;
  padding: var(--sp-3) 4px;
  text-align: center;
  cursor: pointer;
  transition: border-color .12s, background .12s;
}
.type-card.active {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 12%, var(--surface));
}
.type-card .emoji { font-size: 24px; line-height: 1; }
.type-card .label { font-size: 11px; margin-top: 6px; font-weight: 500; }

/* Slot inputs */
#slotsBox { display: flex; flex-direction: column; gap: 6px; margin-bottom: var(--sp-2); }
.slot-input-row {
  display: flex; gap: var(--sp-2); align-items: center;
  background: var(--surface);
  padding: 6px;
  border-radius: var(--r-md);
}
.slot-input-row input[type="datetime-local"] {
  flex: 1; min-width: 0;
  background: transparent; border: none;
  color: var(--text); font-size: 14px;
  outline: none;
  padding: 8px 10px;
  font-family: inherit;
  color-scheme: dark;
  height: 38px;
}
.slot-input-row .del {
  width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--r-sm);
  color: var(--destructive); cursor: pointer;
  font-size: 16px;
  flex-shrink: 0;
}
.slot-input-row .del:active { background: var(--surface-press); }

/* Reminder chips */
.rem-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
}
.rem-chip {
  position: relative;
  background: var(--surface);
  border: 1.5px solid transparent;
  border-radius: var(--r-sm);
  padding: 8px 10px;
  cursor: pointer;
  user-select: none;
  transition: background .12s, border-color .12s;
}
.rem-chip input {
  position: absolute; opacity: 0; pointer-events: none;
}
.rem-chip label {
  font-size: 13px;
  display: flex; align-items: center; gap: 6px;
  cursor: pointer;
}
.rem-chip label::before {
  content: ""; width: 16px; height: 16px;
  border-radius: 4px;
  border: 1.5px solid var(--hint);
  flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 11px; line-height: 1;
  transition: background .12s, border-color .12s;
}
.rem-chip.checked label::before {
  background: var(--accent);
  border-color: var(--accent);
  content: "✓"; color: white;
}
.rem-chip.checked {
  background: color-mix(in srgb, var(--accent) 10%, var(--surface));
  border-color: var(--accent);
}

/* Geo chip */
.geo-chip {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--surface);
  padding: 6px 12px;
  border-radius: var(--r-pill);
  font-size: 12px;
  border-left: 3px solid var(--accent);
}
.geo-chip .x {
  color: var(--destructive); cursor: pointer;
  font-weight: 700;
  margin-left: 2px;
}

/* Score stepper */
.score-row {
  display: flex; align-items: center;
  background: var(--surface);
  border-radius: var(--r-md);
  padding: var(--sp-2) var(--sp-3);
  margin-bottom: 6px;
}
.score-row .team-num { font-weight: 600; flex: 1; }
.score-stepper { display: flex; align-items: center; gap: var(--sp-2); flex-shrink: 0; }
.score-stepper button {
  width: 34px; height: 34px;
  border-radius: var(--r-sm);
  border: 1px solid var(--separator);
  background: var(--bg); color: var(--text);
  font-size: 18px; font-weight: 600;
  cursor: pointer;
  transition: background .12s;
}
.score-stepper button:active { background: var(--surface-press); }
.score-stepper .value {
  min-width: 32px; text-align: center;
  font-size: 20px; font-weight: 700;
}

/* =================== BOTTOM NAV =================== */
.bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0;
  height: calc(var(--nav-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--header-bg);
  border-top: 1px solid var(--separator);
  display: flex; z-index: 20;
}
.nav-btn {
  flex: 1; background: transparent; border: none;
  color: var(--hint); cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px;
  padding: 6px 0;
  transition: color .15s;
  min-width: 0;
}
.nav-btn .nav-icon {
  font-size: 20px;
  filter: grayscale(0.3);
  transition: filter .15s;
}
.nav-btn .nav-label {
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.1px;
}
.nav-btn.active { color: var(--accent); }
.nav-btn.active .nav-icon { filter: none; }
.nav-btn:active { transform: scale(0.96); }

/* =================== CHIP ROW (game-type filter) =================== */
.chip-row {
  display: flex; gap: 6px;
  overflow-x: auto; overscroll-behavior-x: contain;
  scrollbar-width: none;
  margin: 0 calc(-1 * var(--sp-4)) var(--sp-3);
  padding: 0 var(--sp-4) 2px;
  -webkit-overflow-scrolling: touch;
}
.chip-row::-webkit-scrollbar { display: none; }
.chip-row:empty { display: none; }
.chip {
  border: 1px solid var(--separator);
  background: var(--surface);
  color: var(--text);
  padding: 6px 12px;
  border-radius: var(--r-pill);
  font-size: 13px; font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  transition: background .12s, border-color .12s;
}
.chip:active { transform: scale(0.97); }
.chip.active {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-text);
  font-weight: 600;
}

/* =================== PLAYER OVERRIDE PILL =================== */
.override-pill {
  display: inline-block;
  background: var(--surface-press);
  color: var(--text);
  font-size: 10px; font-weight: 700;
  padding: 1px 6px;
  border-radius: var(--r-pill);
  margin-left: 4px;
  vertical-align: middle;
}

/* =================== CUSTOM TYPE / ADD TILE =================== */
.type-card.type-add {
  border: 1.5px dashed var(--separator);
  background: transparent;
  color: var(--hint);
}
.type-card.type-add .emoji { font-size: 22px; }
.type-card.type-add:active { border-color: var(--accent); color: var(--text); }
.type-custom-mark {
  font-size: 9px; color: var(--hint);
  text-transform: uppercase; letter-spacing: 0.4px;
  margin-top: 2px;
}

/* =================== PLAN KIND SWITCH =================== */
#planKindSwitch {
  margin: 0 0 var(--sp-2);
  padding: 0;
}

/* =================== STATS attendance =================== */
.stat-row .attended { color: var(--accent); font-weight: 600; }
.stat-row .pct.att { color: var(--accent); }

/* =================== TIER OVERRIDE ROW (in tier modal) =================== */
.tier-override-row {
  display: flex; align-items: center; gap: var(--sp-2);
  padding: 8px 10px;
  background: var(--surface);
  border-radius: var(--r-md);
  margin-bottom: 6px;
}
.tier-override-row .game-label {
  flex: 1; min-width: 0;
  font-size: 13px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.tier-override-row .icon-btn.clear-override {
  width: 30px; height: 30px;
  font-size: 14px;
  color: var(--hint);
}

/* =================== HISTORY DAY HEADERS =================== */
.day-header {
  font-size: 12px; font-weight: 700;
  color: var(--hint);
  text-transform: uppercase; letter-spacing: 0.5px;
  padding: var(--sp-3) 4px 6px;
}
.day-header:first-child { padding-top: 0; }

/* =================== STATS ENRICHED =================== */
.stat-row { gap: var(--sp-2); }
.stat-row .stat-main { flex: 1; min-width: 0; }
.stat-row .stat-main .name {
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  margin-bottom: 2px;
}
.stat-row .nums { gap: 6px; flex-wrap: wrap; }
.stat-row .nums .games { color: var(--hint); }
.stat-row .streak {
  font-size: 10px; font-weight: 700;
  padding: 2px 6px; border-radius: var(--r-pill);
}
.stat-row .streak.good { background: rgba(52,199,89,0.18); color: var(--success); }
.stat-row .streak.bad  { background: rgba(239,91,91,0.18); color: var(--destructive); }
.form-dots {
  display: flex; gap: 2px;
  flex-shrink: 0;
  flex-direction: row-reverse;
}
.form-dot {
  width: 16px; height: 16px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 50%;
  font-size: 9px; font-weight: 700;
  color: #fff;
}
.form-dot.w { background: var(--success); }
.form-dot.l { background: var(--destructive); opacity: 0.8; }

/* =================== EVENT EDIT MODE =================== */
.ev-edit-bar {
  display: flex; justify-content: flex-end;
  margin-bottom: var(--sp-2);
}
.ev-edit-form .teams-actions { margin-top: var(--sp-3); }

/* =================== TAB SUBTITLE =================== */
.tab-subtitle {
  font-size: 12px;
  color: var(--hint);
  line-height: 1.4;
  margin: 2px 0 var(--sp-3);
}

/* =================== TEAM NAME INLINE EDIT =================== */
.team-name-edit {
  outline: none;
  border-radius: 6px;
  padding: 2px 6px; margin: -2px -6px;
  cursor: text;
  transition: background .12s;
}
.team-name-edit:focus { background: var(--surface-elev); }
.team-name-edit:hover:not(:focus) { background: rgba(255,255,255,0.03); }
.member .name {
  cursor: pointer;
  border-radius: 4px;
  padding: 1px 4px;
  margin: -1px -4px;
  transition: background .12s;
}
.member .name:active { background: var(--surface-press); }

/* =================== PLAYER PROFILE =================== */
.profile-card {
  display: flex; flex-direction: column; gap: var(--sp-3);
}
.profile-tier { display: flex; justify-content: center; }
.profile-tier .tier-badge {
  width: 56px; height: 56px; min-width: 56px;
  border-radius: var(--r-md);
  font-size: 24px;
}
.profile-stats {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px;
}
.profile-stats > div {
  background: var(--surface);
  padding: var(--sp-2);
  border-radius: var(--r-sm);
  text-align: center;
  display: flex; flex-direction: column;
  min-height: 56px; justify-content: center;
}
.profile-stats b { font-size: 18px; }
.profile-stats span { font-size: 10px; color: var(--hint); margin-top: 2px; }
.profile-line {
  background: var(--surface);
  padding: 8px 10px; border-radius: var(--r-sm);
  font-size: 14px;
}

/* =================== MVP VOTING =================== */
.mvp-list { display: flex; flex-direction: column; gap: 6px; }
.mvp-row {
  display: flex; align-items: center; gap: var(--sp-3);
  padding: 10px 12px;
  background: var(--surface);
  color: var(--text);
  border: 1.5px solid transparent;
  border-radius: var(--r-md);
  cursor: pointer;
  transition: border-color .12s, background .12s;
  width: 100%; text-align: left;
}
.mvp-row:active { transform: scale(0.98); }
.mvp-row .name { flex: 1; font-weight: 500; }
.mvp-row .vote-pill {
  font-size: 11px; font-weight: 700;
  background: rgba(255, 178, 66, 0.18); color: #ffb142;
  padding: 3px 8px; border-radius: var(--r-pill);
}

/* =================== POTLUCK =================== */
.potluck-list { display: flex; flex-direction: column; gap: 6px; margin-bottom: var(--sp-2); }
.potluck-row {
  display: flex; align-items: center; gap: var(--sp-2);
  padding: 8px 12px;
  background: var(--surface);
  border-radius: var(--r-md);
  font-size: 14px;
}
.potluck-item { flex: 1; }
.potluck-who {
  font-size: 12px; color: var(--hint);
  background: var(--surface-elev);
  padding: 3px 8px; border-radius: var(--r-pill);
}
.potluck-who.mine { background: rgba(52,199,89,0.18); color: var(--success); }
.potluck-add { display: flex; gap: 6px; }
.potluck-add input { flex: 1; height: 36px; font-size: 13px; }
.potluck-add .btn { white-space: nowrap; }

/* =================== PHOTO GRID =================== */
.photo-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
}
.photo-cell {
  aspect-ratio: 1 / 1;
  border-radius: var(--r-sm);
  overflow: hidden;
  background: var(--surface);
  position: relative;
}
.photo-cell img {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
}

/* =================== GOALS / ASSISTS =================== */
.ga-section { margin: 8px 0; }
.ga-section summary {
  list-style: none;
  cursor: pointer;
  padding: 8px 12px;
  background: var(--surface);
  border-radius: var(--r-sm);
  font-size: 13px; font-weight: 500;
}
.ga-section summary::-webkit-details-marker { display: none; }
.ga-section[open] summary { border-bottom-left-radius: 0; border-bottom-right-radius: 0; }
.ga-hint { color: var(--hint); font-size: 11px; font-weight: 400; }
.ga-list {
  background: var(--surface);
  padding: 6px 8px;
  border-radius: 0 0 var(--r-sm) var(--r-sm);
  display: flex; flex-direction: column; gap: 4px;
}
.ga-row {
  display: flex; align-items: center; gap: var(--sp-2);
  flex-wrap: wrap;
  padding: 4px 0;
}
.ga-row .name { flex: 1; min-width: 80px; font-size: 13px; }
.ga-stepper {
  display: inline-flex; align-items: center; gap: 4px;
  background: var(--bg);
  border-radius: 6px;
  padding: 2px 4px;
}
.ga-stepper button {
  width: 22px; height: 22px;
  border: none; background: transparent;
  color: var(--text); font-size: 14px;
  cursor: pointer; border-radius: 4px;
}
.ga-stepper button:active { background: var(--surface-press); }
.ga-val { min-width: 16px; text-align: center; font-weight: 700; font-size: 13px; }
.ga-label { font-size: 12px; opacity: 0.7; }

.signup-chip.clickable { cursor: pointer; }
.signup-chip.clickable:active { background: var(--surface-elev); }

/* =================== MAP PICKER =================== */
.modal-fullscreen {
  max-height: 100vh;
  height: 100vh;
  border-radius: 0;
}
.map-search {
  display: flex; gap: 6px; padding: 6px var(--sp-4);
  background: var(--surface);
  border-bottom: 1px solid var(--separator);
}
.map-search .input { height: 36px; flex: 1; }
.map-search .btn { white-space: nowrap; }
.map-container {
  flex: 1; min-height: 300px;
  position: relative;
  background: var(--surface);
}
.map-container .leaflet-container {
  background: var(--surface);
  font-family: inherit;
}
/* Dark theme tweaks for Leaflet */
.leaflet-control-attribution { font-size: 9px !important; opacity: 0.6; background: rgba(0,0,0,0.4) !important; color: white !important; }
.leaflet-control-zoom a { background: var(--surface) !important; color: var(--text) !important; border: 1px solid var(--separator) !important; }
.leaflet-control-zoom a:hover { background: var(--surface-press) !important; }
.map-status {
  padding: 8px var(--sp-4);
  font-size: 12px; color: var(--hint);
  background: var(--surface);
  border-top: 1px solid var(--separator);
  word-break: break-word;
  max-height: 60px; overflow-y: auto;
}
.map-results {
  position: absolute; left: var(--sp-4); right: var(--sp-4);
  top: 110px; max-height: 50vh; overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--separator);
  border-radius: var(--r-md);
  z-index: 1000;
  box-shadow: 0 6px 24px rgba(0,0,0,0.4);
}
.map-result-row {
  padding: 10px 12px;
  font-size: 13px;
  cursor: pointer;
  border-bottom: 1px solid var(--separator);
}
.map-result-row:last-child { border-bottom: none; }
.map-result-row:active { background: var(--surface-press); }

/* =================== TEAMS STEPPER (replaces 2-3-4-5-6 seg) =================== */
.teams-stepper {
  display: flex; align-items: center; gap: var(--sp-2);
  flex-wrap: wrap;
  background: var(--bg);
  padding: 6px; border-radius: var(--r-md);
  margin-bottom: var(--sp-2);
}
.teams-stepper .ts-label {
  font-size: 12px; color: var(--hint); font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.3px;
}
.teams-stepper .ts-btn {
  width: 36px; height: 36px;
  border-radius: var(--r-sm);
  border: 1px solid var(--separator);
  background: var(--surface); color: var(--text);
  font-size: 18px; font-weight: 700;
  cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
}
.teams-stepper .ts-btn:active { background: var(--surface-press); transform: scale(0.95); }
.teams-stepper .ts-val {
  min-width: 36px; text-align: center;
  font-size: 20px; font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.teams-stepper .ts-quick {
  display: inline-flex; gap: 4px;
  margin-left: auto;
  flex-wrap: wrap;
}
.teams-stepper .quick-n {
  width: 30px; height: 30px;
  border-radius: var(--r-sm);
  border: 1px solid var(--separator);
  background: transparent; color: var(--hint);
  font-size: 12px; font-weight: 600;
  cursor: pointer;
}
.teams-stepper .quick-n.active {
  background: var(--accent); color: var(--accent-text);
  border-color: var(--accent);
}

/* =================== ROUND DRAFT D&D (reserves as drop target) =================== */
.reserves-block.dnd-target {
  outline: 2px dashed var(--accent);
  outline-offset: -3px;
}
.reserves-block .members.reserves-members {
  display: flex; flex-direction: row; flex-wrap: wrap; gap: 4px;
  margin-top: 6px;
}
.reserves-block .member {
  background: var(--surface-elev);
  padding: 6px 10px;
  border-radius: var(--r-pill);
  font-size: 12px;
  display: inline-flex; align-items: center; gap: 6px;
}

/* =================== GUESTS («+1») =================== */
.guests-list { display: flex; flex-direction: column; gap: 4px; margin-bottom: var(--sp-2); }
.guest-row {
  display: flex; align-items: center; gap: var(--sp-2);
  padding: 8px 12px;
  background: var(--surface);
  border-radius: var(--r-md);
  border-left: 3px solid #b388ff;
  font-size: 13px;
}
.guest-row .name { flex: 1; min-width: 0; font-weight: 500; }
.guest-row .guest-host {
  font-size: 11px; color: var(--hint);
  background: var(--surface-elev);
  padding: 2px 8px; border-radius: var(--r-pill);
}

/* =================== ROUNDS (multi-round events) =================== */
.rounds-list { display: flex; flex-direction: column; gap: 4px; margin-bottom: var(--sp-2); }
.round-row {
  display: flex; align-items: center; gap: var(--sp-2);
  padding: 8px 12px;
  background: var(--surface);
  border-radius: var(--r-md);
  font-size: 13px;
}
.round-num {
  width: 26px; height: 26px;
  background: var(--accent); color: var(--accent-text);
  border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 12px;
  flex-shrink: 0;
}
.round-score { font-weight: 700; font-size: 14px; }
.round-meta { color: var(--hint); font-size: 11px; flex: 1; }

.round-pick-list { display: flex; flex-direction: column; gap: 4px; }
.pick-row {
  display: flex; align-items: center; gap: var(--sp-3);
  padding: 10px 12px;
  background: var(--surface);
  border-radius: var(--r-md);
  cursor: pointer;
}
.pick-row input { accent-color: var(--accent); width: 18px; height: 18px; flex-shrink: 0; }
.pick-row .name { font-size: 14px; }
.pick-row .badge-tg { font-size: 10px; background: rgba(179, 136, 255, 0.18); color: #b388ff; padding: 2px 6px; border-radius: 4px; margin-left: 4px; }

/* =================== RESERVES =================== */
.reserves-block {
  background: var(--surface);
  border-radius: var(--r-md);
  padding: var(--sp-3);
  margin-top: 4px;
  border-left: 3px solid var(--hint);
}
.reserves-head { font-size: 13px; color: var(--hint); margin-bottom: 6px; font-weight: 600; }
.reserves-list { display: flex; flex-wrap: wrap; gap: 6px; }
.reserve-chip {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--surface-elev);
  padding: 5px 10px;
  border-radius: var(--r-pill);
  font-size: 13px;
}
.reserve-chip .clickable { cursor: pointer; }

/* =================== ATTENDANCE (no-show) =================== */
.attendance-summary {
  font-size: 12px; color: var(--hint);
  margin-bottom: 8px;
  display: flex; flex-wrap: wrap; gap: 6px;
}
.no-show-pill {
  background: rgba(239, 91, 91, 0.18);
  color: var(--destructive);
  padding: 2px 8px; border-radius: var(--r-pill);
  font-size: 11px; font-weight: 600;
}
.all-attended-pill {
  background: rgba(52, 199, 89, 0.18);
  color: var(--success);
  padding: 2px 8px; border-radius: var(--r-pill);
  font-size: 11px; font-weight: 600;
}
.attendance-list { display: flex; flex-direction: column; gap: 4px; }
.attendance-row {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px;
  background: var(--surface);
  border-radius: var(--r-md);
  font-size: 14px;
}
.attendance-row.came  { background: rgba(52, 199, 89, 0.10); }
.attendance-row.noshow { background: rgba(239, 91, 91, 0.10); }
.att-toggle {
  width: 32px; height: 32px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: var(--r-sm);
  cursor: pointer; font-size: 18px;
  background: var(--surface-elev);
  flex-shrink: 0;
}
.att-toggle.on  { background: rgba(52, 199, 89, 0.3); }
.att-toggle.off { background: rgba(239, 91, 91, 0.3); }
.attendance-row .name { flex: 1; cursor: pointer; }
.attendance-row.noshow .name { text-decoration: line-through; opacity: 0.7; }

/* =================== RELIABILITY BADGES =================== */
.t-badge.rel-high { background: rgba(52, 199, 89, 0.18); color: var(--success); }
.t-badge.rel-mid  { background: rgba(255, 178, 66, 0.18); color: #ffb142; }
.t-badge.rel-low  { background: rgba(239, 91, 91, 0.18); color: var(--destructive); }
.profile-line.rel-high { border-left: 3px solid var(--success); padding-left: 10px; }
.profile-line.rel-mid  { border-left: 3px solid #ffb142; padding-left: 10px; }
.profile-line.rel-low  { border-left: 3px solid var(--destructive); padding-left: 10px; }

/* =================== TOURNAMENT IN STATS =================== */
.chip.tournament-chip {
  background: linear-gradient(135deg, #ffb142 0%, #ffd700 100%);
  color: #1a1100; font-weight: 700;
  border-color: transparent;
}
.chip.tournament-chip.active {
  box-shadow: 0 0 0 2px var(--accent);
}

.t-badges { display: inline-flex; gap: 4px; margin-top: 4px; flex-wrap: wrap; }
.t-badge {
  font-size: 10px; font-weight: 700;
  padding: 2px 6px;
  border-radius: var(--r-pill);
  white-space: nowrap;
}
.t-badge.gold   { background: rgba(255, 215, 0, 0.2); color: #ffd700; }
.t-badge.silver { background: rgba(192, 192, 192, 0.2); color: #e0e0e0; }

.tournament-leaderboard {
  display: flex; flex-direction: column; gap: 8px;
  margin-bottom: var(--sp-3);
}
.tournament-medal-card {
  background: var(--surface);
  border-radius: var(--r-md);
  padding: 12px;
  border-left: 3px solid #ffd700;
}
.tournament-medal-card .t-head { font-size: 15px; }
.tournament-medal-card .t-winner {
  color: #ffd700; font-size: 13px; margin-top: 4px; font-weight: 600;
}
.tournament-medal-card .t-podium {
  display: flex; flex-wrap: wrap; gap: 6px;
  margin-top: 8px;
  font-size: 12px;
}
.podium-cell {
  background: var(--surface-elev);
  padding: 4px 8px; border-radius: var(--r-pill);
}

.pairs-list { display: flex; flex-direction: column; gap: 4px; margin-bottom: var(--sp-3); }
.pair-row {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px;
  background: var(--surface);
  border-radius: var(--r-md);
  font-size: 13px;
}
.pair-rank { color: var(--hint); font-weight: 700; min-width: 24px; text-align: center; }
.pair-names { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pair-names .clickable { cursor: pointer; }
.pair-stats { color: var(--hint); font-size: 12px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.pair-stats b { color: var(--text); }

.tournament-history-row {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--surface);
  border-radius: var(--r-sm);
  padding: 8px 12px;
  margin-bottom: 4px;
  font-size: 13px;
  gap: 8px;
}
.t-winner-inline { color: #ffd700; font-size: 12px; font-weight: 600; white-space: nowrap; }
.t-no-winner { color: var(--hint); font-size: 12px; }

/* =================== EXPENSES (payment splitting) =================== */
.expense-row {
  display: flex; align-items: center; gap: var(--sp-2);
  padding: 10px 12px;
  background: var(--surface);
  border-radius: var(--r-md);
  margin-bottom: 6px;
}
.expense-row .info { flex: 1; min-width: 0; }
.expense-row .who { font-size: 12px; color: var(--hint); }
.expense-row .amt { font-weight: 700; font-size: 15px; white-space: nowrap; }
.expense-shares {
  display: flex; flex-wrap: wrap; gap: 4px;
  margin-top: 6px;
  font-size: 11px;
}
.share-chip {
  background: var(--surface-elev);
  padding: 3px 8px; border-radius: var(--r-pill);
  cursor: pointer;
}
.share-chip.settled { opacity: 0.45; text-decoration: line-through; }

.balance-row {
  display: flex; align-items: center; gap: var(--sp-2);
  padding: 6px 10px;
  background: var(--surface-elev);
  border-radius: var(--r-sm);
  margin-bottom: 4px;
  font-size: 13px;
}
.balance-row .nick { flex: 1; }
.balance-row .net { font-weight: 700; font-variant-numeric: tabular-nums; }
.balance-row .net.positive { color: var(--success); }
.balance-row .net.negative { color: var(--destructive); }

.expense-add {
  display: flex; flex-direction: column; gap: 6px;
  background: var(--surface);
  padding: 10px; border-radius: var(--r-md);
  margin-top: 8px;
}
.expense-add .row { display: flex; gap: 6px; }
.expense-add input.amt-input {
  width: 110px; text-align: right;
  font-variant-numeric: tabular-nums;
}

/* =================== TOURNAMENTS =================== */
.tournament-card {
  background: var(--surface);
  border-radius: var(--r-md);
  padding: var(--sp-3);
  cursor: pointer;
}
.tournament-card .t-head {
  display: flex; align-items: center; gap: var(--sp-2);
  font-weight: 600;
}
.tournament-card .t-head .title-text { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tournament-card .t-meta {
  font-size: 11px; color: var(--hint); margin-top: 4px;
}

.standings-table {
  background: var(--surface);
  border-radius: var(--r-md);
  padding: 8px;
}
.standings-row {
  display: grid;
  grid-template-columns: 28px 1fr 40px 40px 50px;
  gap: 6px; align-items: center;
  padding: 6px 4px;
  border-radius: 6px;
  font-size: 13px;
}
.standings-row.head {
  font-size: 10px; color: var(--hint);
  text-transform: uppercase; font-weight: 600;
  letter-spacing: 0.4px;
}
.standings-row .rank { font-weight: 700; color: var(--hint); text-align: center; }
.standings-row .name { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.standings-row .w { color: var(--success); text-align: right; font-weight: 700; }
.standings-row .l { color: var(--destructive); text-align: right; }
.standings-row .pct { text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }
.standings-row.gold .rank { color: gold; }
.standings-row.silver .rank { color: silver; }
.standings-row.bronze .rank { color: #cd7f32; }

/* =================== TOAST =================== */
.toast {
  position: fixed;
  bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 16px);
  left: 50%; transform: translateX(-50%);
  background: rgba(0,0,0,0.92);
  color: white;
  padding: 10px 18px;
  border-radius: var(--r-pill);
  font-size: 14px;
  z-index: 100;
  animation: toastIn .2s ease;
  max-width: 90vw;
  text-align: center;
  box-shadow: 0 4px 16px rgba(0,0,0,0.3);
}
.toast.error { background: var(--destructive); }
@keyframes toastIn {
  from { opacity: 0; transform: translate(-50%, 10px); }
  to   { opacity: 1; transform: translate(-50%, 0); }
}

/* =================== EMPTY / LOADING =================== */
.empty {
  text-align: center; color: var(--hint);
  padding: var(--sp-8) var(--sp-4);
}
.empty .emoji { font-size: 36px; margin-bottom: var(--sp-2); opacity: 0.7; }
.empty .text { font-size: 14px; line-height: 1.45; }

.skel {
  height: 44px;
  background: linear-gradient(90deg,
    var(--surface) 0%,
    var(--surface-elev) 50%,
    var(--surface) 100%);
  background-size: 200% 100%;
  animation: shimmer 1.2s infinite;
  border-radius: var(--r-md);
  margin-bottom: 6px;
}
@keyframes shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* =================== SAFE FALLBACKS =================== */
@supports not (color: color-mix(in srgb, white 50%, black)) {
  .type-card.active { background: rgba(51,144,236,0.12); }
  .rem-chip.checked { background: rgba(51,144,236,0.10); }
}
