:root {
  --bg: #f4f6eb;
  --bg-2: #d9e6cb;
  --ink: #1f2a1f;
  --brand: #0f766e;
  --brand-2: #14532d;
  --accent: #f59e0b;
  --card: #ffffffee;
  --danger: #b91c1c;
  --ok: #166534;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Trebuchet MS", "Segoe UI", sans-serif;
  color: var(--ink);
  background: radial-gradient(circle at 20% 10%, var(--bg-2), var(--bg));
}

html,
body {
  max-width: 100%;
  overflow-x: hidden;
}

.bg-layer {
  position: fixed;
  inset: 0;
  z-index: -1;
  background-image:
    linear-gradient(115deg, #ffffff66 10%, transparent 60%),
    repeating-linear-gradient(45deg, #00000008 0 1px, transparent 1px 14px);
}

.topbar {
  padding: 1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: nowrap;
  gap: 0.7rem;
  border-bottom: 3px solid var(--brand);
  background: #fefefeee;
  position: sticky;
  top: 0;
  z-index: 10;
  min-height: auto;
}

.topbar > div:first-child {
  flex-shrink: 0;
  min-width: 0;
}

.top-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: nowrap;
  justify-content: flex-end;
  flex-shrink: 0;
  align-items: center;
}

.brand-kicker {
  margin: 0;
  font-size: 0.8rem;
  text-transform: uppercase;
  color: var(--brand-2);
  letter-spacing: 0.06em;
}

h1 {
  margin: 0;
  font-size: 1.4rem;
}

.layout {
  display: grid;
  gap: 1rem;
  padding: 1rem;
  min-width: 0;
}

.card {
  background: var(--card);
  border-radius: 16px;
  padding: 1rem;
  box-shadow: 0 8px 24px #00000014;
}

.hero h2 {
  margin-top: 0;
}

.hero-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
}

.hero-links a {
  color: var(--brand);
  font-weight: 700;
}

.btn {
  border: 1px solid #00000020;
  background: white;
  color: var(--ink);
  border-radius: 10px;
  padding: 0.5rem 0.9rem;
  cursor: pointer;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn-primary {
  background: linear-gradient(125deg, var(--brand), var(--brand-2));
  color: white;
  border: 0;
}

.btn-ghost {
  background: transparent;
}

.hidden {
  display: none !important;
}

.content,
.sidebar {
  display: grid;
  gap: 1rem;
  min-width: 0;
}

.section-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.inline-actions {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
  min-width: 0;
}

.small-note {
  font-size: 0.88rem;
  color: #334155;
  margin-top: 0.5rem;
}

#sidebar-quick-panel h3 {
  margin-top: 0;
  margin-bottom: 0.9rem;
}

.quick-panel-block {
  border: 1px solid #0000001a;
  border-radius: 10px;
  padding: 0.8rem;
  background: linear-gradient(180deg, #ffffff, #f8fafc);
}

.quick-panel-block + .quick-panel-block {
  margin-top: 0.75rem;
}

.quick-panel-block p {
  margin: 0;
  line-height: 1.4;
}

.quick-panel-label {
  margin: 0 0 0.35rem;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  color: #475569;
  letter-spacing: 0.03em;
}

#quick-next-deadline,
#quick-today-progress {
  margin: 0 0 0.6rem;
  color: #0f172a;
  font-weight: 600;
  line-height: 1.35;
}

#quick-private-cta {
  display: inline-block;
  margin-top: 0.6rem;
}

#scoring-reference-card h3 {
  margin-top: 0;
  margin-bottom: 0.55rem;
}

.scoring-table-wrap {
  overflow-x: auto;
}

.scoring-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.86rem;
}

.scoring-table th,
.scoring-table td {
  border-bottom: 1px solid #00000018;
  padding: 0.42rem 0.35rem;
  text-align: left;
}

.scoring-table th:nth-child(2),
.scoring-table th:nth-child(3),
.scoring-table td:nth-child(2),
.scoring-table td:nth-child(3) {
  text-align: center;
  width: 4.6rem;
}

.scoring-table tbody tr:last-child td {
  border-bottom: 0;
}

#notifications-card h3 {
  margin-top: 0;
  margin-bottom: 0.85rem;
}

#notifications-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.7rem;
}

