:root {
  --pitch-950: #1a0507;
  --brand-700: #7d131a;
  --brand-600: #9c171d;
  --brand-500: #c22128;
  --brand-100: #f5dcdb;
  --gold-500: #e0a52c;
  --gold-600: #8a5f10;
  --chalk-50: #faf6f5;
  --paper: #ffffff;
  --ink: #17120f;
  --ink-soft: #5c4f49;
  --ink-faint: #756860;
  --line: #e8ded9;
  --line-soft: #f3ece9;
  --green-600: #23875a;
  --green-100: #ddf3e7;
  --amber-600: #b4791b;
  --amber-100: #faecd4;
  --red-600: #c23b3b;
  --red-100: #fbe3e3;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(26, 5, 7, 0.06), 0 8px 24px -12px rgba(26, 5, 7, 0.18);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --pitch-950: #0d0203; --brand-700: #c2444b; --brand-600: #cf565c; --brand-500: #db6f74;
    --brand-100: #3a1e1e; --gold-500: #f0b93e; --gold-600: #e0a52c; --chalk-50: #150a09;
    --paper: #1f0f0d; --ink: #f2e9e6; --ink-soft: #cdb9b3; --ink-faint: #a08880;
    --line: #3a1e1a; --line-soft: #241211; --green-600: #52c98a; --green-100: #12301f;
    --amber-600: #e0aa4e; --amber-100: #332405; --red-600: #e57575; --red-100: #341414;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px -12px rgba(0,0,0,.5);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--chalk-50);
  color: var(--ink);
  font-family: "Segoe UI", ui-sans-serif, system-ui, -apple-system, Roboto, Arial, sans-serif;
  font-size: 15px;
  line-height: 1.5;
}
h1, h2, h3, h4 { font-family: inherit; font-weight: 800; letter-spacing: -0.01em; margin: 0; color: var(--ink); }
p { margin: 0; color: var(--ink-soft); }
a { color: var(--brand-600); text-decoration: none; }
button, input { font-family: inherit; }
:focus-visible { outline: 2px solid var(--brand-500); outline-offset: 2px; }

