/* ─────────────────────────────────────────────────────────────
   Quiniela Mundial 2026 — Premium Mobile-First Styles
   ───────────────────────────────────────────────────────────── */

:root {
  /* Color Palette - HSL for easier manipulation */
  --p-h: 142; /* Primary Hue (Green) */
  --p-s: 71%;
  --p-l: 45%;
  
  --primary:    hsl(var(--p-h), var(--p-s), var(--p-l));
  --primary-gl: hsla(var(--p-h), var(--p-s), var(--p-l), 0.15);
  --primary-dk: hsl(var(--p-h), var(--p-s), 35%);
  
  --gold:       #f59e0b;
  --gold-gl:    rgba(245, 158, 11, 0.1);
  --red:        #ef4444;
  --blue:       #3b82f6;
  
  /* Dark Mode Surfaces */
  --bg:         #0b1219;
  --surface:    #151f2b;
  --surface2:   #1e293b;
  --border:     rgba(255, 255, 255, 0.08); /* Sophisticated thin borders */
  --border-focus: hsla(var(--p-h), var(--p-s), var(--p-l), 0.5);
  
  /* Text */
  --text:       #f8fafc;
  --text-muted: #94a3b8;
  
  /* Glass and Shadows */
  --glass-bg:   rgba(21, 31, 43, 0.7);
  --glass-border: rgba(255, 255, 255, 0.1);
  --shadow-sm:  0 4px 6px -1px rgb(0 0 0 / 0.1);
  --shadow-md:  0 10px 15px -3px rgb(0 0 0 / 0.2);
  --shadow-lg:  0 20px 25px -5px rgb(0 0 0 / 0.3);
  
  --radius:     16px; /* Slightly more rounded for premium feel */
  --nav-height: 64px;
}

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

html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Outfit', 'Segoe UI', system-ui, sans-serif;
  min-height: 100vh;
  line-height: 1.5;
  overflow-x: hidden;
}

/* ── UTILITIES ────────────────────────────── */
.hidden { display: none !important; }
.glass {
  background: var(--glass-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--glass-border);
}
.shadow-btn { box-shadow: 0 4px 14px 0 hsla(var(--p-h), var(--p-s), var(--p-l), 0.39); }
.desktop-only { display: flex; }
@media (max-width: 768px) { .desktop-only { display: none !important; } }

/* ── SCROLLBAR ────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--surface2); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ── AUTH ─────────────────────────────────── */
#auth-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at top left, #0d2d1a 0%, var(--bg) 50%);
  padding: 1.5rem;
}

