/* ───────────────────────── Quizz! — playful theme ───────────────────────── */
:root {
  --c0: #e84855;   /* red    / triangle */
  --c1: #2d7dd2;   /* blue   / diamond  */
  --c2: #f4b400;   /* gold   / circle   */
  --c3: #2bb673;   /* green  / square   */
  --ink: #1f1147;
  --paper: #ffffff;
  --shadow: 0 10px 30px rgba(31, 17, 71, .18);
  --radius: 22px;
  font-synthesis: none;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: 'Fredoka', 'Baloo 2', system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  color: var(--ink);
  background: linear-gradient(-45deg, #7b2ff7, #f107a3, #ff7e5f, #2d7dd2, #2bb673);
  background-size: 400% 400%;
  animation: drift 22s ease infinite;
  min-height: 100%;
  -webkit-font-smoothing: antialiased;
}
@keyframes drift {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

a { color: inherit; }

.wrap {
  max-width: 980px;
  margin: 0 auto;
  padding: 28px 18px 64px;
}
.wrap-wide { max-width: 1200px; }

/* ── brand ── */
.brand {
  font-weight: 700;
  font-size: clamp(2.4rem, 6vw, 4rem);
  color: #fff;
  text-align: center;
  letter-spacing: .5px;
  text-shadow: 0 4px 0 rgba(0, 0, 0, .12);
  margin: 6px 0 2px;
}
.brand .pop { display: inline-block; animation: pop 2.6s ease-in-out infinite; }
@keyframes pop { 0%,100% { transform: translateY(0) rotate(-3deg); } 50% { transform: translateY(-8px) rotate(3deg); } }
.tagline { text-align: center; color: #fff; opacity: .95; font-size: 1.15rem; margin-bottom: 26px; }

/* ── cards ── */
.card {
  background: var(--paper);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 26px;
  margin: 0 auto 22px;
}
.card h2 { margin-top: 0; }

/* ── buttons ── */
.btn {
  display: inline-flex; align-items: center; gap: .5rem; justify-content: center;
  border: none; cursor: pointer;
  font-family: inherit; font-weight: 600; font-size: 1.05rem;
  padding: 14px 24px; border-radius: 999px;
  background: var(--ink); color: #fff;
  box-shadow: 0 6px 0 rgba(0,0,0,.18);
  transition: transform .08s ease, box-shadow .08s ease, filter .15s ease;
  text-decoration: none;
}
.btn:hover { filter: brightness(1.07); }
.btn:active { transform: translateY(4px); box-shadow: 0 2px 0 rgba(0,0,0,.18); }
.btn:disabled { opacity: .5; cursor: not-allowed; box-shadow: none; transform: none; }
.btn-lg { font-size: 1.25rem; padding: 18px 34px; }
.btn-pink   { background: #f107a3; }
.btn-purple { background: #7b2ff7; }
.btn-green  { background: var(--c3); }
.btn-blue   { background: var(--c1); }
.btn-gold   { background: var(--c2); color: #3a2a00; }
.btn-ghost  { background: rgba(255,255,255,.18); color:#fff; box-shadow:none; border:2px solid rgba(255,255,255,.5); }
.btn-sm { padding: 8px 14px; font-size: .92rem; box-shadow: 0 4px 0 rgba(0,0,0,.18); }
.btn-danger { background: var(--c0); }
.btn-row { display: flex; gap: 12px; flex-wrap: wrap; }

/* ── form fields ── */
label { font-weight: 600; display: block; margin: 14px 0 6px; }
input[type=text], input[type=password], textarea, select {
  width: 100%; font-family: inherit; font-size: 1.05rem;
  padding: 12px 14px; border: 2px solid #e6e1f5; border-radius: 14px;
  background: #faf9ff; color: var(--ink); outline: none;
}
input[type=text]:focus, textarea:focus { border-color: #7b2ff7; }
textarea { resize: vertical; min-height: 60px; }
.muted { color: #6b6588; }
.hint { font-size: .9rem; color: #6b6588; }

.alert { padding: 14px 16px; border-radius: 14px; margin: 0 0 18px; font-weight: 600; }
.alert-error { background: #ffe3e6; color: #b00020; }
.alert-ok    { background: #e3fbef; color: #0a7d46; }

/* ── divider with "oder" ── */
.or { display:flex; align-items:center; gap:12px; color:#fff; margin:18px 0; opacity:.9; }
.or::before, .or::after { content:""; flex:1; height:2px; background:rgba(255,255,255,.45); border-radius:2px; }

/* ── code / pin display ── */
.pin {
  font-weight: 700; letter-spacing: .35em;
  font-size: clamp(2.4rem, 9vw, 5.5rem);
  background: #fff; color: var(--ink);
  border-radius: 18px; padding: 8px 20px 8px 28px; display: inline-block;
  box-shadow: var(--shadow);
}
.copybox {
  display:flex; gap:8px; align-items:center;
  background:#f3f0ff; border:2px dashed #c9bdf2; border-radius:14px; padding:10px 12px;
  font-size:.95rem; word-break:break-all;
}

/* ── answer tiles (host display + player buttons) ── */
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.tile {
  border: none; cursor: pointer; color: #fff; font-family: inherit; font-weight: 600;
  font-size: 1.5rem; text-align: left; padding: 22px 22px; border-radius: 18px;
  display: flex; align-items: center; gap: 16px; min-height: 96px;
  box-shadow: 0 8px 0 rgba(0,0,0,.18); transition: transform .08s, box-shadow .08s, opacity .2s, filter .2s;
}
.tile:active { transform: translateY(5px); box-shadow: 0 3px 0 rgba(0,0,0,.18); }
.tile .shape { font-size: 1.6rem; line-height: 1; }
.tile-0 { background: var(--c0); }
.tile-1 { background: var(--c1); }
.tile-2 { background: var(--c2); color: #3a2a00; }
.tile-3 { background: var(--c3); }
.tile.dim { opacity: .35; filter: grayscale(.4); }
.tile.chosen { outline: 5px solid #fff; outline-offset: -5px; }

/* ── answer reveal ──
   • every tile's playful colour is muted (grayed)
   • the correct answer is always shown in green (so everyone learns it)
   • a BORDER marks the answer THIS player picked — green if right, red if
     wrong, and no border at all if they didn't answer */
.tile.revealed { opacity: .5; filter: grayscale(.92) brightness(.9); transition: filter .25s ease, opacity .25s ease; }

.tile.revealed.correct {
  opacity: 1; filter: none;
  background: var(--c3) !important; color: #fff !important;        /* green = correct */
}
.tile.revealed.correct::after { content: '✓'; margin-left: auto; font-size: 1.7rem; font-weight: 700; }

/* border = your selection */
.tile.revealed.pick-right {
  outline: 7px solid #fff; outline-offset: -7px;
  box-shadow: 0 0 0 7px rgba(43,182,115,.55), 0 12px 26px rgba(43,182,115,.45);
  animation: rightpulse .6s ease;
}
.tile.revealed.pick-wrong {
  opacity: 1; filter: none;
  background: var(--c0) !important; color: #fff !important;        /* solid red — same recolor style as the green correct tile */
  outline: 7px solid #fff; outline-offset: -7px;
  box-shadow: 0 0 0 7px rgba(232,72,85,.5), 0 12px 26px rgba(232,72,85,.4);
}
.tile.revealed.pick-wrong::after { content: '✗'; margin-left: auto; font-size: 1.7rem; font-weight: 700; }
@keyframes rightpulse { 0%{ transform:scale(1);} 40%{ transform:scale(1.04);} 100%{ transform:scale(1);} }
.tile:disabled { cursor: default; }
@media (max-width: 560px) { .tiles { grid-template-columns: 1fr; } .tile { font-size: 1.25rem; min-height: 76px; } }

/* ── big question text / image ── */
.qtext { font-size: clamp(1.6rem, 4.4vw, 3.2rem); line-height: 1.12; margin: 6px 0 18px; text-align:center; color:var(--ink); }
.qimg { max-width: 100%; max-height: 42vh; border-radius: 16px; display:block; margin: 0 auto 18px; box-shadow: var(--shadow); }

/* ── timer ring ── */
.timer { font-weight:700; font-size:2rem; }
.timerbar { height: 16px; background: rgba(255,255,255,.4); border-radius: 999px; overflow: hidden; margin: 12px 0; }
.timerbar > span { display:block; height:100%; width:100%; background: linear-gradient(90deg, var(--c3), var(--c2), var(--c0)); transition: width .1s linear; }

/* ── leaderboard ── */
.board { list-style:none; margin:0; padding:0; }
.board li {
  display:flex; align-items:center; gap:12px; padding:12px 14px; border-radius:14px; margin-bottom:8px;
  background:#f6f3ff; font-size:1.1rem; animation: slidein .35s ease;
}
.board li .rank { font-weight:700; width:34px; height:34px; border-radius:50%; background:#7b2ff7; color:#fff; display:grid; place-items:center; }
.board li .nm { flex:1; font-weight:600; }
.board li .sc { font-weight:700; }
.board li.me { outline: 3px solid #7b2ff7; }
.board li:nth-child(1) .rank { background: var(--c2); color:#3a2a00; }
.board li:nth-child(2) .rank { background: #b9b9c9; }
.board li:nth-child(3) .rank { background: #cd7f32; }
@keyframes slidein { from { opacity:0; transform: translateX(14px);} to{ opacity:1; transform:none; } }

/* ── roster chips ── */
.chips { display:flex; flex-wrap:wrap; gap:10px; }
.chip { background:#7b2ff7; color:#fff; padding:10px 16px; border-radius:999px; font-weight:600; animation: popin .3s ease; }
@keyframes popin { from{ transform:scale(.6); opacity:0;} to{ transform:scale(1); opacity:1; } }

/* ── admin question editor ── */
.qcard { background:#faf9ff; border:2px solid #ece8fb; border-radius:18px; padding:18px; margin-bottom:16px; }
.qcard .qhead { display:flex; align-items:center; gap:10px; margin-bottom:10px; }
.qcard .qnum { font-weight:700; background:#7b2ff7; color:#fff; border-radius:10px; padding:4px 12px; }
.qcard .spacer { flex:1; }
.optrow { display:flex; align-items:center; gap:10px; margin:8px 0; }
.optrow .swatch { width:26px; height:26px; border-radius:8px; flex:none; }
.optrow input[type=radio] { width:22px; height:22px; accent-color:#2bb673; }
.thumb { max-height:120px; border-radius:12px; display:block; margin:8px 0; box-shadow: var(--shadow); }
.toast { position:fixed; bottom:20px; left:50%; transform:translateX(-50%); background:var(--ink); color:#fff; padding:12px 20px; border-radius:999px; box-shadow:var(--shadow); opacity:0; transition:opacity .2s; z-index:50; }
.toast.show { opacity:1; }

.center { text-align:center; }
.hide { display:none !important; }
.spin { animation: spin 1s linear infinite; display:inline-block; }
@keyframes spin { to { transform: rotate(360deg);} }
