/* ================= GLOBAL ================= */

body {
  font-family: 'Segoe UI', Arial, sans-serif;
  margin: 0;
  background: #f4f6f9;
  color: #333;
}

/* ================= HEADER ================= */

.main-header {
  background: #111827;
  padding: 1rem 2rem;
  box-shadow: 0 2px 6px rgba(0,0,0,0.1);
}

.header-container {
  max-width: 1200px;
  margin: auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.logo {
  color: #fbbf24;
  font-weight: bold;
  cursor: pointer;
  font-size: 1.3rem;
  letter-spacing: 1px;
}

.auth-area {
  display: flex;
  gap: 10px;
}

/* ================= BUTTONS ================= */

.primary-btn,
.secondary-btn {
  border: none;
  padding: 10px 16px;
  cursor: pointer;
  border-radius: 6px;
  font-size: 0.9rem;
  transition: all 0.2s ease;
}

.primary-btn {
  background: #2563eb;
  color: white;
}

.primary-btn:hover {
  background: #1e40af;
}

.secondary-btn {
  background: #374151;
  color: white;
}

.secondary-btn:hover {
  background: #111827;
}

/* ================= SECTION ================= */

.section,
.admin-section {
  max-width: 1000px;
  margin: 40px auto;
  padding: 30px;
  background: white;
  border-radius: 12px;
  box-shadow: 0 5px 20px rgba(0,0,0,0.05);
}

/* ================= INPUTS ================= */

input {
  padding: 10px 12px;
  border-radius: 6px;
  border: 1px solid #d1d5db;
  font-size: 0.9rem;
  outline: none;
  transition: border 0.2s ease;
}

input:focus {
  border: 1px solid #2563eb;
}

/* ================= MODAL ================= */

.modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  padding: 20px;
}

.modal-content {
  background: white;
  width: 100%;
  max-width: 400px;
  margin: 10% auto;
  padding: 30px;
  border-radius: 12px;
  text-align: center;
  box-shadow: 0 10px 30px rgba(0,0,0,0.15);
}

.modal-content input {
  width: 100%;
  margin: 10px 0;
}

/* ================= ADMIN NAVIGATION ================= */

.admin-nav {
  max-width: 1000px;
  margin: 30px auto 0;
  display: flex;
  justify-content: center;
  gap: 15px;
  flex-wrap: wrap;
}

.admin-nav button {
  padding: 10px 20px;
  border-radius: 25px;
  border: 1px solid #e5e7eb;
  background: white;
  cursor: pointer;
  font-weight: 500;
  transition: all 0.2s ease;
}

.admin-nav button:hover {
  background: #2563eb;
  color: white;
  border-color: #2563eb;
}

/* ================= ADMIN BOX ================= */

.admin-box {
  max-width: 400px;
  margin: 20px auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* ================= USERS LIST ================= */

.users-list {
  margin-top: 30px;
  display: flex;
  flex-direction: column;
  gap: 15px;
}

.user-card {
  background: #f9fafb;
  padding: 18px;
  border-radius: 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border: 1px solid #e5e7eb;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.user-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 15px rgba(0,0,0,0.05);
}

/* ================= TEXT ================= */

h2 {
  margin-top: 0;
  font-weight: 600;
}

/* ================= HIDDEN ================= */

.hidden {
  display: none !important;
}

/* ================= RESPONSIVE ================= */

@media (max-width: 768px) {

  .header-container {
    flex-direction: column;
    gap: 10px;
    text-align: center;
  }

  .admin-nav {
    gap: 10px;
  }

  .user-card {
    flex-direction: column;
    gap: 10px;
    text-align: center;
  }

  .section,
  .admin-section {
    margin: 20px;
    padding: 20px;
  }

}

/* ================= MAIN NAV ================= */

.main-nav {
  display: flex;
  gap: 25px;
}

.nav-link {
  text-decoration: none;
  color: #e5e7eb;
  font-weight: 500;
  transition: color 0.2s ease;
}

.nav-link:hover {
  color: #fbbf24;
}

/* ================= FIX TEXT COLORS ================= */

/* Make header text visible again */
.welcome-text {
  color: #e5e7eb;
  font-weight: 500;
}

/* Navigation links fix */
.nav-link {
  text-decoration: none;
  color: #e5e7eb;
  font-weight: 500;
  padding: 6px 10px;
  border-radius: 6px;
}

.nav-link:hover {
  color: #fbbf24;
  background: rgba(255,255,255,0.05);
}

.main-nav a {
  text-decoration: none;
  color: #e5e7eb;
  font-weight: 500;
  padding: 6px 10px;
  border-radius: 6px;
  transition: 0.2s ease;
}

.main-nav a:hover {
  color: #fbbf24;
  background: rgba(255, 255, 255, 0.08);
}

/* ================= PAGE SECTION ================= */

.page-section {
  max-width: 1000px;
  margin: 30px auto;
  padding: 0 20px;
}

/* hidden pages */
.page-section.hidden {
  display: none;
}

/* visible page */
.page-section:not(.hidden) {
  display: block;
}

/* ================= PAGE BOX ================= */

.page-box {
  background: white;
  color: #111827;
  padding: 30px;
  border-radius: 12px;
  box-shadow: 0 5px 20px rgba(0,0,0,0.08);
}

/* PAGE TITLES */

.page-box h2 {
  color: #111827;
  margin-bottom: 25px;
}

/* ================= PAGE SECTION ================= */

.page-section {
  max-width: 1000px;
  margin: 30px auto;
  padding: 0 20px;
}

/* hidden pages */
.page-section.hidden {
  display: none;
}

#welcomeText {
  color: #f9fafb;
  font-weight: 500;
  margin-right: 10px;
  letter-spacing: 0.3px;
}