.brand-row { display: flex; align-items: center; gap: 10px; }
.brand-mark { width: 34px; height: 34px; border-radius: 8px; background: linear-gradient(155deg, var(--brand-500), var(--brand-700)); display: flex; align-items: center; justify-content: center; box-shadow: inset 0 0 0 1px rgba(255,255,255,0.18); flex: none; }
.brand-mark svg { width: 20px; height: 20px; }
.brand-name { font-weight: 800; font-size: 14.5px; line-height: 1.15; letter-spacing: -0.01em; }
.brand-name span { display: block; font-weight: 500; font-size: 10.5px; color: #d9a8a0; letter-spacing: 0.03em; text-transform: uppercase; margin-top: 1px; }

.card { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; border-radius: 8px; padding: 10px 18px; font-size: 13.5px; font-weight: 700; cursor: pointer; border: 1px solid transparent; text-decoration: none; }
.btn.primary { background: var(--brand-600); color: #fff; }
.btn.primary:hover { background: var(--brand-700); }
.btn.ghost { background: var(--paper); color: var(--ink); border-color: var(--line); }
.btn.ghost:hover { border-color: var(--brand-500); color: var(--brand-600); }

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field label { font-size: 12px; font-weight: 700; color: var(--ink-soft); }
.field input { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; font-size: 13.5px; background: var(--chalk-50); color: var(--ink); }
.field input:focus { border-color: var(--brand-500); background: var(--paper); }
.field-error { font-size: 12px; color: var(--red-600); margin-top: -8px; margin-bottom: 14px; }

.chip { display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 700; }
.chip.ok { background: var(--green-100); color: var(--green-600); }
.chip.warn { background: var(--amber-100); color: var(--amber-600); }
.chip.info { background: var(--brand-100); color: var(--brand-700); }
.chip.bad { background: var(--red-100); color: var(--red-600); }

/* ---------- Login ---------- */
.login-screen { min-height: 100vh; background: radial-gradient(120% 140% at 15% 0%, #33090c, var(--pitch-950) 62%); display: flex; align-items: center; justify-content: center; padding: 24px; }
.login-card { width: 100%; max-width: 380px; }
.login-card .brand-row { justify-content: center; margin-bottom: 26px; }
.login-card .brand-name { color: #fff; font-size: 16px; }
.login-panel { background: var(--paper); border-radius: 14px; box-shadow: 0 20px 60px -20px rgba(0,0,0,.5); padding: 28px; }
.login-panel h1 { font-size: 18px; margin-bottom: 4px; }
.login-panel p.lead { font-size: 13px; margin-bottom: 20px; }

/* ---------- Dashboard shell ---------- */
.shell-header { background: var(--pitch-950); padding: 14px 26px; display: flex; align-items: center; justify-content: space-between; }
.shell-header .brand-name { color: #fff; }
.shell-nav { background: var(--pitch-950); padding: 0 26px; display: flex; align-items: center; justify-content: space-between; gap: 12px; border-top: 1px solid rgba(255,255,255,.08); flex-wrap: wrap; }
.shell-nav-tabs { display: flex; gap: 4px; flex-wrap: wrap; }
.shell-nav a { padding: 12px 14px; font-size: 13px; font-weight: 700; color: #fff; border-bottom: 2px solid transparent; white-space: nowrap; }
.shell-nav a:hover { color: var(--gold-500); }
.shell-nav a.active { color: var(--gold-500); border-color: var(--gold-500); }
.shell-nav-right { display: flex; align-items: center; gap: 10px; padding: 8px 0; }
.team-switcher { background: rgba(255,255,255,.08); color: #fff; border: 1px solid rgba(255,255,255,.16); border-radius: 6px; padding: 6px 10px; font-size: 12.5px; font-weight: 600; }
.team-switcher option { color: #17120f; }
.shell-nav-right .btn-new-team { font-size: 12.5px; font-weight: 700; color: var(--gold-500); }
.shell-nav-right .btn-new-team:hover { color: #f0b93e; }
.shell-main { max-width: 920px; margin: 36px auto; padding: 0 24px 60px; }
.role-pill { display: inline-flex; align-items: center; gap: 6px; background: var(--brand-100); color: var(--brand-700); font-size: 11.5px; font-weight: 800; text-transform: uppercase; letter-spacing: .04em; padding: 4px 10px; border-radius: 999px; }
form.logout-form { display: inline; }
form.logout-form button { all: unset; cursor: pointer; color: #ecd6d2; font-size: 13px; font-weight: 700; }
form.logout-form button:hover { color: #fff; }

.screen-head { margin-bottom: 22px; display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.screen-head h2 { font-size: 20px; }
.screen-head p { margin-top: 4px; max-width: 60ch; font-size: 13.5px; }

.grid-2 { display: grid; grid-template-columns: 1.3fr 1fr; gap: 18px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
@media (max-width: 760px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 560px) { .form-row { grid-template-columns: 1fr; } }
.field select, .field textarea { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; font-size: 13.5px; background: var(--chalk-50); color: var(--ink); font-family: inherit; }
.field .hint { font-size: 11.5px; color: var(--ink-faint); font-weight: 500; }
.btn.sm { padding: 6px 11px; font-size: 12px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); }
table.data { width: 100%; border-collapse: collapse; font-size: 13.3px; min-width: 480px; }
table.data th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--ink-faint); background: var(--line-soft); padding: 10px 14px; font-weight: 700; }
table.data td { padding: 10px 14px; border-top: 1px solid var(--line); color: var(--ink); }
table.data tr:hover td { background: var(--chalk-50); }
table.data td.num, table.data th.num { text-align: center; }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--brand-100); color: var(--brand-700); display: inline-flex; align-items: center; justify-content: center; font-weight: 800; font-size: 11px; flex: none; }
.player-cell { display: flex; align-items: center; gap: 9px; }

.upload-tile { border: 1.5px dashed var(--line); border-radius: 10px; background: var(--chalk-50); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; padding: 18px 10px; cursor: pointer; text-align: center; color: var(--ink-faint); }
.upload-tile:hover { border-color: var(--brand-500); color: var(--brand-600); }
.upload-tile.done { border-style: solid; border-color: var(--green-600); background: var(--green-100); color: var(--green-600); }
.upload-tile svg { width: 22px; height: 22px; }
.upload-tile .label { font-size: 11.5px; font-weight: 700; }
.upload-tile input[type="file"] { display: none; }

.photo-slot { width: 84px; height: 84px; border-radius: 50%; border: 1.5px dashed var(--line); display: flex; align-items: center; justify-content: center; cursor: pointer; color: var(--ink-faint); background: var(--chalk-50); flex: none; overflow: hidden; position: relative; }
.photo-slot.done { border-style: solid; border-color: var(--brand-600); background: var(--brand-100); color: var(--brand-700); font-weight: 800; font-size: 22px; }
.photo-slot img { width: 100%; height: 100%; object-fit: cover; }
.photo-slot svg { width: 24px; height: 24px; }
.photo-slot input[type="file"] { display: none; }

.team-photo-tile { width: 180px; aspect-ratio: 16/10; border: 1.5px dashed var(--line); border-radius: 10px; background: var(--chalk-50); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; color: var(--ink-faint); cursor: pointer; flex: none; text-align: center; overflow: hidden; position: relative; }
.team-photo-tile:hover { border-color: var(--brand-500); color: var(--brand-600); }
.team-photo-tile.done { border-style: solid; border-color: var(--brand-600); }
.team-photo-tile img { width: 100%; height: 100%; object-fit: cover; position: absolute; inset: 0; }
.team-photo-tile svg { width: 24px; height: 24px; }
.team-photo-tile .label { font-size: 11px; font-weight: 700; position: relative; }
.team-photo-tile input[type="file"] { display: none; }
.torneo-pill { display: inline-flex; align-items: center; gap: 5px; font-size: 10.5px; font-weight: 800; text-transform: uppercase; letter-spacing: .03em; padding: 4px 9px; border-radius: 999px; color: #fff; }

.subnav { display: flex; gap: 6px; margin-bottom: 16px; border-bottom: 1px solid var(--line); }
.subnav a { background: none; border: none; padding: 9px 4px; margin-right: 14px; font-size: 13px; font-weight: 700; color: var(--ink-faint); cursor: pointer; border-bottom: 2px solid transparent; }
.subnav a.active { color: var(--brand-600); border-color: var(--brand-600); }

.alert { padding: 12px 16px; border-radius: 8px; font-size: 13.5px; margin-bottom: 16px; }
.alert.success { background: var(--green-100); color: var(--green-600); }
.alert.error { background: var(--red-100); color: var(--red-600); }
