/* ============================================================
   Cartolão Web — Design System
   Mobile-first · PWA-ready · Thumb-friendly
   ============================================================ */

:root {
  /* Cores */
  --c-primary:     #15803d;
  --c-primary-d:   #14532d;
  --c-primary-l:   #22c55e;
  --c-primary-bg:  #f0fdf4;
  --c-gold:        #d97706;
  --c-gold-bg:     #fffbeb;
  --c-gold-light:  #fef3c7;
  --c-red:         #dc2626;
  --c-red-bg:      #fef2f2;
  --c-orange:      #ea580c;
  --c-orange-bg:   #fff7ed;
  --c-blue:        #1d4ed8;
  --c-blue-bg:     #eff6ff;

  /* Neutros */
  --c-white:  #ffffff;
  --c-bg:     #f3f4f6;
  --c-card:   #ffffff;
  --c-border: #e5e7eb;
  --c-text:   #111827;
  --c-muted:  #6b7280;
  --c-faint:  #9ca3af;

  /* Tipografia */
  --f-body:   system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --f-base:   16px;
  --f-sm:     13px;
  --f-xs:     11px;

  /* Sombras */
  --sh-sm: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.05);
  --sh-md: 0 4px 12px rgba(0,0,0,.08), 0 2px 4px rgba(0,0,0,.04);
  --sh-up: 0 -4px 16px rgba(0,0,0,.06);

  /* Formas */
  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 16px;
  --r-xl: 20px;

  /* Nav inferior */
  --nav-h: 62px;
}

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--f-body);
  font-size: var(--f-base);
  line-height: 1.5;
  color: var(--c-text);
  background: var(--c-bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overscroll-behavior-y: none;
}
a { color: inherit; }
button, input, select, textarea { font: inherit; }
img { display: block; max-width: 100%; }

/* ── Top header ── */
.site-header {
  position: sticky;
  top: 0;
  z-index: 200;
  background: var(--c-primary);
  color: var(--c-white);
  padding: 0 16px;
  height: 54px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: 0 2px 8px rgba(0,0,0,.25);
}
.site-header .brand {
  font-weight: 800;
  font-size: 18px;
  letter-spacing: -.3px;
  text-decoration: none;
  color: var(--c-white);
  display: flex;
  align-items: center;
  gap: 6px;
}
.site-header .player-info {
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 8px;
  opacity: .9;
}
.site-header .player-info a {
  color: rgba(255,255,255,.75);
  text-decoration: underline;
  font-size: 12px;
}

/* ── Main ── */
main {
  max-width: 600px;
  margin: 0 auto;
  padding: 14px 12px calc(var(--nav-h) + 16px + env(safe-area-inset-bottom));
}

/* ── Bottom Navigation ── */
.bottom-nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  z-index: 200;
  background: var(--c-white);
  border-top: 1px solid var(--c-border);
  display: flex;
  padding-bottom: env(safe-area-inset-bottom);
  box-shadow: var(--sh-up);
}
.bottom-nav a {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 8px 4px 10px;
  color: var(--c-faint);
  text-decoration: none;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .3px;
  text-transform: uppercase;
  -webkit-tap-highlight-color: transparent;
  transition: color .15s;
}
.bottom-nav a .nav-icon { font-size: 22px; line-height: 1; }
.bottom-nav a.active { color: var(--c-primary); }
.bottom-nav a:active { opacity: .6; }

/* ── Cards ── */
.card {
  background: var(--c-card);
  border-radius: var(--r-md);
  box-shadow: var(--sh-sm);
  overflow: hidden;
  margin-bottom: 10px;
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 14px;
  background: #fafafa;
  border-bottom: 1px solid var(--c-border);
  font-size: var(--f-sm);
  color: var(--c-muted);
  gap: 8px;
}
.card-body { padding: 16px; }

/* ── Match Card ── */
.match-card.open  { border-left: 3px solid var(--c-primary-l); }
.match-card.live  { border-left: 3px solid var(--c-orange); }
.match-card.done  { opacity: .92; }

