@import url("https://fonts.googleapis.com/css2?family=Fredoka:wght@400;500;600;700&display=swap");

:root {
  --pink: #ff3d9a;
  --pink-2: #ff8ccf;
  --purple: #7b2cff;
  --purple-2: #b07cff;
  --deep: #1a0b2e;
  --ink: #ffffff;
  --muted: #e9d8ff;
  --card: rgba(30, 10, 55, 0.72);
  --card-border: rgba(255, 140, 207, 0.35);
  --a0: #ff2e93;   /* star   */
  --a1: #6d28ff;   /* heart  */
  --a2: #c026d3;   /* diamond*/
  --a3: #3b5bdb;   /* circle */
  --good: #2fd38a;
  --bad: #ff4d6d;
  --radius: 18px;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: "Fredoka", system-ui, -apple-system, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--deep);
  min-height: 100vh;
  overflow-x: hidden;
}

/* ---------------- background ---------------- */
#bg { position: fixed; inset: 0; z-index: -2; overflow: hidden; }
#bg .slide {
  position: absolute; inset: 0;
  background-size: cover; background-position: center 25%;
  opacity: 0; transition: opacity 1.6s ease;
  transform: scale(1.06);
  animation: kenburns 24s ease-in-out infinite alternate;
}
#bg .slide.on { opacity: 1; }
@keyframes kenburns { to { transform: scale(1.14) translate(-1.5%, -1%); } }
#bg::after {
  content: ""; position: absolute; inset: 0;
  background:
    radial-gradient(ellipse at top left, rgba(255, 61, 154, .55), transparent 60%),
    radial-gradient(ellipse at bottom right, rgba(123, 44, 255, .65), transparent 60%),
    linear-gradient(160deg, rgba(26, 11, 46, .55), rgba(26, 11, 46, .8));
}

/* fallback member panels (used when /backgrounds has no photos) */
.member-slide {
  display: flex; align-items: center; justify-content: center; flex-direction: column;
  background: linear-gradient(135deg, var(--c1), var(--c2));
}
.member-slide .emoji { font-size: min(38vw, 340px); filter: drop-shadow(0 20px 40px rgba(0,0,0,.35)); opacity: .55; }
.member-slide .mname {
  font-size: min(14vw, 150px); font-weight: 700; letter-spacing: .04em;
  color: rgba(255,255,255,.22); text-transform: uppercase; line-height: 1; margin-top: -.2em;
  text-align: center;
}
.member-slide .zoo { font-size: min(5vw, 40px); color: rgba(255,255,255,.35); margin-top: .4em; }

.sparkles { position: fixed; inset: 0; pointer-events: none; z-index: -1; }
.sparkles span {
  position: absolute; bottom: -20px; font-size: 18px; opacity: .7;
  animation: rise linear infinite;
}
@keyframes rise { to { transform: translateY(-110vh) rotate(360deg); opacity: 0; } }

.bg-credit {
  position: fixed; right: 12px; bottom: 8px; font-size: 13px; color: rgba(255,255,255,.7);
  text-shadow: 0 1px 4px rgba(0,0,0,.6); z-index: 1; pointer-events: none;
}

/* ---------------- layout ---------------- */
.wrap { max-width: 1100px; margin: 0 auto; padding: 24px 16px 60px; }
.center { display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 100vh; text-align: center; padding: 24px 16px; }

