:root {
  --gaia-bg-1: #46178f;
  --gaia-bg-2: #2d0b59;
  --gaia-accent: #ffd23f;
  --gaia-ink: #1f1147;
  --gaia-card: #ffffff;
  --gaia-muted: #6b6685;
  --gaia-line: #e7e3f3;
  --shape-red: #e21b3c;
  --shape-blue: #1368ce;
  --shape-yellow: #d89e00;
  --shape-green: #26890c;
  --ok: #26890c;
  --err: #e21b3c;
  --radius: 16px;
  --shadow: 0 10px 30px rgba(20, 6, 50, 0.28);
  font-synthesis: none;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  font-family:
    "Montserrat",
    -apple-system,
    "Segoe UI",
    Helvetica,
    Arial,
    sans-serif;
  color: var(--gaia-ink);
  min-height: 100vh;
  background: radial-gradient(
    120% 120% at 50% 0%,
    var(--gaia-bg-1) 0%,
    var(--gaia-bg-2) 70%
  );
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* floating background blobs */
.bg-blobs {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
}
.bg-blobs span {
  position: absolute;
  border-radius: 50%;
  filter: blur(60px);
  opacity: 0.45;
  animation: floaty 14s ease-in-out infinite;
}
.bg-blobs span:nth-child(1) {
  width: 340px;
  height: 340px;
  background: #ff3355;
  top: -80px;
  left: -60px;
}
.bg-blobs span:nth-child(2) {
  width: 300px;
  height: 300px;
  background: #1fd0ff;
  bottom: -80px;
  right: -40px;
  animation-delay: -4s;
}
.bg-blobs span:nth-child(3) {
  width: 260px;
  height: 260px;
  background: #ffd23f;
  top: 40%;
  right: 20%;
  animation-delay: -8s;
}
@keyframes floaty {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(28px);
  }
}
@media (prefers-reduced-motion: reduce) {
  .bg-blobs span {
    animation: none;
  }
}

.wrap {
  position: relative;
  z-index: 1;
  max-width: 720px;
  margin: 0 auto;
  padding: 1.25rem 1rem 4rem;
}
.wrap.wide {
  max-width: 1000px;
}

/* ── account strip (top corner) ─────────────────────────────────────────── */
.account-strip-corner {
  position: fixed;
  top: 0.6rem;
  right: 0.75rem;
  z-index: 30;
}
.account-strip-corner-link {
  color: #fff;
  text-decoration: none;
  font-weight: 600;
  opacity: 0.9;
}
.account-strip {
  color: #eee;
  font-size: 0.85rem;
}
.index-account-menu {
  position: relative;
}
.index-account-menu-btn {
  list-style: none;
  cursor: pointer;
  color: #fff;
  background: rgba(255, 255, 255, 0.14);
  border-radius: 999px;
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  font-size: 1.4rem;
  line-height: 1;
  border: 0;
}
.index-account-menu-btn::-webkit-details-marker {
  display: none;
}
.index-account-menu-nav {
  position: absolute;
  right: 0;
  margin-top: 0.4rem;
  background: #fff;
  color: var(--gaia-ink);
  border-radius: 12px;
  box-shadow: var(--shadow);
  min-width: 180px;
  padding: 0.4rem;
  display: grid;
  gap: 0.15rem;
}
.index-account-menu-link {
  display: block;
  padding: 0.6rem 0.7rem;
  border-radius: 8px;
  text-decoration: none;
  color: var(--gaia-ink);
  background: none;
  border: 0;
  text-align: left;
  width: 100%;
  font: inherit;
  cursor: pointer;
}
.index-account-menu-link:hover {
  background: var(--gaia-line);
}
.index-account-menu-sep {
  height: 1px;
  background: var(--gaia-line);
  margin: 0.2rem 0;
}

/* ── headings / text ────────────────────────────────────────────────────── */
h1,
h2 {
  line-height: 1.15;
}
.page-title {
  color: #fff;
  margin: 0.25rem 0 1rem;
  font-size: 1.7rem;
  font-weight: 800;
  letter-spacing: -0.01em;
}
.brand-name {
  color: #fff;
  font-weight: 900;
  letter-spacing: -0.02em;
}
.muted {
  color: var(--gaia-muted);
}
.hint {
  color: rgba(255, 255, 255, 0.8);
  font-size: 0.85rem;
}
a {
  color: #ffd23f;
}