/* ================= LEADERBOARD TABLE FIX ================= */

.leaderboard-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 20px;
  background: #ffffff;
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 4px 15px rgba(0,0,0,0.08);

  /* IMPORTANT FIX */
  color: #111827; /* ensures text is visible */
}

/* HEADER */
.leaderboard-table thead {
  background: #111827;
  color: #ffffff;
}

.leaderboard-table th {
  color: #ffffff !important;
  padding: 14px 12px;
  text-align: left;
  font-size: 0.9rem;
  letter-spacing: 0.5px;
}

/* BODY TEXT */
.leaderboard-table td {
  padding: 12px;
  border-bottom: 1px solid #e5e7eb;
  font-size: 0.95rem;
  color: #111827; /* FIX: force visible text */
}

/* STRIPED ROWS */
.leaderboard-table tbody tr:nth-child(even) {
  background: #f9fafb;
}

/* HOVER */
.leaderboard-table tbody tr:hover {
  background: #eef2ff;
}

/* RANK COLUMN */
.leaderboard-table td:first-child {
  font-weight: bold;
  color: #2563eb;
}

/* ================= CENTER ALIGN LEADERBOARD TABLE ================= */

.leaderboard-table th,
.leaderboard-table td {
  text-align: center;
  vertical-align: middle;
}

/* ================= MOBILE RESPONSIVE IMPROVEMENTS ================= */

@media (max-width: 768px) {

  /* HEADER STACK */
  .header-container {
    flex-direction: column;
    align-items: center;
    gap: 12px;
  }

  .main-nav {
    flex-wrap: wrap;
    justify-content: center;
    gap: 12px;
  }

  .main-nav a {
    font-size: 0.9rem;
    padding: 6px 8px;
  }

  #welcomeText {
    font-size: 0.9rem;
  }

  /* PAGE BOX */
  .page-box {
    padding: 20px;
  }

  .page-box h2 {
    font-size: 1.2rem;
  }

  /* SECTION CONTAINER */
  .page-section {
    margin: 15px;
    padding: 0;
  }

  /* TABLE WRAPPER (IMPORTANT) */
  .table-wrapper {
    width: 100%;
    overflow-x: auto;
  }

  /* TABLE */
  .leaderboard-table {
    min-width: 600px; /* prevents squishing */
    font-size: 0.85rem;
  }

  .leaderboard-table th,
  .leaderboard-table td {
    padding: 10px 8px;
  }
}

/* EXTRA SMALL PHONES */
@media (max-width: 480px) {

  .logo {
    font-size: 1rem;
  }

  .main-nav a {
    font-size: 0.8rem;
  }

  .leaderboard-table {
    font-size: 0.8rem;
  }

}

/* ================= ADMIN RESPONSIVE IMPROVEMENTS ================= */

