/*
 * Top of the Class — player web app.
 * Visual system: Queezy Quiz UI Kit (Rubik + purple), same tokens as the
 * Unity client (Assets/UI/Theme/design-tokens.uss).
 */

@font-face {
  font-family: "Rubik";
  src: url("../fonts/Rubik-Regular.ttf") format("truetype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Rubik";
  src: url("../fonts/Rubik-Medium.ttf") format("truetype");
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Rubik";
  src: url("../fonts/Rubik-Bold.ttf") format("truetype");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

:root {
  --cream: #efeefc;
  --ink: #0c092a;
  --muted: #858494;
  --surface: #ffffff;
  --primary: #6a5ae0;
  --primary-soft: #9087e5;
  --primary-deep: #5b4ed1;
  --lavender: #e8e5fa;
  --pink: #ff8fa2;
  --peach: #ffd6dd;
  --orange: #ff9f40;
  --success: #1db954;
  --error: #ff4d6d;

  --s1: 4px;
  --s2: 8px;
  --s3: 12px;
  --s4: 16px;
  --s6: 24px;
  --s8: 32px;
  --s12: 48px;

  --r-card: 32px;
  --r-pill: 999px;
  --r-button: 20px;
  --r-input: 16px;
  --r-sheet: 40px;

  --shadow-card: 0 18px 40px rgba(12, 9, 42, 0.08);
  --shadow-soft: 0 8px 18px rgba(12, 9, 42, 0.06);
}

* {
  box-sizing: border-box;
}

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

body {
  min-height: 100vh;
  background: var(--cream);
  color: var(--ink);
  font-family: "Rubik", -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(680px 420px at 12% -8%, rgba(144, 135, 229, 0.28), transparent 70%),
    radial-gradient(560px 380px at 96% 4%, rgba(255, 143, 162, 0.18), transparent 70%);
  z-index: 0;
}

#app {
  position: relative;
  z-index: 1;
  max-width: 980px;
  margin: 0 auto;
  padding: 20px 16px 120px;
  min-height: 100vh;
}

/* Auth and onboarding screens stay a comfortable reading width. */
.narrow {
  max-width: 520px;
  margin: 0 auto;
}

/* App screens use the full width on desktop with the hero as a side panel. */
@media (min-width: 900px) {
  .wide {
    display: grid;
    grid-template-columns: 340px minmax(0, 1fr);
    gap: 20px;
    align-items: start;
  }

  .wide > * {
    grid-column: 2;
  }

  .wide > .hero,
  .wide > .result-banner {
    grid-column: 1;
    grid-row: 1 / -1;
    position: sticky;
    top: 20px;
    margin-bottom: 0;
  }

  .wide > .sheet:last-of-type {
    margin-bottom: 0;
  }

  .wide .nav {
    max-width: 980px;
  }
}

/* ---------- typography ---------- */

h1,
h2,
h3,
h4 {
  margin: 0;
  font-weight: 700;
  letter-spacing: -0.01em;
}

h1 {
  font-size: 26px;
  line-height: 1.2;
}

h2 {
  font-size: 20px;
}

h3 {
  font-size: 17px;
}

p {
  margin: 0;
}

.caption {
  color: var(--muted);
  font-size: 13px;
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 11px;
  font-weight: 600;
  color: var(--primary-soft);
}

/* ---------- layout blocks ---------- */

.hero {
  position: relative;
  overflow: hidden;
  background: linear-gradient(155deg, var(--primary) 0%, var(--primary-deep) 100%);
  color: #fff;
  border-radius: var(--r-card);
  padding: 26px 24px 28px;
  margin-bottom: 16px;
}

.hero::after {
  content: "";
  position: absolute;
  width: 260px;
  height: 260px;
  right: -90px;
  bottom: -140px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
}

.hero::before {
  content: "";
  position: absolute;
  width: 120px;
  height: 120px;
  right: 26px;
  top: -50px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
}

.hero h1,
.hero h2,
.hero p {
  position: relative;
  z-index: 1;
}

.hero .sub {
  color: rgba(255, 255, 255, 0.78);
  margin-top: 6px;
  font-size: 15px;
}

.logo-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #fff;
  border-radius: 18px;
  padding: 10px 14px;
  margin-bottom: 18px;
}

.logo-chip img {
  display: block;
  width: 168px;
  height: auto;
}

.sheet {
  background: var(--surface);
  border-radius: var(--r-card);
  padding: 22px 20px;
  box-shadow: var(--shadow-card);
  margin-bottom: 16px;
}

.sheet.tight {
  padding: 18px 18px;
}

.card {
  background: var(--surface);
  border-radius: 24px;
  padding: 18px;
  box-shadow: var(--shadow-soft);
  margin-bottom: 14px;
}