/* ── cards ──────────────────────────────────────────────────────────────── */
.card {
  background: var(--gaia-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.1rem 1.15rem;
  margin: 0 0 0.9rem;
}
.card h1,
.card h2,
.card h3 {
  margin-top: 0;
}

/* ── buttons ────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  background: var(--gaia-accent);
  color: #1f1147;
  font-weight: 800;
  font-size: 1rem;
  padding: 0.8rem 1.3rem;
  border-radius: 999px;
  border: 0;
  cursor: pointer;
  text-decoration: none;
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.18);
  transition: transform 0.06s ease;
}
.btn:active {
  transform: translateY(2px);
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.18);
}
.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.btn.secondary {
  background: #efeafc;
  color: #46178f;
}
.btn.ghost {
  background: rgba(255, 255, 255, 0.16);
  color: #fff;
  box-shadow: none;
}
.btn.danger {
  background: var(--err);
  color: #fff;
}
.btn.block {
  display: flex;
  width: 100%;
}
.btn.big {
  font-size: 1.2rem;
  padding: 1rem 1.6rem;
}

/* ── forms ──────────────────────────────────────────────────────────────── */
.field {
  margin: 0 0 0.9rem;
}
.field label {
  display: block;
  font-weight: 700;
  margin-bottom: 0.35rem;
  color: var(--gaia-ink);
}
.card .field .hint,
.card .hint {
  color: var(--gaia-muted);
}
input[type="text"],
input[type="email"],
input[type="number"],
input[type="tel"],
input[type="search"],
select,
textarea {
  width: 100%;
  padding: 0.75rem 0.85rem;
  border: 2px solid var(--gaia-line);
  border-radius: 12px;
  font-size: 1rem;
  font-family: inherit;
  background: #fff;
  color: var(--gaia-ink);
}
input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: #46178f;
}
.check-row {
  font-weight: 500;
}

/* ── flash messages ─────────────────────────────────────────────────────── */
.flash {
  border-radius: 12px;
  padding: 0.7rem 0.9rem;
  margin: 0 0 0.9rem;
  font-weight: 600;
}
.flash.ok {
  background: #dff5da;
  color: #1c5c0c;
}
.flash.err {
  background: #ffe0e5;
  color: #9c0c22;
}

/* ── login hero ─────────────────────────────────────────────────────────── */
.login-hero {
  position: relative;
  z-index: 1;
  padding: 2rem 1rem 1rem;
}
.login-hero-inner {
  max-width: 460px;
  margin: 0 auto;
  text-align: center;
}
.login-hero-title {
  color: #fff;
  font-size: 3rem;
  font-weight: 900;
  margin: 0;
  letter-spacing: -0.03em;
}
.login-hero-sub {
  color: rgba(255, 255, 255, 0.9);
  margin: 0.35rem 0 1.5rem;
  font-size: 1.05rem;
}
.login-hero-card {
  background: #fff;
  border-radius: 20px;
  box-shadow: var(--shadow);
  padding: 1.4rem 1.3rem;
  text-align: left;
  position: relative;
}
.login-hero-card h1 {
  font-size: 1.4rem;
  margin: 0 0 0.9rem;
}
.login-hero-card-lang {
  position: absolute;
  top: 0.7rem;
  right: 0.7rem;
}
.login-hero-card-lang button {
  background: #f1edfb;
  border: 0;
  border-radius: 999px;
  width: 38px;
  height: 38px;
  font-size: 1.2rem;
  cursor: pointer;
}
.login-hero-footer {
  margin-top: 1rem;
  text-align: center;
}
.login-hero-help {
  background: #fff4d6;
  padding: 0.6rem 0.7rem;
  border-radius: 10px;
  font-size: 0.9rem;
  color: #6a4c00;
}
.login-benefits-section {
  position: relative;
  z-index: 1;
  background: rgba(255, 255, 255, 0.06);
  margin-top: 2rem;
}
.login-benefits-section-inner {
  max-width: 720px;
  margin: 0 auto;
  padding: 2rem 1rem;
}
.login-benefits-heading {
  color: #fff;
}
.login-benefits-list {
  color: rgba(255, 255, 255, 0.92);
  line-height: 1.9;
  padding-left: 1.1rem;
}

