@import url('https://fonts.googleapis.com/css2?family=Saira+Condensed:ital,wght@0,400;0,500;0,600;0,700;0,800;1,400;1,600;1,700;1,800&family=Saira+Extra+Condensed:ital,wght@0,400;0,500;0,600;0,700;0,800;1,400;1,600;1,700;1,800&display=swap');

/* ============================================================
   The Finals — Custom Lobby Manager
   Official brand theme (Saira Condensed + TF red)
   ============================================================ */

:root {
  --bg: #1D1A20;          /* TF dark neutral */
  --bg-2: #241f29;
  --panel: #2a2431;
  --panel-2: #332c3b;
  --border: #423a4d;
  --border-2: #5a4d6b;
  --text: #F1F2F4;        /* TF light neutral */
  --muted: #9d95a8;
  --accent: #D21F3C;      /* TF primary red */
  --accent-2: #ff5470;    /* TF red highlight */
  --accent-deep: #8f1428;
  --green: #35d07f;
  --red: #ff2e4d;
  --blue: #4aa3ff;
  --purple: #b06bff;
  --radius: 8px;
  --font-body: 'Saira Condensed', 'Segoe UI', system-ui, sans-serif;
  --font-display: 'Saira Extra Condensed', 'Saira Condensed', sans-serif;
  --mono: 'Consolas', 'SF Mono', 'Menlo', monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
}

body {
  background:
    radial-gradient(1100px 480px at 85% -10%, rgba(210, 31, 60, 0.16), transparent 60%),
    radial-gradient(900px 420px at 5% 110%, rgba(210, 31, 60, 0.09), transparent 60%),
    var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-weight: 500;
  letter-spacing: 0.2px;
  min-height: 100vh;
}

h1, h2, h3 {
  font-family: var(--font-display);
  font-weight: 800;
  font-style: italic;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

a { color: var(--accent-2); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- layout ---------- */
.container {
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 20px 60px;
}

header.site {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 22px 0 18px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 26px;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand .logo {
  width: 46px;
  height: 46px;
  background: linear-gradient(135deg, var(--accent), var(--accent-deep));
  display: grid;
  place-items: center;
  font-family: var(--font-display);
  font-weight: 800;
  font-style: italic;
  font-size: 22px;
  color: #fff;
  letter-spacing: -1px;
  clip-path: polygon(0 0, 100% 0, 100% 74%, 74% 100%, 0 100%);
  box-shadow: 0 0 24px rgba(210, 31, 60, 0.45);
}

.brand h1 {
  margin: 0;
  font-size: 26px;
  font-weight: 800;
  font-style: italic;
  letter-spacing: 1px;
  text-transform: uppercase;
  line-height: 1;
}

.brand h1 span { color: var(--accent); }

.brand .sub {
  margin: 4px 0 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 2px;
  text-transform: uppercase;
}

/* ---------- buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  padding: 9px 18px;
  border-radius: 6px;
  font-family: var(--font-display);
  font-style: italic;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn:hover { border-color: var(--accent); color: #fff; transform: translateY(-1px); }
.btn:active { transform: translateY(0); }

.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-deep));
  border-color: transparent;
  color: #fff;
  font-weight: 800;
}
.btn-primary:hover { box-shadow: 0 4px 18px rgba(210, 31, 60, 0.5); border-color: transparent; color: #fff; }

.btn-danger { color: var(--red); }
.btn-danger:hover { border-color: var(--red); background: rgba(255, 77, 77, 0.08); }

.btn-ghost { background: transparent; }

.btn-sm { padding: 6px 12px; font-size: 13px; }

.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

/* ---------- forms ---------- */
label.field {
  display: block;
  font-family: var(--font-display);
  font-style: italic;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--muted);
  margin: 14px 0 6px;
}

input, select, textarea {
  width: 100%;
  background: var(--bg-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 14px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s ease;
}

input:focus, select:focus, textarea:focus { border-color: var(--accent); }

textarea { resize: vertical; min-height: 90px; font-family: var(--mono); font-size: 13px; }

input[type='datetime-local'] {
  font-family: var(--font-display);
  font-size: 16px;
  letter-spacing: 0.5px;
  color-scheme: dark;
}

/* ---------- game cards ---------- */
.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}

.toolbar .title {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 800;
  font-style: italic;
  letter-spacing: 1px;
  text-transform: uppercase;
}

.toolbar .count { color: var(--muted); font-weight: 500; }

.toolbar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.filters { display: flex; gap: 8px; flex-wrap: wrap; }

.chip {
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  padding: 6px 16px;
  border-radius: 999px;
  font-family: var(--font-display);
  font-style: italic;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  cursor: pointer;
  transition: all 0.15s ease;
}

.chip.active {
  background: rgba(210, 31, 60, 0.16);
  border-color: var(--accent);
  color: #fff;
}

.games {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 16px;
}

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  position: relative;
  overflow: hidden;
  transition: border-color 0.15s ease;
}

.card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 4px;
  background: repeating-linear-gradient(135deg, var(--accent) 0 14px, var(--accent-deep) 14px 28px);
}