@media (max-width: 768px) {

  /* ADMIN NAV BUTTONS */
  .admin-nav {
    flex-wrap: wrap;
    gap: 10px;
    padding: 0 15px;
  }

  .admin-nav button {
    flex: 1 1 45%;
    font-size: 0.85rem;
    padding: 10px;
  }

  /* ADMIN SECTIONS */
  .admin-section {
    margin: 20px 15px;
    padding: 20px;
  }

  /* CREATE USER BOX */
  .admin-box {
    width: 100%;
    max-width: 100%;
  }

  .admin-box input {
    width: 100%;
  }

  .admin-box button {
    width: 100%;
  }

  /* USERS LIST CARDS */
  .user-card {
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 10px;
  }

}

/* EXTRA SMALL PHONES */
@media (max-width: 480px) {

  .admin-nav button {
    flex: 1 1 100%;
  }

  .logo {
    font-size: 1rem;
  }

  h2 {
    font-size: 1.2rem;
  }

}

/* ================= FIFA MATCH GRID ================= */

.matches-container {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
  gap: 24px;
  padding: 15px;
  margin-top: 20px;
}

/* ================= MATCH CARD ================= */

.match-card {
  background: linear-gradient(135deg, #0a1f44, #102b63);
  color: #ffffff;
  border-radius: 18px;
  padding: 25px 20px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.35);
  transition: 0.3s ease;
  text-align: center;
  position: relative;
  overflow: hidden;
}

.match-card:hover {
  transform: translateY(-6px);
  box-shadow: 0 14px 35px rgba(0,0,0,0.45);
}

/* ================= MATCH NUMBER ================= */

.match-header {
  font-size: 13px;
  letter-spacing: 1px;
  font-weight: 600;
  opacity: 0.85;
  margin-bottom: 15px;
}

/* ================= DATE & GROUP ================= */

.match-info p {
  margin: 4px 0;
  font-size: 13px;
  opacity: 0.85;
}

/* ================= TEAMS STYLE ================= */

.match-info p:last-child {
  font-size: 20px;
  font-weight: 700;
  margin-top: 18px;
  letter-spacing: 0.5px;
}

/* ================= PREDICTION SECTION ================= */

.prediction-row {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 12px;
  margin-top: 22px;
  flex-wrap: wrap;
}

/* Score Inputs */

.prediction-row input {
  width: 60px;
  height: 45px;
  border-radius: 10px;
  border: none;
  font-size: 18px;
  font-weight: bold;
  text-align: center;
  background: #ffffff;
  color: #0a1f44;
  outline: none;
}

/* Save Button */

.primary-btn {
  background: #ffcc00;
  color: #0a1f44;
  border: none;
  padding: 10px 16px;
  border-radius: 10px;
  font-weight: 700;
  cursor: pointer;
  transition: 0.2s ease;
}

.primary-btn:hover {
  background: #ffd633;
}

/* ================= LOCKED TEXT ================= */

.match-card b {
  color: #ffcc00;
}

/* ================= RESPONSIVE ================= */

/* Tablet */
@media (max-width: 992px) {
  .matches-container {
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  }
}

/* Mobile */
@media (max-width: 600px) {

  .matches-container {
    grid-template-columns: 1fr;
  }

  .match-card {
    padding: 20px 15px;
  }

  .match-info p:last-child {
    font-size: 18px;
  }

  .prediction-row input {
    width: 55px;
    height: 42px;
    font-size: 16px;
  }

  .primary-btn {
    padding: 8px 14px;
    font-size: 14px;
  }
}

/* Small phones */
@media (max-width: 400px) {

  .match-info p:last-child {
    font-size: 16px;
  }

  .prediction-row input {
    width: 50px;
    height: 38px;
    font-size: 15px;
  }
}

/* ================= PREDICTION TABLE ================= */

#predictionTable {
  max-height: 400px;
  overflow-y: auto;
}

.pred-table {
  width: 100%;
  border-collapse: collapse;
}

.pred-table th,
.pred-table td {
  padding: 10px;
  border-bottom: 1px solid #eee;
  text-align: center;
}

.pred-table th {
  background: #111827;
  color: white;
}

/* ===== Prediction Table Responsive Fix ===== */

.pred-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 500px; /* prevents squishing */
}

.pred-table th,
.pred-table td {
  padding: 10px;
  text-align: center;
  border: 1px solid #ddd;
}

#predictionTable {
  overflow-x: auto;
}

/* Final score box styling */
.final-score-box {
  margin-bottom: 15px;
  padding: 10px;
  background: #f4f6f9;
  border-radius: 6px;
  text-align: center;
  font-weight: bold;
}

