body {
    margin: 0;
    font-family: Arial, sans-serif;
    background: #0f172a;
    color: #e2e8f0;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 40px 16px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='80' height='80' viewBox='0 0 40 40'%3E%3Cg fill-rule='evenodd'%3E%3Cg fill='%23bcbd81' fill-opacity='1'%3E%3Cpath d='M0 38.59l2.83-2.83 1.41 1.41L1.41 40H0v-1.41zM0 1.4l2.83 2.83 1.41-1.41L1.41 0H0v1.41zM38.59 40l-2.83-2.83 1.41-1.41L40 38.59V40h-1.41zM40 1.41l-2.83 2.83-1.41-1.41L38.59 0H40v1.41zM20 18.6l2.83-2.83 1.41 1.41L21.41 20l2.83 2.83-1.41 1.41L20 21.41l-2.83 2.83-1.41-1.41L18.59 20l-2.83-2.83 1.41-1.41L20 18.59z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
}

h1 {
    font-size: 36px;
    margin-bottom: 30px;
    letter-spacing: 1px;
}

/* =========================
   INDEX GRID
   ========================= */

.grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 20px;
    width: 100%;
    max-width: 1000px;
}

.card {
    position: relative;
    background: #1e293b;
    border-radius: 12px;
    padding: 16px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.3);
}

.category-title {
    font-size: 20px;
    font-weight: bold;
    margin-bottom: 10px;
    border-bottom: 1px solid #334155;
    padding-bottom: 6px;

    /* leave room for Play button */
    padding-right: 100px;
}

.scoreboard {
    font-size: 14px;
    line-height: 1.6;
}

.row {
    display: flex;
    justify-content: space-between;
    padding: 4px 0;
    border-bottom: 1px dashed #334155;
}

.rank {
    color: #38bdf8;
    font-weight: bold;
}

.score {
    color: #22c55e;
    font-weight: bold;
}

.play-btn {
    position: absolute;
    top: 5px;
    right: 5px;
    background: #22c55e;
    color: white;
    border: none;
    padding: 8px 14px;
    border-radius: 8px;
    font-weight: bold;
    cursor: pointer;
    transition: 0.2s;
    margin-bottom: 10px;
    border-bottom: 1px solid #334155;
    padding-bottom: 6px;
}

.play-btn:hover {
    opacity: 0.9;
}

/* =========================
   QUIZ PAGE
   ========================= */

.quiz-card {
    width: 100%;
    max-width: 600px;
}

.quiz-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    margin-bottom: 15px;
}

.btn {
    width: 100%;
    padding: 10px;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    font-weight: bold;
    margin-top: 10px;
}

.primary {
    background: #3b82f6;
    color: white;
}

.primary:hover {
    background: #2563eb;
}

.secondary {
    background: #334155;
    color: white;
}

.secondary:hover {
    background: #475569;
}

.success {
    background: #22c55e;
    color: white;
}

.success:hover {
    opacity: 0.9;
}

.results {
    margin-top: 20px;
}

.question-box {
    background: #facc15;
    color: black;
    padding: 12px;
    border-radius: 8px;
    margin-bottom: 10px;
}

.options-box {
    background: #3b82f6;
    padding: 12px;
    border-radius: 8px;
}

.answer-box {
    background: #22c55e;
    color: black;
    padding: 12px;
    border-radius: 8px;
    margin-top: 10px;
}

.question-counter {
    margin-top: 5px;
    font-size: 14px;
    color: #94a3b8;
}

.quiz-timer {
    font-size: 16px;
    font-weight: bold;
    color: #38bdf8;
    text-align: right;
    min-width: 60px;
}

/* =========================
   ANSWER OPTIONS
   ========================= */

.option {
    background: #334155;
    padding: 10px;
    margin: 6px 0;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.25s ease;
}

.option:hover {
    background: #475569;
    transform: scale(1.02);
}

.option.selected {
    outline: 2px solid #000000;
}

