:root {
  --bg: #1b1033;
  --bg-grad-a: #2b1055;
  --bg-grad-b: #7597de;
  --card: #ffffff;
  --card-text: #241b3c;
  --muted: #6b6280;
  --accent: #ff6b35;
  --correct: #22c55e;
  --incorrect: #ef4444;
  --radius: 18px;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: linear-gradient(135deg, var(--bg-grad-a), var(--bg) 45%, var(--bg-grad-b));
  color: #fff;
}

.app-header {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 20px 20px 0;
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(27, 16, 51, 0.85);
  backdrop-filter: blur(8px);
}

.brand {
  font-size: 2.2rem;
  font-weight: 800;
  letter-spacing: -0.5px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.brand-mascot {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  flex-shrink: 0;
}

.tabs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 14px;
}

.tab-btn {
  flex: 0 0 auto;
  padding: 10px 18px;
  border-radius: 999px;
  border: 2px solid transparent;
  background: rgba(255,255,255,0.08);
  color: #fff;
  font-weight: 700;
  font-size: 0.95rem;
  cursor: pointer;
  transition: transform 0.15s ease, background 0.15s ease;
  white-space: nowrap;
}

@media (hover: hover) and (pointer: fine) {
  .tab-btn:hover { transform: translateY(-1px); background: rgba(255,255,255,0.16); }
}

.tab-btn.active {
  background: var(--tab-color, var(--accent));
  border-color: rgba(255,255,255,0.4);
  color: #1b1033;
}

main#app {
  max-width: 820px;
  margin: 0 auto;
  padding: 24px 20px 80px;
}

/* ---- Cards / Daily overview ---- */

.daily-hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  margin-bottom: 20px;
  text-align: center;
}

.daily-hero .hero-mascot {
  width: 140px;
  height: 140px;
}

.daily-hero .hero-tagline {
  font-weight: 700;
  color: rgba(255,255,255,0.85);
}

.lifetime-banner {
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.18);
  border-radius: 14px;
  padding: 14px 20px;
  margin-bottom: 20px;
}

.lifetime-banner-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.lifetime-banner .label {
  font-weight: 700;
  font-size: 0.9rem;
  color: rgba(255,255,255,0.85);
}

.lifetime-banner .value {
  font-weight: 900;
  font-size: 1.3rem;
}

.section-title {
  font-size: 1.3rem;
  font-weight: 800;
  margin: 6px 0 16px;
  text-align: center;
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 16px;
}

.category-card {
  background: var(--card);
  color: var(--card-text);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.25);
  border-top: 6px solid var(--cat-color, var(--accent));
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.category-card h3 {
  margin: 0;
  font-size: 1.15rem;
  display: flex;
  align-items: center;
  gap: 8px;
}

.category-card .stat-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.85rem;
  color: var(--muted);
}

.category-card .streak {
  font-weight: 800;
  color: var(--card-text);
}

.btn {
  border: none;
  border-radius: 999px;
  padding: 12px 20px;
  font-weight: 800;
  font-size: 0.95rem;
  cursor: pointer;
  transition: transform 0.1s ease, filter 0.15s ease;
}

@media (hover: hover) and (pointer: fine) {
  .btn:hover { filter: brightness(1.08); }
}
.btn:active { transform: scale(0.97); }

.btn-primary {
  background: var(--cat-color, var(--accent));
  color: #1b1033;
}

.btn-secondary {
  background: #f1f0f6;
  color: var(--card-text);
}

.btn-block { width: 100%; }

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

.locked-note {
  font-size: 0.85rem;
  color: var(--muted);
  text-align: center;
  padding: 8px;
  background: #f7f6fb;
  border-radius: 10px;
}

.share-section {
  margin-top: 18px;
  display: flex;
  justify-content: center;
}

.share-section .btn {
  max-width: 320px;
}

.share-toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%) translateY(12px);
  background: var(--card);
  color: var(--card-text);
  font-weight: 700;
  font-size: 0.9rem;
  padding: 12px 22px;
  border-radius: 999px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.35);
  opacity: 0;
  transition: opacity 0.25s ease, transform 0.25s ease;
  z-index: 100;
}

.share-toast.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ---- Category unlimited view ---- */

.category-hero {
  background: var(--card);
  color: var(--card-text);
  border-radius: var(--radius);
  padding: 24px;
  border-top: 6px solid var(--cat-color, var(--accent));
  margin-bottom: 20px;
}

.category-hero h2 {
  margin: 0 0 6px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.category-hero .sub {
  color: var(--muted);
  margin-bottom: 16px;
}

.hero-stats {
  display: flex;
  gap: 24px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}

.hero-stat {
  display: flex;
  flex-direction: column;
}

.hero-stat .label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--muted);
}