/* ── quiz dashboard ─────────────────────────────────────────────────────── */
.top-bar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.9rem;
  padding-right: 4.5rem;
  flex-wrap: wrap;
  margin-bottom: 1.1rem;
}
.top-bar > :first-child {
  flex: 1 1 260px;
  min-width: 0;
}
.top-bar > .btn,
.top-bar > form,
.top-bar > a {
  flex-shrink: 0;
}
.page-header-row {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  min-width: 0;
}
.page-back-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.16);
  color: #fff;
  text-decoration: none;
  font-size: 1.6rem;
  font-weight: 700;
  line-height: 1;
  flex-shrink: 0;
}
.page-back-link:hover {
  background: rgba(255, 255, 255, 0.24);
}
.create-mode-dialog-backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 1rem;
  background: rgba(13, 7, 28, 0.66);
  backdrop-filter: blur(8px);
}
.create-mode-dialog {
  width: min(680px, 100%);
  margin: 0;
}
.create-mode-dialog h2 {
  margin: 0 0 0.5rem;
}
.create-mode-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.9rem;
}
.create-mode-card {
  display: grid;
  gap: 0.35rem;
  padding: 1rem;
  background: #f6f2ff;
  border: 2px solid transparent;
  border-radius: 16px;
  color: var(--gaia-ink);
  text-decoration: none;
  transition: transform 0.12s ease, border-color 0.12s ease, box-shadow 0.12s ease;
}
.create-mode-card:hover {
  transform: translateY(-1px);
  border-color: rgba(70, 23, 143, 0.24);
  box-shadow: 0 10px 20px rgba(31, 17, 71, 0.12);
}
.create-mode-card strong {
  font-size: 1.05rem;
}
.create-mode-card span {
  color: var(--gaia-muted);
  line-height: 1.45;
}
.create-ai-hint {
  font-weight: 600;
}
.quiz-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.8rem;
}
.quiz-row {
  display: flex;
  align-items: center;
  gap: 0.9rem;
}
.quiz-row .quiz-meta {
  flex: 1;
  min-width: 0;
}
.quiz-row .quiz-title {
  font-weight: 800;
  font-size: 1.1rem;
}
.quiz-row .quiz-sub {
  color: var(--gaia-muted);
  font-size: 0.9rem;
}
.quiz-row .quiz-actions {
  display: flex;
  gap: 0.4rem;
  flex-shrink: 0;
}
.fab {
  position: fixed;
  right: 1.1rem;
  bottom: 1.1rem;
  z-index: 25;
  width: 62px;
  height: 62px;
  border-radius: 50%;
  background: var(--gaia-accent);
  color: #1f1147;
  font-size: 2.2rem;
  display: grid;
  place-items: center;
  text-decoration: none;
  box-shadow: var(--shadow);
  font-weight: 800;
}
.empty {
  color: rgba(255, 255, 255, 0.85);
  text-align: center;
  padding: 2rem 1rem;
}

/* ── question editor ────────────────────────────────────────────────────── */
.q-editor {
  display: grid;
  gap: 0.7rem;
}
.q-row {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
}
.q-row .field {
  flex: 1;
  min-width: 120px;
  margin: 0;
}
.opt-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 0.55rem;
}
.opt-shape {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  color: #fff;
  font-weight: 900;
}
.opt-row input[type="text"] {
  flex: 1;
}
.q-card-list {
  list-style: none;
  margin: 0 0 1rem;
  padding: 0;
  display: grid;
  gap: 0.6rem;
}
.q-card-list li {
  background: #fff;
  border-radius: 12px;
  padding: 0.8rem 0.9rem;
  box-shadow: var(--shadow);
}
.q-card-list .q-num {
  color: var(--gaia-muted);
  font-weight: 700;
  font-size: 0.85rem;
}
.q-card-list .q-text {
  font-weight: 700;
}

/* shape colors */
.shape-0 {
  background: var(--shape-red);
}
.shape-1 {
  background: var(--shape-blue);
}
.shape-2 {
  background: var(--shape-yellow);
}
.shape-3 {
  background: var(--shape-green);
}

