/* Quiz Rocket shared look: a friendly night sky with bright, chunky buttons. */
@import url('https://fonts.googleapis.com/css2?family=Baloo+2:wght@500;700;800&display=swap');

:root {
  --sky-1: #1b1250;
  --sky-2: #3a1d7a;
  --sky-3: #0d3b66;
  --ink: #1d1b2f;
  --card: #ffffff;
  --muted: #6b6785;
  --gold: #ffc83d;
  --silver: #c9d3e0;
  --bronze: #e08a4f;
  --good: #16a34a;
  --bad: #dc2626;
  /* answer colours: star, heart, moon, bolt */
  --a0: #e8590c;
  --a1: #db2777;
  --a2: #0f8b8d;
  --a3: #7c3aed;
  --radius: 18px;
  --shadow: 0 6px 0 rgba(0, 0, 0, .25);
  font-family: 'Baloo 2', 'Segoe UI', system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  color: #fff;
  background: radial-gradient(ellipse at 20% 0%, var(--sky-2), transparent 60%),
              radial-gradient(ellipse at 90% 100%, var(--sky-3), transparent 55%),
              var(--sky-1);
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
}
button, input, select, textarea { font: inherit; }

/* ----- twinkling stars and floating planets ----- */
.sky { position: fixed; inset: 0; pointer-events: none; z-index: 0; overflow: hidden; }
.sky .star { position: absolute; background: #fff; border-radius: 50%; animation: twinkle 3s ease-in-out infinite; }
/* theme decorations and effects */
.sky .deco { position: absolute; line-height: 1; filter: drop-shadow(0 6px 8px rgba(0, 0, 0, .25)); }
.sky .deco.float { animation: float 7s ease-in-out infinite; }
.sky .deco.bob { animation: bob 3s ease-in-out infinite; }
.sky .deco.sway { animation: sway 5s ease-in-out infinite; transform-origin: bottom center; }
.sky .deco.spin { animation: spin 8s linear infinite; }
.sky .deco.drift { animation: drift 30s ease-in-out infinite; opacity: .9; }
.sky .deco.swim { animation: swim 16s ease-in-out infinite; }
.sky .particle { position: absolute; top: -40px; opacity: .85; }
.sky .particle.fall { animation: fall 12s linear infinite; }
.sky .particle.rise { top: auto; bottom: -40px; animation: rise 12s linear infinite; opacity: .6; }
.sky .burst { position: absolute; width: 160px; height: 160px; border-radius: 50%; animation: burst 3.2s ease-out infinite;
  background: radial-gradient(circle, transparent 30%, currentColor 31%, currentColor 34%, transparent 35%),
              repeating-conic-gradient(currentColor 0 4deg, transparent 4deg 30deg);
  -webkit-mask: radial-gradient(circle, transparent 20%, #000 21%, #000 70%, transparent 71%);
          mask: radial-gradient(circle, transparent 20%, #000 21%, #000 70%, transparent 71%); }
.sky .burst.b1 { color: #ffc83d; }
.sky .burst.b2 { color: #ff6b9d; animation-delay: -.8s; }
.sky .burst.b3 { color: #4dd0e1; animation-delay: -1.6s; }
.sky .burst.b4 { color: #b388ff; animation-delay: -2.4s; }
@keyframes bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-14px); } }
@keyframes sway { 0%, 100% { transform: rotate(-6deg); } 50% { transform: rotate(6deg); } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes drift { 0%, 100% { transform: translateX(0); } 50% { transform: translateX(60px); } }
@keyframes swim { 0%, 100% { transform: translateX(0) scaleX(-1); } 49% { transform: translateX(120px) scaleX(-1); } 50% { transform: translateX(120px) scaleX(1); } 99% { transform: translateX(0) scaleX(1); } }
@keyframes fall { from { transform: translateY(0) rotate(0); } to { transform: translateY(110vh) rotate(360deg); } }
@keyframes rise { from { transform: translateY(0); } to { transform: translateY(-110vh); } }
@keyframes burst { 0% { transform: scale(.1); opacity: 0; } 15% { opacity: 1; } 70% { opacity: .9; } 100% { transform: scale(1.2); opacity: 0; } }
/* For people who switch off animations: everything holds still, with snow, bubbles etc. scattered across the screen. */
@media (prefers-reduced-motion: reduce) {
  .sky * { animation: none !important; }
  .sky .particle { top: var(--y) !important; bottom: auto !important; }
  .sky .star { opacity: .7; }
  .sky .burst { transform: scale(.9); opacity: .8; }
  .sky .rocket { display: none; }
}

.sky .planet { position: absolute; border-radius: 50%; opacity: .9; animation: float 14s ease-in-out infinite; }
.sky .planet.p1 { width: 140px; height: 140px; left: -40px; top: 18%;
  background: radial-gradient(circle at 30% 30%, #ffd27a, #f08a24 60%, #b45309); }
.sky .planet.p2 { width: 90px; height: 90px; right: 6%; top: 8%;
  background: radial-gradient(circle at 30% 30%, #a5f3fc, #06b6d4 60%, #0e7490); animation-delay: -5s; }
.sky .planet.p2::after { content: ''; position: absolute; left: -30%; top: 42%; width: 160%; height: 16%;
  border-radius: 50%; border: 5px solid rgba(255, 255, 255, .55); transform: rotate(-18deg); }
.sky .planet.p3 { width: 60px; height: 60px; right: 12%; bottom: 10%;
  background: radial-gradient(circle at 30% 30%, #f9a8d4, #db2777 65%, #9d174d); animation-delay: -9s; }
.sky .rocket { position: absolute; font-size: 42px; left: -60px; bottom: 20%; animation: flyby 22s linear infinite; }
@keyframes twinkle { 0%, 100% { opacity: .25; } 50% { opacity: 1; } }
@keyframes float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-22px); } }
@keyframes flyby {
  0% { transform: translate(0, 0) rotate(45deg); }
  60% { transform: translate(115vw, -40vh) rotate(45deg); }
  100% { transform: translate(115vw, -40vh) rotate(45deg); }
}

.app { position: relative; z-index: 1; }
.hidden { display: none !important; }

/* ----- logo ----- */
.logo { display: inline-flex; align-items: center; gap: 8px; font-weight: 800; font-size: 34px; letter-spacing: .5px;
  color: #fff; text-decoration: none; text-shadow: 0 3px 0 rgba(0, 0, 0, .3); }
.logo .mark { font-size: 1.1em; display: inline-block; animation: float 4s ease-in-out infinite; }
.logo b { color: var(--gold); }

/* ----- cards, buttons, inputs ----- */
.card { background: var(--card); color: var(--ink); border-radius: var(--radius); box-shadow: var(--shadow); padding: 24px; }
.btn { border: 0; border-radius: 14px; padding: 12px 22px; font-weight: 800; font-size: 18px; cursor: pointer;
  color: #fff; background: var(--a3); box-shadow: 0 4px 0 rgba(0, 0, 0, .3); transition: transform .08s; }
.btn:hover { filter: brightness(1.08); }
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 rgba(0, 0, 0, .3); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.big { font-size: 22px; padding: 14px 28px; width: 100%; }
.btn.green { background: var(--good); }
.btn.orange { background: var(--a0); }
.btn.pink { background: var(--a1); }
.btn.teal { background: var(--a2); }
.btn.ghost { background: #eeeaf8; color: var(--ink); }
.btn.dark { background: rgba(0, 0, 0, .45); }
.btn.danger { background: var(--bad); }
.btn.small { font-size: 15px; padding: 7px 14px; }

.input { width: 100%; border: 3px solid #d9d4ee; border-radius: 14px; padding: 12px 14px; font-size: 20px;
  color: var(--ink); background: #fff; outline: none; }
.input:focus { border-color: var(--a3); }
.input.center { text-align: center; font-weight: 800; letter-spacing: 2px; }
.error { color: var(--bad); font-weight: 700; min-height: 1.4em; margin: 8px 0 0; }
.muted { color: var(--muted); }

/* ----- answer shapes ----- */
.shape svg { width: 100%; height: 100%; display: block; }
.ans { position: relative; display: flex; align-items: center; gap: 14px; border: 0; border-radius: var(--radius);
  color: #fff; font-weight: 800; text-align: left; box-shadow: var(--shadow); padding: 14px 18px; cursor: pointer;
  transition: transform .1s, opacity .3s, filter .3s; }
.ans .shape { flex: 0 0 auto; width: 44px; height: 44px; }
.ans.a0 { background: var(--a0); }
.ans.a1 { background: var(--a1); }
.ans.a2 { background: var(--a2); }
.ans.a3 { background: var(--a3); }
.ans.dim { opacity: .3; filter: grayscale(.6); }
.ans .tick { margin-left: auto; font-size: 30px; }

/* ----- timer ring ----- */
.timer { position: relative; width: 110px; height: 110px; }
.timer svg { transform: rotate(-90deg); width: 100%; height: 100%; }
.timer .num { position: absolute; inset: 0; display: grid; place-items: center; font-size: 40px; font-weight: 800; }

/* ----- leaderboard rows ----- */
.board { display: flex; flex-direction: column; gap: 10px; }
.row { display: grid; grid-template-columns: 48px 52px 1fr auto; align-items: center; gap: 10px; background: rgba(255, 255, 255, .12);
  border-radius: 14px; padding: 8px 16px; font-weight: 800; font-size: 22px; animation: slideIn .5s both; }
.row .rank { font-size: 22px; text-align: center; }
.row .av { font-size: 34px; text-align: center; }
.row .pts { font-variant-numeric: tabular-nums; }
.row.me { background: rgba(255, 200, 61, .35); outline: 3px solid var(--gold); }
.row .streak { font-size: 15px; margin-left: 8px; color: var(--gold); }
.row { position: relative; }
.row .members { font-size: .7em; margin-left: 10px; letter-spacing: 2px; opacity: .9; }
.row .move { display: inline-block; font-size: .65em; margin-left: 10px; padding: 0 8px; border-radius: 10px;
  opacity: 0; transform: scale(.4); transition: all .4s cubic-bezier(.2, 1.6, .4, 1); vertical-align: middle; }
.row .move.show { opacity: 1; transform: scale(1); }
.row .move.up { background: var(--good); }
.row .move.down { background: rgba(220, 38, 38, .8); }
/* team colours */
.team0 { --team: var(--a0); }
.team1 { --team: var(--a1); }
.team2 { --team: var(--a2); }
.team3 { --team: var(--a3); }
.row.team-row { border-left: 10px solid var(--team); }
@keyframes slideIn { from { opacity: 0; transform: translateX(-30px); } to { opacity: 1; transform: none; } }

/* ----- medals ----- */
.medal { width: 120px; height: 140px; }

/* ----- pop-in animation ----- */
.pop { animation: pop .45s cubic-bezier(.2, 1.6, .4, 1) both; }
@keyframes pop { from { transform: scale(.4); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.bounce { animation: bounce 1.2s ease-in-out infinite; }
@keyframes bounce { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-12px); } }

/* ----- pin answer pictures ----- */
/* The board is exactly the picture's shape (--ratio = width / height) and no taller than --maxh. */
.pin-board { position: relative; flex: 0 0 auto; line-height: 0; border-radius: 14px; overflow: hidden; box-shadow: var(--shadow);
  width: min(100%, calc(var(--maxh, 50vh) * var(--ratio, 1.5))); aspect-ratio: var(--ratio, 1.5); }
.pin-board img { display: block; width: 100%; height: 100%; user-select: none; -webkit-user-select: none; }
.pin-target { position: absolute; aspect-ratio: 1; transform: translate(-50%, -50%); border-radius: 50%;
  border: 4px solid #fff; background: rgba(34, 197, 94, .45); box-shadow: 0 0 0 3px var(--good), 0 0 18px rgba(0, 0, 0, .4); pointer-events: none; }
.pin-target::after { content: ''; position: absolute; left: 50%; top: 50%; width: 8px; height: 8px; border-radius: 50%; background: #fff; transform: translate(-50%, -50%); }
/* `translate` (not `transform`) centres pins, so the pop-in animation (which uses transform) doesn't move them. */
.pin-dot { position: absolute; width: 16px; height: 16px; border-radius: 50%; translate: -50% -50%; border: 3px solid #fff;
  box-shadow: 0 2px 4px rgba(0, 0, 0, .5); pointer-events: none; animation: pop .4s cubic-bezier(.2, 1.6, .4, 1) both; }
.pin-dot.in { background: var(--good); }
.pin-dot.out { background: var(--bad); }
.my-pin { position: absolute; font-size: 40px; line-height: 1; translate: -50% -92%; pointer-events: none;
  filter: drop-shadow(0 3px 3px rgba(0, 0, 0, .5)); animation: pop .3s cubic-bezier(.2, 1.6, .4, 1) both; }

canvas.confetti { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 50; }

.sound-btn { position: fixed; right: 14px; bottom: 14px; z-index: 40; width: 48px; height: 48px; border-radius: 50%;
  border: 0; background: rgba(0, 0, 0, .4); color: #fff; font-size: 22px; cursor: pointer; }

/* Shown while the connection to the game is lost (QR.watchConnection). */
.offline-banner { position: fixed; top: 0; left: 0; right: 0; z-index: 100; background: #f59e0b; color: #1f1300; text-align: center;
  font-weight: 800; padding: calc(8px + env(safe-area-inset-top, 0px)) 12px 8px; box-shadow: 0 3px 10px rgba(0, 0, 0, .3); animation: offlinePulse 1.6s ease-in-out infinite; }
.offline-banner.hidden { display: none; }
@keyframes offlinePulse { 50% { background: #fbbf24; } }

/* The big screen's 3D shows (show3d.js): Flock Together's sheep and the quizzes' rockets. */
.ps3d { position: fixed; inset: 0; z-index: 50; cursor: pointer; overflow: hidden;
  background: radial-gradient(ellipse at 50% 30%, #f9a8d4, #7c3aed 45%, #1b1250 85%); animation: ps3dIn .4s ease-out; }
.ps3d canvas { position: absolute; inset: 0; display: block; }
.ps3d.out { opacity: 0; transition: opacity .45s; }
.ps3d-caption { position: absolute; top: 5vh; left: 0; right: 0; margin: 0; text-align: center; padding: 0 20px;
  font-size: clamp(30px, 5vw, 68px); font-weight: 900; color: #fff; text-shadow: 0 4px 0 #db2777, 0 8px 24px rgba(0, 0, 0, .4); }
.ps3d-label { position: absolute; translate: -50% 0; display: flex; flex-direction: column; align-items: center; gap: 2px;
  background: #fff; color: var(--ink); border-radius: 18px; padding: 8px 18px 10px; box-shadow: var(--shadow);
  font-size: clamp(18px, 2.2vw, 28px); white-space: nowrap; transition: transform .3s, background .3s, color .3s; }
.ps3d-label .ps3d-av { font-size: 1.6em; line-height: 1; }
.ps3d-label i { font-style: normal; font-weight: 900; font-size: .75em; }
.ps3d-label i:empty { display: none; }
.ps3d-label.now { background: #f472b6; color: #fff; transform: scale(1.15); animation: ps3dPulse 1s ease-in-out infinite alternate; }
.ps3d-label.free { background: #bbf7d0; }
@keyframes ps3dIn { from { opacity: 0; } }
@keyframes ps3dPulse { to { transform: scale(1.25); box-shadow: 0 0 40px rgba(244, 114, 182, .9); } }
.ps3d-tag { position: absolute; translate: -50% -100%; display: flex; align-items: center; gap: 4px; background: rgba(255, 255, 255, .92); color: var(--ink);
  border-radius: 999px; padding: 2px 10px 2px 6px; font-size: clamp(12px, 1.3vw, 18px); white-space: nowrap; box-shadow: 0 3px 8px rgba(0, 0, 0, .25); pointer-events: none; }
.ps3d-tag span { font-size: 1.3em; }
.ps3d.space { background: radial-gradient(ellipse at 50% 20%, #4c2a9e, #1b1250 55%, #07051c 100%); }
.ps3d.space .ps3d-caption { text-shadow: 0 4px 0 #7c3aed, 0 8px 24px rgba(0, 0, 0, .5); }
.ps3d-tag.big { font-size: clamp(16px, 2vw, 26px); padding: 4px 14px 4px 8px; }
.ps3d-tag.lead { background: linear-gradient(#fde68a, #facc15); transform: scale(1.15); transition: transform .3s; }
.ps3d-tag.podium1, .ps3d-tag.podium2, .ps3d-tag.podium3 { translate: -50% 0; font-size: clamp(16px, 2.2vw, 28px); padding: 6px 16px 6px 10px; transition: opacity .3s; }
.ps3d-tag.podium1 { background: linear-gradient(#fef3c7, #fde047); }
.ps3d-caption.ps3d-count { font-size: clamp(80px, 16vw, 220px); top: 2vh; }

/* A list rolling up its box (QR.rollList): fades at the top and bottom, pauses under the mouse. */
.rolling { overflow: hidden !important; -webkit-mask-image: linear-gradient(transparent, #000 12%, #000 88%, transparent); mask-image: linear-gradient(transparent, #000 12%, #000 88%, transparent); }
.rolling > .roll { animation: rollUp 10s linear 2.5s infinite; } /* the duration is set per list */
.rolling:hover > .roll { animation-play-state: paused; }
.roll-gap { height: 30px; }
@keyframes rollUp { to { transform: translateY(-50%); } }