.card.flat {
  box-shadow: none;
  border: 1px solid var(--lavender);
}

.row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.between {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.stack > * + * {
  margin-top: 12px;
}

.spacer {
  flex: 1;
}

/* ---------- buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 52px;
  padding: 14px 20px;
  border: 0;
  border-radius: var(--r-button);
  background: var(--primary);
  color: #fff;
  font-family: inherit;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.12s ease, background 0.16s ease, box-shadow 0.16s ease;
  box-shadow: 0 10px 22px rgba(106, 90, 224, 0.24);
}

.btn:hover {
  background: var(--primary-deep);
}

.btn:active {
  transform: translateY(1px);
}

.btn:focus-visible {
  outline: 3px solid var(--primary-soft);
  outline-offset: 2px;
}

.btn.block {
  width: 100%;
}

.btn.ghost {
  background: var(--lavender);
  color: var(--primary-deep);
  box-shadow: none;
}

.btn.ghost:hover {
  background: #ddd8f7;
}

.btn.quiet {
  background: transparent;
  color: var(--primary-deep);
  box-shadow: none;
}

.btn.quiet:hover {
  background: var(--lavender);
}

.btn.small {
  min-height: 40px;
  padding: 9px 14px;
  font-size: 14px;
  border-radius: 14px;
}

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

.link {
  background: none;
  border: 0;
  padding: 0;
  font: inherit;
  color: var(--primary-deep);
  font-weight: 500;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* ---------- forms ---------- */

.field {
  margin-bottom: 14px;
}

.field label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 6px;
}

.input {
  width: 100%;
  min-height: 52px;
  padding: 14px 16px;
  background: #f7f6fd;
  border: 1.5px solid transparent;
  border-radius: var(--r-input);
  font-family: inherit;
  font-size: 16px;
  color: var(--ink);
  transition: border-color 0.15s ease, background 0.15s ease;
}

.input::placeholder {
  color: #a9a7bb;
}

.input:focus {
  outline: none;
  background: #fff;
  border-color: var(--primary);
}

.input[aria-invalid="true"] {
  border-color: var(--error);
  background: #fff5f7;
}

.hint {
  font-size: 12px;
  color: var(--muted);
  margin-top: 6px;
}

.hint.ok {
  color: var(--success);
}

.hint.bad {
  color: var(--error);
}

.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 14px;
}

.segmented button {
  min-height: 46px;
  border-radius: 14px;
  border: 1.5px solid var(--lavender);
  background: #fff;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
}

.segmented button[aria-pressed="true"] {
  border-color: var(--primary);
  background: var(--lavender);
  color: var(--primary-deep);
}

/* ---------- alerts ---------- */

.alert {
  border-radius: 16px;
  padding: 12px 14px;
  font-size: 14px;
  margin-bottom: 14px;
  background: #fff1f4;
  color: #a30019;
  border: 1px solid #ffd0da;
}

.alert.ok {
  background: #edfbf1;
  color: #0c6b2e;
  border-color: #bdeccb;
}

/* ---------- chips / pills ---------- */

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: var(--r-pill);
  font-size: 13px;
  font-weight: 600;
  background: var(--lavender);
  color: var(--primary-deep);
}

.pill.on-purple {
  background: rgba(255, 255, 255, 0.16);
  color: #fff;
}

.pill.pink {
  background: var(--peach);
  color: #b3243c;
}

.pill.orange {
  background: #ffe9d3;
  color: #a65a00;
}

.avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--peach);
  color: #b3243c;
  font-weight: 700;
  font-size: 17px;
  flex: 0 0 auto;
}

.avatar.on-purple {
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
}

/* ---------- progress / timer ---------- */

.playbar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}

.progress {
  flex: 1;
  height: 8px;
  border-radius: var(--r-pill);
  background: rgba(255, 255, 255, 0.28);
  overflow: hidden;
}

.progress > span {
  display: block;
  height: 100%;
  border-radius: var(--r-pill);
  background: #fff;
  transition: width 0.3s ease;
}

.timer {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  font-size: 14px;
  color: var(--pink);
}

.hero .timer {
  color: #fff;
}

/* ---------- answer options ---------- */

.options {
  display: grid;
  gap: 10px;
  margin-top: 16px;
}

.option {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 60px;
  padding: 14px 16px;
  border: 2px solid var(--lavender);
  border-radius: var(--r-button);
  background: #fff;
  font-family: inherit;
  font-size: 16px;
  font-weight: 500;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
  transition: border-color 0.14s ease, background 0.14s ease, transform 0.1s ease;
}