/* ── live game: shared stage ────────────────────────────────────────────── */
.stage {
  position: relative;
  z-index: 1;
  min-height: 92vh;
  display: flex;
  flex-direction: column;
  padding: 1rem;
  max-width: 1000px;
  margin: 0 auto;
}
.stage-center {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  color: #fff;
}
.stage-center.final-screen {
  position: relative;
  overflow: hidden;
}
.join-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 1.25rem;
  align-items: center;
  justify-items: center;
}
.pin-display {
  text-align: center;
  color: #fff;
}
.pin-display .pin-label {
  font-size: 1rem;
  opacity: 0.85;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
.pin-display .pin-code {
  font-size: clamp(2.8rem, 12vw, 5.5rem);
  font-weight: 900;
  letter-spacing: 0.15em;
}
.pin-display .join-url {
  color: var(--gaia-accent);
  font-weight: 700;
}
.join-qr-wrap {
  background: #fff;
  border-radius: 18px;
  padding: 0.8rem;
  box-shadow: var(--shadow);
}
.join-qr {
  display: block;
  width: min(28vw, 220px);
  height: auto;
}

.player-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: center;
  margin: 1.2rem 0;
}
.player-chip {
  background: rgba(255, 255, 255, 0.16);
  color: #fff;
  border-radius: 999px;
  padding: 0.45rem 0.9rem;
  font-weight: 700;
  animation: pop 0.3s ease;
}
@keyframes pop {
  from {
    transform: scale(0.6);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}

.question-text {
  color: #fff;
  font-size: clamp(1.4rem, 4vw, 2.4rem);
  font-weight: 800;
  text-align: center;
  margin: 0.5rem 0 1rem;
}
.q-progress {
  color: rgba(255, 255, 255, 0.85);
  font-weight: 700;
}

/* timer ring */
.timer-ring {
  --pct: 100;
  width: 84px;
  height: 84px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: conic-gradient(
    var(--gaia-accent) calc(var(--pct) * 1%),
    rgba(255, 255, 255, 0.18) 0
  );
  color: #fff;
  font-weight: 900;
  font-size: 1.6rem;
}
.timer-ring .inner {
  width: 66px;
  height: 66px;
  border-radius: 50%;
  background: var(--gaia-bg-2);
  display: grid;
  place-items: center;
}

.count-badge {
  background: rgba(255, 255, 255, 0.16);
  color: #fff;
  border-radius: 999px;
  padding: 0.4rem 0.9rem;
  font-weight: 700;
}

/* answer grid (host display + player) */
.answers-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.7rem;
  width: 100%;
  margin-top: auto;
}
.answer-btn {
  border: 0;
  border-radius: 14px;
  color: #fff;
  font-weight: 800;
  font-size: 1.15rem;
  cursor: pointer;
  padding: 1.2rem 1rem;
  display: flex;
  align-items: center;
  gap: 0.7rem;
  text-align: left;
  min-height: 84px;
  box-shadow: 0 5px 0 rgba(0, 0, 0, 0.22);
  transition:
    transform 0.06s ease,
    opacity 0.2s ease;
}
.answer-btn .glyph {
  font-size: 1.5rem;
}
.answer-btn:active {
  transform: translateY(3px);
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.22);
}
.answer-btn:disabled {
  cursor: default;
}
.answer-btn.dim {
  opacity: 0.35;
}
.answer-btn.reveal-correct {
  outline: 4px solid #fff;
}
.answer-btn.bg-0 {
  background: var(--shape-red);
}
.answer-btn.bg-1 {
  background: var(--shape-blue);
}
.answer-btn.bg-2 {
  background: var(--shape-yellow);
}
.answer-btn.bg-3 {
  background: var(--shape-green);
}
.answer-count {
  margin-left: auto;
  background: rgba(0, 0, 0, 0.22);
  border-radius: 999px;
  padding: 0.15rem 0.6rem;
  font-size: 0.95rem;
}

/* player result screens */
.result-full {
  position: fixed;
  inset: 0;
  z-index: 5;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: #fff;
  text-align: center;
  padding: 1.5rem;
}
.result-full.correct {
  background: var(--ok);
}
.result-full.wrong {
  background: var(--err);
}
.result-full .big-emoji {
  font-size: 4rem;
}
.result-full h1 {
  font-size: 2.2rem;
  margin: 0.5rem 0;
}
.result-score {
  font-size: 1.4rem;
  font-weight: 800;
}