.logo {
  font-size: clamp(42px, 9vw, 96px); font-weight: 700; line-height: 1; margin: 0 0 6px;
  background: linear-gradient(90deg, #fff, var(--pink-2), #fff, var(--purple-2));
  background-size: 300% 100%;
  -webkit-background-clip: text; background-clip: text; color: transparent;
  animation: shimmer 6s linear infinite;
  filter: drop-shadow(0 6px 20px rgba(255, 61, 154, .5));
}
@keyframes shimmer { to { background-position: 300% 0; } }
.tag { color: var(--muted); font-size: clamp(16px, 3vw, 22px); margin: 0 0 28px; }

.panel {
  background: var(--card); border: 2px solid var(--card-border);
  border-radius: var(--radius); padding: 22px;
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  box-shadow: 0 20px 60px rgba(0,0,0,.35);
}
.panel h2 { margin: 0 0 14px; font-size: 24px; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.grow { flex: 1; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.hidden { display: none !important; }

.home-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 18px; width: 100%; max-width: 900px; }
.home-grid .panel { text-align: left; }

/* ---------------- controls ---------------- */
input, select, textarea {
  font: inherit; color: #2a0f45; background: #fff;
  border: 3px solid transparent; border-radius: 12px;
  padding: 12px 14px; font-size: 18px; width: 100%;
  outline: none; transition: border-color .15s;
}
input:focus, select:focus, textarea:focus { border-color: var(--pink); }
textarea { resize: vertical; min-height: 70px; }
.pin-input { text-align: center; font-size: 30px; font-weight: 700; letter-spacing: .25em; }

button, .btn {
  font: inherit; font-weight: 600; font-size: 18px; cursor: pointer;
  border: 0; border-radius: 12px; padding: 12px 20px; color: #fff;
  background: linear-gradient(135deg, var(--pink), var(--purple));
  box-shadow: 0 5px 0 rgba(0,0,0,.3); transition: transform .08s, filter .15s;
  text-decoration: none; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
}
button:hover, .btn:hover { filter: brightness(1.1); }
button:active, .btn:active { transform: translateY(3px); box-shadow: 0 2px 0 rgba(0,0,0,.3); }
button:disabled { opacity: .5; cursor: not-allowed; }
button.ghost, .btn.ghost { background: rgba(255,255,255,.14); box-shadow: none; }
button.danger { background: linear-gradient(135deg, #ff4d6d, #c9184a); }
button.big, .btn.big { font-size: 24px; padding: 16px 30px; }
button.block, .btn.block { width: 100%; }

.error { color: #ffd1dc; background: rgba(255, 77, 109, .25); border-radius: 10px; padding: 8px 12px; }
.error:empty { display: none; }

/* ---------------- answers ---------------- */
.answers { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.ans {
  border-radius: 14px; padding: 22px 18px; font-size: clamp(18px, 2.6vw, 30px); font-weight: 600;
  display: flex; align-items: center; gap: 14px; text-align: left; min-height: 96px;
  box-shadow: 0 6px 0 rgba(0,0,0,.3); color: #fff; transition: opacity .3s, transform .3s;
  word-break: break-word;
}
.ans .shape { font-size: 1.4em; flex: none; width: 1.3em; text-align: center; }
.ans.a0 { background: var(--a0); }
.ans.a1 { background: var(--a1); }
.ans.a2 { background: var(--a2); }
.ans.a3 { background: var(--a3); }
.ans.dim { opacity: .28; transform: scale(.97); }
.ans.right { outline: 5px solid #fff; }
.ans .count { margin-left: auto; font-size: .8em; background: rgba(0,0,0,.25); border-radius: 10px; padding: 2px 10px; }

/* player tap buttons */
.pads { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; height: calc(100vh - 170px); min-height: 320px; }
.pads.two { grid-template-rows: 1fr; }
.pad {
  border-radius: 18px; font-size: 22px; flex-direction: column; padding: 14px; gap: 6px;
  box-shadow: 0 7px 0 rgba(0,0,0,.3); height: 100%;
}
.pad .shape { font-size: 64px; line-height: 1; }
.pad .txt { font-size: 17px; font-weight: 500; opacity: .95; }
.pad.a0 { background: var(--a0); } .pad.a1 { background: var(--a1); }
.pad.a2 { background: var(--a2); } .pad.a3 { background: var(--a3); }

/* ---------------- host screens ---------------- */
.topbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.pill { background: rgba(255,255,255,.15); border-radius: 999px; padding: 6px 16px; font-weight: 600; }

.join-banner { display: grid; grid-template-columns: auto 1fr auto; gap: 20px; align-items: center; }
.join-url { font-size: clamp(20px, 3.4vw, 40px); font-weight: 700; word-break: break-all; }
.pin-big {
  font-size: clamp(52px, 10vw, 110px); font-weight: 700; letter-spacing: .08em; line-height: 1;
  background: #fff; color: var(--purple); border-radius: 18px; padding: 10px 24px;
}
.players { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin: 22px 0; min-height: 60px; }
.chip {
  background: #fff; color: #3b0d6b; border-radius: 999px; padding: 8px 18px; font-size: 22px; font-weight: 600;
  animation: pop .35s cubic-bezier(.2, 1.6, .5, 1); cursor: default;
}
.chip:hover { text-decoration: line-through; cursor: pointer; }
@keyframes pop { from { transform: scale(0); } to { transform: scale(1); } }

.question-text {
  background: #fff; color: #2a0f45; border-radius: var(--radius);
  font-size: clamp(24px, 4vw, 48px); font-weight: 700; text-align: center; padding: 26px; margin-bottom: 20px;
  box-shadow: 0 12px 40px rgba(0,0,0,.3);
}
.q-mid { display: grid; grid-template-columns: 120px 1fr 120px; align-items: center; margin-bottom: 20px; gap: 12px; }
.timer {
  width: 110px; height: 110px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  font-size: 46px; font-weight: 700; background: linear-gradient(135deg, var(--pink), var(--purple));
  box-shadow: 0 0 0 6px rgba(255,255,255,.25);
}
.timer.low { animation: pulse .5s ease-in-out infinite alternate; }
@keyframes pulse { to { transform: scale(1.08); box-shadow: 0 0 0 10px rgba(255, 61, 154, .5); } }
.answered-box { text-align: center; font-size: 22px; }
.answered-box b { display: block; font-size: 48px; }
.author { text-align: center; color: var(--muted); margin-bottom: 10px; }

.bars { display: flex; justify-content: center; align-items: flex-end; gap: 22px; height: 180px; margin-bottom: 20px; }
.bar { width: 80px; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; }
.bar .fill { width: 100%; border-radius: 10px 10px 0 0; transition: height .8s cubic-bezier(.2, 1, .3, 1); min-height: 6px; }
.bar .lbl { font-size: 26px; font-weight: 700; margin-bottom: 4px; }

.board { max-width: 720px; margin: 0 auto; display: flex; flex-direction: column; gap: 10px; }
.board .line {
  display: flex; justify-content: space-between; align-items: center;
  background: rgba(255,255,255,.95); color: #2a0f45; border-radius: 14px; padding: 14px 22px;
  font-size: 26px; font-weight: 600; animation: slide .4s ease backwards;
}
.board .line:nth-child(1) { background: linear-gradient(90deg, #fff, #ffe0f1); }
@keyframes slide { from { transform: translateX(-40px); opacity: 0; } }
.board .line .streak { font-size: 18px; color: var(--pink); margin-left: 10px; }

.podium { display: flex; justify-content: center; align-items: flex-end; gap: 16px; margin: 30px 0; }
.podium .step { width: min(28vw, 220px); text-align: center; }
.podium .block {
  border-radius: 16px 16px 0 0; display: flex; align-items: flex-start; justify-content: center;
  font-size: 60px; font-weight: 700; padding-top: 10px;
  animation: grow 1s cubic-bezier(.2, 1, .3, 1) backwards;
}
.podium .p1 .block { height: 260px; background: linear-gradient(180deg, var(--pink), #c2185b); animation-delay: 1.4s; }
.podium .p2 .block { height: 190px; background: linear-gradient(180deg, var(--purple-2), var(--purple)); animation-delay: .7s; }
.podium .p3 .block { height: 140px; background: linear-gradient(180deg, #e0a3ff, #8e44ad); }
.podium .name { font-size: 26px; font-weight: 700; margin-bottom: 4px; word-break: break-word; }
.podium .pts { color: var(--muted); margin-bottom: 10px; }
@keyframes grow { from { height: 0; } }

/* ---------------- player result ---------------- */
.result { font-size: 40px; font-weight: 700; }
.result .icon { font-size: 110px; display: block; animation: pop .5s cubic-bezier(.2, 1.6, .5, 1); }
.result.good .icon { color: var(--good); }
.result.bad .icon { color: var(--bad); }
.scorebar {
  position: fixed; left: 0; right: 0; bottom: 0; display: flex; justify-content: space-between;
  padding: 12px 18px; background: rgba(26, 11, 46, .85); font-weight: 600; font-size: 18px;
  backdrop-filter: blur(8px);
}

/* ---------------- card editor ---------------- */
.card-edit { margin-bottom: 16px; }
.card-edit .ans-edit { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.ans-field { display: flex; align-items: center; gap: 8px; border-radius: 12px; padding: 6px 8px; }
.ans-field.a0 { background: var(--a0); } .ans-field.a1 { background: var(--a1); }
.ans-field.a2 { background: var(--a2); } .ans-field.a3 { background: var(--a3); }
.ans-field input[type=text] { padding: 8px 10px; font-size: 16px; }
.ans-field .shape { font-size: 22px; width: 24px; text-align: center; }
.ans-field label { display: flex; align-items: center; gap: 4px; font-size: 13px; white-space: nowrap; cursor: pointer; }
.ans-field input[type=radio] { width: 22px; height: 22px; accent-color: #fff; }
.card-num { font-weight: 700; color: var(--pink-2); }
.deck-list { display: flex; flex-direction: column; gap: 8px; }
.deck-item { display: flex; align-items: center; gap: 10px; background: rgba(255,255,255,.1); border-radius: 12px; padding: 10px 14px; }
.deck-item .grow { font-weight: 600; }
.deck-item button { padding: 8px 14px; font-size: 15px; }

label.check { display: flex; align-items: center; gap: 8px; cursor: pointer; }
label.check input { width: 20px; height: 20px; accent-color: var(--pink); }

.toast {
  position: fixed; left: 50%; top: 20px; transform: translateX(-50%);
  background: #fff; color: var(--purple); font-weight: 600; padding: 12px 22px; border-radius: 999px;
  box-shadow: 0 10px 30px rgba(0,0,0,.3); z-index: 10; animation: pop .3s;
}

.qr { background: #fff; border-radius: 14px; padding: 8px; width: 170px; cursor: zoom-in; box-shadow: 0 0 0 4px var(--pink-2); }
.qr-svg svg { display: block; width: 100%; height: auto; }
.qr-overlay {
  position: fixed; inset: 0; z-index: 20; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 18px; background: rgba(26, 11, 46, .92); backdrop-filter: blur(8px); cursor: zoom-out; padding: 16px; text-align: center;
  animation: pop .3s;
}
.qr-big { background: #fff; border-radius: 24px; padding: 18px; width: min(70vh, 86vw); box-shadow: 0 0 0 8px var(--pink), 0 0 60px rgba(255, 61, 154, .6); }

@media (max-width: 700px) {
  .qr { margin: 0 auto; }
  .answers { grid-template-columns: 1fr; }
  .join-banner { grid-template-columns: 1fr; text-align: center; }
  .q-mid { grid-template-columns: 80px 1fr 80px; }
  .timer { width: 74px; height: 74px; font-size: 32px; }
  .card-edit .ans-edit { grid-template-columns: 1fr; }
  .bars { gap: 10px; } .bar { width: 56px; }
}