/* Teams block */
.match-teams {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}
.team-block {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  min-width: 0;
}
.team-flag    { font-size: 30px; line-height: 1; }
.team-name    { font-size: 13px; font-weight: 700; text-align: center; color: var(--c-text); line-height: 1.2; }

/* Closed match — compact row */
.match-compact {
  display: flex;
  align-items: center;
  gap: 10px;
}
.mc-teams {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 600;
  flex-wrap: wrap;
}
.mc-score {
  font-size: 20px;
  font-weight: 800;
  padding: 0 4px;
  color: var(--c-text);
}
.mc-score-dash { font-size: 18px; color: var(--c-muted); font-weight: 300; }

/* My bet row */
.my-bet {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding-top: 10px;
  margin-top: 10px;
  border-top: 1px dashed var(--c-border);
  font-size: var(--f-sm);
  color: var(--c-muted);
}
.no-bet { font-size: var(--f-sm); color: var(--c-faint); font-style: italic; }

/* ── Score Steppers ── */
.stepper-group {
  display: flex;
  align-items: center;
  gap: 10px;
  justify-content: center;
}
.stepper {
  display: flex;
  align-items: stretch;
  border-radius: var(--r-sm);
  border: 2px solid var(--c-border);
  overflow: hidden;
  background: var(--c-white);
  transition: border-color .15s;
}
.stepper:focus-within { border-color: var(--c-primary-l); }
.step-btn {
  width: 46px;
  height: 54px;
  border: none;
  background: #f9fafb;
  font-size: 26px;
  font-weight: 300;
  color: var(--c-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  transition: background .1s, color .1s;
  touch-action: manipulation;
}
.step-btn:active { background: #e5e7eb; color: var(--c-text); }
.step-num {
  width: 54px;
  height: 54px;
  border: none;
  border-left: 2px solid var(--c-border);
  border-right: 2px solid var(--c-border);
  background: var(--c-white);
  font-size: 28px;
  font-weight: 800;
  text-align: center;
  color: var(--c-text);
  padding: 0;
  appearance: textfield;
  -moz-appearance: textfield;
  transition: background .1s;
}
.step-num:focus { outline: none; background: var(--c-primary-bg); }
.step-num::-webkit-inner-spin-button,
.step-num::-webkit-outer-spin-button { -webkit-appearance: none; }
.step-num.bump { animation: num-bump .18s ease-out; }
@keyframes num-bump {
  0%   { transform: scale(1); }
  40%  { transform: scale(1.2); color: var(--c-primary); }
  100% { transform: scale(1); }
}
.vs-sep {
  font-size: 22px;
  font-weight: 800;
  color: #d1d5db;
  flex-shrink: 0;
}

/* ── Save bar ── */
.save-bar {
  position: sticky;
  bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 8px);
  z-index: 50;
  background: var(--c-white);
  border-radius: var(--r-md);
  box-shadow: var(--sh-md);
  padding: 10px 12px;
  margin-top: 10px;
}
.btn-save {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 16px;
  background: var(--c-primary);
  color: var(--c-white);
  border: none;
  border-radius: var(--r-sm);
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  letter-spacing: .2px;
  -webkit-tap-highlight-color: transparent;
  transition: background .15s, transform .1s, opacity .15s;
  touch-action: manipulation;
}
.btn-save:hover  { background: var(--c-primary-d); }
.btn-save:active { transform: scale(.97); }
.btn-save:disabled { opacity: .5; cursor: not-allowed; transform: none; }

/* Generic button */
.btn {
  display: block;
  width: 100%;
  padding: 15px;
  background: var(--c-primary);
  color: var(--c-white);
  border: none;
  border-radius: var(--r-sm);
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background .15s;
  touch-action: manipulation;
}
.btn:hover { background: var(--c-primary-d); }
.btn-danger { background: var(--c-red); }
.btn-danger:hover { background: #b91c1c; }
.btn-ghost {
  background: transparent;
  color: var(--c-primary);
  border: 2px solid var(--c-border);
}
.btn-ghost:hover { background: var(--c-primary-bg); border-color: var(--c-primary-l); }

/* ── Badges ── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: var(--f-xs);
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 20px;
  text-transform: uppercase;
  letter-spacing: .4px;
  white-space: nowrap;
  flex-shrink: 0;
}
.badge-open    { background: var(--c-primary-bg); color: var(--c-primary); }
.badge-live    { background: var(--c-orange-bg);  color: var(--c-orange); }
.badge-done    { background: #f3f4f6;             color: var(--c-muted); }
.badge-pending { background: var(--c-blue-bg);    color: var(--c-blue); }
.badge-live::before { content: ''; display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--c-orange); animation: pulse 1.5s infinite; }
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: .3; }
}

.pts-badge   { font-size: 12px; padding: 4px 10px; }
.pts-5       { background: var(--c-gold-light); color: var(--c-gold); }
.pts-3       { background: var(--c-primary-bg); color: var(--c-primary); }
.pts-0       { background: #f3f4f6;             color: var(--c-muted); }
.pts-neg     { background: var(--c-red-bg);     color: var(--c-red); }

/* ── Alerts ── */
.alert {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-radius: var(--r-sm);
  margin-bottom: 10px;
  font-weight: 500;
  font-size: 14px;
}
.alert-success { background: var(--c-primary-bg); color: var(--c-primary); }
.alert-error   { background: var(--c-red-bg);     color: var(--c-red); }
.alert-warn    { background: var(--c-gold-bg);     color: var(--c-gold); }

/* ── Toast ── */
.toast {
  position: fixed;
  bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 16px);
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  opacity: 0;
  z-index: 9999;
  background: #1f2937;
  color: white;
  padding: 12px 20px;
  border-radius: var(--r-lg);
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  box-shadow: var(--sh-md);
  transition: opacity .25s, transform .25s;
  pointer-events: none;
  max-width: calc(100vw - 32px);
  white-space: normal;
  text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.toast-success { background: var(--c-primary-d); }
.toast.toast-error   { background: var(--c-red); }
.toast.toast-warn    { background: var(--c-gold); }

/* ── Section title ── */
.section-title {
  font-size: var(--f-xs);
  font-weight: 700;
  letter-spacing: .8px;
  text-transform: uppercase;
  color: var(--c-faint);
  margin: 4px 0 10px;
}

/* ── Ranking table ── */
.ranking-table { width: 100%; border-collapse: collapse; }
.ranking-table th {
  padding: 8px 14px;
  text-align: left;
  font-size: var(--f-xs);
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--c-muted);
  border-bottom: 2px solid var(--c-border);
  font-weight: 700;
}
.ranking-table th:not(:nth-child(2)) { text-align: right; }
.ranking-table th:nth-child(2) { text-align: left; }
.ranking-table td { padding: 12px 14px; border-bottom: 1px solid var(--c-border); vertical-align: middle; }
.ranking-table tr:last-child td { border-bottom: none; }
.ranking-table tr.me td { background: var(--c-primary-bg); }
.rank { font-size: 18px; text-align: right; width: 40px; }
.player-name { font-weight: 600; font-size: 15px; }
.pts-col { text-align: right; color: var(--c-muted); font-size: 14px; }
.pts-total { text-align: right; font-weight: 800; font-size: 20px; color: var(--c-text); }
.pts-bonus-col { text-align: right; font-size: 14px; }
.hint { font-size: 12px; color: var(--c-faint); text-align: center; margin-top: 8px; line-height: 1.6; }
.you-badge {
  display: inline-block;
  font-size: 9px;
  background: var(--c-primary);
  color: white;
  border-radius: 10px;
  padding: 1px 6px;
  margin-left: 5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .3px;
  vertical-align: middle;
}

/* ── Palpites / Results table ── */
.bet-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.bet-table th {
  padding: 7px 10px;
  font-size: var(--f-xs);
  color: var(--c-muted);
  text-transform: uppercase;
  letter-spacing: .4px;
  border-bottom: 1px solid var(--c-border);
  font-weight: 700;
}
.bet-table th.left { text-align: left; }
.bet-table td {
  text-align: center;
  padding: 10px;
  border-bottom: 1px solid var(--c-border);
}
.bet-table tr:last-child td { border-bottom: none; }
.bet-table tr.me td { background: var(--c-primary-bg); }
.bet-table td.player-col { text-align: left; font-weight: 600; }
.bet-table td.score-col { font-weight: 800; font-size: 16px; }
.bet-table td.sep-col   { color: var(--c-faint); }

/* ── Results ── */
.final-score {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin-bottom: 16px;
}
.score-team-name { font-size: 14px; font-weight: 700; color: var(--c-muted); }
.score-board {
  font-size: 36px;
  font-weight: 900;
  color: var(--c-text);
  line-height: 1;
  letter-spacing: -1px;
}

/* ── Empty state ── */
.empty {
  text-align: center;
  padding: 60px 20px;
  color: var(--c-muted);
}
.empty .icon { font-size: 56px; display: block; margin-bottom: 14px; }
.empty p { font-size: 15px; }

/* ── Footer ── */
.site-footer {
  text-align: center;
  padding: 16px;
  font-size: 12px;
  color: #d1d5db;
}

/* ── Login ── */
.login-body { background: linear-gradient(160deg, #14532d 0%, #15803d 60%, #16a34a 100%); min-height: 100vh; }
.login-body main { padding: 32px 16px 24px; display: flex; flex-direction: column; align-items: center; justify-content: flex-start; min-height: 100vh; }
.login-logo { font-size: 64px; margin-bottom: 8px; filter: drop-shadow(0 4px 8px rgba(0,0,0,.3)); }
.login-app-name { font-size: 30px; font-weight: 900; color: white; margin-bottom: 4px; }
.login-tagline { font-size: 14px; color: rgba(255,255,255,.75); margin-bottom: 32px; }
.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--c-white);
  border-radius: var(--r-xl);
  padding: 28px 24px;
  box-shadow: 0 8px 32px rgba(0,0,0,.25);
}
.login-card h2 { font-size: 18px; margin-bottom: 16px; }
.label { font-weight: 600; font-size: 14px; color: var(--c-muted); margin-bottom: 10px; display: block; }
.player-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 20px; }
.player-btn {
  width: 100%;
  padding: 14px 16px;
  background: var(--c-bg);
  border: 2px solid var(--c-border);
  border-radius: var(--r-sm);
  cursor: pointer;
  font-size: 15px;
  font-weight: 600;
  text-align: left;
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--c-text);
  -webkit-tap-highlight-color: transparent;
  transition: border-color .15s, background .15s, transform .1s;
  touch-action: manipulation;
}
.player-btn:hover  { border-color: var(--c-primary-l); background: var(--c-primary-bg); }
.player-btn:active { transform: scale(.98); }
.divider {
  text-align: center;
  color: var(--c-faint);
  font-size: 12px;
  margin: 18px 0;
  display: flex;
  align-items: center;
  gap: 10px;
}
.divider::before, .divider::after { content: ''; flex: 1; height: 1px; background: var(--c-border); }
.new-form { display: flex; flex-direction: column; gap: 10px; }
.text-input {
  width: 100%;
  padding: 14px 16px;
  border: 2px solid var(--c-border);
  border-radius: var(--r-sm);
  font-size: 16px;
  background: var(--c-bg);
  color: var(--c-text);
  transition: border-color .15s, background .15s;
  -webkit-appearance: none;
}
.text-input:focus { border-color: var(--c-primary-l); background: var(--c-white); outline: none; }
.login-card .btn { margin-top: 0; }