.hero-stat .value {
  font-size: 1.4rem;
  font-weight: 800;
}

.button-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

/* ---- Quiz play screen ---- */

.quiz-card {
  background: var(--card);
  color: var(--card-text);
  border-radius: var(--radius);
  padding: 26px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.3);
}

.quiz-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 10px;
  font-weight: 700;
}

.turn-banner {
  background: var(--cat-color, var(--accent));
  color: #1b1033;
  border-radius: 12px;
  padding: 8px 14px;
  font-weight: 800;
  margin-bottom: 14px;
  display: inline-block;
}

.tiebreaker-banner {
  background: linear-gradient(90deg, #ff2d78, #ff6b35);
  color: #fff;
  border-radius: 12px;
  padding: 10px 14px;
  font-weight: 800;
  margin-bottom: 14px;
  text-align: center;
}

.progress-bar {
  height: 8px;
  background: #eee;
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 20px;
}

.progress-fill {
  height: 100%;
  background: var(--cat-color, var(--accent));
  transition: width 0.25s ease;
}

.question-text {
  font-size: 1.3rem;
  font-weight: 800;
  margin-bottom: 20px;
  line-height: 1.35;
}

.options-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

.option-btn {
  text-align: left;
  padding: 14px 16px;
  border-radius: 14px;
  border: 2px solid #e6e4ee;
  background: #fafafe;
  color: var(--card-text);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

@media (hover: hover) and (pointer: fine) {
  .option-btn:hover:not(:disabled) {
    border-color: var(--cat-color, var(--accent));
    transform: translateY(-1px);
  }
}

.option-btn:disabled { cursor: default; }

.option-btn.correct {
  background: var(--correct);
  border-color: var(--correct);
  color: #fff;
}

.option-btn.incorrect {
  background: var(--incorrect);
  border-color: var(--incorrect);
  color: #fff;
}

.option-btn.reveal-correct {
  border-color: var(--correct);
  box-shadow: inset 0 0 0 2px var(--correct);
}

.scoreboard-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
}

.scoreboard-mascot {
  width: 44px;
  height: 44px;
  flex-shrink: 0;
}

.scoreboard {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 0;
}

.team-chip {
  padding: 8px 14px;
  border-radius: 999px;
  background: #f1f0f6;
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--card-text);
}

.team-chip.active-turn {
  background: var(--cat-color, var(--accent));
  color: #1b1033;
}

/* ---- Results screen ---- */

.results-card {
  background: var(--card);
  color: var(--card-text);
  border-radius: var(--radius);
  padding: 32px;
  text-align: center;
  box-shadow: 0 10px 30px rgba(0,0,0,0.3);
}

.results-mascot {
  width: 100px;
  height: 100px;
  margin-bottom: 8px;
}

.results-score {
  font-size: 3rem;
  font-weight: 900;
  margin: 10px 0;
}

.results-sub {
  color: var(--muted);
  margin-bottom: 20px;
}

.standings-list {
  list-style: none;
  padding: 0;
  margin: 16px 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.standings-list li {
  display: flex;
  justify-content: space-between;
  background: #f7f6fb;
  padding: 10px 16px;
  border-radius: 12px;
  font-weight: 700;
}

.standings-list li.winner {
  background: #fff3d6;
  border: 2px solid #ffcc4d;
}

/* ---- Modal (setup) ---- */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(12, 6, 26, 0.65);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 50;
}

.modal-box {
  background: var(--card);
  color: var(--card-text);
  border-radius: var(--radius);
  padding: 26px;
  max-width: 420px;
  width: 100%;
}

.modal-box h3 {
  margin-top: 0;
  text-align: center;
}

.modal-mascot {
  display: block;
  width: 80px;
  height: 80px;
  margin: 0 auto 12px;
}

.team-count-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin: 16px 0;
}

.team-count-row button {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background: #f1f0f6;
  font-size: 1.2rem;
  font-weight: 800;
  cursor: pointer;
}

.team-name-input {
  width: 100%;
  padding: 10px 12px;
  border-radius: 10px;
  border: 2px solid #e6e4ee;
  margin-bottom: 8px;
  font-size: 0.95rem;
}

.modal-actions {
  display: flex;
  gap: 10px;
  margin-top: 18px;
}

.muted-link {
  background: none;
  border: none;
  color: var(--muted);
  text-decoration: underline;
  cursor: pointer;
  font-size: 0.85rem;
}

@media (max-width: 480px) {
  .results-score { font-size: 2.2rem; }
}
