:root {
  --navy: #0c1f3f;
  --navy-deep: #081528;
  --gold: #f5c518;
  --gold-hover: #e6b608;
  --green: #1faa59;
  --green-hover: #18924c;
  --bg: #f3f5f8;
  --card: #ffffff;
  --text: #1a2332;
  --muted: #6b7280;
  --border: #e2e8f0;
  --radius: 12px;
  --shadow: 0 4px 24px rgba(12, 31, 63, 0.08);
  --font: "DM Sans", system-ui, sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  line-height: 1.5;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

main {
  flex: 1; /* ocupa o espaço restante */
}

.container {
  width: min(1240px, 92vw);
  margin-inline: auto;
}

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

/* Header */
.site-header {
  background: var(--card);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 50;
}

.header-inner {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  padding: 0.85rem 0;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.brand-icon {
  font-size: 1.5rem;
}

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
}

.brand-text strong {
  font-size: 1rem;
}

.brand-text small {
  font-size: 0.62rem;
  letter-spacing: 0.08em;
  color: var(--muted);
  font-weight: 600;
}

.main-nav {
  display: flex;
  gap: 0.35rem;
  flex: 1;
  justify-content: center;
}

.main-nav a {
  padding: 0.45rem 1rem;
  border-radius: 999px;
  font-weight: 500;
  font-size: 0.95rem;
  color: var(--muted);
}

.main-nav a.active {
  background: #eef1f6;
  color: var(--text);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-left: auto;
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.85rem;
  color: var(--muted);
}

.user-chip img {
  border-radius: 50%;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  box-sizing: border-box;
  min-height: 2.75rem;
  padding: 0.55rem 1.15rem;
  border: 2px solid transparent;
  border-radius: 999px;
  font-family: inherit;
  font-size: 0.9rem;
  line-height: 1.25;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
}

.btn-lg {
  min-height: 3rem;
  padding: 0.85rem 1.6rem;
  font-size: 1rem;
}

.btn-sm {
  min-height: 2rem;
  padding: 0.4rem 0.85rem;
  font-size: 0.82rem;
}

.btn-primary {
  background: var(--gold);
  color: var(--navy-deep);
  border-color: var(--gold);
}

.btn-primary:hover {
  background: var(--gold-hover);
  border-color: var(--gold-hover);
}

.btn-secondary {
  background: transparent;
  color: #fff;
  border-color: rgba(255, 255, 255, 0.85);
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.1);
}

.btn-enter {
  background: var(--green);
  color: #fff;
  border-color: var(--green);
}

.btn-enter:hover {
  background: var(--green-hover);
  border-color: var(--green-hover);
}

.btn-outline {
  border-color: var(--border);
  background: var(--card);
  color: var(--text);
}

.btn-outline:hover {
  background: var(--bg);
}

.btn-ghost {
  background: transparent;
  color: var(--muted);
  border-color: transparent;
}

.btn-ghost:hover {
  color: var(--text);
  background: var(--bg);
}

.btn-card {
  width: 100%;
  min-height: auto;
  margin-top: 1rem;
  padding: 0.7rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  font-size: 0.9rem;
  white-space: normal;
}

.btn-save {
  border-color: var(--green-hover);
  color: var(--card);
  font-weight: 600;
  background-color: var(--green);
}

.btn-card:disabled {
  opacity: 0.65;
  cursor: not-allowed;
}

/* Hero */
.hero {
  background: linear-gradient(180deg, var(--navy) 0%, var(--navy-deep) 100%);
  background-image: url('../../assets/images/hero-bg.png');
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  color: #fff;
  padding: 3rem 0 3.5rem;
}

.hero-inner {
  text-align: center;
  max-width: 640px;
}

.hero-badge {
  display: inline-block;
  background: rgba(255, 255, 255, 0.12);
  border-radius: 999px;
  padding: 0.35rem 0.9rem;
  font-size: 0.82rem;
  margin-bottom: 1rem;
}

.hero-title {
  font-size: clamp(2.4rem, 6vw, 3.4rem);
  margin: 0 0 0.75rem;
  font-weight: 700;
  color: #009C3B;
  font-style: italic;
}

.text-gold {
  color: var(--gold);
}

.hero-subtitle {
  margin: 0 auto 1.75rem;
  color: rgba(255, 255, 255, 0.88);
  font-size: 1.05rem;
  text-wrap-style: balance;
}

.hero-actions {
  display: flex;
  gap: 0.75rem;
  justify-content: center;
  flex-wrap: wrap;
}

/* Games */
.games-section {
  padding: 3rem 0;
}