@media (max-width: 480px) {
  .pred-table th,
  .pred-table td {
    padding: 6px;
    font-size: 13px;
  }
}

/* ================= BRACKET STAGE UI ================= */

#bracketContainer {
  margin-top: 20px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* GROUP CARD */
.bracket-group {
  background: #111827;
  color: #ffffff;
  padding: 18px;
  border-radius: 12px;
  box-shadow: 0 6px 18px rgba(0,0,0,0.15);
  text-align: left;
}

/* GROUP TITLE */
.bracket-group h3 {
  margin: 0 0 12px 0;
  color: #fbbf24;
  font-size: 1.1rem;
}

/* LABELS */
.bracket-group label {
  display: block;
  margin-top: 10px;
  font-size: 0.85rem;
  color: #e5e7eb;
}

/* DROPDOWNS FIX (IMPORTANT) */
.bracket-group select {
  width: 100%;
  padding: 10px;
  margin-top: 6px;
  border-radius: 8px;
  border: 1px solid #374151;
  background: #ffffff;   /* FIX WHITE VISIBILITY */
  color: #111827;        /* FIX TEXT VISIBILITY */
  font-size: 0.9rem;
  outline: none;
  cursor: pointer;
}

.bracket-group select:focus {
  border-color: #fbbf24;
}

/* ================= BEST 3RD SECTION ================= */

#thirdContainer {
  margin-top: 15px;
}

/* TEAM CHECKBOX CARDS */
.third-team {
  background: #ffffff;   /* FIXED (was invisible issue) */
  color: #111827;        /* FIXED text visibility */
  padding: 10px;
  border-radius: 10px;
  border: 1px solid #e5e7eb;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.9rem;
  cursor: pointer;
  transition: 0.2s ease;
}

.third-team:hover {
  background: #f3f4f6;
  transform: translateY(-2px);
}

/* CHECKBOX SIZE */
.third-team input {
  transform: scale(1.2);
  cursor: pointer;
}

/* COUNTER TEXT */
#thirdCount {
  margin-top: 12px;
  font-weight: 600;
  color: #111827;
}

/* SAVE BUTTON FIX */
#bracket button.primary-btn {
  margin-top: 20px;
  width: 100%;
  padding: 12px;
  font-size: 1rem;
}

/* ================= GROUP CARD MODERN UI ================= */

.group-teams {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 10px;
}

/* TEAM ROW */
.team-row {
  background: #ffffff;
  color: #111827;
  padding: 10px 12px;
  border-radius: 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: 0.2s ease;
  border: 1px solid #e5e7eb;
}

.team-row:hover {
  transform: translateY(-2px);
  background: #f9fafb;
}

/* TEAM NAME */
.team-name {
  font-weight: 600;
}

/* BUTTONS */
.team-actions {
  display: flex;
  gap: 6px;
}

.mini-btn {
  border: none;
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 0.75rem;
  cursor: pointer;
  font-weight: 600;
}

.first-btn {
  background: #2563eb;
  color: white;
}

.second-btn {
  background: #f59e0b;
  color: white;
}

/* SELECTION PREVIEW */
.selection-preview {
  margin-top: 10px;
  color: #e5e7eb;
}

/* ================= CLEAN GROUP UI ================= */

.team-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 10px;
  margin-top: 12px;
}

/* TEAM BUTTON STYLE */
.team-pill {
  background: #ffffff;
  color: #111827;
  padding: 10px;
  border-radius: 10px;
  text-align: center;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid #e5e7eb;
  transition: 0.2s ease;
}

.team-pill:hover {
  transform: translateY(-2px);
  background: #f3f4f6;
}

/* SELECTED STATES */
.team-pill.first {
  background: #2563eb;
  color: white;
}

.team-pill.second {
  background: #f59e0b;
  color: white;
}

/* GROUP CARD */
.bracket-group {
  background: #111827;
  color: white;
  padding: 18px;
  border-radius: 12px;
  margin-bottom: 20px;
}

.selection-preview {
  margin-top: 10px;
  color: #e5e7eb;
}

#bracketContainer > div {
  background: #111827;
  color: white;
  padding: 18px;
  border-radius: 12px;
  margin-bottom: 20px;
  box-shadow: 0 6px 18px rgba(0,0,0,0.15);
}