/* ── Admin ── */
.admin-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 16px; }
.stat-card {
  background: var(--c-white);
  border-radius: var(--r-md);
  padding: 16px;
  box-shadow: var(--sh-sm);
  text-align: center;
}
.stat-num { font-size: 32px; font-weight: 900; color: var(--c-primary); line-height: 1; }
.stat-label { font-size: 12px; color: var(--c-muted); margin-top: 4px; font-weight: 600; text-transform: uppercase; letter-spacing: .4px; }
.admin-actions { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
.match-status-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-bottom: 1px solid var(--c-border);
  font-size: 14px;
  gap: 10px;
}
.match-status-row:last-child { border-bottom: none; }
.msr-time { color: var(--c-muted); font-size: 12px; font-weight: 600; min-width: 40px; }
.msr-teams { flex: 1; font-weight: 600; }
.msr-score { font-weight: 800; }

/* ── Login wrap ── */
.login-wrap {
  width: 100%;
  max-width: 400px;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.back-link {
  display: block;
  text-align: center;
  margin-top: 16px;
  font-size: 14px;
  color: rgba(255,255,255,.7);
  text-decoration: none;
}
.back-link:hover { color: white; }

/* ── Player grid (login) ── */
.player-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 16px;
}
.player-grid .player-btn {
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 14px 10px;
  gap: 6px;
}
.player-btn-icon { font-size: 20px; }

