:root {
  --font: "Montserrat", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  /* Warna diambil dari logo TEA label: ungu satin gelap + emas */
  --ink: #2a1630;
  --ink-2: #5d4a62;
  --ink-3: #8a7a8e;
  --sand: #f6eff7;
  --sand-2: #eadcee;
  --card: #ffffff;
  --line: #e2d1e6;
  --brand: #5b1a68;
  --brand-2: #47124f;
  --gold: #d4a443;
  --gold-ink: #2e1a00;
  --danger: #b4372a;
  --ok: #17845f;
  --night: #24082a;
  --night-2: #33103b;
  --night-3: #45164e;
  --night-line: rgba(255, 228, 248, 0.14);
  --on-night: #f8efe4;
  --on-night-2: rgba(248, 239, 228, 0.72);
  --a: #0f7a65;
  --b: #c94c35;
  --c: #e3a01b;
  --d: #3d6fd6;
  --radius: 14px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  color: var(--ink);
  background: var(--sand);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  line-height: 1.45;
}
button, input, select, textarea { font: inherit; color: inherit; }
img { max-width: 100%; display: block; }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- butang & input ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 18px; border-radius: 999px; border: 1.5px solid transparent;
  font-weight: 700; font-size: 15px; cursor: pointer; text-decoration: none;
  transition: transform .08s ease, background-color .15s ease, opacity .15s ease;
  background: var(--card); color: var(--ink); border-color: var(--line);
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--brand); color: #fff; border-color: var(--brand); }
.btn-primary:hover { background: var(--brand-2); }
.btn-gold { background: var(--gold); color: var(--gold-ink); border-color: var(--gold); }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-danger { color: var(--danger); }
.btn-lg { min-height: 56px; font-size: 18px; padding: 0 28px; }
.btn-block { width: 100%; }
.btn-sm { min-height: 34px; padding: 0 12px; font-size: 13px; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field > span { font-size: 13px; font-weight: 600; color: var(--ink-2); }
.input, select.input, textarea.input {
  width: 100%; min-height: 46px; padding: 10px 14px; border-radius: 12px;
  border: 1.5px solid var(--line); background: var(--card); font-size: 16px;
}
textarea.input { min-height: 70px; resize: vertical; }
.input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(91, 26, 104, .16); }
.error-text { color: var(--danger); font-size: 14px; font-weight: 600; min-height: 1.2em; }

/* ---------- tema permainan (gelap) ---------- */
body.game {
  color: var(--on-night);
  background-color: var(--night);
  /* kilauan satin seperti latar logo */
  background-image:
    radial-gradient(120% 70% at 0% 0%, rgba(122, 32, 128, .55) 0%, transparent 60%),
    radial-gradient(90% 60% at 100% 100%, rgba(96, 22, 104, .45) 0%, transparent 60%);
  background-attachment: fixed;
}
body.game[data-tone] { background-image: none; }
body.game[data-tone=""] {
  background-image:
    radial-gradient(120% 70% at 0% 0%, rgba(122, 32, 128, .55) 0%, transparent 60%),
    radial-gradient(90% 60% at 100% 100%, rgba(96, 22, 104, .45) 0%, transparent 60%);
}
body.game .btn { background: rgba(255,255,255,.08); color: var(--on-night); border-color: var(--night-line); }
body.game .btn-gold { background: var(--gold); color: var(--gold-ink); border-color: var(--gold); }
body.game .btn-primary { background: var(--on-night); color: var(--night); border-color: var(--on-night); }
body.game .btn-ghost { background: transparent; border-color: transparent; }
body.game .input { background: #fff; color: var(--ink); border-color: transparent; }

.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 800; letter-spacing: -.01em; }
.brand-logo { width: 34px; height: 34px; border-radius: 9px; object-fit: cover; flex: none; }
.host .brand-logo { width: 44px; height: 44px; border-radius: 11px; }
.hero-logo {
  width: 132px; height: 132px; border-radius: 28px; object-fit: cover; margin: 0 auto 8px;
  box-shadow: 0 0 0 1.5px rgba(212, 164, 67, .55), 0 14px 40px rgba(0, 0, 0, .35);
}
body:not(.game) .hero-logo { width: 96px; height: 96px; border-radius: 22px; box-shadow: 0 8px 24px rgba(42, 22, 48, .2); }