#notifications-list li {
  background: linear-gradient(180deg, #f8fafc, #f1f5f9);
  border: 1px solid #e2e8f0;
  border-left: 4px solid var(--brand);
  border-radius: 10px;
  padding: 0.7rem 0.75rem;
  line-height: 1.45;
  color: #1f2937;
  font-size: 0.95rem;
}

.match-phase {
  margin-top: 1.5rem;
}

.match-phase > h4 {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #64748b;
  margin-bottom: 0.75rem;
  padding-bottom: 0.4rem;
  border-bottom: 2px solid var(--brand);
  display: inline-block;
}

.match-grid {
  display: grid;
  gap: 0.75rem;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  min-width: 0;
}

.match-pagination {
  margin-top: 0.8rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.match-card {
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 14px;
  padding: 1rem;
  background: var(--card);
  display: flex;
  flex-direction: column;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
  transition:
    box-shadow 0.2s,
    transform 0.15s;
}

.match-card:hover {
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
  transform: translateY(-1px);
}

.match-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
}

.match-group-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: #64748b;
}

.match-status {
  font-size: 0.7rem;
  font-weight: 700;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
}

.status-scheduled {
  background: #e0f2fe;
  color: #0369a1;
}
.status-live {
  background: #dcfce7;
  color: #15803d;
  animation: pulse-live 1.5s ease-in-out infinite;
}
.status-finished {
  background: #f1f5f9;
  color: #475569;
}
.status-postponed {
  background: #fef3c7;
  color: #b45309;
}

@keyframes pulse-live {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.6;
  }
}

.match-teams {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: 0.4rem;
  min-height: 2.45rem;
  margin-bottom: 0.75rem;
}

.team {
  display: grid;
  align-items: center;
  gap: 0.35rem;
  min-width: 0;
}

.team.home-team {
  grid-template-columns: 24px minmax(0, 1fr);
  justify-items: stretch;
}

.team.away-team {
  grid-template-columns: minmax(0, 1fr) 24px;
  justify-items: stretch;
}

.team-flag-slot {
  width: 24px;
  height: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.team-flag-img {
  width: 24px;
  height: 18px;
  object-fit: cover;
  border-radius: 2px;
  flex-shrink: 0;
  display: block;
}

.team-name {
  font-weight: 700;
  font-size: 0.84rem;
  line-height: 1.2;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: normal;
  word-break: keep-all;
  overflow-wrap: normal;
  hyphens: none;
  min-width: 0;
  text-align: center;
  justify-self: stretch;
}

.match-score-display {
  display: flex;
  align-items: center;
  gap: 0.2rem;
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--brand);
  min-width: 50px;
  justify-content: center;
  flex-shrink: 0;
}

.score-vs {
  font-size: 0.85rem;
  font-weight: 600;
  color: #94a3b8;
}

.match-info {
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
  color: #64748b;
  margin-bottom: 0.75rem;
  flex-wrap: wrap;
  gap: 0.25rem;
  border-top: 1px solid rgba(0, 0, 0, 0.05);
  padding-top: 0.55rem;
}

.match-venue {
  flex: 1 1 100%;
  white-space: normal;
  overflow-wrap: anywhere;
}

.prediction-section {
  border-top: 1px solid rgba(0, 0, 0, 0.06);
  padding-top: 0.65rem;
  margin-top: auto;
}

.prediction-label {
  font-size: 0.75rem;
  color: #64748b;
  display: block;
  text-align: center;
  margin-bottom: 0.45rem;
}

.official-result {
  font-size: 0.76rem;
  color: #0f172a;
  display: block;
  text-align: center;
  margin: -0.1rem 0 0.45rem;
}

.prediction-countdown {
  display: block;
  text-align: center;
  margin: -0.1rem 0 0.45rem;
  font-size: 0.75rem;
  font-weight: 700;
  color: #0f766e;
}

.score-inputs {
  display: grid;
  grid-template-columns: auto auto auto;
  gap: 0.35rem;
  align-items: center;
  justify-content: center;
  margin-bottom: 0.5rem;
}

.score-inputs input {
  width: 3.2rem;
  min-width: 3.2rem;
  text-align: center;
  padding: 0.45rem 0.35rem;
}

.prediction-section .save-prediction {
  width: 100%;
}

.prediction-section .edit-prediction {
  width: 100%;
}

.prediction-lock-note {
  display: block;
  margin-top: 0.4rem;
  font-size: 0.72rem;
  text-align: center;
  color: #b45309;
}