/* ── PIN inputs ── */
.pin-inputs {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin-bottom: 20px;
}
.pin-d {
  width: 62px;
  height: 72px;
  border: 2px solid var(--c-border);
  border-radius: var(--r-md);
  font-size: 30px;
  font-weight: 800;
  text-align: center;
  background: var(--c-bg);
  color: var(--c-text);
  transition: border-color .15s, background .15s, box-shadow .15s;
  -webkit-appearance: none;
}
.pin-d:focus {
  border-color: var(--c-primary-l);
  background: var(--c-white);
  outline: none;
  box-shadow: 0 0 0 3px rgba(34, 197, 94, .2);
}

/* ── Bet rows (vertical layout) ── */
.bet-rows { display: flex; flex-direction: column; gap: 8px; }
.bet-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.bet-team-label {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex: 1;
}
.bt-flag { font-size: 28px; flex-shrink: 0; line-height: 1; }
.bt-name {
  font-size: 15px;
  font-weight: 700;
  color: var(--c-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.bet-divider {
  text-align: center;
  font-size: 15px;
  font-weight: 700;
  color: var(--c-faint);
  letter-spacing: 2px;
}

/* ── Admin user management ── */
.admin-user-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--c-border);
  flex-wrap: wrap;
}
.admin-user-row:last-child { border-bottom: none; }
.admin-user-info { min-width: 0; flex: 1; }
.admin-user-fields {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
  flex-wrap: wrap;
}
.text-input-sm {
  padding: 8px 10px;
  font-size: 14px;
  border: 2px solid var(--c-border);
  border-radius: var(--r-sm);
  background: var(--c-bg);
  color: var(--c-text);
  -webkit-appearance: none;
}
.text-input-sm:focus { border-color: var(--c-primary-l); background: var(--c-white); outline: none; }
.pin-admin { width: 80px; text-align: center; letter-spacing: 2px; }
.btn-sm {
  display: inline-flex;
  align-items: center;
  padding: 9px 14px;
  background: var(--c-primary);
  color: var(--c-white);
  border: none;
  border-radius: var(--r-sm);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
  transition: background .15s;
}
.btn-sm:hover { background: var(--c-primary-d); }

/* ── Responsive ── */
@media (max-width: 380px) {
  .team-name { font-size: 12px; }
  .team-flag { font-size: 26px; }
  .step-btn  { width: 40px; }
  .step-num  { width: 48px; font-size: 24px; }
  .bt-name   { font-size: 13px; }
  .pin-d     { width: 54px; height: 64px; font-size: 26px; }
  .pin-inputs { gap: 8px; }
}
@media (min-width: 600px) {
  main { padding-left: 16px; padding-right: 16px; }
}