/* pilihan jawapan */
.choice-a { --tone: var(--a); --on-tone: #fff; }
.choice-b { --tone: var(--b); --on-tone: #fff; }
.choice-c { --tone: var(--c); --on-tone: var(--gold-ink); }
.choice-d { --tone: var(--d); --on-tone: #fff; }
.letter {
  flex: none; width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center;
  font-weight: 800; background: rgba(0,0,0,.16); color: var(--on-tone);
}

/* ---------- pemain (telefon) ---------- */
.player {
  min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column;
  max-width: 560px; margin: 0 auto; padding: max(12px, env(safe-area-inset-top)) 16px max(16px, env(safe-area-inset-bottom));
}
.player-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 44px; }
.chip {
  display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px; border-radius: 999px;
  background: rgba(255,255,255,.1); font-weight: 700; font-size: 14px; max-width: 60vw;
}
.chip .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip .score { color: var(--gold); }
.screen { flex: 1; display: flex; flex-direction: column; gap: 16px; padding-top: 12px; }
.center { justify-content: center; align-items: center; text-align: center; }
.join-card { width: 100%; max-width: 380px; display: flex; flex-direction: column; gap: 12px; }
.join-title { font-size: 28px; font-weight: 800; margin: 0 0 4px; letter-spacing: -.02em; }
.pin-input { text-align: center; font-size: 28px !important; font-weight: 800; letter-spacing: .3em; min-height: 64px !important; }
.name-input { text-align: center; font-size: 22px !important; font-weight: 700; min-height: 60px !important; }
.muted { color: var(--on-night-2); }
body:not(.game) .muted { color: var(--ink-2); }
.big-icon {
  width: 84px; height: 84px; border-radius: 50%; display: grid; place-items: center;
  background: rgba(255,255,255,.1); font-size: 40px; font-weight: 800;
}
.big-icon svg { width: 44px; height: 44px; }
.headline { font-size: 26px; font-weight: 800; margin: 0; letter-spacing: -.02em; }
.sub { font-size: 16px; margin: 0; }

.q-meta { display: flex; justify-content: space-between; align-items: center; font-size: 14px; font-weight: 700; color: var(--on-night-2); }
.q-text { font-size: clamp(18px, 5vw, 22px); font-weight: 700; margin: 0; line-height: 1.35; }
.q-image { max-height: 28vh; width: auto; margin: 0 auto; border-radius: 12px; object-fit: contain; }
.timebar { height: 8px; border-radius: 999px; background: rgba(255,255,255,.12); overflow: hidden; }
.timebar > i { display: block; height: 100%; background: var(--gold); width: 100%; transform-origin: left center; }
.double-badge { background: var(--gold); color: var(--gold-ink); border-radius: 999px; padding: 2px 10px; font-size: 12px; font-weight: 800; }

.choices { display: flex; flex-direction: column; gap: 10px; margin-top: auto; }
.choice-btn {
  display: flex; align-items: center; gap: 12px; width: 100%; min-height: 68px; padding: 12px 14px;
  border: none; border-radius: 16px; background: var(--tone); color: var(--on-tone);
  font-size: 18px; font-weight: 700; text-align: left; cursor: pointer;
  box-shadow: inset 0 -4px 0 rgba(0,0,0,.18); transition: transform .08s ease, opacity .2s ease;
}
.choice-btn:active { transform: scale(.98); box-shadow: inset 0 -1px 0 rgba(0,0,0,.18); }
.choice-btn:disabled { cursor: default; }
.choice-btn.dim { opacity: .35; }
.choice-btn.picked { outline: 4px solid #fff; outline-offset: 2px; }
.choice-btn .mark { margin-left: auto; font-size: 22px; }

.countdown {
  width: 132px; height: 132px; border-radius: 50%; display: grid; place-items: center; margin: 8px auto;
  font-size: 64px; font-weight: 800; background: var(--gold); color: var(--gold-ink);
  animation: pop .9s ease infinite;
}
@keyframes pop { 0% { transform: scale(.9); } 30% { transform: scale(1.04); } 100% { transform: scale(1); } }

body.game { transition: background-color .35s ease; }
body.game[data-tone="ok"] { background: var(--ok); }
body.game[data-tone="bad"] { background: var(--danger); }
body.game[data-tone="none"] { background: var(--night-3); }
body.game[data-tone="ok"] .chip, body.game[data-tone="bad"] .chip { background: rgba(0,0,0,.2); }
body.game[data-tone="ok"] .chip .score, body.game[data-tone="bad"] .chip .score { color: #fff; }
.points { font-size: 44px; font-weight: 800; letter-spacing: -.02em; }
.rank-pill { background: rgba(0,0,0,.2); padding: 8px 16px; border-radius: 999px; font-weight: 700; }
.connection {
  position: fixed; left: 50%; bottom: 16px; transform: translateX(-50%); z-index: 50;
  background: #fff; color: var(--ink); padding: 8px 14px; border-radius: 999px; font-size: 13px; font-weight: 700;
  box-shadow: 0 6px 20px rgba(0,0,0,.25);
}

/* ---------- hos (projektor) ---------- */
.host { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; padding: clamp(14px, 2.2vw, 32px); gap: clamp(12px, 2vw, 24px); }
.host-bar { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.host-bar .actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.host-main { flex: 1; display: flex; flex-direction: column; gap: clamp(12px, 2vw, 24px); min-height: 0; }
.panel { background: var(--night-2); border: 1px solid var(--night-line); border-radius: 22px; padding: clamp(16px, 2.4vw, 32px); }

.lobby-grid { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: clamp(16px, 3vw, 40px); align-items: center; }
.join-label { font-size: clamp(16px, 2vw, 24px); color: var(--on-night-2); margin: 0; }
.join-label b { color: var(--on-night); }
.pin-big { font-size: clamp(56px, 10vw, 140px); font-weight: 800; letter-spacing: .06em; line-height: 1; margin: 8px 0 0; font-variant-numeric: tabular-nums; }
.qr { background: #fff; border-radius: 18px; padding: 12px; width: clamp(150px, 20vw, 260px); }
.qr img { width: 100%; height: auto; }
.qr p { color: var(--ink); text-align: center; margin: 6px 0 0; font-size: 13px; font-weight: 700; }
.players-wrap { flex: 1; display: flex; flex-direction: column; gap: 12px; min-height: 120px; }
.players-head { display: flex; justify-content: space-between; align-items: center; font-weight: 700; font-size: clamp(15px, 1.6vw, 20px); }
.player-chips { display: flex; flex-wrap: wrap; gap: 10px; align-content: flex-start; }
.player-chip {
  border: none; background: var(--on-night); color: var(--night); font-weight: 800; border-radius: 999px;
  padding: 10px 18px; font-size: clamp(15px, 1.6vw, 22px); cursor: pointer; animation: pop .35s ease 1;
}
.player-chip:hover { background: #ffd9d2; text-decoration: line-through; }
.waiting { color: var(--on-night-2); font-size: clamp(16px, 1.8vw, 22px); }

.host-q { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: clamp(12px, 2vw, 28px); align-items: center; }
.host-q-text { font-size: clamp(24px, 3.6vw, 52px); font-weight: 800; text-align: center; margin: 0; line-height: 1.2; letter-spacing: -.01em; }
.host-q-image { max-height: 34vh; width: auto; margin: 0 auto; border-radius: 16px; object-fit: contain; }
.ring {
  width: clamp(76px, 9vw, 124px); height: clamp(76px, 9vw, 124px); border-radius: 50%;
  display: grid; place-items: center; font-size: clamp(28px, 3.6vw, 48px); font-weight: 800;
  background: var(--gold); color: var(--gold-ink); font-variant-numeric: tabular-nums;
}
.stat { text-align: center; min-width: clamp(76px, 9vw, 124px); }
.stat b { display: block; font-size: clamp(28px, 3.6vw, 48px); line-height: 1; }
.stat span { font-size: clamp(12px, 1.2vw, 16px); color: var(--on-night-2); font-weight: 700; }
.host-choices { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: clamp(10px, 1.4vw, 18px); margin-top: auto; }
.host-choice {
  display: flex; align-items: center; gap: 16px; min-height: clamp(72px, 11vh, 120px); padding: 14px 20px;
  border-radius: 18px; background: var(--tone); color: var(--on-tone); font-size: clamp(18px, 2.2vw, 30px); font-weight: 800;
  box-shadow: inset 0 -5px 0 rgba(0,0,0,.18); transition: opacity .3s ease;
}
.host-choice .letter { width: clamp(36px, 3.4vw, 52px); height: clamp(36px, 3.4vw, 52px); font-size: clamp(18px, 2vw, 26px); }
.host-choice.dim { opacity: .3; }
.host-choice .count { margin-left: auto; font-variant-numeric: tabular-nums; display: flex; align-items: center; gap: 8px; }
.get-ready { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 18px; margin: auto 0; }
.get-ready .countdown { width: clamp(120px, 14vw, 200px); height: clamp(120px, 14vw, 200px); font-size: clamp(56px, 8vw, 110px); }

.bars { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: clamp(10px, 2vw, 32px); align-items: end; height: clamp(120px, 24vh, 260px); padding: 0 clamp(0px, 4vw, 80px); }
.bar { display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 8px; height: 100%; }
.bar i { display: block; width: 100%; max-width: 160px; border-radius: 12px 12px 4px 4px; background: var(--tone); min-height: 8px; transition: height .6s cubic-bezier(.2,.8,.2,1); }
.bar b { font-size: clamp(20px, 2.4vw, 32px); }
.bar.dim { opacity: .35; }

.board { display: flex; flex-direction: column; gap: 10px; width: 100%; max-width: 900px; margin: 0 auto; }
.board-row {
  display: grid; grid-template-columns: 56px minmax(0, 1fr) auto; align-items: center; gap: 14px;
  background: var(--night-2); border: 1px solid var(--night-line); border-radius: 16px; padding: 14px 18px;
  font-size: clamp(18px, 2.2vw, 28px); font-weight: 800; animation: slide .45s ease both;
}
.board-row:first-child { background: var(--on-night); color: var(--night); }
.board-row .pos { font-variant-numeric: tabular-nums; opacity: .7; }
.board-row .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@keyframes slide { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }

/* papan markah beranimasi */
.sb { position: relative; width: 100%; max-width: 980px; margin: 0 auto; animation: fadeUp .45s ease both; }
.sb-row {
  position: absolute; left: 0; right: 0; top: 0; height: clamp(54px, 8.6vh, 84px);
  display: flex; align-items: center; gap: 16px; padding: 0 clamp(16px, 2vw, 28px); border-radius: 16px;
  background: var(--night-2); border: 1px solid var(--night-line);
  font-size: clamp(20px, 2.6vw, 34px); font-weight: 800; will-change: transform;
}
.sb-row.moving { transition: transform .95s cubic-bezier(.22, .9, .25, 1), opacity .6s ease, background-color .45s ease, color .45s ease; }
.sb-row.lead { background: var(--on-night); color: var(--night); border-color: transparent; box-shadow: 0 10px 30px rgba(0,0,0,.25); }
.sb-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sb-score { font-variant-numeric: tabular-nums; }
.sb-arrow {
  display: inline-flex; align-items: center; gap: 2px; color: var(--gold); font-size: .7em; opacity: 0; transform: translateY(8px) scale(.6);
  transition: opacity .35s ease, transform .45s cubic-bezier(.3, 1.6, .5, 1);
}
.sb-row.lead .sb-arrow { color: #a8740f; }
.sb-arrow.show { opacity: 1; transform: none; }
.sb-banner {
  align-self: center; display: inline-flex; align-items: center; gap: 14px; padding: 14px 26px; border-radius: 999px;
  background: rgba(212, 164, 67, .16); border: 1px solid rgba(212, 164, 67, .5); color: var(--on-night);
  font-size: clamp(16px, 2vw, 26px); font-weight: 600; opacity: 0; transform: translateY(24px); min-height: 1px;
  transition: opacity .5s ease, transform .6s cubic-bezier(.22, .9, .25, 1);
}
.sb-banner:empty { padding: 0; border: none; }
.sb-banner.show { opacity: 1; transform: none; }
.sb-banner b { color: var(--gold); }
.sb-banner-icon { width: 44px; height: 44px; border-radius: 50%; background: var(--gold); color: var(--gold-ink); display: grid; place-items: center; flex: none; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
.confetti { position: fixed; inset: 0; width: 100vw; height: 100vh; pointer-events: none; z-index: 60; }
.rank-pop { animation: pop .6s ease 1; }
.rank-move { display: inline-flex; align-items: center; gap: 6px; padding: 6px 14px; border-radius: 999px; font-weight: 800; font-size: 15px; }
.rank-move.up { background: var(--gold); color: var(--gold-ink); animation: pop .6s ease .2s both; }
.rank-move.down { background: rgba(255,255,255,.12); color: var(--on-night-2); }
.double-badge.none { background: rgba(255,255,255,.14); color: var(--on-night); }

.podium { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); align-items: end; gap: clamp(10px, 2vw, 28px); max-width: 1000px; width: 100%; margin: auto auto 0; }
.step { display: flex; flex-direction: column; align-items: center; gap: 10px; animation: rise .8s cubic-bezier(.2,.8,.2,1) both; }
.step .who { font-size: clamp(18px, 2.4vw, 32px); font-weight: 800; text-align: center; overflow-wrap: anywhere; }
.step .pts { color: var(--on-night-2); font-weight: 700; font-size: clamp(14px, 1.6vw, 20px); }
.step .block {
  width: 100%; border-radius: 18px 18px 0 0; display: grid; place-items: start center; padding-top: 14px;
  font-size: clamp(32px, 5vw, 72px); font-weight: 800;
}
.step.p1 .block { height: clamp(150px, 30vh, 320px); background: var(--gold); color: var(--gold-ink); }
.step.p2 .block { height: clamp(110px, 22vh, 230px); background: #d9d4c8; color: var(--night); }
.step.p3 .block { height: clamp(80px, 16vh, 170px); background: #c58a5c; color: #2c1606; }
.step.p3 { animation-delay: .3s; } .step.p2 { animation-delay: 1.1s; } .step.p1 { animation-delay: 2s; }
.step.p1 .block { box-shadow: 0 0 0 0 rgba(212, 164, 67, .6); animation: glow 1.6s ease 2.6s 2; }
.podium-title { animation: fadeUp .6s ease both; }
.podium-rest { animation: fadeUp .6s ease 2.8s both; }
@keyframes glow { 0% { box-shadow: 0 0 0 0 rgba(212, 164, 67, .6); } 100% { box-shadow: 0 0 0 28px rgba(212, 164, 67, 0); } }
@keyframes rise { from { opacity: 0; transform: translateY(40px); } to { opacity: 1; transform: none; } }

/* ---------- admin ---------- */
.admin { max-width: 980px; margin: 0 auto; padding: 20px 16px 120px; }
.admin-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 20px; flex-wrap: wrap; }
.tabs { display: flex; gap: 6px; background: var(--sand-2); padding: 4px; border-radius: 999px; }
.tab { border: none; background: transparent; padding: 8px 16px; border-radius: 999px; font-weight: 700; cursor: pointer; color: var(--ink-2); text-decoration: none; font-size: 14px; }
.tab.active { background: var(--card); color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,.06); }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 18px; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
h1.page { font-size: 26px; margin: 0; letter-spacing: -.02em; }
h2.section { font-size: 18px; margin: 28px 0 12px; }
.quiz-list { display: grid; gap: 12px; }
.quiz-item { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 12px; align-items: center; }
.quiz-item h3 { margin: 0 0 4px; font-size: 17px; }
.quiz-item p { margin: 0; color: var(--ink-2); font-size: 14px; }
.quiz-actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.live-banner { background: var(--brand); color: #fff; border-color: var(--brand); }
.live-banner .btn { background: #fff; color: var(--brand); border-color: #fff; }
.badge { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; background: var(--sand-2); color: var(--ink-2); }
.badge.ok { background: #dff1e8; color: #0d5a40; }
.badge.live { background: #fff1d4; color: #6b4600; }
.empty { text-align: center; padding: 40px 20px; color: var(--ink-2); }

.editor-q { display: flex; flex-direction: column; gap: 12px; }
.editor-q-head { display: flex; align-items: center; gap: 8px; }
.editor-q-head .num { font-weight: 800; background: var(--sand-2); border-radius: 8px; padding: 4px 10px; font-size: 14px; white-space: nowrap; }
.editor-choices { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.editor-choice { display: flex; align-items: center; gap: 8px; border: 1.5px solid var(--line); border-radius: 12px; padding: 6px 8px 6px 6px; background: var(--card); }
.editor-choice.is-correct { border-color: var(--ok); background: #f0faf5; }
.editor-choice .letter { background: var(--tone); color: var(--on-tone); width: 30px; height: 30px; font-size: 14px; border-radius: 8px; }
.editor-choice input[type=text] { border: none; flex: 1; min-width: 0; padding: 8px 4px; font-size: 15px; background: transparent; }
.editor-choice input[type=text]:focus { outline: none; }
.correct-toggle { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 700; color: var(--ink-2); cursor: pointer; white-space: nowrap; }
.correct-toggle input { width: 18px; height: 18px; accent-color: var(--ok); }
.editor-opts { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.editor-opts select { width: auto; min-height: 40px; }
.check { display: inline-flex; gap: 8px; align-items: center; font-size: 14px; font-weight: 600; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--brand); }
.savebar {
  position: fixed; left: 0; right: 0; bottom: 0; background: rgba(246,241,231,.94); backdrop-filter: blur(8px);
  border-top: 1px solid var(--line); padding: 12px 16px max(12px, env(safe-area-inset-bottom)); z-index: 20;
}
.savebar .inner { max-width: 980px; margin: 0 auto; display: flex; gap: 10px; align-items: center; }
table.results { width: 100%; border-collapse: collapse; font-size: 15px; }
table.results th, table.results td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--line); }
table.results th { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-3); }
table.results td.num, table.results th.num { text-align: right; font-variant-numeric: tabular-nums; }
.table-wrap { overflow-x: auto; }
table.results a { color: var(--brand); font-weight: 700; }
.meter { height: 8px; border-radius: 999px; background: var(--sand-2); overflow: hidden; min-width: 80px; }
.meter i { display: block; height: 100%; background: var(--ok); }
.toast {
  position: fixed; left: 50%; top: 16px; transform: translateX(-50%); z-index: 100; background: var(--ink); color: #fff;
  padding: 10px 16px; border-radius: 12px; font-weight: 600; font-size: 14px; box-shadow: 0 8px 24px rgba(0,0,0,.2);
}
.toast.err { background: var(--danger); }

/* bentuk jawapan */
.shape { display: inline-flex; line-height: 0; }
.letter .shape svg { filter: drop-shadow(0 1px 1px rgba(0,0,0,.18)); }
.choice-c .letter .shape { color: var(--gold-ink); }
.choice-btn .letter, .host-choice .letter, .slot .shape { color: #fff; }
.choice-c.choice-btn .letter, .choice-c.host-choice .letter, .choice-c.slot .shape { color: var(--gold-ink); }
.slot .shape { flex: none; }

/* mod sorok di telefon: petak besar 2x2 */
.look-up { display: inline-flex; align-items: center; justify-content: center; gap: 8px; margin: 0; padding: 10px 14px; border-radius: 12px; background: rgba(255,255,255,.08); font-weight: 700; color: var(--on-night-2); text-align: center; }
.choices.big { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; flex: 1; margin-top: 12px; }
.choices.big .choice-btn { min-height: 26vh; flex-direction: column; justify-content: center; gap: 8px; padding: 12px; text-align: center; font-size: 17px; }
.choices.big .choice-btn .letter { width: auto; height: auto; background: transparent; }
.choices.big .choice-btn .mark { margin: 0; position: absolute; top: 10px; right: 10px; }
.choices.big .choice-btn { position: relative; }
.multi-box { display: flex; flex-direction: column; gap: 10px; margin-top: auto; }
.q-big .multi-box, .q-big .choices.big { flex: 1; }
.q-big { display: flex; flex-direction: column; }

/* ---------- jenis soalan ---------- */
.type-badge {
  display: inline-block; padding: 4px 12px; border-radius: 999px; font-size: 13px; font-weight: 700;
  background: rgba(255,255,255,.1); color: var(--on-night); border: 1px solid var(--night-line);
}
body:not(.game) .type-badge { background: var(--sand-2); color: var(--ink-2); border-color: transparent; font-size: 12px; }
.btn.dim { opacity: .55; }

.type-form { display: flex; flex-direction: column; gap: 10px; }
.type-input { text-align: center; font-size: 22px !important; font-weight: 700; min-height: 60px !important; }
.typed {
  display: inline-flex; align-items: center; gap: 10px; padding: 10px 18px; border-radius: 999px;
  background: var(--night-2); border: 1px solid var(--night-line); font-weight: 800; font-size: clamp(16px, 2vw, 26px);
  overflow-wrap: anywhere;
}
.typed.ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.typed .n { opacity: .75; font-variant-numeric: tabular-nums; }
.typed-list { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }

.slider-box { display: flex; flex-direction: column; gap: 14px; margin-top: auto; }
.slider-value { font-size: 60px; font-weight: 800; text-align: center; line-height: 1; font-variant-numeric: tabular-nums; color: var(--gold); }
input.range { width: 100%; height: 40px; accent-color: var(--gold); cursor: pointer; }
.range-row { display: flex; align-items: center; gap: 10px; }
.range-row .lbl { font-size: 14px; font-weight: 700; color: var(--on-night-2); }
.step-btn { width: 56px; min-height: 56px !important; padding: 0 !important; font-size: 28px !important; }

.pin-box { display: flex; flex-direction: column; gap: 12px; align-items: center; margin-top: auto; }
.pin-wrap { position: relative; display: inline-block; max-width: 100%; border-radius: 14px; overflow: hidden; line-height: 0; }
.pin-wrap img { display: block; max-width: 100%; max-height: 46vh; width: auto; height: auto; user-select: none; -webkit-user-drag: none; }
.pin-wrap.pickable { cursor: crosshair; touch-action: manipulation; outline: 2px dashed rgba(212, 164, 67, .7); outline-offset: -2px; }
.pin-dot {
  position: absolute; width: 20px; height: 20px; border-radius: 50%; transform: translate(-50%, -50%);
  border: 3px solid #fff; background: #8b7e90; box-shadow: 0 2px 8px rgba(0,0,0,.45); pointer-events: none;
}
.pin-dot.ok { background: var(--ok); }
.pin-dot.me { width: 28px; height: 28px; background: var(--gold); z-index: 2; }
.pin-target {
  position: absolute; aspect-ratio: 1; border-radius: 50%; transform: translate(-50%, -50%); pointer-events: none;
  border: 3px dashed #fff; background: rgba(23, 132, 95, .38);
}
.host-pin { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.host-pin .pin-wrap img { max-height: 56vh; }

.puzzle-box { display: flex; flex-direction: column; gap: 12px; margin-top: auto; }
.puzzle-slots { display: flex; flex-direction: column; gap: 8px; }
.slot {
  min-height: 52px; border-radius: 14px; border: 2px dashed var(--night-line); display: flex; align-items: center; gap: 10px;
  padding: 8px 12px; font-weight: 700; font-size: 16px; text-align: left; background: transparent; color: var(--on-night);
}
.slot.filled { border: none; background: var(--tone); color: var(--on-tone); cursor: pointer; box-shadow: inset 0 -3px 0 rgba(0,0,0,.18); }
.slot .pos { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; background: rgba(0,0,0,.18); font-weight: 800; flex: none; }
.slot .txt { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.puzzle-items { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.puzzle-item { min-height: 56px; font-size: 15px; padding: 8px 10px; gap: 8px; }
.puzzle-item .letter { width: 28px; height: 28px; border-radius: 8px; font-size: 14px; }
.reveal-order { text-align: left; background: rgba(0,0,0,.18); border-radius: 14px; padding: 12px 16px; }
.reveal-order ol { margin: 0; padding-left: 22px; font-weight: 700; }

.numline { position: relative; height: 70px; margin: 40px clamp(10px, 4vw, 60px) 10px; width: calc(100% - 2 * clamp(10px, 4vw, 60px)); }
.numline .axis { position: absolute; left: 0; right: 0; top: 50%; height: 6px; margin-top: -3px; border-radius: 999px; background: rgba(255,255,255,.2); }
.numline .band { position: absolute; top: 50%; height: 34px; margin-top: -17px; background: rgba(23, 132, 95, .5); border-radius: 10px; }
.numline .mark { position: absolute; top: 4px; bottom: 4px; width: 4px; margin-left: -2px; background: var(--gold); border-radius: 2px; }
.numline .mark b { position: absolute; bottom: 100%; left: 50%; transform: translateX(-50%); margin-bottom: 4px; color: var(--gold); font-size: clamp(18px, 2.2vw, 30px); white-space: nowrap; }
.numline .dot { position: absolute; width: 18px; height: 18px; margin: -9px 0 0 -9px; border-radius: 50%; border: 2px solid #fff; background: #8b7e90; }
.numline .dot.ok { background: var(--ok); }
.numline .ends { position: absolute; left: 0; right: 0; top: 100%; display: flex; justify-content: space-between; font-weight: 700; color: var(--on-night-2); font-size: clamp(13px, 1.4vw, 18px); }
.host-hint { margin: auto 0; display: flex; flex-direction: column; align-items: center; gap: 16px; text-align: center; font-size: clamp(18px, 2.4vw, 30px); font-weight: 700; color: var(--on-night-2); width: 100%; }
.order-list { display: flex; flex-direction: column; gap: 10px; width: 100%; max-width: 820px; margin: 0 auto; }
.order-list .host-choice { min-height: clamp(56px, 8vh, 84px); }

/* editor */
.type-picker { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 8px; }
.type-picker .btn { justify-content: flex-start; border-radius: 14px; min-height: 48px; }
select.type-select { width: auto; max-width: 60%; min-height: 34px !important; padding: 4px 10px !important; font-size: 13px !important; font-weight: 700; border-radius: 999px !important; }
.tf-toggle { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.tf-btn {
  min-height: 56px; border-radius: 14px; border: 2px solid var(--line); background: var(--card); font-weight: 800; font-size: 17px;
  cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 8px; color: var(--ink-2);
}
.tf-btn.on { border-color: var(--ok); background: #e7f6ef; color: #0d5a40; }
.num-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; }
.num-grid .input { min-height: 42px; }
.hint { font-size: 13px; color: var(--ink-2); margin: 0; }
.pin-editor .pin-wrap { border: 1px solid var(--line); }
.pin-editor .pin-wrap img { max-height: 360px; }
.accepted-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }

/* ---------- editor 3 lajur ---------- */
.ed { display: flex; flex-direction: column; height: 100vh; height: 100dvh; }
.ed-top { display: flex; align-items: center; gap: 10px; padding: 10px 14px; background: var(--card); border-bottom: 1px solid var(--line); }
.ed-title {
  flex: 1; min-width: 0; border: 1.5px solid var(--line); border-radius: 10px; padding: 9px 12px;
  font-size: 16px; font-weight: 700; background: var(--sand); color: var(--ink);
}
.ed-title:focus { outline: none; border-color: var(--brand); background: #fff; }
.ed-body { flex: 1; min-height: 0; display: grid; grid-template-columns: 210px minmax(0, 1fr) 290px; }

.ed-list { display: flex; flex-direction: column; background: var(--card); border-right: 1px solid var(--line); min-height: 0; }
.ed-slides { flex: 1; overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 10px; }
.ed-add { padding: 12px; border-top: 1px solid var(--line); }
.ed-slide { cursor: pointer; border-radius: 12px; padding: 6px; outline: none; transition: background-color .15s; }
.ed-slide:hover, .ed-slide:focus-visible { background: var(--sand); }
.ed-slide.active { background: var(--sand-2); }
.ed-slide.dragging { opacity: .4; }
.ed-slide.drop-target { box-shadow: inset 0 3px 0 var(--brand); }
.ed-slide-head { display: flex; gap: 8px; align-items: center; font-size: 12px; font-weight: 700; color: var(--ink-2); margin: 0 2px 6px; }
.ed-slide-head span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ed-thumb {
  background: #fff; border: 1.5px solid var(--line); border-radius: 10px; padding: 7px;
  display: flex; flex-direction: column; gap: 5px; aspect-ratio: 16 / 10;
}
.ed-slide.active .ed-thumb { border-color: var(--brand); box-shadow: 0 0 0 2px rgba(91, 26, 104, .18); }
.t-q { font-size: 10.5px; font-weight: 700; text-align: center; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; color: var(--ink-2); }
.t-mid { flex: 1; display: flex; align-items: center; justify-content: center; position: relative; min-height: 0; }
.t-time { position: absolute; left: 0; width: 20px; height: 20px; border-radius: 50%; border: 1.5px solid var(--line); font-size: 9px; font-weight: 700; display: grid; place-items: center; color: var(--ink-3); }
.t-mid img { max-height: 100%; max-width: 60%; border-radius: 4px; object-fit: cover; }
.t-img { width: 34px; height: 24px; border: 1.5px dashed var(--line); border-radius: 4px; display: grid; place-items: center; color: var(--ink-3); }
.t-ans { display: grid; grid-template-columns: 1fr 1fr; gap: 3px; }
.t-ans i { height: 8px; border-radius: 3px; background: var(--tone); }
.t-ans i.ok { box-shadow: 0 0 0 1.5px var(--ok); }
.t-ans i.wide { grid-column: 1 / -1; }
.t-ans i.plain { background: var(--sand-2); height: 10px; }
.t-ans i.line { background: var(--line); height: 3px; margin: 4px 0; }
.t-ans.t-puzzle { gap: 2px; }
.t-ans.t-puzzle i { height: 4px; }

.ed-canvas {
  overflow-y: auto; min-height: 0; padding: clamp(14px, 2.5vw, 32px); color: var(--on-night);
  background-color: var(--night);
  background-image:
    radial-gradient(120% 70% at 0% 0%, rgba(122, 32, 128, .55) 0%, transparent 60%),
    radial-gradient(90% 60% at 100% 100%, rgba(96, 22, 104, .45) 0%, transparent 60%);
}
.ed-stage { max-width: 980px; margin: 0 auto; display: flex; flex-direction: column; gap: 16px; min-height: 100%; }
.ed-qtext {
  width: 100%; border: none; border-radius: 12px; padding: 16px 20px; resize: none; background: #fff; color: var(--ink);
  font-size: clamp(18px, 2.2vw, 28px); font-weight: 700; text-align: center; box-shadow: inset 0 -3px 0 rgba(0,0,0,.08);
}
.ed-qtext:focus { outline: 3px solid var(--gold); }
.ed-media { display: flex; justify-content: center; }
.ed-drop {
  width: min(560px, 100%); min-height: 240px; border-radius: 14px; background: rgba(255,255,255,.9); color: var(--ink-2);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; padding: 20px; text-align: center;
  border: 2px dashed transparent; transition: border-color .2s, background-color .2s;
}
.ed-drop.over { border-color: var(--gold); background: #fff; }
.ed-drop-art { color: var(--brand); opacity: .5; }
.ed-plus {
  width: 50px; height: 50px; border-radius: 12px; border: 1px solid var(--line); background: #fff; display: grid; place-items: center;
  cursor: pointer; color: var(--ink); box-shadow: 0 2px 8px rgba(0,0,0,.1);
}
.ed-plus:hover { border-color: var(--brand); color: var(--brand); }
.ed-drop-title { margin: 0; font-size: 18px; font-weight: 700; color: var(--ink); }
.ed-drop-sub { margin: 0; font-size: 14px; }
.link { background: none; border: none; padding: 0; font: inherit; font-weight: 700; color: var(--brand); text-decoration: underline; cursor: pointer; }
.ed-media-img { display: inline-flex; flex-direction: column; align-items: center; gap: 8px; max-width: 100%; }
.ed-media-img > img { max-height: 300px; max-width: 100%; border-radius: 12px; background: #fff; }
.ed-media-actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; }
.ed-media-actions .btn { background: rgba(255,255,255,.94); color: var(--ink); }
.ed-media-actions .btn-danger { color: var(--danger); }
.ed-media .pin-wrap img { max-height: 340px; }
.spinner { width: 36px; height: 36px; border-radius: 50%; border: 4px solid var(--sand-2); border-top-color: var(--brand); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.ed-answers { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-top: auto; }
.ed-answers.one { grid-template-columns: 1fr; }
.ed-hint { margin: 0; color: var(--on-night-2); font-weight: 600; font-size: 14px; text-align: center; }
.ed-answer {
  display: flex; align-items: center; gap: 12px; background: #fff; border-radius: 12px; padding: 8px; min-height: 76px;
  box-shadow: inset 0 -3px 0 rgba(0,0,0,.08); transition: box-shadow .2s;
}
.ed-answer.is-correct { box-shadow: inset 0 0 0 3px var(--ok); }
.ed-strip { align-self: stretch; width: 50px; border-radius: 9px; background: var(--tone, var(--brand)); color: var(--on-tone, #fff); display: grid; place-items: center; flex: none; font-size: 20px; }
.ed-answer.plain .ed-strip { background: var(--sand-2); color: var(--brand); }
.ed-answer input { flex: 1; min-width: 0; border: none; font-size: 17px; font-weight: 600; padding: 8px 4px; background: transparent; color: var(--ink); }
.ed-answer input:focus { outline: none; }
.ed-answer-text { flex: 1; font-size: 18px; font-weight: 800; color: var(--ink); }
.ed-count { font-size: 12px; color: var(--ink-3); padding-right: 6px; }
.ed-correct {
  width: 40px; height: 40px; border-radius: 50%; border: 2px solid var(--line); background: #fff; color: transparent;
  display: grid; place-items: center; cursor: pointer; flex: none; transition: background-color .15s, border-color .15s, color .15s;
}
.ed-correct:hover { border-color: var(--ok); color: var(--ok); }
.ed-correct.on { background: var(--ok); border-color: var(--ok); color: #fff; }
.ed-card { background: #fff; border-radius: 14px; padding: 16px; display: flex; flex-direction: column; gap: 12px; color: var(--ink); }

.ed-props { background: var(--card); border-left: 1px solid var(--line); overflow-y: auto; min-height: 0; }
.ed-props-body { display: flex; flex-direction: column; gap: 14px; padding: 16px; min-height: 100%; }
.ed-props-title { font-size: 16px; margin: 0; }
.ed-prop { display: flex; flex-direction: column; gap: 6px; }
.ed-prop-label { display: inline-flex; gap: 8px; align-items: center; font-size: 14px; font-weight: 700; }
.ed-apply { align-self: flex-start; font-size: 13px; margin-top: -6px; }
.ed-props-actions { display: flex; gap: 6px; align-items: center; border-top: 1px solid var(--line); padding-top: 14px; flex-wrap: wrap; }
.ed-props .spacer { flex: 1; }

.ed-overlay { position: fixed; inset: 0; z-index: 80; background: rgba(36, 8, 42, .35); }
.ed-overlay.center { display: grid; place-items: center; padding: 16px; }
.ed-menu {
  position: absolute; left: 16px; bottom: 16px; width: min(460px, calc(100vw - 32px)); background: #fff; border-radius: 16px; padding: 14px;
  box-shadow: 0 20px 50px rgba(36, 8, 42, .3); animation: fadeUp .2s ease;
}
.ed-menu-title { margin: 0 0 10px; font-weight: 800; font-size: 14px; color: var(--ink-2); }
.ed-menu-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.ed-menu-item {
  display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 14px 8px; border-radius: 12px;
  border: 1.5px solid var(--line); background: var(--sand); cursor: pointer; font-weight: 700; font-size: 13px; color: var(--ink); text-align: center;
}
.ed-menu-item:hover, .ed-menu-item:focus { border-color: var(--brand); background: #fff; outline: none; }
.ed-menu-icon { width: 40px; height: 40px; border-radius: 10px; background: var(--brand); color: #fff; display: grid; place-items: center; }
.ed-modal {
  width: min(520px, 100%); background: #fff; border-radius: 18px; padding: 20px; display: flex; flex-direction: column; gap: 14px;
  box-shadow: 0 20px 50px rgba(36, 8, 42, .3); animation: fadeUp .2s ease;
}
.ed-switch { display: flex; gap: 12px; align-items: flex-start; padding: 12px; border-radius: 12px; background: var(--sand); cursor: pointer; }
.ed-switch input { width: 20px; height: 20px; margin-top: 2px; accent-color: var(--brand); flex: none; }
.ed-switch small { display: block; color: var(--ink-2); font-size: 13px; margin-top: 4px; line-height: 1.45; }

@media (max-width: 900px) {
  .ed { height: auto; min-height: 100vh; min-height: 100dvh; }
  .ed-body { display: flex; flex-direction: column; }
  .ed-list { border-right: none; border-bottom: 1px solid var(--line); }
  .ed-slides { flex-direction: row; overflow-x: auto; overflow-y: hidden; padding: 10px; }
  .ed-slide { flex: none; width: 150px; }
  .ed-add { border-top: none; padding: 0 10px 10px; }
  .ed-canvas { overflow: visible; }
  .ed-props { border-left: none; border-top: 1px solid var(--line); overflow: visible; }
  .ed-answers { grid-template-columns: 1fr; }
  .hide-sm { display: none !important; }
  .ed-menu { left: 16px !important; right: 16px; bottom: 16px !important; width: auto; }
  .ed-menu-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 720px) {
  .accepted-list { grid-template-columns: 1fr; }
  .lobby-grid { grid-template-columns: 1fr; text-align: center; }
  .qr { margin: 0 auto; }
  .host-q { grid-template-columns: auto minmax(0, 1fr); }
  .host-q .stat { display: none; }
  .host-choices { grid-template-columns: 1fr; }
  .editor-choices { grid-template-columns: 1fr; }
  .quiz-item { grid-template-columns: 1fr; }
  .quiz-actions { justify-content: flex-start; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