/* leaderboard */
.leaderboard {
  list-style: none;
  margin: 1rem 0;
  padding: 0;
  display: grid;
  gap: 0.5rem;
  width: 100%;
  max-width: 520px;
}
.leaderboard li {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  background: #fff;
  color: var(--gaia-ink);
  border-radius: 12px;
  padding: 0.7rem 0.9rem;
  font-weight: 700;
  box-shadow: var(--shadow);
}
.leaderboard .lb-rank {
  width: 1.8rem;
  text-align: center;
  color: var(--gaia-muted);
}
.leaderboard .lb-name {
  flex: 1;
}
.leaderboard .lb-score {
  color: #46178f;
  font-weight: 900;
}
.leaderboard li.me {
  outline: 3px solid var(--gaia-accent);
}

/* podium */
.podium {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 0.8rem;
  margin: 1.5rem 0;
}
.podium .col {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 92px;
}
.podium .bar {
  background: var(--gaia-accent);
  color: #1f1147;
  border-radius: 12px 12px 0 0;
  width: 92px;
  display: grid;
  place-items: center;
  font-weight: 900;
  transform-origin: center bottom;
}
.podium .col.p1 .bar {
  height: 150px;
}
.podium .col.p2 .bar {
  height: 110px;
  background: #d7ccf5;
}
.podium .col.p3 .bar {
  height: 82px;
  background: #c9a3ff;
}
.podium .pname {
  color: #fff;
  font-weight: 800;
  margin-bottom: 0.4rem;
}
.final-podium .col {
  opacity: 0;
  animation: podium-fade-in 0.24s ease forwards;
}
.final-podium .col:nth-child(1) {
  animation-delay: 0.04s;
}
.final-podium .col:nth-child(2) {
  animation-delay: 0.24s;
}
.final-podium .col:nth-child(3) {
  animation-delay: 0.44s;
}
.final-podium .col .bar {
  transform: scaleY(0.08);
  animation: podium-rise 0.88s cubic-bezier(0.2, 0.9, 0.25, 1.35) forwards;
}
.final-podium .col:nth-child(1) .bar {
  animation-delay: 0.04s;
}
.final-podium .col:nth-child(2) .bar {
  animation-delay: 0.24s;
}
.final-podium .col:nth-child(3) .bar {
  animation-delay: 0.44s;
}

.confetti-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 2;
}
.confetti-piece {
  position: absolute;
  width: 10px;
  height: 16px;
  background: var(--confetti-color);
  border-radius: 2px;
  opacity: 0;
  box-shadow: 0 0 12px rgba(255, 255, 255, 0.28);
  animation: confetti-burst 1.7s cubic-bezier(0.18, 0.84, 0.34, 1) var(--delay) forwards;
}
.confetti-piece:nth-child(3n) {
  width: 12px;
  height: 12px;
  border-radius: 50%;
}

@keyframes podium-fade-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}
@keyframes podium-rise {
  0% {
    transform: scaleY(0.08);
  }
  60% {
    transform: scaleY(1.08);
  }
  78% {
    transform: scaleY(0.92);
  }
  100% {
    transform: scaleY(1);
  }
}
@keyframes confetti-burst {
  0% {
    opacity: 0;
    transform: translate3d(0, 0, 0) rotate(0deg) scale(0.7);
  }
  10% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: translate3d(var(--dx), var(--dy), 0) rotate(var(--rot)) scale(1);
  }
}

@media (prefers-reduced-motion: reduce) {
  .final-podium .col,
  .final-podium .col .bar,
  .confetti-piece {
    animation: none;
    opacity: 1;
    transform: none;
  }
}

@media (max-width: 420px) {
  .create-mode-grid {
    grid-template-columns: 1fr;
  }
  .top-bar {
    padding-right: 0;
    padding-top: 3rem;
    flex-direction: column;
    align-items: flex-start;
  }
  .join-panel {
    grid-template-columns: 1fr;
  }
  .join-qr {
    width: min(52vw, 180px);
  }
  .answer-btn {
    font-size: 1rem;
    padding: 1rem 0.8rem;
    min-height: 72px;
  }
  .podium {
    gap: 0.45rem;
  }
  .podium .col,
  .podium .bar {
    width: 82px;
    min-width: 82px;
  }
}

.center {
  text-align: center;
}
.stack > * + * {
  margin-top: 0.9rem;
}
.spin {
  display: inline-block;
  width: 34px;
  height: 34px;
  border: 4px solid rgba(255, 255, 255, 0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}
