:root {
  --pj-red: #e0142c;
  --pj-red-dark: #a10f20;
  --pj-black: #16181b;
  --pj-black-soft: #24272c;
  --pj-green: #1e8e3e;
  --pj-yellow: #f2b705;
  --pj-bg: #f4f5f7;
  --pj-card: #ffffff;
  --pj-text: #1c1e21;
  --pj-muted: #6b7280;
  --pj-radius: 16px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top: env(safe-area-inset-top, 0px);
}

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

body {
  margin: 0;
  background: var(--pj-bg);
  color: var(--pj-text);
  font-family: 'Segoe UI', Roboto, -apple-system, BlinkMacSystemFont, sans-serif;
  padding-bottom: calc(72px + var(--safe-bottom));
  -webkit-user-select: none;
  user-select: none;
}
input, textarea, select, .allow-select { -webkit-user-select: text; user-select: text; }

a { text-decoration: none; color: inherit; }

/* ---------- Top App Bar ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  background: linear-gradient(135deg, var(--pj-black) 0%, var(--pj-black-soft) 100%);
  color: #fff;
  padding: calc(14px + var(--safe-top)) 16px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 3px solid var(--pj-red);
}
.topbar h1 {
  font-size: 18px;
  margin: 0;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
}
.topbar .topbar-action { color: #fff; font-size: 20px; opacity: .9; }
.topbar-logo { width: 26px; height: 26px; border-radius: 50%; vertical-align: middle; object-fit: cover; }

.page { max-width: 720px; margin: 0 auto; padding: 14px 14px 24px; }

/* ---------- Cards ---------- */
.card {
  background: var(--pj-card);
  border-radius: var(--pj-radius);
  padding: 16px;
  margin-bottom: 14px;
  box-shadow: 0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.08);
}
.card h2, .card h3 { margin-top: 0; }

