/* ==========================================================================
   GOOROO – visual identity
   Deep violet stage, candy-bright answer tiles, round & bouncy UI.
   ========================================================================== */

@font-face { font-family: 'Fredoka'; font-weight: 400; font-display: swap; src: url('../fonts/fredoka-latin-400-normal.woff2') format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'Fredoka'; font-weight: 600; font-display: swap; src: url('../fonts/fredoka-latin-600-normal.woff2') format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'Fredoka'; font-weight: 700; font-display: swap; src: url('../fonts/fredoka-latin-700-normal.woff2') format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'Fredoka'; font-weight: 400; font-display: swap; src: url('../fonts/fredoka-latin-ext-400-normal.woff2') format('woff2'); unicode-range: U+0100-02AF, U+0304, U+0308, U+0329, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: 'Fredoka'; font-weight: 600; font-display: swap; src: url('../fonts/fredoka-latin-ext-600-normal.woff2') format('woff2'); unicode-range: U+0100-02AF, U+0304, U+0308, U+0329, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: 'Fredoka'; font-weight: 700; font-display: swap; src: url('../fonts/fredoka-latin-ext-700-normal.woff2') format('woff2'); unicode-range: U+0100-02AF, U+0304, U+0308, U+0329, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }

:root {
  --violet-900: #160a33;
  --violet-800: #22104f;
  --violet-700: #331a78;
  --violet-500: #6c3cff;
  --violet-300: #b9a2ff;
  --violet-100: #efe9ff;
  --pink: #ff3b6b;
  --blue: #2f7bff;
  --yellow: #ffb200;
  --green: #17c27a;
  --cyan: #00d1ff;
  --ink: #1c1433;
  --muted: #6e6688;
  --line: #e6e0f5;
  --bg: #f6f3ff;
  --card: #fff;
  --radius: 18px;
  --radius-sm: 12px;
  --shadow: 0 10px 30px -12px rgba(40, 16, 110, .25);
  --shadow-pop: 0 6px 0 rgba(0, 0, 0, .22);
  --font: 'Fredoka', ui-rounded, 'SF Pro Rounded', system-ui, -apple-system, 'Segoe UI', sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: var(--font); color: var(--ink); background: var(--bg); line-height: 1.45; -webkit-font-smoothing: antialiased; }
a { color: var(--violet-500); }
img { max-width: 100%; }
h1, h2, h3 { line-height: 1.15; margin: 0 0 .5em; font-weight: 700; }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--muted); }
.small { font-size: .88rem; }
.center { text-align: center; }
.right { text-align: right; }
.mono { font-variant-numeric: tabular-nums; letter-spacing: .06em; font-weight: 600; }

