/* ============================================================================
   quizzapp — shared joyful theme
   Colorful, rounded, bouncy. Used by the landing, host and guest front-ends.
   ========================================================================== */

:root {
  --pink: #ff4d8d;
  --purple: #7c3aed;
  --violet: #a855f7;
  --teal: #06d6a0;
  --yellow: #ffd166;
  --blue: #4cc9f0;
  --red: #ef476f;
  --orange: #ff8c42;

  --ink: #221b3a;
  --ink-soft: #6b6488;
  --surface: #ffffff;
  --surface-2: #f7f4ff;

  --radius: 22px;
  --radius-sm: 14px;
  --shadow: 0 18px 40px -16px rgba(60, 20, 90, 0.45);
  --shadow-sm: 0 8px 20px -10px rgba(60, 20, 90, 0.4);
  --ring: 0 0 0 4px rgba(124, 58, 237, 0.25);

  --font: "Trebuchet MS", "Segoe UI", system-ui, -apple-system, sans-serif;

  --bg-grad: linear-gradient(135deg, #7c3aed 0%, #ec4899 45%, #ff8c42 100%);
}

* {
  box-sizing: border-box;
}

/* The hidden attribute must always win, even over class display rules
   (e.g. .btn { display: inline-flex }) so [hidden] toggling works everywhere. */
[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  height: 100%;
}

body {
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg-grad);
  background-attachment: fixed;
  min-height: 100%;
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
}

/* A custom background image (per-quiz / per-question) is layered behind. */
body.has-custom-bg::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -3;
  background-image: var(--custom-bg);
  background-size: cover;
  background-position: center;
  transition: background-image 0.6s ease;
}
body.has-custom-bg::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -2;
  background: linear-gradient(180deg, rgba(30, 10, 50, 0.25), rgba(30, 10, 50, 0.55));
}

/* The floating-sprite + fireworks canvas/layer sits above background, below UI. */
.fx-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: -1;
  overflow: hidden;
}
.fx-sprite {
  position: absolute;
  will-change: transform, opacity;
  user-select: none;
  filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.15));
}
.fx-canvas {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 50;
}

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

.app {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: clamp(16px, 4vw, 40px);
}

.screen {
  width: 100%;
  max-width: 720px;
  margin: auto;
  animation: pop-in 0.45s cubic-bezier(0.2, 1.3, 0.4, 1) both;
}
.screen.wide {
  max-width: 1040px;
}
.screen[hidden] {
  display: none;
}

.card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: clamp(20px, 4vw, 36px);
}
.card + .card {
  margin-top: 18px;
}

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

.brand {
  font-size: clamp(2.2rem, 7vw, 3.6rem);
  font-weight: 900;
  letter-spacing: -1px;
  text-align: center;
  color: #fff;
  text-shadow: 0 4px 0 rgba(0, 0, 0, 0.12), 0 12px 30px rgba(0, 0, 0, 0.25);
  margin: 0 0 4px;
}
.tagline {
  text-align: center;
  color: rgba(255, 255, 255, 0.92);
  font-weight: 600;
  margin: 0 0 24px;
}
h1,
h2,
h3 {
  margin: 0 0 12px;
  line-height: 1.15;
}
.muted {
  color: var(--ink-soft);
}
.center {
  text-align: center;
}

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

.btn {
  font-family: inherit;
  font-weight: 800;
  font-size: 1.05rem;
  border: none;
  border-radius: var(--radius-sm);
  padding: 14px 22px;
  color: #fff;
  background: var(--purple);
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease, filter 0.12s ease;
  box-shadow: var(--shadow-sm);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  justify-content: center;
}
.btn:hover {
  transform: translateY(-2px) scale(1.02);
  filter: brightness(1.05);
}
.btn:active {
  transform: translateY(1px) scale(0.98);
}
.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}
.btn:focus-visible {
  outline: none;
  box-shadow: var(--ring), var(--shadow-sm);
}
.btn.big {
  font-size: 1.25rem;
  padding: 18px 30px;
  width: 100%;
}
.btn.pink {
  background: var(--pink);
}
.btn.teal {
  background: var(--teal);
  color: #053d2e;
}
.btn.yellow {
  background: var(--yellow);
  color: #5a4300;
}
.btn.blue {
  background: var(--blue);
  color: #06324a;
}
.btn.red {
  background: var(--red);
}
.btn.ghost {
  background: transparent;
  color: var(--purple);
  box-shadow: inset 0 0 0 2px rgba(124, 58, 237, 0.35);
}
.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}
.btn-row .btn {
  flex: 1 1 auto;
}

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

label {
  display: block;
  font-weight: 700;
  margin: 0 0 6px;
}
input[type="text"],
input[type="password"],
textarea {
  font-family: inherit;
  font-size: 1.05rem;
  width: 100%;
  padding: 13px 16px;
  border: 2px solid #e7e0fb;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--ink);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
input:focus,
textarea:focus {
  outline: none;
  border-color: var(--purple);
  box-shadow: var(--ring);
}
.field {
  margin-bottom: 18px;
}

/* ---- pills / badges ----------------------------------------------------- */

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: 999px;
  font-weight: 800;
  font-size: 0.95rem;
  background: var(--surface-2);
  color: var(--purple);
}
.pill.solid {
  background: var(--purple);
  color: #fff;
}

/* ---- player chips (host lobby + guest lobby) ---------------------------- */

.player-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin-top: 10px;
}
.chip {
  background: var(--surface-2);
  color: var(--purple);
  border-radius: 999px;
  padding: 7px 14px;
  font-weight: 800;
  animation: pop-in 0.3s ease both;
}
.chip.muted {
  opacity: 0.5;
}

/* ---- toast / errors ----------------------------------------------------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%) translateY(120%);
  background: var(--ink);
  color: #fff;
  padding: 14px 22px;
  border-radius: var(--radius-sm);
  font-weight: 700;
  box-shadow: var(--shadow);
  z-index: 100;
  transition: transform 0.3s cubic-bezier(0.2, 1.3, 0.4, 1);
  max-width: 90vw;
}
.toast.show {
  transform: translateX(-50%) translateY(0);
}
.toast.error {
  background: var(--red);
}

/* ---- animations --------------------------------------------------------- */

@keyframes pop-in {
  from {
    opacity: 0;
    transform: translateY(18px) scale(0.96);
  }
  to {
    opacity: 1;
    transform: none;
  }
}
@keyframes pulse {
  0%, 100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.06);
  }
}
@keyframes wiggle {
  0%, 100% {
    transform: rotate(-2deg);
  }
  50% {
    transform: rotate(2deg);
  }
}
@keyframes float-up {
  from {
    transform: translateY(110vh) rotate(0deg);
    opacity: 0;
  }
  10% {
    opacity: 1;
  }
  90% {
    opacity: 1;
  }
  to {
    transform: translateY(-20vh) rotate(360deg);
    opacity: 0;
  }
}
.pulse {
  animation: pulse 1.4s ease-in-out infinite;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}