.score-separator {
  font-weight: 700;
  color: #94a3b8;
  text-align: center;
  font-size: 1rem;
  padding: 0 0.1rem;
}

input {
  width: 100%;
  padding: 0.5rem;
  border-radius: 10px;
  border: 1px solid #00000035;
}

.group-actions {
  display: grid;
  gap: 1rem;
}

.group-actions form {
  border: 1px solid #0000001f;
  border-radius: 12px;
  padding: 0.8rem;
  display: grid;
  gap: 0.5rem;
}

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

#ranking-table {
  overflow-x: auto;
  max-width: 100%;
}

#ranking-table table,
.group-ranking-view table {
  width: 100%;
  max-width: 100%;
  table-layout: fixed;
}

#ranking-table th,
#ranking-table td,
.group-ranking-view th,
.group-ranking-view td {
  overflow-wrap: anywhere;
  word-break: break-word;
}

#ranking-table th,
#ranking-table td {
  border-bottom: 1px solid #00000014;
  text-align: left;
  padding: 0.45rem;
}

.demo-badge {
  background: #fef3c7;
  border: 1px solid #f59e0b;
  border-radius: 9px;
  padding: 0.5rem;
  font-weight: 700;
  color: #92400e;
}

.share-grid,
.cta-row {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.plans-grid {
  display: grid;
  gap: 0.8rem;
}

.plans-grid article {
  border: 1px solid #00000016;
  border-radius: 10px;
  padding: 0.8rem;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.plans-grid article h4 {
  margin: 0;
}

.plans-grid article p {
  margin: 0;
  flex: 1;
}

.plans-grid article .btn {
  align-self: flex-start;
  margin-top: auto;
}

.footer {
  padding: 1rem;
  text-align: center;
}

.footer .cta-row {
  justify-content: center;
  margin-bottom: 1rem;
}

.footer .legal-links {
  margin-top: 0.4rem;
}

body.stats-view-mode .layout {
  grid-template-columns: minmax(0, 1fr);
  grid-template-areas: "sidebar";
}

body.stats-view-mode .sidebar {
  width: 100%;
  max-width: 920px;
  margin: 0 auto;
}

body.stats-view-mode #stats-card {
  padding: 1.35rem;
}

body.stats-view-mode #stats-card h3 {
  margin-top: 0;
  margin-bottom: 1rem;
  font-size: 1.55rem;
}

body.stats-view-mode #stats-content p {
  font-size: 1.04rem;
  line-height: 1.5;
}

@media (min-width: 980px) {
  .layout {
    grid-template-columns: 1fr 320px;
    grid-template-areas:
      "hero sidebar"
      "content sidebar";
    align-items: start;
  }

  .hero {
    grid-area: hero;
  }

  .content {
    grid-area: content;
  }

  .sidebar {
    grid-area: sidebar;
    position: static;
  }

  .plans-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  .group-actions {
    grid-template-columns: 1fr 1fr;
  }
}

@media (min-width: 980px) {
  body.stats-view-mode .layout {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas: "sidebar";
  }

  body.stats-view-mode .sidebar {
    max-width: 980px;
  }
}

.group-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
}

.group-header > div {
  flex: 1;
}

.group-header button {
  white-space: nowrap;
  height: fit-content;
  margin-top: 0.5rem;
}