.phase-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 2rem;
  justify-content: center;
}

.phase-filters a {
  padding: 0.35rem 0.85rem;
  border-radius: 999px;
  font-size: 0.85rem;
  background: var(--card);
  border: 1px solid var(--border);
  color: var(--muted);
}

.phase-filters a.active {
  background: var(--navy);
  color: #fff;
  border-color: var(--navy);
}

.games-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1.25rem;
}

.game-card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1rem 1.1rem 1.1rem;
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
}

.game-card-meta {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.78rem;
  color: var(--muted);
  margin-bottom: 1rem;
}

.game-card-meta time {
  text-align: center;
}

.match-form {
  display: flex;
  flex-direction: column;
  flex: 1;
}

.match-form .btn-card {
  margin-top: auto;
}

.pill {
  display: inline-block;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
}

.pill-group {
  background: var(--navy);
  color: #fff;
}

.status-open {
  background: #fef9e0;
  color: #8a6d00;
}

.status-closed {
  background: #f1f3f6;
  color: var(--muted);
}

.status-soon {
  background: #eef2ff;
  color: #4338ca;
}

.status-done {
  background: #e8f5ee;
  color: #1a6b3c;
}

.match-teams {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.team {
  text-align: center;
  display: flex;
  align-items: center;
  flex-direction: column;
}

.team-flag {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--border);
}

.flag-placeholder {
  display: block;
  background: var(--border);
  position: relative;
}

.flag-placeholder::after {
  content: '?';
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  color: var(--muted);
  font-weight: 700;
}

.team-name {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  margin-top: 0.35rem;
}

.score-inputs {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.score-box {
  width: 44px;
  height: 44px;
  text-align: center;
  font-size: 1.1rem;
  font-weight: 700;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-family: inherit;
}

.score-box:disabled {
  background: #f8fafc;
  color: var(--muted);
}

.score-sep {
  font-size: 0.85rem;
  color: var(--muted);
}

.match-result-admin,
.match-result-user {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--green);
  text-align: center;
  margin: 0.5rem 0;
}

/* Flash */
.flash {
  padding: 0.75rem 0;
  font-size: 0.9rem;
  font-weight: 500;
}

.flash-success {
  background: #e8f5ee;
  color: #14532d;
}

.flash-error {
  background: #fde8e8;
  color: #991b1b;
}

/* Pages */
.page-main {
  padding: 2rem 0 3rem;
}

.page-title {
  margin: 0 0 0.35rem;
  font-size: 1.75rem;
}

.page-lead {
  color: var(--muted);
  margin: 0 0 1.5rem;
}

.ranking-table-wrap {
  overflow-x: auto;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}

.ranking-table {
  width: 100%;
  border-collapse: collapse;
}

.ranking-table th,
.ranking-table td {
  padding: 0.85rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.ranking-table th {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.rank-user {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.rank-user img {
  border-radius: 50%;
}

.rank-pos {
  font-weight: 700;
  color: var(--muted);
  width: 3rem;
}

.rank-points {
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--navy);
}

.rank-predictions {
  font-weight: 600;
  color: var(--muted);
  width: 5rem;
}

.bonus-badge {
  font-size: 1rem;
}

.rank-user-btn {
  display: block;
  width: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  font: inherit;
  color: inherit;
  text-align: left;
  cursor: pointer;
  border-radius: 8px;
  transition: background 0.15s ease;
}

.rank-user-btn:hover,
.rank-user-btn:focus-visible {
  background: rgba(12, 31, 63, 0.06);
  outline: none;
}

.rank-user-btn:focus-visible {
  box-shadow: 0 0 0 2px var(--navy);
}

.ranking-modal {
  width: min(740px, 92vw);
  max-height: min(85vh, 720px);
  padding: 0;
  border: 0;
  border-radius: var(--radius);
  box-shadow: 0 20px 60px rgba(12, 31, 63, 0.2);
  background: var(--card);
}

.ranking-modal::backdrop {
  background: rgba(8, 21, 40, 0.55);
}

.ranking-modal-panel {
  display: flex;
  flex-direction: column;
  max-height: min(85vh, 720px);
}

.ranking-modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  background: #f8fafc;
}

.ranking-modal-user .rank-user strong {
  display: block;
  font-size: 1.05rem;
}

.ranking-modal-close {
  flex-shrink: 0;
  width: 2rem;
  height: 2rem;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
}

.ranking-modal-close:hover,
.ranking-modal-close:focus-visible {
  background: rgba(12, 31, 63, 0.08);
  color: var(--text);
  outline: none;
}

.ranking-modal-body {
  overflow-y: auto;
  padding: 0;
}

.ranking-modal-loading {
  padding: 1.5rem 1.25rem;
  margin: 0;
}

.ranking-modal-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.ranking-modal-item {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.75rem 1.5rem;
  padding: 0.85rem 1.25rem;
  border-bottom: 1px solid var(--border);
}

.ranking-modal-item:last-child {
  border-bottom: 0;
}

.ranking-modal-match strong {
  display: block;
}

.ranking-modal-scores {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  align-items: center;
  font-size: 0.92rem;
}

@media (max-width: 560px) {
  .ranking-modal-scores {
    width: 100%;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.35rem;
  }
}

.predictions-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.prediction-item {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.muted {
  color: var(--muted);
  font-size: 0.85rem;
  display: block;
}

.points {
  color: var(--green);
  font-weight: 600;
}

.empty-state {
  text-align: center;
  color: var(--muted);
  padding: 2rem;
}

.games-empty {
  max-width: 28rem;
  margin: 2.5rem auto 3rem;
  padding: 2.5rem 1.5rem;
}

/* Footer */
.site-footer {
  text-align: center;
  padding: 1.4rem 0;
  color: var(--muted);
  font-size: 0.88rem;
  border-top: 1px solid var(--border);
  background: var(--card);
}

/* Admin */
.admin-menu {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
}

.admin-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.admin-card strong {
  font-size: 1.1rem;
}

.admin-card span {
  color: var(--muted);
  font-size: 0.9rem;
}

.card-panel {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow);
}

.admin-form .form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1rem;
  margin-bottom: 1rem;
}

