/* UltimateBall — tema escuro azul-marinho + dourado */
* { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --bg: #070b16;
  --panel: #0e1526;
  --panel2: #141d33;
  --border: #24304e;
  --gold: #e8b64c;
  --gold2: #f5d78a;
  --cyan: #4cc9f0;
  --text: #e8ecf5;
  --muted: #8b96b0;
  --green: #3dd68c;
  --red: #ef5b6f;
}
html, body { height: 100%; }
body {
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  background: var(--bg) url("/assets/stadium.jpg") center top / cover no-repeat fixed;
  color: var(--text);
  min-height: 100vh;
}
body::before {
  content: ""; position: fixed; inset: 0;
  background: linear-gradient(180deg, rgba(7,11,22,.82), rgba(7,11,22,.94));
  pointer-events: none; z-index: 0;
}
#auth-screen, #app, #modal { position: relative; z-index: 1; }
.hidden { display: none !important; }
button { cursor: pointer; font-family: inherit; }

/* ---------- Auth ---------- */
#auth-screen { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 16px; }
.auth-box {
  width: 100%; max-width: 420px; background: rgba(14,21,38,.92);
  border: 1px solid var(--border); border-radius: 18px; padding: 28px; text-align: center;
  box-shadow: 0 20px 60px rgba(0,0,0,.6);
}
.auth-logo { width: 130px; border-radius: 20px; }
.auth-box h1 { font-size: 30px; letter-spacing: 2px; color: var(--gold2); margin: 8px 0 4px; }
.tagline { color: var(--muted); font-size: 14px; margin-bottom: 18px; }
.auth-tabs { display: flex; gap: 8px; margin-bottom: 16px; }
.auth-tabs button {
  flex: 1; padding: 10px; border-radius: 10px; border: 1px solid var(--border);
  background: transparent; color: var(--muted); font-weight: 600;
}
.auth-tabs button.active { background: var(--panel2); color: var(--gold); border-color: var(--gold); }
#auth-form { text-align: left; }
#auth-form label { display: block; font-size: 12px; color: var(--muted); margin: 12px 0 4px; text-transform: uppercase; letter-spacing: 1px; }
#auth-form input {
  width: 100%; padding: 12px; border-radius: 10px; border: 1px solid var(--border);
  background: #0a101f; color: var(--text); font-size: 15px;
}
#auth-form input:focus { outline: none; border-color: var(--gold); }
.btn-gold {
  width: 100%; margin-top: 18px; padding: 13px; border: none; border-radius: 10px;
  background: linear-gradient(135deg, var(--gold), #c98f2b); color: #1a1204;
  font-size: 16px; font-weight: 800; letter-spacing: 1px;
}
.btn-gold:hover { filter: brightness(1.1); }
.btn-gold:disabled { opacity: .5; cursor: default; }
.error { color: var(--red); font-size: 13px; margin-top: 10px; min-height: 16px; }
.auth-note { color: var(--muted); font-size: 12px; margin-top: 14px; }

/* ---------- Header / nav ---------- */
header {
  display: flex; align-items: center; gap: 12px; padding: 10px 16px;
  background: rgba(10,15,28,.92); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 20;
}
.header-logo { width: 44px; height: 44px; border-radius: 10px; }
.header-club { flex: 1; min-width: 0; }
.club-name { font-weight: 800; font-size: 17px; color: var(--gold2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.club-sub { font-size: 12px; color: var(--muted); }
.header-stats { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 14px; }
.coin::before { content: "🪙 "; }
.elo::before { content: "⚔️ "; }
#btn-logout { background: none; border: 1px solid var(--border); color: var(--muted); border-radius: 8px; padding: 6px 10px; }
nav {
  display: flex; gap: 4px; padding: 8px 10px; overflow-x: auto;
  background: rgba(10,15,28,.85); border-bottom: 1px solid var(--border);
  position: sticky; top: 65px; z-index: 19; scrollbar-width: none;
}
nav button {
  padding: 9px 14px; border-radius: 20px; border: 1px solid transparent;
  background: transparent; color: var(--muted); font-weight: 600; font-size: 14px; white-space: nowrap;
}
nav button.active { background: var(--panel2); color: var(--gold); border-color: var(--gold); }
main { max-width: 980px; margin: 0 auto; padding: 18px 14px 60px; }

.panel { background: rgba(14,21,38,.9); border: 1px solid var(--border); border-radius: 14px; padding: 18px; margin-bottom: 16px; }
.panel h2 { color: var(--gold2); font-size: 19px; margin-bottom: 12px; }
.panel h3 { color: var(--text); font-size: 15px; margin: 12px 0 8px; }
.muted { color: var(--muted); font-size: 13px; }
.row { display: flex; gap: 12px; flex-wrap: wrap; }
.grow { flex: 1; min-width: 220px; }

/* ---------- Cartas ---------- */
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(128px, 1fr)); gap: 12px; }
.pcard {
  position: relative; aspect-ratio: 2/3; border-radius: 12px; overflow: hidden;
  background-size: cover; background-position: center; color: #241a05;
  display: flex; flex-direction: column; padding: 9% 10%;
  box-shadow: 0 6px 18px rgba(0,0,0,.5); cursor: pointer; transition: transform .15s;
  border: 1px solid rgba(255,255,255,.15);
}
.pcard:hover { transform: translateY(-3px) scale(1.02); }
.pcard.bronze { background-image: url("/assets/card-bronze.jpg"); color: #2b1708; }
.pcard.silver { background-image: url("/assets/card-silver.jpg"); color: #1c2430; }
.pcard.gold { background-image: url("/assets/card-gold.jpg"); color: #2b1e05; }
.pcard.icon { background-image: url("/assets/card-icon.jpg"); color: #efe6ff; }
.pcard.custom { background-image: url("/assets/card-icon.jpg"); color: #d9f6ff; }
.pcard .top { display: flex; align-items: baseline; gap: 6px; }
.pcard .ovr { font-size: 1.55em; font-weight: 900; line-height: 1; }
.pcard .pos { font-size: .8em; font-weight: 800; }
.pcard .lvl { font-size: .62em; font-weight: 800; margin-left: auto; background: rgba(0,0,0,.35); color: #ffe9ad; padding: 2px 5px; border-radius: 6px; }
.pcard .avatar {
  margin: 4% auto; width: 52%; aspect-ratio: 1; border-radius: 50%;
  background: rgba(0,0,0,.28); display: flex; align-items: center; justify-content: center;
  font-size: 1.5em; font-weight: 900; color: rgba(255,255,255,.92); text-shadow: 0 2px 4px rgba(0,0,0,.6);
  border: 2px solid rgba(255,255,255,.35);
}
.pcard .pname {
  text-align: center; font-weight: 800; font-size: .78em; text-transform: uppercase;
  letter-spacing: .5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.pcard .stats { display: grid; grid-template-columns: 1fr 1fr; gap: 0 10%; font-size: .62em; font-weight: 700; margin-top: 4%; }
.pcard .stats span b { float: right; }
.pcard .meta { text-align: center; font-size: .58em; font-weight: 700; opacity: .85; margin-top: auto; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pcard.mini { font-size: 11px; }

/* ---------- Escalação / campo ---------- */
.pitch {
  position: relative; width: 100%; max-width: 460px; margin: 0 auto; aspect-ratio: 3/4.2;
  background: linear-gradient(180deg, #10502e 0%, #0c3f24 48%, #10502e 52%, #0c3f24 100%);
  border: 2px solid #1e6b3f; border-radius: 14px; overflow: hidden;
}
.pitch::before {
  content: ""; position: absolute; left: 50%; top: 50%; width: 30%; aspect-ratio: 1;
  border: 2px solid rgba(255,255,255,.25); border-radius: 50%; transform: translate(-50%,-50%);
}
.pitch::after {
  content: ""; position: absolute; left: 0; right: 0; top: 50%; border-top: 2px solid rgba(255,255,255,.25);
}
.slot {
  position: absolute; width: 64px; transform: translate(-50%, -50%);
  text-align: center; cursor: pointer; z-index: 2;
}
.slot .chip {
  width: 52px; height: 52px; margin: 0 auto; border-radius: 50%;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  font-weight: 900; font-size: 15px; border: 2px solid rgba(255,255,255,.5);
  background: rgba(0,0,0,.45); color: #fff; transition: transform .12s;
}
.slot:hover .chip { transform: scale(1.1); }
.slot .chip.bronze { background: linear-gradient(135deg,#8a5a2b,#5c3a17); border-color: #c8925a; }
.slot .chip.silver { background: linear-gradient(135deg,#9aa6b5,#5d6673); border-color: #d7dee8; }
.slot .chip.gold { background: linear-gradient(135deg,#d4a437,#95701c); border-color: #ffe08a; }
.slot .chip.icon, .slot .chip.custom { background: linear-gradient(135deg,#4b2d7f,#1c1140); border-color: #b18cff; }
.slot .chip.empty { background: rgba(255,255,255,.08); border-style: dashed; color: var(--muted); font-size: 11px; }
.slot .chip small { font-size: 9px; font-weight: 700; opacity: .8; }
.slot .sname {
  margin-top: 3px; font-size: 10px; font-weight: 700; color: #fff;
  background: rgba(0,0,0,.55); border-radius: 6px; padding: 1px 4px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.bench { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; margin-top: 12px; }
.bench .slot { position: static; transform: none; width: 60px; }
.chem-bar { height: 10px; border-radius: 6px; background: #0a101f; overflow: hidden; margin: 6px 0 2px; }
.chem-fill { height: 100%; background: linear-gradient(90deg, var(--red), var(--gold), var(--green)); transition: width .3s; }
.lineup-controls { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
select, .lineup-controls button {
  padding: 9px 12px; border-radius: 9px; border: 1px solid var(--border);
  background: var(--panel2); color: var(--text); font-size: 14px; font-weight: 600;
}
.stat-badges { display: flex; gap: 14px; flex-wrap: wrap; margin: 10px 0; }
.stat-badges .b { background: var(--panel2); border: 1px solid var(--border); border-radius: 10px; padding: 8px 14px; text-align: center; }
.stat-badges .b .v { font-size: 20px; font-weight: 900; color: var(--gold2); }
.stat-badges .b .l { font-size: 11px; color: var(--muted); text-transform: uppercase; }

/* ---------- Loja ---------- */
.packs { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 14px; }
.pack {
  background: var(--panel2); border: 1px solid var(--border); border-radius: 14px;
  padding: 14px; text-align: center; transition: transform .15s;
}
.pack:hover { transform: translateY(-3px); border-color: var(--gold); }
.pack img { width: 70%; border-radius: 10px; }
.pack h3 { margin: 8px 0 2px; }
.pack .price { color: var(--gold); font-weight: 800; margin-bottom: 8px; }
.pack button { width: 100%; }

/* ---------- Modal ---------- */
#modal {
  position: fixed; inset: 0; background: rgba(3,6,12,.85); z-index: 100;
  display: flex; align-items: center; justify-content: center; padding: 14px;
}
#modal-box {
  width: 100%; max-width: 640px; max-height: 92vh; overflow-y: auto;
  background: var(--panel); border: 1px solid var(--border); border-radius: 16px; padding: 20px;
}
#modal-box h2 { color: var(--gold2); margin-bottom: 12px; }
.modal-close { float: right; background: none; border: none; color: var(--muted); font-size: 22px; }

/* ---------- Partida ---------- */
.scoreboard { display: flex; align-items: center; justify-content: center; gap: 14px; margin: 10px 0 16px; text-align: center; }
.scoreboard .team { flex: 1; font-weight: 800; font-size: 15px; }
.scoreboard .score { font-size: 38px; font-weight: 900; color: var(--gold2); min-width: 110px; }
.match-min { text-align: center; color: var(--cyan); font-weight: 800; margin-bottom: 8px; }
.events { display: flex; flex-direction: column; gap: 6px; }
.evt { padding: 8px 12px; border-radius: 9px; background: var(--panel2); font-size: 14px; border-left: 3px solid var(--border); animation: pop .3s; }
.evt.goal { border-left-color: var(--gold); background: #1d2440; font-weight: 700; }
.evt.card { border-left-color: #ffd24c; }
.evt.end, .evt.start { border-left-color: var(--cyan); color: var(--cyan); }
@keyframes pop { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; } }
.result-banner { text-align: center; font-size: 20px; font-weight: 900; padding: 12px; border-radius: 10px; margin-top: 12px; }
.result-banner.win { background: rgba(61,214,140,.15); color: var(--green); }
.result-banner.draw { background: rgba(139,150,176,.15); color: var(--muted); }
.result-banner.loss { background: rgba(239,91,111,.15); color: var(--red); }

/* ---------- Tabelas ---------- */
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 9px 8px; text-align: left; border-bottom: 1px solid var(--border); }
th { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 1px; }
tr.me { background: rgba(232,182,76,.08); }
td .small-btn {
  padding: 6px 10px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--panel2); color: var(--text); font-size: 12px; font-weight: 700;
}
td .small-btn:hover { border-color: var(--gold); color: var(--gold); }

/* ---------- Criar jogador ---------- */
.sliders label { display: flex; align-items: center; gap: 10px; margin: 10px 0; font-size: 14px; }
.sliders label span.n { width: 92px; color: var(--muted); }
.sliders input[type=range] { flex: 1; accent-color: var(--gold); }
.sliders label b { width: 30px; text-align: right; }
.create-form input[type=text] { padding: 10px; border-radius: 9px; border: 1px solid var(--border); background: #0a101f; color: var(--text); width: 100%; }
.budget { font-weight: 800; margin: 8px 0; }
.budget.over { color: var(--red); }

/* Reveal de pacotes */
.reveal-grid { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
.reveal-grid .pcard { width: 118px; animation: flip .5s ease both; }
@keyframes flip { from { transform: rotateY(90deg) scale(.8); opacity: 0; } to { transform: none; opacity: 1; } }

@media (max-width: 560px) {
  .card-grid { grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); }
  .scoreboard .score { font-size: 28px; min-width: 80px; }
  nav { top: 61px; }
}