#bracketContainer select {
  width: 100%;
  padding: 10px;
  margin-top: 6px;
  border-radius: 8px;
  border: 1px solid #374151;
  background: #ffffff;
  color: #111827;
  font-size: 0.9rem;
  outline: none;
  cursor: pointer;
  transition: 0.2s ease;
}

#bracketContainer select:hover {
  border-color: #fbbf24;
}

#bracketContainer select:focus {
  border-color: #fbbf24;
  box-shadow: 0 0 0 2px rgba(251,191,36,0.2);
}

#bracketContainer label {
  display: block;
  margin-top: 10px;
  font-size: 0.85rem;
  color: #e5e7eb;
  font-weight: 500;
}

* {
  box-sizing: border-box;
}

html, body {
  max-width: 100%;
  overflow-x: hidden;
}

select, input, button {
  max-width: 100%;
}

.admin-box {
  width: 100%;
  overflow: hidden;
}

@media (max-width: 768px) {

  .admin-box {
    padding: 15px;
  }

  .admin-box select {
    width: 100%;
  }

}

#r32Container,
#r16Container,
#qfContainer,
#sfContainer,
#finalContainer {
  overflow-x: auto;
}

@media (max-width: 600px) {

  .modal-content {
    margin: 20% auto;
    padding: 20px;
    width: 95%;
  }

}

@media (max-width: 600px) {

  .modal-content {
    margin: 20% auto;
    padding: 20px;
    width: 95%;
  }

}

.admin-box,
.user-card,
.match-card {
  word-wrap: break-word;
  overflow-wrap: break-word;
}

select {
  min-height: 42px;
}

select {
  min-height: 42px;
}

.table-wrapper,
#predictionTable {
  width: 100%;
  overflow-x: auto;
}

/* ================= RULES PAGE ================= */

#rules .page-box {
  background: white;
  color: #111827;
  text-align: left;
}

.rules-box {
  max-width: 850px;
  margin: 0 auto;
  line-height: 1.7;
}

.rules-box h3 {
  color: #2563eb;
  margin-top: 25px;
  margin-bottom: 10px;
  font-size: 1.05rem;
}

.rules-box ul {
  padding-left: 20px;
}

.rules-box li {
  margin-bottom: 8px;
  color: #374151;
  font-size: 0.95rem;
}

.rules-box hr {
  border: none;
  border-top: 1px solid #e5e7eb;
  margin: 20px 0;
}

.page-title {
  text-align: center;
  font-size: 2rem;
  font-weight: 700;
  margin-bottom: 25px;
  color: #111827;
}

.rules-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 20px;
  margin-top: 20px;
}

@media (max-width: 768px) {
  .rules-grid {
    grid-template-columns: 1fr;
  }

 .rule-card {
  background: #ffffff;
  border-radius: 12px;
  padding: 18px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.06);
}
  .page-title {
    font-size: 1.5rem;
  }
}

.rules-box {
  width: 100%;
  padding: 0 10px;
}


.rules-page {
  max-width: 900px;
  margin: auto;
}

.rules-content {
  text-align: left;
  line-height: 1.8;
  color: #111827;
}

.rules-content h3 {
  margin-top: 25px;
  font-size: 1.2rem;
  color: #111827;
}

.rules-content p {
  margin: 10px 0;
  color: #374151;
}

.rules-content ul {
  padding-left: 20px;
}

.rules-content li {
  margin-bottom: 8px;
  color: #374151;
}

.rules-content hr {
  margin: 20px 0;
  border: none;
  border-top: 1px solid #e5e7eb;
}

/* MOBILE */
@media (max-width: 600px) {

  .rules-content {
    font-size: 0.95rem;
  }

  .rules-page {
    padding: 0 10px;
  }

}

/* ================= HEADER LEFT ================= */

.header-left {
  display: flex;
  align-items: center;
  gap: 15px;
  flex-wrap: wrap;
}

/* ================= BACK BUTTON ================= */

.back-home-btn {
  text-decoration: none;
  background: #fbbf24;
  color: #111827;
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 700;
  transition: 0.2s ease;
}

.back-home-btn:hover {
  background: #fcd34d;
  transform: translateY(-1px);
}

/* ================= MOBILE ================= */

@media (max-width: 768px) {

  .header-left {
    justify-content: center;
    flex-direction: column;
    gap: 10px;
  }

  .back-home-btn {
    width: 100%;
    text-align: center;
  }

}