.admin-form label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.85rem;
  font-weight: 500;
}

.admin-form input,
.admin-form select {
  padding: 0.5rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-family: inherit;
}

.checkbox-label {
  flex-direction: row !important;
  align-items: center;
  gap: 0.5rem !important;
}

.admin-table {
  margin-top: 2rem;
}

.admin-phase-filters {
  margin: 1.5rem 0 0;
}

.admin-form-edit {
  border-color: var(--accent, #2563eb);
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: stretch;
}

.form-actions .btn {
  flex: 0 0 auto;
}

.admin-row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  align-items: center;
}

.admin-row-actions .inline-form {
  display: inline;
}

.admin-table tr.row-editing {
  background: rgba(37, 99, 235, 0.06);
}

.match-label {
  font-weight: 600;
  color: var(--muted);
}

.result-form-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 1rem;
  margin-bottom: 0.75rem;
}

.result-inputs {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.result-inputs input {
  width: 64px;
  padding: 0.5rem;
  text-align: center;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-family: inherit;
}

.config-warning {
  background: var(--card);
  border-radius: var(--radius);
  padding: 2rem;
  border: 1px solid var(--border);
  max-width: 520px;
  margin: 2rem auto;
}

.config-warning code {
  background: #f1f3f6;
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
  font-size: 0.88em;
}

.admin-predictions-groups {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.admin-user-predictions {
  padding: 0;
  overflow: hidden;
}

.admin-user-predictions-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  background: #f8fafc;
}

.admin-user-predictions-head .rank-user {
  flex: 1;
  min-width: 200px;
}

.admin-user-avatar {
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}

.admin-user-avatar-fallback {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--navy);
  color: #fff;
  font-size: 1.1rem;
  font-weight: 700;
}

.admin-user-name {
  display: block;
  font-size: 1.05rem;
}

.admin-user-predictions-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.admin-user-predictions-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.admin-user-prediction-item {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.75rem 1.5rem;
  padding: 0.85rem 1.25rem;
  border-bottom: 1px solid var(--border);
}

.admin-user-prediction-item:last-child {
  border-bottom: none;
}

.admin-user-prediction-match strong {
  display: block;
}

.admin-user-prediction-scores {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 1rem;
  text-align: right;
  justify-content: flex-end;
}

.admin-prediction-sent {
  width: 100%;
  text-align: right;
}

.admin-exact-table {
  margin-top: 0;
  width: 100%;
}

@media (max-width: 768px) {
  .main-nav {
    order: 3;
    width: 100%;
    justify-content: center;
  }

  .header-inner {
    justify-content: center;
  }

  .header-actions {
    margin-left: 0;
  }

  .game-card-meta {
    grid-template-columns: auto;
  }

  .game-card-meta time {
    grid-column: 1 / -1;
    text-align: left;
  }

  .admin-user-prediction-scores {
    text-align: left;
    width: 100%;
  }

  .admin-prediction-sent {
    text-align: left;
  }
}