.option:hover {
  border-color: var(--primary-soft);
}

.option:active {
  transform: scale(0.995);
}

.option:focus-visible {
  outline: 3px solid var(--primary-soft);
  outline-offset: 2px;
}

.option .key {
  width: 30px;
  height: 30px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: var(--cream);
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  flex: 0 0 auto;
}

.option[aria-pressed="true"] {
  border-color: var(--primary);
  background: var(--lavender);
}

.option[aria-pressed="true"] .key {
  background: var(--primary);
  color: #fff;
}

.option.correct {
  border-color: var(--success);
  background: #eefaf1;
}

.option.wrong {
  border-color: var(--error);
  background: #fff1f4;
}

.option:disabled {
  cursor: default;
}

/* ---------- stats ---------- */

.stat-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.stat {
  background: var(--cream);
  border-radius: 20px;
  padding: 14px;
}

.stat .value {
  font-size: 24px;
  font-weight: 700;
  line-height: 1.1;
}

.stat .label {
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
}

/* ---------- leaderboard ---------- */

.leader-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 18px;
}

.leader-row + .leader-row {
  margin-top: 6px;
}

.leader-row.you {
  background: var(--lavender);
}

.leader-row .rank {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 13px;
  font-weight: 700;
  background: var(--cream);
  color: var(--muted);
  flex: 0 0 auto;
}

.leader-row .rank.gold {
  background: #fff1c9;
  color: #8a6100;
}

.leader-row .rank.silver {
  background: #eceef4;
  color: #566078;
}

.leader-row .rank.bronze {
  background: #f7e3d3;
  color: #8a4a1b;
}

.leader-row .name {
  font-weight: 600;
  font-size: 15px;
}

.leader-row .pts {
  margin-left: auto;
  font-weight: 700;
  font-size: 14px;
  color: var(--primary-deep);
}

/* ---------- bottom nav ---------- */

.nav {
  position: fixed;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  width: 100%;
  max-width: 980px;
  padding: 10px 14px 14px;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(14px);
  border-top: 1px solid rgba(12, 9, 42, 0.06);
  border-radius: 24px 24px 0 0;
  z-index: 20;
}

.nav button {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 8px 4px;
  border: 0;
  background: none;
  border-radius: 14px;
  font-family: inherit;
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
}

.nav button[aria-current="page"] {
  color: var(--primary-deep);
}

.nav button[aria-current="page"] .nav-dot {
  background: var(--primary);
}

.nav svg {
  width: 22px;
  height: 22px;
}

/* ---------- misc ---------- */

.top-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}

.icon-btn {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  border: 0;
  background: #fff;
  color: var(--ink);
  display: grid;
  place-items: center;
  cursor: pointer;
  box-shadow: var(--shadow-soft);
}

.icon-btn svg {
  width: 20px;
  height: 20px;
}

.result-banner {
  background: linear-gradient(150deg, var(--primary) 0%, var(--primary-deep) 100%);
  color: #fff;
  border-radius: var(--r-card);
  padding: 24px;
  text-align: center;
  margin-bottom: 16px;
}

.result-banner .score {
  font-size: 48px;
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.03em;
}

.result-banner .vs {
  font-size: 13px;
  opacity: 0.75;
  margin-top: 6px;
}

.review-item {
  border-radius: 18px;
  padding: 14px 16px;
  border: 1.5px solid var(--lavender);
}

.review-item + .review-item {
  margin-top: 8px;
}

.review-item .q {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 4px;
}

.review-item .a {
  font-size: 13px;
  color: var(--muted);
}

.review-item .a strong {
  color: var(--success);
}

.review-item.wrong .a strong {
  color: var(--error);
}

.skeleton {
  background: linear-gradient(90deg, #f2f1fa 25%, #e9e7f7 37%, #f2f1fa 63%);
  background-size: 400% 100%;
  animation: shimmer 1.2s ease infinite;
  border-radius: 16px;
}

@keyframes shimmer {
  0% {
    background-position: 100% 0;
  }
  100% {
    background-position: 0 0;
  }
}

.fade-in {
  animation: fade 0.22s ease both;
}

@keyframes fade {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.footer-note {
  text-align: center;
  color: var(--muted);
  font-size: 12px;
  margin-top: 18px;
}

@media (max-width: 430px) {
  #app {
    padding: 12px 12px 112px;
  }

  .hero {
    border-radius: 26px;
    padding: 22px 18px 24px;
  }

  .sheet {
    border-radius: 26px;
    padding: 18px 16px;
  }

  h1 {
    font-size: 23px;
  }

  .result-banner .score {
    font-size: 42px;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.001ms !important;
    transition-duration: 0.001ms !important;
  }
}