.auth-box {
  width: 100%;
  max-width: 400px;
  padding: 2.5rem 2rem;
  border-radius: 24px;
  animation: fadeIn 0.6s ease-out;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

.auth-logo { text-align: center; margin-bottom: 2rem; }
.ball-container { position: relative; display: inline-block; margin-bottom: 1rem; }
.ball-container .ball { font-size: 3.5rem; filter: drop-shadow(0 10px 15px rgba(0,0,0,0.5)); transform: rotate(-10deg); }
.ball-shadow { width: 40px; height: 8px; background: rgba(0,0,0,0.3); filter: blur(4px); border-radius: 50%; margin: -5px auto 0; }

.auth-logo h1 { font-size: 1.8rem; font-weight: 800; color: #fff; letter-spacing: -0.5px; }
.auth-logo h1 span { color: var(--primary); }
.auth-logo p { color: var(--text-muted); font-size: 0.9rem; margin-top: 0.25rem; font-weight: 300; }

.auth-tabs { display: flex; background: var(--surface2); padding: 4px; border-radius: 12px; margin-bottom: 2rem; }
.auth-tab {
  flex: 1; padding: 0.8rem; text-align: center; cursor: pointer;
  color: var(--text-muted); font-size: 0.9rem; border-radius: 10px; transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
.auth-tab.active { background: var(--surface); color: var(--primary); font-weight: 600; box-shadow: var(--shadow-sm); }

/* ── FORMS ──────────────────────────────── */
.form-group { margin-bottom: 1.25rem; }
.form-group label {
  display: flex; align-items: center; gap: 0.5rem;
  font-size: 0.85rem; color: var(--text-muted); margin-bottom: 0.5rem; font-weight: 500;
}
.form-group label i { width: 16px; height: 16px; color: var(--primary); }

.form-group input {
  width: 100%; padding: 0.85rem 1rem; background: var(--surface);
  border: 1.5px solid var(--border); border-radius: 12px; color: var(--text);
  font-size: 1rem; transition: all 0.2s; font-family: inherit;
}
.form-group input:focus { outline: none; border-color: var(--primary); background: var(--surface2); box-shadow: 0 0 0 4px var(--primary-gl); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.6rem;
  padding: 0.9rem 1.5rem; border: none; border-radius: 12px;
  font-size: 1rem; font-weight: 700; cursor: pointer;
  transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275); font-family: inherit;
}
.btn:hover { transform: translateY(-2px); filter: brightness(1.1); }
.btn:active { transform: translateY(0) scale(0.98); }

.btn-primary { background: linear-gradient(135deg, var(--primary), var(--primary-dk)); color: #000; }
.btn-block { width: 100%; }

.error-msg { color: var(--red); font-size: 0.85rem; text-align: center; margin-top: 1rem; padding: 0.5rem; background: rgba(239, 68, 68, 0.1); border-radius: 8px; }

/* ── APP LAYOUT ───────────────────────── */
header {
  height: var(--nav-height); padding: 0 1.5rem; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 2rem; position: sticky; top: 0; z-index: 1000;
}
.header-logo { font-weight: 800; font-size: 1.1rem; color: #fff; display: flex; align-items: center; gap: 0.5rem; cursor: pointer; }
.header-logo span { color: var(--primary); }

nav.desktop-only { gap: 0.5rem; flex: 1; }
.nav-btn {
  padding: 0.6rem 1rem; border: none; background: transparent; color: var(--text-muted);
  cursor: pointer; border-radius: 12px; font-size: 0.95rem; font-weight: 500;
  transition: all 0.3s; display: flex; align-items: center; gap: 0.5rem;
}
.nav-btn:hover { color: var(--text); background: var(--surface2); }
.nav-btn.active { color: var(--primary); background: var(--primary-gl); font-weight: 700; }

.header-user { margin-left: auto; display: flex; align-items: center; gap: 1rem; }
.user-info-pill {
  display: flex; align-items: center; gap: 0.5rem; background: var(--surface2);
  padding: 4px 12px 4px 4px; border-radius: 30px; border: 1px solid var(--border);
}
.user-avatar {
  width: 32px; height: 32px; border-radius: 50%; background: var(--primary);
  display: flex; align-items: center; justify-content: center; font-weight: 800; color: #000; font-size: 0.9rem;
}
.user-name { font-size: 0.85rem; font-weight: 600; color: var(--text); }

.btn-logout-icon {
  width: 40px; height: 40px; padding: 0; background: var(--surface2); color: var(--text-muted);
  border-radius: 12px; border: 1px solid var(--border);
}
.btn-logout-icon:hover { color: var(--red); background: rgba(239, 68, 68, 0.1); border-color: rgba(239, 68, 68, 0.2); }

.hamburger-btn { display: none; width: 40px; height: 40px; padding: 0; border-radius: 12px; }

@media (max-width: 768px) {
  .hamburger-btn { display: flex; }
  .btn-logout-icon, .user-name { display: none; }
  .user-info-pill { padding-right: 4px; }
}

/* ── MOBILE DRAWER ────────────────────────── */
.drawer-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.6); backdrop-filter: blur(4px);
  z-index: 1500; opacity: 0; transition: opacity 0.3s;
}
.drawer-overlay:not(.hidden) { opacity: 1; }

.mobile-drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: 280px;
  background: var(--surface); border-left: 1px solid var(--border);
  z-index: 1501; display: flex; flex-direction: column;
  transform: translateX(100%); transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
.mobile-drawer:not(.hidden) { transform: translateX(0); }

.drawer-header {
  padding: 1.5rem; display: flex; align-items: center; justify-content: space-between;
  border-bottom: 1px solid var(--border);
}
.drawer-content { flex: 1; padding: 1.5rem; display: flex; flex-direction: column; gap: 0.5rem; }
.drawer-content .nav-btn {
  padding: 1rem; font-size: 1.1rem; border-radius: 16px; width: 100%; justify-content: flex-start;
}
.drawer-content .nav-btn i { width: 20px; height: 20px; color: var(--primary); }

.drawer-footer { padding: 1.5rem; border-top: 1px solid var(--border); }

/* ── MAIN CONTENT ─────────────────────── */
main { padding: 2rem 1rem; max-width: 1200px; margin: 0 auto; width: 100%; transition: all 0.3s; }

.section-title {
  font-size: 1.25rem; font-weight: 800; margin-bottom: 1.5rem; display: flex; align-items: center; gap: 0.75rem; color: #fff;
}
.section-title i { color: var(--primary); }

/* ── TABS ─────────────────────────────── */
.tab-content { display: none; }
.tab-content.active { display: block; animation: tabFade 0.3s ease-out; }

@keyframes tabFade {
  from { opacity: 0; transform: translateY(5px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ── STACKED CARDS / TABLES REPLACEMENT ── */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 20px; padding: 1.5rem; box-shadow: var(--shadow-md); margin-bottom: 1rem; overflow: hidden; }

/* ── STATS GRID ──────────────────────── */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 1rem; margin-bottom: 2rem; }
.stat-card {
  padding: 1.5rem; display: flex; flex-direction: column; align-items: center; position: relative; overflow: hidden;
}
.stat-card::before { content: ''; position: absolute; top: -50%; left: -50%; width: 200%; height: 200%; background: radial-gradient(circle, var(--primary-gl) 0%, transparent 70%); opacity: 0.2; pointer-events: none; }

.stat-val { font-size: 2.2rem; font-weight: 800; line-height: 1; margin-bottom: 0.5rem; }
.stat-label { font-size: 0.75rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 1px; font-weight: 700; }

.stat-card.gold .stat-val { color: var(--gold); }
.stat-card.blue .stat-val { color: var(--blue); }
.stat-card.green .stat-val { color: var(--primary); }

/* ── MATCHES GRID ────────────────────── */
.matches-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 1rem; }

.match-day-header {
  grid-column: 1 / -1; padding: 1.5rem 0 0.5rem; font-size: 0.9rem; font-weight: 800;
  color: var(--text-muted); text-transform: uppercase; letter-spacing: 1px; display: flex; align-items: center; gap: 10px;
}
.match-day-header::after { content: ''; flex: 1; height: 1px; background: var(--border); }

.match-card {
  background: var(--surface); border: 1.5px solid var(--border); border-radius: 20px;
  padding: 1.25rem; transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1); position: relative;
}
.match-card:hover { border-color: var(--border-focus); transform: translateY(-3px); box-shadow: var(--shadow-lg); }

.match-meta { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1rem; }
.match-num { font-size: 0.75rem; font-weight: 600; color: var(--text-muted); background: var(--surface2); padding: 4px 10px; border-radius: 8px; }

.match-badge { font-size: 0.7rem; font-weight: 700; padding: 4px 10px; border-radius: 8px; text-transform: uppercase; }
.badge-upcoming { background: rgba(59, 130, 246, 0.15); color: var(--blue); }
.badge-finished { background: var(--primary-gl); color: var(--primary); }
.badge-locked   { background: var(--surface2); color: var(--text-muted); }
.badge-pts      { background: var(--gold-gl); color: var(--gold); margin-left: 5px; border: 1px solid rgba(245, 158, 11, 0.3); }

.match-body { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 0.5rem 0; }
.team { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 0.5rem; text-align: center; }
.team-flag img { width: 44px; height: 30px; object-fit: cover; border-radius: 4px; box-shadow: 0 4px 10px rgba(0,0,0,0.3); }
.team-name { font-size: 0.85rem; font-weight: 700; color: #fff; }

.score-area { display: flex; align-items: center; gap: 0.5rem; }
.score-input {
  width: 46px; height: 46px; text-align: center; background: var(--surface2); border: 2px solid var(--border);
  border-radius: 12px; color: #fff; font-size: 1.25rem; font-weight: 800; transition: all 0.2s;
}
.score-input:focus { border-color: var(--primary); background: var(--surface); box-shadow: 0 0 0 4px var(--primary-gl); outline: none; }
.score-input:disabled { opacity: 0.8; border-color: var(--border); }
.score-sep { font-size: 1.25rem; font-weight: 800; color: var(--text-muted); opacity: 0.5; }

.result-display { font-size: 1.8rem; font-weight: 900; letter-spacing: 4px; color: var(--primary); }
.score-area .sep { color: var(--text-muted); font-weight: 300; margin: 0 5px; }

.match-footer { margin-top: 1.25rem; padding-top: 0.75rem; border-top: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; }
.stadium-info { font-size: 0.7rem; color: var(--text-muted); display: flex; align-items: center; gap: 4px; }

.pred-feedback { font-size: 0.75rem; font-weight: 700; }
.pred-feedback.saved { color: var(--primary); }
.pred-feedback.exact { color: var(--gold); }

/* ── TABLES ───────────────────────────── */
.table-container { overflow-x: auto; margin: -1.5rem; } /* Negative margin to bleed out of card padding */

table { width: 100%; border-collapse: collapse; min-width: 600px; }
th { text-align: left; background: var(--surface2); font-size: 0.75rem; font-weight: 700; color: var(--text-muted); padding: 1rem; text-transform: uppercase; letter-spacing: 1px; border-bottom: 2px solid var(--bg); }
td { padding: 1.25rem 1rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:last-child td { border-bottom: none; }

/* Table responsive strategy: Turn rows into cards on mobile */
@media (max-width: 640px) {
  table, thead, tbody, th, td, tr { display: block; }
  thead tr { position: absolute; top: -9999px; left: -9999px; }
  tr { border: 1.5px solid var(--border); border-radius: 16px; margin-bottom: 1rem; padding: 1rem; background: var(--surface2); }
  td { border: none; padding: 0.5rem 0; position: relative; padding-left: 45%; text-align: right; }
  td::before {
    content: attr(data-label); position: absolute; left: 0; width: 40%; font-size: 0.75rem;
    font-weight: 700; color: var(--text-muted); text-transform: uppercase; text-align: left;
  }
}

/* ── LEADERBOARD SPECIFICS ─────────────── */
.rank-badge {
  width: 34px; height: 34px; border-radius: 12px; display: flex; align-items: center; justify-content: center;
  font-weight: 900; font-size: 0.95rem; box-shadow: var(--shadow-sm);
}
.rank-1 { background: linear-gradient(135deg, var(--gold), #fbbf24); color: #451a03; }
.rank-2 { background: linear-gradient(135deg, #cbd5e1, #94a3b8); color: #0f172a; }
.rank-3 { background: linear-gradient(135deg, #b45309, #78350f); color: #fff; }
.rank-n { background: var(--surface2); color: var(--text-muted); }

.pts-big { font-size: 1.25rem; font-weight: 900; color: var(--gold); }

/* ── PROGRESS BAR ──────────────────────── */
.progress-wrap { background: var(--surface2); border-radius: 30px; height: 10px; overflow: hidden; margin-top: 1rem; width: 100%; }
.progress-bar { height: 100%; background: linear-gradient(90deg, var(--primary), var(--gold)); border-radius: 30px; transition: width 0.8s cubic-bezier(0.34, 1.56, 0.64, 1); }

/* ── TOAST ─────────────────────────────── */
#toast {
  position: fixed; bottom: 84px; left: 50%; transform: translateX(-50%) translateY(20px);
  padding: 1rem 1.5rem; border-radius: 16px; font-weight: 700; font-size: 0.9rem;
  z-index: 2000; opacity: 0; transition: all 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
  display: flex; align-items: center; gap: 8px; box-shadow: var(--shadow-lg); pointer-events: auto;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast.ok { background: var(--primary); color: #000; }
#toast.err { background: var(--red); color: #fff; }

/* ── MODAL ──────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.8); backdrop-filter: blur(8px);
  display: flex; align-items: center; justify-content: center; z-index: 2000; padding: 1rem;
}
.modal {
  width: 100%; max-width: 550px; border-radius: 24px; padding: 2rem; max-height: 85vh; overflow-y: auto;
  animation: modalScale 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes modalScale {
  from { transform: scale(0.9); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.modal-title { font-size: 1.25rem; font-weight: 800; margin-bottom: 1.5rem; display: flex; justify-content: space-between; align-items: center; }
.modal-close { cursor: pointer; color: var(--text-muted); padding: 5px; transition: 0.2s; }
.modal-close:hover { color: var(--red); transform: rotate(90deg); }

/* ── RESPONSIVE SMALL DEVICES ──────────── */
@media (max-width: 360px) {
  .matches-grid { grid-template-columns: 1fr; }
  .score-input { width: 40px; height: 40px; font-size: 1.1rem; }
  .team-name { font-size: 0.75rem; }
}

/* ── DEADLINE BANNER ───────────────────── */
.deadline-banner {
  border-radius: 16px; padding: 1.25rem; margin-bottom: 1.5rem;
  display: flex; align-items: center; gap: 1rem; animation: pulseBanner 2s infinite alternate;
}
@keyframes pulseBanner {
  from { border-color: rgba(245, 158, 11, 0.2); }
  to { border-color: rgba(245, 158, 11, 0.6); }
}
.deadline-banner.open { background: var(--primary-gl); border: 1.5px solid var(--primary); }
.deadline-banner.urgent { background: var(--gold-gl); border: 1.5px solid var(--gold); }
.deadline-banner.closed { background: rgba(239, 68, 68, 0.1); border: 1.5px solid var(--red); animation: none; }

.deadline-countdown { font-size: 1.1rem; font-weight: 800; color: var(--primary); }
.urgent .deadline-countdown { color: var(--gold); }

/* ── SAVE ALL BAR ─────────────────────── */
.save-bar {
  position: sticky; bottom: 84px; display: flex; justify-content: center; z-index: 50; pointer-events: none;
}
@media (min-width: 769px) { .save-bar { bottom: 1.5rem; } }

.save-bar-inner {
  background: var(--surface2); border: 1.5px solid var(--border-focus); border-radius: 40px;
  padding: 0.75rem 1.5rem; display: flex; align-items: center; gap: 1rem;
  pointer-events: all; box-shadow: var(--shadow-lg); backdrop-filter: blur(10px);
}
.save-progress { font-size: 0.8rem; color: var(--text-muted); font-weight: 600; }

/* ── FILTER BAR ────────────────────────── */
.filter-bar { display: flex; gap: 0.5rem; margin-bottom: 2rem; flex-wrap: wrap; }
.filter-bar input {
  flex: 1; min-width: 200px; padding: 0.8rem 1rem; background: var(--surface);
  border: 1.5px solid var(--border); border-radius: 12px; color: var(--text); font-family: inherit;
}
.filter-bar input:focus { outline: none; border-color: var(--primary); background: var(--surface2); }

.filter-btn {
  padding: 0.6rem 1.2rem; border: 1.5px solid var(--border); background: var(--surface);
  color: var(--text-muted); border-radius: 12px; cursor: pointer; font-size: 0.85rem;
  font-weight: 600; transition: all 0.2s; white-space: nowrap;
}
.filter-btn.active, .filter-btn:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-gl); }

/* ── ADMIN GRID ────────────────────────── */
.admin-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 1rem; }
.admin-match { background: var(--surface); border: 1.5px solid var(--border); border-radius: 20px; padding: 1.25rem; }
.admin-match-title { font-size: 0.85rem; font-weight: 800; margin-bottom: 1rem; color: var(--text-muted); }

.admin-score-row { display: flex; align-items: center; gap: 1rem; margin-bottom: 1rem; }
.admin-team { flex: 1; font-size: 0.9rem; font-weight: 700; }
.admin-input {
  width: 50px; height: 40px; text-align: center; background: var(--surface2); border: 1.5px solid var(--border);
  border-radius: 10px; color: #fff; font-weight: 800; font-size: 1.1rem;
}
.admin-input:focus { border-color: var(--gold); outline: none; }

/* ── MQ SUMMARY ────────────────────────── */
#mq-summary { display: flex; gap: 0.75rem; flex-wrap: wrap; }
.mq-summary-stat {
  background: var(--surface2); border: 1px solid var(--border); border-radius: 12px;
  padding: 0.75rem 1.25rem; text-align: center; flex: 1; min-width: 100px;
}
.mq-summary-stat .val { display: block; font-size: 1.25rem; font-weight: 800; line-height: 1.2; }

/* ── MISC MQ ──────────────────────────── */
.mq-score { font-weight: 800; color: var(--primary); }
.mq-score .sep { font-weight: 400; color: var(--text-muted); padding: 0 4px; }
.mq-badge { font-size: 0.65rem; padding: 2px 8px; border-radius: 6px; font-weight: 700; margin-top: 4px; display: inline-block; }
.mq-badge.exact { background: var(--gold-gl); color: var(--gold); }
.mq-badge.correct { background: var(--primary-gl); color: var(--primary); }
.mq-badge.wrong { background: rgba(239, 68, 68, 0.1); color: var(--red); }

.mq-pts { font-weight: 900; }
.mq-pts.exact { color: var(--gold); }
.mq-pts.correct { color: var(--primary); }
.mq-pts.wrong { color: var(--red); }