.group-ranking-view {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

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

@media (max-width: 760px) {
  .topbar {
    position: static;
    padding: 0.6rem;
    flex-direction: row;
    justify-content: space-between;
    gap: 0.5rem;
    align-items: center;
  }

  .topbar > div:first-child {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
  }

  .brand-kicker {
    font-size: 0.65rem;
    line-height: 1.1;
    white-space: nowrap;
    margin: 0 0 0.15rem 0;
  }

  .top-actions {
    flex-wrap: nowrap;
    gap: 0.4rem;
    flex-shrink: 0;
    align-items: center;
  }

  .top-actions .btn {
    padding: 0.4rem 0.6rem;
    font-size: 0.8rem;
    white-space: nowrap;
  }

  #btn-back-home {
    display: none !important;
  }

  #btn-login {
    display: none !important;
  }

  h1 {
    font-size: 1rem;
    white-space: nowrap;
    margin: 0;
  }

  .layout {
    gap: 0.75rem;
    padding: 0.75rem;
    display: flex;
    flex-direction: column;
  }

  .hero {
    order: 2;
  }

  .sidebar {
    display: contents;
  }

  #profile-card {
    order: 1;
  }

  #notifications-card {
    order: 3;
  }

  #stats-card {
    order: 4;
  }

  #sidebar-quick-panel {
    order: 5;
  }

  #scoring-reference-card {
    order: 6;
  }

  .content {
    order: 7;
  }

  .card {
    border-radius: 14px;
    padding: 0.85rem;
  }

  .section-head {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.55rem;
  }

  .inline-actions,
  .top-actions,
  .share-grid,
  .cta-row,
  .hero-links {
    width: 100%;
    min-width: 0;
  }

  .inline-actions .btn,
  .share-grid .btn,
  .cta-row .btn,
  .cta-row a.btn {
    flex: 1 1 100%;
    text-align: center;
    white-space: normal;
  }

  .top-actions .btn {
    flex: 0 1 auto;
    text-align: center;
    white-space: nowrap;
    padding: 0.45rem 0.65rem;
    font-size: 0.85rem;
  }

  .match-meta {
    flex-wrap: wrap;
    gap: 0.4rem;
  }

  .group-header {
    flex-direction: column;
    gap: 0.6rem;
  }

  .group-header button {
    width: 100%;
    margin-top: 0;
  }

  .modal-content {
    width: calc(100vw - 1rem);
    max-width: 500px;
    max-height: 88vh;
    padding: 1.1rem;
  }

  .scoring-table {
    font-size: 0.8rem;
  }

  .scoring-table th,
  .scoring-table td {
    padding: 0.35rem 0.28rem;
  }

  #ranking-table table,
  .group-ranking-view table {
    font-size: 0.75rem;
    table-layout: auto;
  }

  #ranking-table th,
  #ranking-table td,
  .group-ranking-view th,
  .group-ranking-view td {
    padding: 0.3rem 0.2rem;
  }

  #ranking-table th,
  .group-ranking-view th {
    white-space: nowrap;
    font-size: 0.7rem;
  }
}

@media (max-width: 420px) {
  .brand-kicker {
    font-size: 0.72rem;
  }

  h1 {
    font-size: 1.06rem;
  }

  .btn {
    padding: 0.5rem 0.75rem;
  }

  .score-inputs input {
    width: 2.7rem;
    min-width: 2.7rem;
    padding: 0.4rem 0.25rem;
  }

  .team-name {
    font-size: 0.8rem;
  }

  .modal-features {
    gap: 0.75rem;
  }

  .feature-item {
    padding: 0.75rem;
  }
}

.group-ranking-view th,
.group-ranking-view td {
  border-bottom: 1px solid #00000014;
  text-align: left;
  padding: 0.45rem;
}

/* Modal de Bienvenida */
.modal-overlay {
  position: fixed;
  inset: 0;
  background:
    linear-gradient(rgba(0, 0, 0, 0.42), rgba(0, 0, 0, 0.55)),
    url("/assets/images/imagen de fondo bienvenida.png") center/cover no-repeat;
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
}

.modal-content {
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(4px);
  border-radius: 16px;
  padding: 2rem;
  max-width: 500px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.modal-content h2 {
  margin: 0 0 0.5rem 0;
  color: var(--brand);
  text-align: center;
}

.modal-subtitle {
  text-align: center;
  color: #666;
  margin: 0 0 1.5rem 0;
  font-size: 0.95rem;
}

.modal-features {
  display: grid;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.feature-item {
  background: #f9faf8;
  padding: 1rem;
  border-radius: 10px;
  border-left: 4px solid var(--brand);
}

.feature-item strong {
  color: var(--brand);
  display: block;
  margin-bottom: 0.3rem;
}

.feature-item p {
  margin: 0;
  font-size: 0.9rem;
  color: #555;
  line-height: 1.4;
}

.modal-footer {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  align-items: center;
  padding-top: 1rem;
  border-top: 1px solid #00000014;
}

.modal-credit {
  font-size: 0.9rem;
  color: #666;
  margin: 0;
  text-align: center;
}

.modal-credit a {
  color: var(--brand);
  text-decoration: none;
  transition: color 0.2s;
}

.modal-credit a:hover {
  color: var(--brand-2);
  text-decoration: underline;
}

#btn-close-modal {
  width: 100%;
}