.option.correct {
    background: #22c55e;
    color: black;
    animation: pop 0.3s ease;
}

.option.wrong {
    background: #ef4444;
    color: white;
    animation: shake 0.3s ease;
}

@keyframes pop {
    0% { transform: scale(0.95); }
    100% { transform: scale(1); }
}

@keyframes shake {
    0% { transform: translateX(0); }
    25% { transform: translateX(-4px); }
    50% { transform: translateX(4px); }
    75% { transform: translateX(-4px); }
    100% { transform: translateX(0); }
}


/* =========================
   FOOTERS
   ========================= */

.footer {
    margin-top: 40px;
    font-size: 12px;
    color: #94a3b8;
}

.footer-links {
    margin-top: 10px;
    font-size: 12px;
    color: #94a3b8;
}

.footer-links a {
    margin: 0 8px;
    color: #60a5fa;
    text-decoration: none;
}

.footer-links a:hover {
    text-decoration: underline;
}


/* =========================
   END SCREEN
   ========================= */

.end-overlay {
  position: fixed;
  inset: 0;

  background: rgba(0,0,0,0.7);

  display: flex;
  justify-content: center;
  align-items: center;

  z-index: 9999;

  animation: fadeIn 0.3s ease;
}

.end-card {
  background: #1e293b;

  padding: 32px;
  border-radius: 16px;

  text-align: center;

  width: 90%;
  max-width: 450px;

  box-shadow: 0 0 25px rgba(0,0,0,0.5);

  animation: scaleIn 0.3s ease;
}

.end-card h2 {
  margin-top: 0;
  color: #22c55e;
}

.end-card p {
  font-size: 20px;
  margin: 20px 0;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes scaleIn {
  from {
    transform: scale(0.9);
    opacity: 0;
  }

  to {
    transform: scale(1);
    opacity: 1;
  }
}

.leaderboard-card {
    width: 100%;
    max-width: 500px;
    margin-top: 30px;
}

.row {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr;
  padding: 10px;
  border-bottom: 1px solid rgba(0,0,0,0.1);
  transition: 0.2s;
}

/* 🥇🥈🥉 top 3 */
.rank-1 {
  background: rgba(255, 215, 0, 0.15); /* gold */
  font-weight: bold;
}

.rank-2 {
  background: rgba(192, 192, 192, 0.15); /* silver */
  font-weight: bold;
}

.rank-3 {
  background: rgba(205, 127, 50, 0.15); /* bronze */
  font-weight: bold;
}

/* 4–20 */
.rank-top20 {
  background: rgba(0, 200, 255, 0.08);
}

/* 21–50 */
.rank-top50 {
  background: rgba(0, 255, 120, 0.06);
}

/* 51–100 */
.rank-top100 {
  background: rgba(255, 200, 0, 0.05);
}

.top-bar {
  width: 100%;
  max-width: 1000px;
  display: flex;
  justify-content: flex-end;
  margin-bottom: 10px;
}

.profile-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;

  padding: 10px 16px;

  border: none;
  border-radius: 999px;

  font-size: 1rem;
  font-weight: 700;

  cursor: pointer;

  color: white;

  background: rgba(255,255,255,0.12);

  backdrop-filter: blur(8px);

  transition:
    transform 0.2s ease,
    background 0.2s ease,
    box-shadow 0.2s ease;
}

.profile-btn:hover {
  transform: scale(1.08);

  background: rgba(255,255,255,0.2);

  box-shadow:
    0 0 15px rgba(255,255,255,0.2);
}

@keyframes glow {
  from {
    filter: drop-shadow(0 0 2px rgba(255,215,0,0.4));
  }

  to {
    filter: drop-shadow(0 0 10px rgba(255,152,0,0.7));
  }
}

.header {
  display: grid;
  grid-template-columns: 60px 1fr 60px;

  align-items: center;

  margin-bottom: 30px;
  padding: 20px 0;
}

.hidden {
  display: none;
}