/* ---------- Logo (pure CSS wordmark) ---------- */
.logo { display: inline-flex; align-items: baseline; font-weight: 700; font-size: 1.6rem; letter-spacing: -.02em; color: #fff; text-decoration: none; }
.logo-g { color: var(--yellow); }
.logo-o { display: inline-block; width: .78em; height: .78em; border-radius: 50%; margin: 0 .02em; transform: translateY(.04em); color: transparent; overflow: hidden; }
.logo-o.o1 { background: var(--pink); box-shadow: inset -.12em -.1em 0 rgba(0,0,0,.18); }
.logo-o.o2 { background: var(--cyan); box-shadow: inset -.12em -.1em 0 rgba(0,0,0,.18); animation: blink 5s infinite; }
.logo-r { color: inherit; }
.logo.xl { font-size: 3rem; }
.logo.xxl { font-size: clamp(3.5rem, 12vw, 7rem); }
.admin .sidebar .logo { color: #fff; }
@keyframes blink { 0%, 92%, 100% { transform: translateY(.04em) scaleY(1); } 95% { transform: translateY(.04em) scaleY(.1); } }

/* ---------- Buttons ---------- */
.btn { --b: var(--violet-500); display: inline-flex; align-items: center; justify-content: center; gap: .4em; font: inherit; font-weight: 600; font-size: 1rem;
  padding: .7em 1.2em; border-radius: 999px; border: 0; cursor: pointer; text-decoration: none; color: #fff; background: var(--b);
  box-shadow: 0 4px 0 color-mix(in srgb, var(--b) 60%, #000); transition: transform .12s, box-shadow .12s, filter .15s; white-space: nowrap; }
.btn:hover { filter: brightness(1.08); }
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 color-mix(in srgb, var(--b) 60%, #000); }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.btn:focus-visible, .icon-btn:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 3px solid var(--cyan); outline-offset: 2px; }
.btn-primary { --b: var(--violet-500); }
.btn-success { --b: var(--green); }
.btn-danger { --b: var(--pink); }
.btn-ghost { background: transparent; color: var(--violet-500); box-shadow: inset 0 0 0 2px var(--line); }
.btn-ghost:active { transform: translateY(1px); box-shadow: inset 0 0 0 2px var(--line); }
.btn-ghost-light { background: rgba(255,255,255,.12); color: #fff; box-shadow: inset 0 0 0 2px rgba(255,255,255,.25); }
.btn-ghost-light:active { box-shadow: inset 0 0 0 2px rgba(255,255,255,.25); }
.btn-danger-ghost { background: transparent; color: var(--pink); box-shadow: none; }
.btn-danger-ghost:active { box-shadow: none; }
.btn-sm { font-size: .85rem; padding: .45em .9em; }
.btn-lg { font-size: 1.2rem; padding: .8em 1.6em; }
.btn-block { width: 100%; }
.icon-btn { border: 0; background: rgba(255,255,255,.14); color: inherit; width: 2.6rem; height: 2.6rem; border-radius: 50%; cursor: pointer; font-size: 1.15rem; display: inline-grid; place-items: center; }
.icon-btn.small { width: 2rem; height: 2rem; font-size: .9rem; background: transparent; }
.icon-btn.small:hover { background: var(--violet-100); }
.icon-btn.danger:hover { background: #ffe3ea; }
.icon-btn:disabled { opacity: .3; cursor: default; }

/* ---------- Forms ---------- */
label { display: flex; flex-direction: column; gap: .3rem; font-weight: 600; font-size: .92rem; }
label.inline { flex-direction: row; align-items: center; gap: .45rem; font-weight: 400; }
input, select, textarea { font: inherit; font-weight: 400; color: var(--ink); background: #fff; border: 2px solid var(--line); border-radius: var(--radius-sm); padding: .62em .8em; width: 100%; transition: border-color .15s; }
input:focus, select:focus, textarea:focus { border-color: var(--violet-500); outline: none; }
input[type=checkbox], input[type=radio] { width: auto; accent-color: var(--violet-500); }
input[type=color] { width: 3rem; height: 2.6rem; padding: .15rem; cursor: pointer; }
input[type=file] { padding: .45em; }
textarea { resize: vertical; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; margin-top: 1rem; }
.form-grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); margin: 1rem 0; }
.span-2 { grid-column: span 2; }
.form-actions { display: flex; gap: .6rem; justify-content: flex-end; flex-wrap: wrap; }
.stack { display: flex; flex-direction: column; gap: 1rem; }
.inline-form { display: flex; gap: .5rem; align-items: center; }
.inline-form input:not([type=color]):not([type=checkbox]), .inline-form select { width: auto; flex: 1 1 140px; }
.inline-form.wrap { flex-wrap: wrap; }
.form-error { color: var(--pink); font-weight: 600; min-height: 1.2em; margin: .5rem 0 0; text-align: center; }

/* ---------- Alerts, badges, chips ---------- */
.alert { padding: .8rem 1rem; border-radius: var(--radius-sm); margin-bottom: 1rem; font-weight: 600; }
.alert-success { background: #dcfbea; color: #0b6b41; }
.alert-error { background: #ffe1e8; color: #a3002b; }
.alert-info { background: #e3edff; color: #133f99; }
.badge { display: inline-block; font-size: .75rem; font-weight: 600; padding: .2em .7em; border-radius: 999px; background: var(--violet-100); color: var(--violet-700); vertical-align: middle; }
.badge-published { background: #dcfbea; color: #0b6b41; }
.badge-draft { background: #eee9f8; color: var(--muted); }
.badge-public { background: #e3f6ff; color: #075f86; }
.badge-live { background: #ffe9b8; color: #7a4d00; }
.chip { display: inline-block; font-size: .75rem; font-weight: 600; padding: .15em .65em; border-radius: 999px; background: color-mix(in srgb, var(--c) 18%, #fff); color: color-mix(in srgb, var(--c) 75%, #000); }
.pill { display: inline-block; padding: .25em .8em; border-radius: 999px; background: rgba(255,255,255,.14); font-weight: 600; font-size: .9rem; }
.admin .pill { background: var(--violet-100); color: var(--violet-700); }

/* ---------- Toasts ---------- */
#toasts { position: fixed; z-index: 100; left: 50%; bottom: 1.2rem; transform: translateX(-50%); display: flex; flex-direction: column; gap: .5rem; align-items: center; pointer-events: none; }
.toast { background: var(--ink); color: #fff; padding: .7rem 1.2rem; border-radius: 999px; font-weight: 600; box-shadow: var(--shadow); animation: toastIn .3s cubic-bezier(.3,1.6,.6,1); transition: opacity .4s, transform .4s; }
.toast-error { background: var(--pink); }
.toast-success { background: var(--green); }
.toast.out { opacity: 0; transform: translateY(10px); }
@keyframes toastIn { from { transform: translateY(20px) scale(.9); opacity: 0; } }

/* ---------- Animations ---------- */
.pop-in { animation: popIn .5s cubic-bezier(.3,1.5,.6,1) both; animation-delay: calc(var(--i, 0) * 50ms); }
@keyframes popIn { from { opacity: 0; transform: scale(.85) translateY(14px); } }
.shake { animation: shake .4s; }
@keyframes shake { 20%, 60% { transform: translateX(-8px); } 40%, 80% { transform: translateX(8px); } }
.bump { animation: bump .35s cubic-bezier(.3,1.8,.6,1); }
@keyframes bump { 50% { transform: scale(1.18); } }
.bounce { animation: bounce 1.6s ease-in-out infinite; }
@keyframes bounce { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-14px); } }
.spin { animation: rocket 1.2s ease-in-out infinite; }
@keyframes rocket { 50% { transform: translateY(-10px) rotate(-8deg); } }
.dots { display: inline-flex; gap: .25em; vertical-align: middle; }
.dots i { width: .45em; height: .45em; border-radius: 50%; background: currentColor; animation: dot 1.2s infinite; }
.dots i:nth-child(2) { animation-delay: .15s; } .dots i:nth-child(3) { animation-delay: .3s; }
@keyframes dot { 0%, 80%, 100% { opacity: .25; transform: scale(.8); } 40% { opacity: 1; transform: scale(1); } }
.loader { display: flex; gap: .6rem; justify-content: center; padding: 4rem; }
.loader span { width: 1rem; height: 1rem; border-radius: 50%; background: var(--yellow); animation: dot 1s infinite; }
.loader span:nth-child(2) { background: var(--pink); animation-delay: .15s; } .loader span:nth-child(3) { background: var(--cyan); animation-delay: .3s; }

/* ==========================================================================
   ADMIN
   ========================================================================== */
.admin-shell { display: grid; grid-template-columns: 250px 1fr; min-height: 100vh; background: linear-gradient(90deg, var(--violet-900) 250px, transparent 250px); }
.sidebar { background: linear-gradient(180deg, var(--violet-800), var(--violet-900)); color: #fff; padding: 1.4rem 1rem; display: flex; flex-direction: column; gap: 1.5rem; position: sticky; top: 0; height: 100vh; }
.sidebar-logo { text-decoration: none; padding: 0 .6rem; }
.sidebar nav { display: flex; flex-direction: column; gap: .25rem; flex: 1; }
.sidebar nav a { color: rgba(255,255,255,.8); text-decoration: none; padding: .65rem .8rem; border-radius: var(--radius-sm); font-weight: 600; display: flex; gap: .6rem; transition: background .15s; }
.sidebar nav a:hover { background: rgba(255,255,255,.08); color: #fff; }
.sidebar nav a.active { background: var(--violet-500); color: #fff; box-shadow: 0 4px 0 rgba(0,0,0,.25); }
.sidebar-user { display: flex; align-items: center; justify-content: space-between; gap: .5rem; padding: .8rem; border-radius: var(--radius-sm); background: rgba(255,255,255,.07); }
.sidebar-user strong, .sidebar-user small { display: block; }
.sidebar-user small { color: var(--violet-300); }
.sidebar-user .btn-ghost { color: #fff; box-shadow: inset 0 0 0 2px rgba(255,255,255,.25); }
.admin-main { padding: 1.6rem 2rem 4rem; min-width: 0; }
.admin-top h1 { font-size: 1.9rem; }
.card { background: var(--card); border-radius: var(--radius); padding: 1.4rem; box-shadow: var(--shadow); margin-bottom: 1.4rem; }
.card h2 { font-size: 1.2rem; }
.card.narrow { max-width: 640px; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(380px, 1fr)); gap: 1.4rem; }
.empty { text-align: center; padding: 3rem 1rem; }
.empty-icon { font-size: 3rem; }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(165px, 1fr)); gap: 1rem; margin-bottom: 1.4rem; }
.stat-card { background: var(--card); border-radius: var(--radius); padding: 1.1rem 1.2rem; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: .1rem; position: relative; overflow: hidden; }
.stat-card::after { content: ''; position: absolute; right: -30px; top: -30px; width: 90px; height: 90px; border-radius: 50%; background: var(--violet-100); z-index: 0; }
.stat-card:nth-child(4n+2)::after { background: #ffe3ea; } .stat-card:nth-child(4n+3)::after { background: #fff1cc; } .stat-card:nth-child(4n+4)::after { background: #d9f7ff; }
.stat-card > * { position: relative; z-index: 1; }
.stat-icon { font-size: 1.4rem; }
.stat-card strong { font-size: 2rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat-card strong.small-strong { font-size: 1.05rem; }
.stat-card span:last-child { color: var(--muted); font-size: .9rem; }

.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: .5rem; border-bottom: 2px solid var(--line); }
.table td { padding: .7rem .5rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table tr.dim td { opacity: .5; }
.actions-cell { display: flex; gap: .3rem; justify-content: flex-end; flex-wrap: wrap; }
.actions-cell form { display: inline; }
.meter { display: inline-block; width: 70px; height: 8px; border-radius: 99px; background: var(--line); vertical-align: middle; overflow: hidden; }
.meter span { display: block; height: 100%; width: var(--p); background: linear-gradient(90deg, var(--pink), var(--yellow), var(--green)); background-size: 70px 100%; }

.toolbar { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-bottom: 1.2rem; flex-wrap: wrap; }
.filters { display: flex; gap: .5rem; flex-wrap: wrap; }
.filters input, .filters select { width: auto; }

.quiz-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 1.2rem; }
.quiz-card { background: var(--card); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); display: flex; flex-direction: column; transition: transform .2s; }
.quiz-card:hover { transform: translateY(-4px); }
.quiz-card.selected { outline: 4px solid var(--yellow); }
.quiz-cover { height: 130px; background: linear-gradient(135deg, var(--violet-500), var(--pink)) center / cover; position: relative; padding: .7rem; display: flex; gap: .4rem; align-items: flex-start; }
.quiz-card:nth-child(3n+2) .quiz-cover:not([style]) { background-image: linear-gradient(135deg, var(--blue), var(--cyan)); }
.quiz-card:nth-child(3n+3) .quiz-cover:not([style]) { background-image: linear-gradient(135deg, var(--yellow), var(--pink)); }
.quiz-body { padding: 1rem 1.1rem 1.1rem; display: flex; flex-direction: column; gap: .4rem; flex: 1; }
.quiz-body h3 { margin: 0; font-size: 1.15rem; }
.quiz-actions { display: flex; gap: .4rem; margin-top: auto; padding-top: .5rem; flex-wrap: wrap; }
.quiz-actions form { display: inline; }

/* ---------- Quiz editor ---------- */
.settings-card summary { cursor: pointer; display: flex; justify-content: space-between; align-items: center; gap: 1rem; list-style: none; }
.settings-card summary::-webkit-details-marker { display: none; }
.settings-card summary strong { font-size: 1.2rem; margin-right: .5rem; }
.cover-preview { display: flex; align-items: center; gap: 1rem; margin-top: .4rem; }
.cover-preview img { height: 64px; border-radius: 10px; }
.editor-bar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1rem; gap: 1rem; flex-wrap: wrap; }
.editor-bar-actions { display: flex; gap: .5rem; flex-wrap: wrap; }
.editor { display: grid; grid-template-columns: 320px 1fr; gap: 1.4rem; align-items: start; }
.q-list-wrap { position: sticky; top: 1rem; }
.q-list { list-style: none; margin: 0 0 .8rem; padding: 0; display: flex; flex-direction: column; gap: .5rem; max-height: calc(100vh - 160px); overflow: auto; }
.q-item { display: flex; align-items: center; gap: .5rem; background: #fff; border-radius: var(--radius-sm); padding: .55rem .5rem; box-shadow: 0 2px 0 var(--line); cursor: pointer; border: 2px solid transparent; transition: border-color .15s, transform .15s; }
.q-item:hover { border-color: var(--violet-100); }
.q-item.active { border-color: var(--violet-500); }
.q-item.dragging { opacity: .5; transform: scale(.97); }
.q-grip { cursor: grab; color: var(--muted); letter-spacing: -.2em; }
.q-num { width: 1.8rem; height: 1.8rem; display: grid; place-items: center; border-radius: 50%; background: var(--violet-100); color: var(--violet-700); font-weight: 700; flex-shrink: 0; }
.q-item-text { flex: 1; min-width: 0; font-weight: 600; font-size: .92rem; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.q-item-text small { display: block; color: var(--muted); font-weight: 400; font-size: .78rem; }
.q-item-actions { display: flex; }
.q-empty { padding: 1rem; text-align: center; }
.q-form-card form { display: flex; flex-direction: column; gap: 1rem; }
.q-form-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; }
.q-form-head h2 { margin: 0; }
.seg { display: inline-flex; background: var(--violet-100); border-radius: 999px; padding: .25rem; }
.seg label { flex-direction: row; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span { padding: .4rem .9rem; border-radius: 999px; cursor: pointer; font-weight: 600; color: var(--violet-700); }
.seg input:checked + span { background: var(--violet-500); color: #fff; }
.seg input:focus-visible + span { outline: 3px solid var(--cyan); }
.q-image-preview { display: flex; align-items: center; gap: 1rem; }
.q-image-preview img { max-height: 120px; border-radius: 12px; }
.answers-edit { border: 0; padding: 0; margin: 0; display: flex; flex-direction: column; gap: .6rem; }
.answers-edit legend { font-weight: 600; margin-bottom: .5rem; }
#answers { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .6rem; }
.answer-row { display: flex; align-items: center; gap: .4rem; padding: .4rem; border-radius: var(--radius-sm); background: color-mix(in srgb, var(--c) 14%, #fff); border: 2px solid color-mix(in srgb, var(--c) 45%, #fff); }
.answer-row .tile-letter { background: var(--c); color: #fff; }
.answer-row .answer-color { width: 2.2rem; height: 2.2rem; border: 0; background: transparent; }
.answer-row .answer-text { flex: 1; border-color: transparent; background: #fff; }
.correct-pick { flex-direction: row; cursor: pointer; }
.correct-pick input { position: absolute; opacity: 0; }
.correct-pick span { width: 2.2rem; height: 2.2rem; border-radius: 50%; display: grid; place-items: center; border: 2px solid var(--line); color: transparent; background: #fff; transition: all .15s; }
.correct-pick input:checked + span { background: var(--green); border-color: var(--green); color: #fff; transform: scale(1.08); }
.correct-pick input:focus-visible + span { outline: 3px solid var(--cyan); }

/* Modal (preview) */
.modal { position: fixed; inset: 0; z-index: 50; background: rgba(22,10,51,.7); display: grid; place-items: center; padding: 1rem; backdrop-filter: blur(4px); }
.modal-box { background: var(--violet-800); color: #fff; border-radius: var(--radius); padding: 1.6rem; width: min(900px, 100%); position: relative; animation: popIn .35s cubic-bezier(.3,1.5,.6,1); max-height: 95vh; overflow: auto; }
.modal-close { position: absolute; top: .8rem; right: .8rem; background: rgba(255,255,255,.15); color: #fff; border: 0; width: 2.2rem; height: 2.2rem; border-radius: 50%; cursor: pointer; }
.pv-head { display: flex; gap: .5rem; }
.pv-title { text-align: center; font-size: 1.7rem; margin: 1rem 0; }
.pv-img { display: block; margin: 0 auto 1rem; max-height: 200px; border-radius: 12px; }
.preview-nav { display: flex; justify-content: center; align-items: center; gap: 1rem; margin-top: 1.2rem; }
.preview-nav .btn-ghost { color: #fff; box-shadow: inset 0 0 0 2px rgba(255,255,255,.3); }

/* ==========================================================================
   STAGE (landing, join, host, player) – dark animated background
   ========================================================================== */
.stage { background: radial-gradient(1200px 800px at 20% 10%, var(--violet-700), var(--violet-900)); color: #fff; min-height: 100vh; min-height: 100dvh; overflow-x: hidden; }
.bg-blobs { position: fixed; inset: 0; z-index: 0; pointer-events: none; overflow: hidden; }
.bg-blobs i { position: absolute; border-radius: 50%; filter: blur(70px); opacity: .45; animation: drift 18s ease-in-out infinite alternate; }
.bg-blobs i:nth-child(1) { width: 45vw; height: 45vw; background: var(--pink); left: -10vw; top: -10vw; }
.bg-blobs i:nth-child(2) { width: 40vw; height: 40vw; background: var(--blue); right: -12vw; top: 20vh; animation-duration: 22s; }
.bg-blobs i:nth-child(3) { width: 35vw; height: 35vw; background: var(--yellow); left: 30vw; bottom: -18vw; opacity: .3; animation-duration: 26s; }
@keyframes drift { to { transform: translate(8vw, 6vh) scale(1.15); } }
.stage > *:not(.bg-blobs):not(#confetti):not(.paused-overlay):not(#toasts):not(.conn-banner) { position: relative; z-index: 1; }
#confetti { position: fixed; inset: 0; z-index: 60; pointer-events: none; display: none; }
#confetti.on { display: block; }
.stage .card { background: #fff; color: var(--ink); }

.center-card { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 1.2rem; gap: 1.6rem; }
.center-logo { text-decoration: none; }
.form-card { width: min(420px, 100%); display: flex; flex-direction: column; gap: 1rem; }
.form-card h1, .form-card h2 { font-size: 1.4rem; margin: 0; }
.pin-input, .nick-input { text-align: center; font-size: 1.6rem; font-weight: 700; padding: .6em; letter-spacing: .1em; border-width: 3px; }
.nick-input { letter-spacing: 0; }
.avatar-picker { display: grid; grid-template-columns: repeat(6, 1fr); gap: .4rem; }
.avatar-opt { font-size: 1.7rem; aspect-ratio: 1; border-radius: 14px; border: 3px solid transparent; background: var(--violet-100); cursor: pointer; transition: transform .15s; padding: 0; }
.avatar-opt:hover { transform: scale(1.08); }
.avatar-opt.on { border-color: var(--violet-500); background: #fff; transform: scale(1.12); box-shadow: 0 4px 0 var(--violet-300); }

/* Landing */
.landing-main { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 1rem; }
.landing-hero { display: flex; flex-direction: column; align-items: center; gap: 1.5rem; text-align: center; }
.tagline { font-size: clamp(1.1rem, 3vw, 1.6rem); margin: 0; color: var(--violet-300); }
.join-quick { display: flex; gap: .6rem; background: #fff; padding: .5rem; border-radius: 999px; box-shadow: var(--shadow); }
.join-quick .pin-input { border: 0; width: 13rem; font-size: 1.4rem; padding: .3em .6em; border-radius: 999px; }

/* ---------- Host stage ---------- */
.host { display: flex; flex-direction: column; height: 100vh; height: 100dvh; overflow: hidden; }
.stage-top { display: flex; align-items: center; justify-content: space-between; padding: .9rem 1.6rem; gap: 1rem; }
.stage-top-info { display: flex; gap: .6rem; align-items: center; font-weight: 600; flex-wrap: wrap; justify-content: center; }
.stage-top-actions { display: flex; gap: .4rem; }
.stage-main { flex: 1; min-height: 0; display: flex; flex-direction: column; padding: 0 2rem; }
.host-controls { display: flex; justify-content: center; gap: .8rem; padding: 1rem; flex-wrap: wrap; background: rgba(0,0,0,.18); }
.host-controls.busy { opacity: .6; pointer-events: none; }

.lobby { flex: 1; display: grid; grid-template-rows: auto 1fr; gap: 1.5rem; min-height: 0; }
.lobby-join { display: flex; align-items: center; justify-content: center; gap: 3rem; background: #fff; color: var(--ink); border-radius: 28px; padding: 1.4rem 2.5rem; margin: 0 auto; box-shadow: 0 12px 0 rgba(0,0,0,.2); }
.join-text p { margin: 0; font-size: 1.3rem; }
.pin-label { color: var(--muted); font-weight: 600; margin-top: .6rem !important; }
.big-pin { font-size: clamp(3rem, 8vw, 6.5rem); font-weight: 700; letter-spacing: .04em; line-height: 1; color: var(--violet-700); font-variant-numeric: tabular-nums; }
.qr { width: 170px; height: 170px; }
.qr svg { width: 100%; height: 100%; display: block; }
.lobby-players { display: flex; flex-direction: column; align-items: center; gap: 1rem; min-height: 0; }
.lobby-count { font-size: 1.6rem; font-weight: 700; background: rgba(0,0,0,.25); padding: .3rem 1.2rem; border-radius: 999px; }
.lobby-count span { font-size: 2.2rem; color: var(--yellow); }
.players-cloud { display: flex; flex-wrap: wrap; gap: .7rem; justify-content: center; align-content: flex-start; overflow: auto; max-width: 1200px; padding: .5rem; }
.player-chip { font: inherit; display: inline-flex; align-items: center; gap: .5rem; background: #fff; color: var(--ink); font-weight: 700; font-size: 1.25rem; padding: .35rem 1rem .35rem .4rem; border-radius: 999px; border: 0; cursor: pointer; box-shadow: 0 4px 0 rgba(0,0,0,.2); transition: transform .2s, opacity .3s; }
.player-chip .av { font-size: 1.6rem; width: 2.4rem; height: 2.4rem; display: grid; place-items: center; background: var(--violet-100); border-radius: 50%; }
.player-chip:hover { text-decoration: line-through; transform: scale(1.04); }
.player-chip.enter { animation: chipIn .6s cubic-bezier(.3,1.7,.5,1); }
.player-chip.offline { opacity: .5; }
@keyframes chipIn { from { transform: scale(0) rotate(-12deg); opacity: 0; } }
.waiting-hint { font-size: 1.3rem; color: var(--violet-300); }

.intro { margin: auto; text-align: center; }
.intro-kicker { font-size: 1.6rem; color: var(--yellow); margin: 0; font-weight: 600; }
.intro-title { font-size: clamp(2.5rem, 7vw, 5rem); margin: .2em 0; }
.intro-meta { font-size: 1.3rem; color: var(--violet-300); }

.question-screen { flex: 1; display: flex; flex-direction: column; gap: 1rem; min-height: 0; padding-bottom: 1rem; }
.q-title { background: #fff; color: var(--ink); text-align: center; font-size: clamp(1.5rem, 3.2vw, 2.6rem); padding: .8rem 1.4rem; border-radius: 22px; margin: 0; box-shadow: 0 8px 0 rgba(0,0,0,.18); }
.q-middle { flex: 1; min-height: 0; display: grid; grid-template-columns: 160px 1fr 160px; align-items: center; gap: 1.5rem; }
.q-media { height: 100%; display: grid; place-items: center; min-height: 0; }
.q-media img { max-height: 100%; max-width: 100%; object-fit: contain; border-radius: 18px; box-shadow: 0 10px 30px rgba(0,0,0,.35); }
.q-media-empty { font-size: 1.4rem; font-weight: 700; color: var(--violet-300); }
.timer-ring { width: 150px; height: 150px; position: relative; display: grid; place-items: center; }
.timer-ring svg { position: absolute; inset: 0; transform: rotate(-90deg); }
.timer-ring circle { fill: none; stroke-width: 12; }
.timer-ring .bg { stroke: rgba(255,255,255,.15); fill: rgba(0,0,0,.2); }
.timer-ring .fg { stroke: var(--yellow); stroke-linecap: round; stroke-dasharray: 326.7; transition: stroke .3s; }
.timer-ring span { font-size: 3.4rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.timer-ring.urgent .fg { stroke: var(--pink); }
.timer-ring.urgent span { animation: bump .5s infinite; color: #ffd0dc; }
.answered-box { width: 150px; height: 150px; border-radius: 50%; background: rgba(0,0,0,.2); display: flex; flex-direction: column; align-items: center; justify-content: center; }
.answered-box strong { font-size: 3.2rem; line-height: 1; }
.leadin { height: 14px; background: rgba(255,255,255,.12); border-radius: 99px; overflow: hidden; }
.leadin-bar span { display: block; height: 14px; width: 0; background: linear-gradient(90deg, var(--cyan), var(--yellow)); border-radius: 99px; }

.tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .9rem; }
.tile { --c: var(--violet-500); display: flex; align-items: center; gap: 1rem; background: var(--c); color: #fff; border-radius: 18px; padding: 1rem 1.2rem; min-height: 86px; font-size: clamp(1.1rem, 2.2vw, 1.8rem); font-weight: 700; box-shadow: 0 6px 0 color-mix(in srgb, var(--c) 60%, #000); animation: popIn .45s cubic-bezier(.3,1.5,.6,1) both; animation-delay: calc(var(--i, 0) * 70ms); transition: opacity .4s, transform .4s, filter .4s; }
.tile-letter { flex-shrink: 0; width: 2.4rem; height: 2.4rem; border-radius: 12px; display: grid; place-items: center; background: rgba(255,255,255,.25); font-weight: 700; font-size: 1.2rem; }
.tile-text { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.tile-count { font-size: 1.6rem; }
.tile.wrong { opacity: .32; filter: grayscale(.6); transform: scale(.97); }
.tile.correct { transform: scale(1.03); box-shadow: 0 6px 0 color-mix(in srgb, var(--c) 60%, #000), 0 0 0 5px #fff; }
.tiles.revealed { margin-top: auto; }

.bars { flex: 1; min-height: 140px; display: flex; justify-content: center; align-items: flex-end; gap: 1.4rem; }
.bar { width: 90px; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: .3rem; }
.bar-fill { width: 100%; height: var(--h); min-height: 8px; background: var(--c); border-radius: 12px 12px 4px 4px; animation: grow .9s cubic-bezier(.3,1.3,.5,1) both; animation-delay: calc(var(--i) * 90ms); transform-origin: bottom; }
.bar:not(.ok) .bar-fill { opacity: .45; }
.bar-n { font-size: 1.6rem; font-weight: 700; }
.bar-l { font-weight: 700; }
@keyframes grow { from { transform: scaleY(0); } }
.explanation { text-align: center; font-size: 1.3rem; background: rgba(0,0,0,.25); padding: .7rem 1.2rem; border-radius: 16px; margin: 0 auto; max-width: 900px; }

.leaderboard { flex: 1; display: flex; flex-direction: column; align-items: center; padding-top: 1rem; }
.lb-title { font-size: 3rem; background: #fff; color: var(--violet-700); padding: .2em 1em; border-radius: 22px; }
.lb-list { position: relative; width: min(900px, 100%); margin-top: 1.5rem; }
.lb-row { position: absolute; left: 0; right: 0; top: 0; height: 64px; display: flex; align-items: center; gap: 1rem; background: rgba(255,255,255,.95); color: var(--ink); border-radius: 16px; padding: 0 1.2rem; font-size: 1.5rem; font-weight: 700; transition: transform .9s cubic-bezier(.3,1.25,.5,1); box-shadow: 0 5px 0 rgba(0,0,0,.2); }
.lb-row.lead { background: linear-gradient(90deg, #fff6d6, #fff); box-shadow: 0 5px 0 rgba(0,0,0,.2), 0 0 0 4px var(--yellow); }
.lb-rank { width: 2.4rem; height: 2.4rem; border-radius: 50%; display: grid; place-items: center; background: var(--violet-100); color: var(--violet-700); font-size: 1.2rem; }
.lb-row.lead .lb-rank { background: var(--yellow); color: #fff; }
.lb-av { font-size: 2rem; }
.lb-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-up { color: var(--green); font-size: 1rem; }
.lb-gain { color: var(--green); font-size: 1rem; background: #dcfbea; padding: .1em .6em; border-radius: 99px; }
.lb-score { font-variant-numeric: tabular-nums; min-width: 5ch; text-align: right; }
.streak { font-size: 1rem; }

.podium-screen { flex: 1; display: flex; flex-direction: column; align-items: center; min-height: 0; }
.podium-title { font-size: 2.4rem; margin: .5rem 0 1rem; }
.podium { flex: 1; display: flex; align-items: flex-end; gap: 1rem; min-height: 0; width: min(900px, 100%); }
.podium-col { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; }
.podium-player { display: flex; flex-direction: column; align-items: center; gap: .2rem; margin-bottom: .8rem; opacity: 0; animation: podiumIn .6s cubic-bezier(.3,1.6,.5,1) forwards; }
@keyframes podiumIn { from { opacity: 0; transform: scale(.6) translateY(30px); } to { opacity: 1; transform: none; } }
.podium-av { font-size: 4rem; }
.podium-player strong { font-size: 1.7rem; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.podium-score { font-size: 1.2rem; color: var(--violet-300); font-weight: 600; }
.podium-block { width: 100%; border-radius: 18px 18px 0 0; display: grid; place-items: start center; padding-top: 1rem; font-size: 3.4rem; font-weight: 700; color: rgba(255,255,255,.9); transform-origin: bottom; animation: grow 1s cubic-bezier(.3,1.2,.5,1) both; }
.podium-col.first .podium-block { height: 48%; background: linear-gradient(180deg, var(--yellow), #e08a00); animation-delay: 1.6s; }
.podium-col.second .podium-block { height: 34%; background: linear-gradient(180deg, #c7c2e0, #8d86ad); animation-delay: .9s; }
.podium-col.third .podium-block { height: 24%; background: linear-gradient(180deg, #ff9b6b, #c95a2b); animation-delay: .3s; }
.podium-col.first .podium-player { animation-delay: 2.3s; }
.podium-col.second .podium-player { animation-delay: 1.6s; }
.podium-col.third .podium-player { animation-delay: 1s; }
.podium-col.first .podium-av { animation: bounce 1.4s 3s ease-in-out infinite; }
.runners { list-style-position: inside; width: min(600px, 100%); display: grid; gap: .3rem; padding: 0; margin: 1rem 0; font-size: 1.1rem; }
.runners li { display: flex; justify-content: space-between; background: rgba(255,255,255,.1); padding: .3rem .9rem; border-radius: 10px; }

.paused-overlay { position: fixed; inset: 0; z-index: 40; background: rgba(22,10,51,.75); display: grid; place-items: center; backdrop-filter: blur(6px); }
.paused-box { text-align: center; }
.paused-icon { font-size: 5rem; }

/* ---------- Player (mobile first) ---------- */
.player { display: flex; flex-direction: column; min-height: 100vh; min-height: 100dvh; transition: background .4s; }
.player[data-result="good"] { background: radial-gradient(900px 700px at 50% 20%, #23c785, #0b6b41); }
.player[data-result="bad"] { background: radial-gradient(900px 700px at 50% 20%, #ff5a83, #8a0f33); }
.player[data-result="timeout"] { background: radial-gradient(900px 700px at 50% 20%, #8b7bbd, #3a2f63); }
.player-top { display: flex; justify-content: space-between; align-items: center; padding: .7rem 1rem; background: rgba(0,0,0,.2); }
.me { display: flex; align-items: center; gap: .5rem; font-weight: 700; min-width: 0; }
.me-av { font-size: 1.5rem; }
.me-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.player-top-right { display: flex; align-items: center; gap: .4rem; }
.q-counter { font-weight: 600; background: rgba(255,255,255,.15); border-radius: 999px; padding: .1rem .7rem; }
.q-counter:empty { display: none; }
.player-main { flex: 1; display: flex; flex-direction: column; padding: 1rem; }
.player-bottom { display: flex; align-items: center; justify-content: center; gap: .7rem; padding: .8rem; background: rgba(0,0,0,.25); font-weight: 700; }
.p-score { font-size: 1.5rem; font-variant-numeric: tabular-nums; }
.p-score-label { color: var(--violet-300); }
.p-rank { background: var(--yellow); color: var(--ink); padding: .1rem .7rem; border-radius: 999px; }
.p-msg, .p-result { margin: auto; text-align: center; display: flex; flex-direction: column; align-items: center; gap: .6rem; }
.p-msg h2, .p-result h2 { font-size: 2rem; margin: 0; }
.p-msg p, .p-result p { margin: 0; font-size: 1.15rem; }
.p-avatar { font-size: 5.5rem; background: rgba(255,255,255,.15); width: 9rem; height: 9rem; border-radius: 50%; display: grid; place-items: center; }
.p-emoji { font-size: 4.5rem; }
.p-emoji.big { font-size: 6rem; }
.muted-light { color: var(--violet-300); }
.p-points { font-size: 3.2rem; font-weight: 700; background: rgba(0,0,0,.2); padding: .1em .6em; border-radius: 999px; }
.p-correct { background: rgba(0,0,0,.2); padding: .6rem 1rem; border-radius: 14px; }
.p-place strong { color: var(--yellow); }
.p-result.good .p-place strong, .p-result.bad .p-place strong { color: #fff; text-decoration: underline; }
.p-streak { font-weight: 700; }
.locked-tile { background: var(--c); padding: 1.4rem 2rem; border-radius: 20px; font-size: 1.4rem; font-weight: 700; box-shadow: 0 6px 0 rgba(0,0,0,.25); animation: bump .5s; }
.mini-podium { list-style: none; padding: 0; margin: .5rem 0 1rem; width: min(320px, 90vw); display: grid; gap: .3rem; counter-reset: pod; }
.mini-podium li { display: flex; justify-content: space-between; background: rgba(255,255,255,.12); border-radius: 10px; padding: .4rem .8rem; counter-increment: pod; }
.mini-podium li::before { content: counter(pod) '.'; margin-right: .5rem; color: var(--yellow); font-weight: 700; }
.mini-podium li span:first-child { flex: 1; text-align: left; }

.p-question { flex: 1; display: flex; flex-direction: column; gap: .8rem; position: relative; }
.p-q-text { margin: 0; text-align: center; font-size: 1.2rem; font-weight: 600; background: rgba(0,0,0,.2); padding: .7rem; border-radius: 14px; }
.p-timebar { height: 10px; border-radius: 99px; background: rgba(255,255,255,.15); overflow: hidden; }
.p-timebar span { display: block; height: 100%; background: linear-gradient(90deg, var(--pink), var(--yellow)); transform-origin: left; }
.p-tiles { flex: 1; display: grid; grid-template-columns: 1fr 1fr; gap: .7rem; transition: opacity .3s; }
.p-tiles.n2, .p-tiles.tf { grid-template-columns: 1fr; }
.p-tiles.n3 .p-tile:last-child, .p-tiles.n5 .p-tile:last-child { grid-column: span 2; }
.p-tiles.waiting { opacity: .25; pointer-events: none; }
.p-tiles.locked .p-tile:not(.chosen) { opacity: .3; transform: scale(.95); }
.p-tile { --c: var(--violet-500); font: inherit; color: #fff; background: var(--c); border: 0; border-radius: 20px; padding: 1rem; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .5rem; font-size: 1.15rem; font-weight: 700; cursor: pointer; min-height: 90px;
  box-shadow: 0 6px 0 color-mix(in srgb, var(--c) 60%, #000); transition: transform .12s, box-shadow .12s, opacity .3s; animation: popIn .4s cubic-bezier(.3,1.5,.6,1) both; animation-delay: calc(var(--i) * 60ms); -webkit-tap-highlight-color: transparent; }
.p-tile:active { transform: translateY(4px); box-shadow: 0 2px 0 color-mix(in srgb, var(--c) 60%, #000); }
.p-tile .tile-letter { width: 2.6rem; height: 2.6rem; font-size: 1.3rem; }
.p-tile.chosen { transform: scale(1.03); box-shadow: 0 6px 0 color-mix(in srgb, var(--c) 60%, #000), 0 0 0 4px #fff; }
.p-tile-text { overflow-wrap: anywhere; }
.p-leadin { position: absolute; inset: 0; z-index: 3; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .5rem; background: rgba(22,10,51,.55); border-radius: 20px; backdrop-filter: blur(3px); }
.p-leadin-label { font-size: 1.6rem; font-weight: 700; }
.p-leadin-num { font-size: 6rem; font-weight: 700; color: var(--yellow); line-height: 1; animation: bump 1s infinite; }
.conn-banner { position: fixed; top: 0; left: 0; right: 0; z-index: 80; background: var(--pink); color: #fff; text-align: center; font-weight: 700; padding: .4rem; transform: translateY(-100%); transition: transform .3s; }
.conn-banner.on { transform: none; }

/* ---------- Responsive ---------- */
@media (max-width: 1000px) {
  .admin-shell { grid-template-columns: 1fr; background: none; }
  .sidebar { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; padding: .8rem; gap: .6rem; }
  .sidebar nav { flex-direction: row; flex-wrap: wrap; flex: 1 1 100%; order: 3; }
  .sidebar nav a { padding: .45rem .7rem; font-size: .9rem; }
  .sidebar-user { margin-left: auto; padding: .4rem .6rem; }
  .admin-main { padding: 1rem; }
  .editor { grid-template-columns: 1fr; }
  .q-list-wrap { position: static; }
  .q-list { max-height: none; }
  .grid-2 { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .form-grid, .form-grid.three, #answers { grid-template-columns: 1fr; }
  .span-2 { grid-column: auto; }
  .lobby-join { flex-direction: column; gap: 1rem; padding: 1rem; }
  .q-middle { grid-template-columns: 1fr 1fr; }
  .q-media { display: none; }
  .tiles { grid-template-columns: 1fr; }
  .stage-main { padding: 0 1rem; }
  .table { font-size: .9rem; }
  .table th:nth-child(n+4):not(:last-child), .table td:nth-child(n+4):not(:last-child) { display: none; }
}
@media (max-height: 760px) and (min-width: 761px) {
  .tile { min-height: 64px; padding: .7rem 1rem; }
  .timer-ring, .answered-box { width: 120px; height: 120px; }
  .timer-ring span { font-size: 2.6rem; }
}

/* ---------- Accessibility: reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
  .bg-blobs i { animation: none; }
}
