:root {
  --teal: #08b8b8;
  --teal-dark: #009fa3;
  --teal-light: #e9faf9;
  --yellow: #ffc928;
  --yellow-light: #fff8e1;
  --black: #0a0a0a;
  --white: #ffffff;
  --sub: #4a4a4a;
  --gray: #9ca3af;
  --gray-light: #f3f4f6;
  --success: #31c48d;
  --alert: #ef5b5b;
  --border: #e5e5e5;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  --radius: 1rem;
  --radius-lg: 1.5rem;
}
* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; font-family: "Plus Jakarta Sans", sans-serif; color: var(--black); }
body.app-body {
  background: #cbddf3;
  background-image: repeating-conic-gradient(from 0deg at 50% 50%, rgba(255,255,255,.15) 0deg 2deg, transparent 2deg 8deg);
  min-height: 100%;
}
.app-shell {
  min-height: 100%;
  max-width: 480px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  position: relative;
}
.font-display { font-family: "Baloo 2", sans-serif; }
.badge {
  font-size: 0.65rem; font-weight: 700; padding: 0.25rem 0.6rem;
  border-radius: 999px; background: var(--teal-light); color: var(--teal-dark);
  letter-spacing: 0.05em; text-transform: uppercase;
}
.card {
  background: var(--white); border-radius: var(--radius-lg); border: 1px solid var(--border);
  padding: 1.25rem; box-shadow: var(--shadow-sm);
}
.card-elevated {
  background: var(--white); border-radius: var(--radius-lg); padding: 1.5rem; box-shadow: var(--shadow);
}
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem;
  padding: 0.875rem 1.5rem; border-radius: var(--radius-lg);
  font-family: "Baloo 2", sans-serif; font-weight: 700; font-size: 1rem;
  border: none; cursor: pointer; transition: all 0.2s ease; width: 100%;
}
.btn:active { transform: scale(0.98); }
.btn-primary { background: var(--black); color: var(--white); box-shadow: 0 4px 14px rgba(0,0,0,.15); }
.btn-primary:hover { background: #1a1a1a; }
.btn-primary:disabled, .btn:disabled { background: #b9b9b9; box-shadow: none; cursor: not-allowed; }
.btn-secondary { background: var(--white); color: var(--black); border: 2px solid var(--black); }
.btn-teal { background: var(--teal); color: var(--white); box-shadow: 0 4px 14px rgba(8,184,184,.25); }
.input-group { margin-bottom: 1rem; }
.input-label {
  display: block; font-size: 0.75rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.08em; color: var(--sub); margin-bottom: 0.375rem;
}
.input-field {
  width: 100%; padding: 0.875rem 1rem; border: 2px solid var(--border); border-radius: var(--radius);
  font-family: "Plus Jakarta Sans", sans-serif; font-size: 0.9375rem; font-weight: 600;
  color: var(--black); background: var(--white); outline: none;
}
.input-field:focus { border-color: var(--teal); box-shadow: 0 0 0 3px rgba(8,184,184,.1); }
.input-error { border-color: var(--alert) !important; }
.error-msg { color: var(--alert); font-size: 0.75rem; font-weight: 600; margin-top: 0.25rem; display: none; }
.error-msg.show { display: flex; }
.app-header {
  padding: 0.85rem 1.25rem;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  background: var(--white);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 40;
}
.logo-img {
  grid-column: 2;
  height: 48px;
  max-width: min(240px, 72vw);
  width: auto;
  object-fit: contain;
  display: block;
  margin: 0 auto;
}
.app-header .badge {
  grid-column: 3;
  justify-self: end;
}
.login-logo {
  display: flex;
  justify-content: center;
  align-items: center;
  margin: 0 auto 1.15rem;
}
.login-logo img {
  width: auto;
  height: auto;
  max-width: 220px;
  max-height: 84px;
  object-fit: contain;
  display: block;
  filter: drop-shadow(0 10px 22px rgba(7, 42, 44, 0.12));
}
.welcome-overlay {
  position: fixed;
  inset: 0;
  z-index: 120;
  background: rgba(5, 16, 20, 0.62);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
}
.welcome-overlay[hidden] { display: none !important; }
.welcome-overlay.open { display: flex !important; }
.welcome-dialog {
  background: #fff;
  border-radius: 1.35rem;
  max-width: 420px;
  width: 100%;
  overflow: hidden;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.28);
  display: flex;
  flex-direction: column;
}
.welcome-dialog img {
  width: 100%;
  height: auto;
  display: block;
  max-height: 70vh;
  object-fit: contain;
  background: #0a1214;
}
.welcome-dialog .welcome-actions {
  padding: 0.9rem 1rem 1.1rem;
  flex-shrink: 0;
}
@media (max-width: 640px) {
  .welcome-overlay.open {
    padding: 0;
    align-items: stretch;
    justify-content: stretch;
  }
  .welcome-dialog {
    max-width: none;
    width: 100%;
    height: 100%;
    min-height: 100dvh;
    border-radius: 0;
    box-shadow: none;
  }
  .welcome-dialog img {
    flex: 1 1 auto;
    min-height: 0;
    max-height: none;
    height: 100%;
    object-fit: cover;
    object-position: center;
  }
  .welcome-dialog .welcome-actions {
    padding: 0.85rem 1rem calc(0.85rem + env(safe-area-inset-bottom, 0px));
    background: #fff;
  }
}
.ranking-prize {
  font-size: 1.2rem;
  line-height: 1;
  flex-shrink: 0;
  width: 1.5rem;
  text-align: center;
}
.screen-pad { padding: 1.25rem; }
.hearts-row { display: flex; gap: 0.25rem; }
.heart { width: 20px; height: 20px; }
.heart-filled { fill: var(--yellow); color: var(--yellow); }
.heart-empty { fill: none; color: #d9d9d9; }
.timer-ring {
  width: 80px; height: 80px; border-radius: 50%; border: 4px solid var(--teal);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: var(--white);
}
.timer-ring.urgent { border-color: var(--alert); animation: pulse 0.8s infinite; }
.timer-number { font-family: "Baloo 2", sans-serif; font-size: 1.75rem; font-weight: 800; line-height: 1; }
.timer-label { font-size: 0.625rem; color: var(--sub); font-weight: 600; }
.progress-track { width: 100%; height: 6px; background: var(--gray-light); border-radius: 999px; overflow: hidden; }
.progress-fill { height: 100%; background: var(--teal); border-radius: 999px; transition: width 0.4s ease; }
.option-btn {
  width: 100%; display: flex; align-items: center; gap: 0.75rem; padding: 1rem 1.25rem;
  border: 2px solid transparent; border-radius: var(--radius); background: var(--white);
  text-align: left; font-family: "Plus Jakarta Sans", sans-serif; font-size: 0.9375rem; font-weight: 600;
  cursor: pointer; box-shadow: var(--shadow-sm); margin-bottom: 0.625rem;
}
.option-btn:hover:not(:disabled) { border-color: var(--teal); transform: translateX(4px); }
.option-btn.correct { background: #e7f9f2; border-color: var(--success); }
.option-btn.wrong { background: #fdecec; border-color: var(--alert); }
.option-btn.inactive { opacity: 0.5; }
.option-letter {
  width: 28px; height: 28px; border-radius: 50%; background: var(--teal-light); color: var(--teal-dark);
  display: flex; align-items: center; justify-content: center; font-family: "Baloo 2", sans-serif; font-weight: 700; flex-shrink: 0;
}
.option-btn.correct .option-letter { background: var(--success); color: white; }
.option-btn.wrong .option-letter { background: var(--alert); color: white; }
.ranking-chrome {
  flex-shrink: 0;
  background: #cbddf3;
  background-image: repeating-conic-gradient(from 0deg at 50% 50%, rgba(255,255,255,.15) 0deg 2deg, transparent 2deg 8deg);
  position: sticky;
  top: 76px;
  z-index: 30;
  padding-bottom: 0.25rem;
}
.ranking-list { flex: 1; min-height: 0; }
.ranking-tabs { display: flex; gap: 0.5rem; padding: 0 1.25rem 0.75rem; }
.ranking-tab {
  flex: 1; padding: 0.625rem 0.4rem; border-radius: var(--radius); border: 2px solid var(--border);
  background: var(--white); font-family: "Baloo 2", sans-serif; font-weight: 700; font-size: 0.7rem;
  cursor: pointer; text-align: center; text-decoration: none; color: var(--black);
}
.ranking-tab.active { background: var(--black); color: var(--white); border-color: var(--black); }
.ranking-row { display: flex; align-items: center; gap: 0.75rem; padding: 0.875rem 1.25rem; border-bottom: 1px solid var(--border); background: var(--white); }
.ranking-row.me { background: var(--teal-light); }
.ranking-rank { width: 32px; height: 32px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-family: "Baloo 2", sans-serif; font-weight: 800; }
.ranking-rank.gold { background: var(--yellow-light); color: #b45309; }
.ranking-rank.silver { background: #f3f4f6; color: #6b7280; }
.ranking-rank.bronze { background: #fef3c7; color: #92400e; }
.ranking-rank.normal { background: var(--gray-light); color: var(--sub); }
.ranking-info { flex: 1; min-width: 0; }
.ranking-alias { font-weight: 700; }
.ranking-meta { font-size: 0.75rem; color: var(--sub); }
.ranking-score { text-align: right; }
.ranking-score-num { font-family: "Baloo 2", sans-serif; font-weight: 800; font-size: 1.125rem; color: var(--teal-dark); }
.bottom-nav {
  display: flex; border-top: 1px solid var(--border); background: var(--white); padding: 0.5rem 0;
  position: sticky; bottom: 0; z-index: 40;
}
.nav-item {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 0.25rem;
  padding: 0.375rem 0; color: var(--gray); font-size: 0.625rem; font-weight: 700;
  text-transform: uppercase; text-decoration: none; background: none; border: none; cursor: pointer;
}
.nav-item.active { color: var(--teal-dark); }
.nav-item svg { width: 22px; height: 22px; }
.cat-selector { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.5rem; }
.cat-card {
  background: var(--white); border: 2px solid var(--border); border-radius: var(--radius);
  padding: 0.75rem 0.25rem; text-align: center; position: relative;
}
.cat-card.active { border-color: var(--teal); box-shadow: 0 0 0 3px rgba(8,184,184,.15); }
.cat-card-emoji { font-size: 1.5rem; }
.cat-card-name { font-family: "Baloo 2", sans-serif; font-weight: 700; font-size: 0.65rem; }
.cat-card-check {
  position: absolute; top: 6px; right: 6px; width: 18px; height: 18px; background: var(--teal);
  border-radius: 50%; color: white; font-size: 0.7rem; display: flex; align-items: center; justify-content: center;
}
.prize-carousel { overflow: hidden; margin: 0; border-radius: var(--radius-lg); height: 180px; background: var(--white); border: 1px solid var(--border); }
.prize-carousel-track { display: flex; transition: transform 0.5s ease; height: 100%; }
.prize-carousel-slide { min-width: 100%; display: flex; align-items: center; justify-content: center; flex-direction: column; padding: 0.5rem; }
.prize-carousel-slide img { max-height: 110px; max-width: 90%; object-fit: contain; }
.prize-carousel-name { font-family: "Baloo 2", sans-serif; font-weight: 800; font-size: 1rem; text-align: center; margin-top: 0.35rem; }
.prize-carousel-dots { display: flex; justify-content: center; gap: 0.5rem; margin-top: 0.75rem; }
.prize-carousel-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--gray); border: none; cursor: pointer; }
.prize-carousel-dot.active { background: var(--teal); width: 20px; border-radius: 4px; }
.stats-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.75rem; margin-bottom: 1.5rem; }
.stat-box { background: var(--white); border-radius: var(--radius); padding: 1rem 0.5rem; text-align: center; border: 1px solid var(--border); }
.stat-value { font-family: "Baloo 2", sans-serif; font-size: 1.5rem; font-weight: 800; color: var(--teal-dark); }
.stat-label { font-size: 0.625rem; font-weight: 700; text-transform: uppercase; color: var(--sub); }
.qcat-tag { display: inline-block; padding: 0.25rem 0.625rem; border-radius: 6px; font-size: 0.625rem; font-weight: 800; text-transform: uppercase; }
.qcat-fin { background: #dbeafe; color: #1e40af; }
.qcat-cult { background: #fce7f3; color: #9d174d; }
.qcat-cred { background: #d1fae5; color: #065f46; }
.trophy-glow {
  width: 80px; height: 80px; border-radius: 50%; background: var(--yellow-light);
  display: flex; align-items: center; justify-content: center; margin: 0 auto; font-size: 2.5rem;
}
.close-banner { background: linear-gradient(135deg, var(--alert), #dc2626); color: white; padding: 0.625rem 1rem; text-align: center; font-size: 0.75rem; font-weight: 700; }
.cat-badge { display: inline-flex; align-items: center; gap: 0.375rem; padding: 0.375rem 0.875rem; border-radius: 999px; font-size: 0.8125rem; font-weight: 700; border: 1.5px solid var(--teal); background: var(--white); color: var(--teal-dark); }
.login-wrap { padding: 1.25rem; display: flex; flex-direction: column; justify-content: center; min-height: 100%; }
.text-center { text-align: center; }
.text-sub { color: var(--sub); }
.text-gray { color: var(--gray); }
.text-sm { font-size: 0.875rem; }
.text-xs { font-size: 0.75rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-3 { margin-bottom: 0.75rem; }
.mb-4 { margin-bottom: 1rem; }
.mb-6 { margin-bottom: 1.5rem; }
.mt-2 { margin-top: 0.5rem; }
.mt-4 { margin-top: 1rem; }
.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 0.5rem; }
.space-y > * + * { margin-top: 0.625rem; }
@keyframes pulse { 0%,100% { transform: scale(1); } 50% { transform: scale(1.05); } }
@keyframes fadeIn { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
.fade-in { animation: fadeIn 0.4s ease; }
.info-row { display: flex; align-items: center; justify-content: space-between; }
.lives-count { font-family: "Baloo 2", sans-serif; font-weight: 800; font-size: 1.25rem; color: var(--teal-dark); }
.login-title { font-size: 1.5rem; font-weight: 800; line-height: 1.2; }
.home-hello { font-size: 1.5rem; font-weight: 800; }
.trivia-qtext { font-size: 1.1rem; font-weight: 700; line-height: 1.35; }
.login-hero { margin-bottom: 1.5rem; }

@media (min-width: 900px) {
  body.app-body {
    padding: 0;
    background-color: #d9e7f6;
    background-image:
      radial-gradient(900px 420px at 50% -8%, rgba(255, 255, 255, 0.95), transparent 70%),
      repeating-conic-gradient(from 0deg at 50% 50%, rgba(255,255,255,.12) 0deg 2deg, transparent 2deg 10deg);
  }
  .app-shell {
    max-width: none;
    min-height: 100vh;
    background: transparent;
    border: none;
    border-radius: 0;
    box-shadow: none;
  }
  .app-header {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    padding: 0.85rem 18rem 0.85rem 2rem;
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(10px);
  }
  .logo-img {
    height: 52px;
    max-width: 260px;
    grid-column: 2;
    margin: 0 auto;
  }
  .app-header .badge {
    grid-column: 3;
    justify-self: end;
  }
  .bottom-nav {
    position: fixed;
    top: 12px;
    right: 20px;
    left: auto;
    bottom: auto;
    width: auto;
    display: flex;
    gap: 0.2rem;
    padding: 0.3rem;
    border: 1px solid var(--border);
    border-radius: 999px;
    box-shadow: var(--shadow);
    z-index: 50;
  }
  .nav-item {
    flex: 0 0 auto;
    flex-direction: row;
    padding: 0.5rem 0.95rem;
    font-size: 0.72rem;
    border-radius: 999px;
    gap: 0.4rem;
  }
  .nav-item.active { background: var(--teal-light); color: var(--teal-dark); }
  .screen-pad,
  .ranking-chrome,
  .ranking-list,
  .close-banner {
    width: 100%;
    max-width: none;
    margin-left: 0;
    margin-right: 0;
  }
  .close-banner { border-radius: 0; }
  .screen-pad { padding: 2rem 4vw 3rem; }
  .login-wrap,
  .login-wrap.alias-wrap {
    display: flex;
    flex-direction: column;
    justify-content: center;
    width: 100%;
    max-width: none;
    margin: 0;
    padding: 4rem 4vw 3rem;
    min-height: 100vh;
  }
  .login-panel {
    width: 100%;
    max-width: 440px;
    margin: 0 auto;
  }
  .login-hero { margin-bottom: 1.5rem; }
  .login-title { font-size: 1.75rem; }
  .login-logo img { max-width: 240px; max-height: 96px; }
  .home-desk {
    display: block;
    width: 100%;
    padding-bottom: 3rem;
  }
  .home-hello { font-size: 2rem; }
  .home-play {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.75rem;
    margin-top: 1.5rem;
  }
  .home-play .card {
    margin: 0 !important;
  }
  .home-play .btn,
  .home-play > p {
    grid-column: 1 / -1;
  }
  .home-play .btn {
    max-width: none;
    width: 100%;
    justify-self: stretch;
  }
  .cat-card { padding: 1rem 0.5rem; }
  .cat-card-name { font-size: 0.85rem; }
  .prize-carousel {
    height: auto;
    overflow: visible;
    background: transparent;
    border: none;
  }
  .prize-carousel-track {
    display: grid !important;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 0.75rem;
    transform: none !important;
    height: auto;
  }
  .prize-carousel-slide {
    min-width: 0;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 1.15rem;
    padding: 1rem 0.75rem;
    box-shadow: var(--shadow-sm);
  }
  .prize-carousel-slide img { max-height: 120px; }
  .prize-carousel-dots { display: none; }
  .ranking-chrome {
    top: 72px;
    background: transparent;
    background-image: none;
    max-width: none;
    padding-left: 4vw;
    padding-right: 4vw;
  }
  .ranking-tabs { padding: 0 0 1rem; }
  .ranking-tab { font-size: 0.88rem; padding: 0.7rem 0.5rem; }
  .ranking-list {
    margin-bottom: 2.5rem;
    padding: 0 4vw 0;
    border: none;
    border-radius: 0;
    box-shadow: none;
  }
  .ranking-list .ranking-row:first-child { border-top: 1px solid var(--border); }
  .ranking-row { padding: 1rem 1.35rem; }
  .trivia-desk { padding-bottom: 3rem; }
  .trivia-board { display: block; }
  .trivia-ocol {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
  }
  .option-btn { margin-bottom: 0; padding: 1.05rem 1.2rem; font-size: 1rem; }
  .timer-ring { width: 100px; height: 100px; }
  .timer-number { font-size: 2rem; }
  .trivia-qtext { font-size: 1.4rem; }
  .result-desk {
    max-width: none;
    width: 100%;
    padding-top: 2.75rem;
    padding-bottom: 3rem;
  }
  .result-desk .space-y {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.75rem;
  }
  .result-desk .space-y > * { margin-top: 0; }
  .result-desk .space-y .btn { max-width: none; width: 100%; }
  .stat-value { font-size: 1.85rem; }
  .welcome-dialog { max-width: 480px; }
}

body.post-event-page .app-shell {
  max-width: none;
}
.post-event-screen {
  padding: 0.35rem 0 5.25rem;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.post-event-art {
  width: 100%;
  margin: 0 auto;
  display: block;
  line-height: 0;
}
.post-event-img {
  width: 100%;
  height: auto;
  display: block;
  border-radius: 0;
  box-shadow: none;
}
.post-event-foot {
  margin-top: 0.85rem;
  text-align: center;
  width: 100%;
  max-width: 480px;
  padding: 0 1rem;
}
.post-event-foot a { color: var(--teal-dark); font-weight: 700; }
@media (min-width: 900px) {
  .post-event-screen {
    min-height: calc(100vh - 72px);
    justify-content: center;
    padding: 1rem 2rem 3rem;
  }
  .post-event-art {
    max-width: min(920px, 92vw);
  }
  .post-event-foot {
    max-width: min(920px, 92vw);
  }
}