.card:hover { border-color: var(--border-2); transform: translateY(-2px); }

.card.started { opacity: 0.65; }
.card.started::before { background: var(--muted); }

.card-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
}

.card-top-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.card h3 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 800;
  font-style: italic;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  line-height: 1.1;
  word-break: break-word;
}

.badge {
  flex-shrink: 0;
  font-family: var(--font-display);
  font-style: italic;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid;
}

.badge.CASHOUT { color: var(--accent-2); border-color: rgba(255, 84, 112, 0.5); background: rgba(210, 31, 60, 0.14); }
.badge.RANKED_CASHOUT { color: #fff; border-color: var(--accent); background: rgba(210, 31, 60, 0.28); }
.badge.TDM { color: var(--blue); border-color: rgba(74, 163, 255, 0.5); background: rgba(74, 163, 255, 0.1); }
.badge.HEAD2HEAD { color: var(--red); border-color: rgba(255, 46, 77, 0.5); background: rgba(255, 46, 77, 0.1); }
.badge.POINT_BREAK { color: var(--green); border-color: rgba(53, 208, 127, 0.5); background: rgba(53, 208, 127, 0.1); }
.badge.POWER_SHIFT { color: var(--purple); border-color: rgba(176, 107, 255, 0.5); background: rgba(176, 107, 255, 0.1); }

.meta {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  color: var(--muted);
}

.meta .row { display: flex; align-items: center; gap: 8px; }
.meta .row b { color: var(--text); font-weight: 600; }
.meta .date-row b { font-size: 17px; font-weight: 700; letter-spacing: 0.3px; }

.meta .live {
  color: var(--red);
  font-weight: 800;
  letter-spacing: 1px;
  font-size: 11px;
  animation: pulse 1.4s infinite;
}

@keyframes pulse { 50% { opacity: 0.4; } }

/* teams */
.teams {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
}

.team {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px;
}

.team-head {
  font-family: var(--font-display);
  font-style: italic;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--accent-2);
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}

.team-count {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
  font-weight: 600;
}

.team-players {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.player {
  font-size: 13px;
  font-family: var(--mono);
  padding: 4px 8px;
  border-radius: 6px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  word-break: break-word;
}

.player .player-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.avatar {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  background: var(--bg-2);
  border: 1px solid var(--border);
}

.player.empty {
  color: var(--muted);
  border-style: dashed;
  background: transparent;
  font-size: 11px;
  padding: 2px 8px;
}

.player.me {
  border-color: var(--accent);
  color: #fff;
  background: rgba(210, 31, 60, 0.16);
}

.you-tag {
  font-family: var(--font-display);
  font-style: italic;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--accent-2);
  flex-shrink: 0;
}

/* joined state */
.join.joined {
  align-items: center;
  justify-content: space-between;
  background: rgba(46, 204, 113, 0.08);
  border: 1px solid rgba(46, 204, 113, 0.4);
  border-radius: 8px;
  padding: 8px 12px;
}

.joined-label {
  font-size: 13px;
  color: var(--green);
}

.capacity-bar {
  height: 6px;
  border-radius: 999px;
  background: var(--bg-2);
  overflow: hidden;
}

.capacity-bar .fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  transition: width 0.3s ease;
}

.capacity-bar .fill.full { background: var(--red); }

/* join form */
.join {
  display: flex;
  gap: 8px;
  margin-top: auto;
}

.join input { flex: 1; }

.join select {
  flex: 0 0 auto;
  max-width: 150px;
  font-size: 13px;
}

/* locked (not signed in) state */
.join.locked {
  align-items: center;
  background: rgba(157, 149, 168, 0.08);
  border: 1px dashed var(--border);
  border-radius: 8px;
  padding: 10px 12px;
}

.locked-label {
  font-size: 13px;
  color: var(--muted);
}

/* ---------- identity bar ---------- */
.identity {
  margin: 16px 0;
}

.identity-box {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
}

.identity-box.signed {
  border-color: rgba(46, 204, 113, 0.4);
  background: rgba(46, 204, 113, 0.05);
}

.identity-box .avatar {
  width: 40px;
  height: 40px;
}

.identity-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.identity-info b {
  font-size: 15px;
}

.identity-id {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--accent-2);
  letter-spacing: 1px;
}

.identity-hint {
  font-size: 12px;
  color: var(--muted);
}