#auth-view, #profile-view {
  max-width: 500px;
  margin: 40px auto;
  text-align: center;
}

input {
  padding: 6px;
  margin-left: 8px;
}

.badge {
  display: inline-block;
  padding: 6px 10px;
  margin: 4px;
  border-radius: 12px;
  background: rgba(0,0,0,0.1);
  font-size: 12px;
}

.streak {
  display: inline-block;
  padding: 6px 10px;
  margin: 4px;
  border-radius: 12px;
  background: rgba(0,0,0,0.1);
  font-size: 12px;
}

.main-title {
  margin: 0;

  font-size: 3rem;
  font-weight: 800;
  letter-spacing: 2px;

  background: linear-gradient(
    90deg,
    #ffd700,
    #ff9800,
    #ff5722
  );

  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;

  text-shadow:
    0 2px 10px rgba(255, 152, 0, 0.25);

  animation: glow 3s ease-in-out infinite alternate;
}
.auth-overlay {
  position: fixed;
  inset: 0;

  display: flex;
  align-items: center;
  justify-content: center;

  background: rgba(0,0,0,0.55);

  backdrop-filter: blur(6px);

  z-index: 9999;
}

.auth-popup {
  width: min(420px, 90%);

  padding: 32px;

  border-radius: 24px;

  text-align: center;

  background: rgba(25,25,35,0.95);

  border: 1px solid rgba(255,255,255,0.08);

  box-shadow:
    0 20px 60px rgba(0,0,0,0.4);

  animation: popupIn 0.25s ease;
}

.auth-popup h2 {
  margin-top: 0;
  margin-bottom: 12px;

  font-size: 2rem;
}

.auth-popup p {
  margin-bottom: 24px;

  color: rgba(255,255,255,0.75);

  line-height: 1.5;
}

.hidden {
  display: none;
}

@keyframes popupIn {
  from {
    opacity: 0;
    transform: scale(0.92);
  }

  to {
    opacity: 1;
    transform: scale(1);
  }
}
.floating-profile {
  position: fixed;

  top: 20px;
  right: 20px;

  z-index: 1000;
}
.profile-info {
  width: 100%;
  margin-bottom: 30px;
  border-collapse: collapse;
}

.profile-info td {
  padding: 10px;
}
.table-wrapper {
  width: 100%;
  overflow-x: auto;
  margin-top: 20px;
}

.badges-table {
  width: max-content;
  min-width: 100%;
  border-collapse: collapse;
}

.badges-table th,
.badges-table td {
  padding: 12px;
  border-bottom: 1px solid #334155;
  white-space: nowrap;
}

.badges-table th {
  background: #1e293b;
  text-align: left;
}

.badge-group {
  display: flex;
  gap: 6px;
}

.badge-slot {
  display: inline-flex;

  justify-content: center;
  align-items: center;

  min-width: 48px;
  height: 36px;

  border-radius: 18px;

  font-size: 12px;
  font-weight: bold;

  padding: 0 10px;
}

.badge-earned {
  background: #22c55e;
  color: white;
}

.badge-locked {
  background: #334155;
  color: #94a3b8;
}
.streak-value {
  display: inline-block;

  min-width: 70px;

  text-align: center;

  padding: 6px 12px;

  border-radius: 999px;

  background: rgba(34, 197, 94, 0.15);

  color: #22c55e;

  font-weight: bold;
}
.play-btn.results-btn {
  background: #64748b; /* slate gray */
}

.play-btn.results-btn:hover {
  background: #475569;
}
.results-modal {
  position: fixed;
  inset: 0;

  display: flex;
  justify-content: center;
  align-items: center;

  background: rgba(0,0,0,0.65);

  z-index: 10000;
}

.results-card {
  background: #1e293b;

  padding: 30px;

  border-radius: 16px;

  min-width: 320px;

  text-align: center;

  box-shadow: 0 0 25px rgba(0,0,0,0.4);
}

.results-card h2 {
  margin-top: 0;
}

.hidden {
  display: none;
}