.section-title {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--pj-muted);
  font-weight: 700;
  margin: 20px 4px 10px;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: none;
  border-radius: 12px;
  padding: 12px 18px;
  font-weight: 700;
  font-size: 15px;
  cursor: pointer;
  min-height: 46px;
  transition: transform .08s ease;
}
.btn:active { transform: scale(.97); }
.btn-block { width: 100%; }
.btn-red { background: var(--pj-red); color: #fff; }
.btn-black { background: var(--pj-black); color: #fff; }
.btn-outline { background: transparent; border: 2px solid var(--pj-black); color: var(--pj-black); }
.btn-green { background: var(--pj-green); color: #fff; }
.btn-yellow { background: var(--pj-yellow); color: #16181b; }
.btn-ghost { background: #eef0f2; color: var(--pj-text); }
.btn-sm { padding: 8px 12px; font-size: 13px; min-height: 36px; border-radius: 10px; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- Forms ---------- */
label { font-size: 13px; font-weight: 600; color: var(--pj-muted); display: block; margin: 10px 0 4px; }
input[type=text], input[type=email], input[type=password], input[type=number],
input[type=date], input[type=time], input[type=url], textarea, select {
  width: 100%;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1.5px solid #dfe2e6;
  font-size: 15px;
  background: #fff;
}
textarea { min-height: 80px; resize: vertical; }

/* ---------- Badges / status ---------- */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}
.badge-green { background: #e3f6e9; color: var(--pj-green); }
.badge-red { background: #fde4e7; color: var(--pj-red-dark); }
.badge-yellow { background: #fff3d6; color: #8a6300; }
.badge-gray { background: #eceef1; color: var(--pj-muted); }

.team-badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 700;
}

/* ---------- Player row/list ---------- */
.player-row {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 4px; border-bottom: 1px solid #f0f1f3;
}
.player-row:last-child { border-bottom: none; }
.avatar {
  width: 40px; height: 40px; border-radius: 50%;
  background: var(--pj-black); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 15px; flex-shrink: 0;
  background-size: cover; background-position: center;
}
.avatar.team-vermelho { background-color: var(--pj-red); border: 3px solid var(--pj-red-dark); }
.avatar.team-preto { background-color: var(--pj-black); border: 3px solid #000; }
.player-meta { flex: 1; min-width: 0; }
.player-name { font-weight: 700; font-size: 14.5px; }
.player-sub { font-size: 12px; color: var(--pj-muted); }

/* ---------- Confirmation buttons ---------- */
.confirm-group { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; }
.confirm-btn {
  padding: 12px 4px; border-radius: 12px; border: 2px solid #e3e5e8;
  background: #fff; text-align: center; font-weight: 700; font-size: 13px; cursor: pointer;
}
.confirm-btn.active-vou { background: #e3f6e9; border-color: var(--pj-green); color: var(--pj-green); }
.confirm-btn.active-nao { background: #fde4e7; border-color: var(--pj-red); color: var(--pj-red-dark); }
.confirm-btn.active-indeciso { background: #fff3d6; border-color: var(--pj-yellow); color: #8a6300; }

/* ---------- Toggle switch (vai jogar / não vai) ---------- */
.switch { position: relative; display: inline-block; width: 52px; height: 30px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .slider {
  position: absolute; cursor: pointer; inset: 0;
  background-color: #dfe2e6; transition: .2s; border-radius: 999px;
}
.switch .slider::before {
  position: absolute; content: ""; height: 24px; width: 24px; left: 3px; bottom: 3px;
  background-color: #fff; transition: .2s; border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0,0,0,.3);
}
.switch input:checked + .slider { background-color: var(--pj-green); }
.switch input:checked + .slider::before { transform: translateX(22px); }
.switch-label { font-size: 11px; font-weight: 700; color: var(--pj-muted); margin-top: 3px; text-align: center; }
.jersey-input {
  width: 52px !important; text-align: center; font-weight: 700; padding: 8px 4px !important;
  margin-right: 8px; flex-shrink: 0;
}

/* ---------- Progress bar ---------- */
.progress-track {
  height: 14px; background: #eceef1; border-radius: 999px; overflow: hidden;
}
.progress-fill {
  height: 100%; background: linear-gradient(90deg, var(--pj-green), #46c46a);
  border-radius: 999px; transition: width .4s ease;
}

/* ---------- Sponsor block ---------- */
.sponsor-block {
  display: block; background: linear-gradient(135deg, var(--pj-black), var(--pj-black-soft));
  color: #fff; border-radius: var(--pj-radius); padding: 14px 16px; margin-bottom: 14px;
  border: 2px solid var(--pj-yellow);
}
.sponsor-label { font-size: 11px; text-transform: uppercase; letter-spacing: .07em; color: var(--pj-yellow); font-weight: 700; }
.sponsor-content { display: flex; align-items: center; gap: 12px; margin-top: 6px; }
.sponsor-content img { width: 48px; height: 48px; object-fit: contain; border-radius: 8px; background: #fff; }
.sponsor-logo-placeholder {
  width: 48px; height: 48px; border-radius: 8px; background: var(--pj-yellow); color: #16181b;
  display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 20px;
}
.sponsor-name { font-weight: 800; font-size: 15px; }
.sponsor-desc { font-size: 12.5px; color: #d6d8db; margin-top: 2px; }

/* ---------- Field (escalação) ---------- */
.field-wrap {
  position: relative;
  background: repeating-linear-gradient(0deg, #2f9e44, #2f9e44 40px, #34ad4b 40px, #34ad4b 80px);
  border-radius: var(--pj-radius);
  aspect-ratio: 3 / 4;
  overflow: hidden;
  border: 4px solid #fff;
  box-shadow: 0 2px 8px rgba(0,0,0,.15);
}
.field-wrap::before {
  content: ''; position: absolute; inset: 8px; border: 2px solid rgba(255,255,255,.65); border-radius: 8px;
}
.field-wrap::after {
  content: ''; position: absolute; top: 50%; left: 8px; right: 8px; height: 2px; background: rgba(255,255,255,.65);
}
.field-slot {
  position: absolute; width: 56px; height: 66px; margin-left: -28px; margin-top: -33px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  touch-action: none; cursor: grab;
}
.field-slot .avatar { width: 42px; height: 42px; font-size: 13px; box-shadow: 0 2px 5px rgba(0,0,0,.3); }
.field-slot .field-name {
  color: #fff; font-size: 10.5px; font-weight: 700; text-shadow: 0 1px 3px rgba(0,0,0,.8);
  margin-top: 2px; max-width: 60px; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.field-slot.dragging { opacity: .55; z-index: 50; }
.sub-btn {
  position: absolute; top: -6px; right: -6px; width: 20px; height: 20px; border-radius: 50%;
  background: #fff; border: 1px solid #dfe2e6; font-size: 11px; line-height: 1;
  display: flex; align-items: center; justify-content: center; padding: 0; cursor: pointer;
}
.reserves-zone {
  margin-top: 14px; border: 2px dashed #cfd3d8; border-radius: var(--pj-radius);
  padding: 10px; min-height: 90px;
}
.reserves-zone.drop-hover, .field-wrap.drop-hover { outline: 3px solid var(--pj-yellow); }
.reserves-list { display: flex; flex-wrap: wrap; gap: 10px; }
.reserve-chip { display: flex; flex-direction: column; align-items: center; width: 58px; touch-action: none; cursor: grab; }
.reserve-chip .field-name { font-size: 10.5px; font-weight: 700; margin-top: 2px; max-width: 58px; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- Bottom nav ---------- */
.bottom-nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  background: #fff; border-top: 1px solid #e5e7eb;
  display: flex; padding-bottom: var(--safe-bottom);
  box-shadow: 0 -2px 8px rgba(0,0,0,.05);
}
.bottom-nav a {
  flex: 1; text-align: center; padding: 9px 2px 8px; font-size: 10.5px; color: var(--pj-muted); font-weight: 600;
}
.bottom-nav a.active { color: var(--pj-red); }
.bottom-nav .nav-icon { display: block; font-size: 20px; margin-bottom: 2px; }

/* ---------- Ranking ---------- */
.rank-row { display: flex; align-items: center; gap: 10px; padding: 10px 4px; border-bottom: 1px solid #f0f1f3; }
.rank-pos { width: 26px; text-align: center; font-weight: 800; color: var(--pj-muted); }
.rank-pos.top1 { color: var(--pj-yellow); }
.rank-pos.top2 { color: #9aa0a6; }
.rank-pos.top3 { color: #cd7f32; }
.rank-value { font-weight: 800; color: var(--pj-red-dark); margin-left: auto; }

/* ---------- Partida: timer e disputa de pênaltis ---------- */
#game-timer.time-up { color: var(--pj-red); animation: pulse 1s infinite; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .4; } }
.penalty-panel { background: #f7f8fa; border-radius: 12px; padding: 12px; margin: 10px 0; }
.penalty-turn { text-align: center; font-weight: 700; margin-bottom: 10px; }
.penalty-score { display: flex; justify-content: space-around; font-size: 22px; font-weight: 800; margin-bottom: 10px; }
.penalty-round-log { font-size: 12px; color: var(--pj-muted); text-align: center; margin-bottom: 10px; }

/* ---------- Misc ---------- */
.muted { color: var(--pj-muted); font-size: 13px; }
.empty-state { text-align: center; padding: 30px 10px; color: var(--pj-muted); }
.flash { padding: 12px 14px; border-radius: 12px; margin-bottom: 14px; font-weight: 600; font-size: 14px; }
.flash-success { background: #e3f6e9; color: var(--pj-green); }
.flash-error { background: #fde4e7; color: var(--pj-red-dark); }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.tag-goleiro { background: #e7f0ff; color: #1c5cc7; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 700; }
.tag-linha { background: #f1eefc; color: #6b3fcf; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 700; }

.login-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(160deg, var(--pj-black) 0%, var(--pj-red-dark) 140%);
  padding: 20px;
}
.login-card { background: #fff; border-radius: 20px; padding: 28px 22px; width: 100%; max-width: 380px; }
.login-logo { text-align: center; font-size: 40px; margin-bottom: 6px; }
.login-logo-img { display: block; width: 110px; height: 110px; border-radius: 50%; object-fit: cover; margin: 0 auto 10px; box-shadow: 0 2px 10px rgba(0,0,0,.15); }
.login-title { text-align: center; font-weight: 800; font-size: 20px; margin-bottom: 4px; }
.login-sub { text-align: center; color: var(--pj-muted); font-size: 13px; margin-bottom: 18px; }