.identity-hint code {
  font-family: var(--mono);
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 5px;
  color: var(--accent-2);
}

.identity-form {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.identity-form input {
  min-width: 200px;
  font-family: var(--mono);
  letter-spacing: 1px;
  text-transform: uppercase;
}

/* ---------- empty state ---------- */
.empty {
  text-align: center;
  padding: 70px 20px;
  color: var(--muted);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
}

.empty .big { font-size: 44px; margin-bottom: 10px; }
.empty h2 { margin: 0 0 6px; color: var(--text); font-size: 24px; font-style: italic; }

/* ---------- toast ---------- */
.toast-wrap {
  position: fixed;
  bottom: 20px;
  right: 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 100;
}

.toast {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  color: var(--text);
  padding: 12px 18px;
  border-radius: 8px;
  font-size: 14px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.5);
  animation: slideIn 0.2s ease;
  max-width: 340px;
}

.toast.error { border-left-color: var(--red); }
.toast.success { border-left-color: var(--green); }

@keyframes slideIn {
  from { transform: translateX(30px); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* ---------- admin ---------- */
.login-box {
  max-width: 380px;
  margin: 80px auto;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 30px;
}

.login-box h2 {
  margin: 0 0 4px;
  font-size: 26px;
  font-style: italic;
  letter-spacing: 1px;
  text-transform: uppercase;
}

.login-box p { margin: 0 0 10px; color: var(--muted); font-size: 13px; }

.admin-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.admin-table th {
  text-align: left;
  font-family: var(--font-display);
  font-style: italic;
  font-size: 13px;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--muted);
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--panel-2);
}

.admin-table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
  vertical-align: middle;
}

.admin-table tr:last-child td { border-bottom: none; }
.admin-table tr:hover td { background: rgba(255, 255, 255, 0.02); }

.admin-table .names {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--muted);
  max-width: 260px;
  word-break: break-word;
}

.admin-table .names .team-line { margin: 1px 0; }
.admin-table .names .team-line b { color: var(--text); }

.admin-table .actions { white-space: nowrap; text-align: right; }

/* modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(5, 7, 10, 0.75);
  backdrop-filter: blur(3px);
  display: grid;
  place-items: center;
  z-index: 50;
  padding: 20px;
}

.modal {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  padding: 24px;
}

.modal h2 {
  margin: 0 0 4px;
  font-size: 24px;
  font-style: italic;
  letter-spacing: 1px;
  text-transform: uppercase;
}

.modal .hint { color: var(--muted); font-size: 13px; margin: 0 0 6px; }

.modal .modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 22px;
}

.form-error {
  color: var(--red);
  font-size: 13px;
  margin-top: 12px;
  min-height: 18px;
}

.gm-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

/* per-team participant fields in the modal */
#f_teams {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 14px;
}

.team-field .team-cap {
  color: var(--muted);
  font-size: 11px;
  font-weight: 400;
  margin-left: 4px;
}

.team-field textarea { min-height: 70px; }

/* player picker (admin modal) */
.picker { position: relative; }
.picker-toggle {
  width: 100%;
  text-align: left;
  border: 1px solid var(--border);
  background: var(--bg-2);
  color: var(--text);
  padding: 9px 12px;
  border-radius: 8px;
  font-family: inherit;
  font-size: 13px;
  cursor: pointer;
  transition: border-color 0.15s ease;
}
.picker-toggle:hover { border-color: var(--accent); }
.picker-list {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  z-index: 20;
  max-height: 220px;
  overflow-y: auto;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.45);
}
.picker-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  font-size: 13px;
  cursor: pointer;
}
.picker-item:hover { background: rgba(210, 31, 60, 0.16); }
.picker-item.disabled { opacity: 0.4; cursor: not-allowed; }
.picker-item em { margin-left: auto; font-size: 10px; color: var(--muted); font-style: normal; }
.picker-item .avatar { width: 20px; height: 20px; }
.picker-empty { padding: 10px; font-size: 12px; color: var(--muted); }
.picked { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.picked-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 6px 3px 4px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 12px;
}
.picked-chip .avatar { width: 18px; height: 18px; }
.picked-x {
  border: none;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 15px;
  line-height: 1;
  padding: 0 2px;
}
.picked-x:hover { color: var(--red); }

footer.site {
  margin-top: 40px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 12px;
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
}

.hidden { display: none !important; }

@media (max-width: 640px) {
  .admin-table thead { display: none; }
  .admin-table, .admin-table tbody, .admin-table tr, .admin-table td { display: block; width: 100%; }
  .admin-table tr { border-bottom: 1px solid var(--border); padding: 8px 0; }
  .admin-table td { border: none; padding: 4px 14px; }
  .admin-table .actions { text-align: left; }
}
