/* ============ Ular Tangga Edukasi — Room Online ============ */
:root {
  --bg: #f6efe0;
  --ink: #2b2a33;
  --muted: #7a7466;
  --green: #1f8a5b;
  --green-d: #146b45;
  --orange: #f08a24;
  --orange-d: #b8600c;
  --red: #e0474c;
  --card: #ffffff;
  --line: #efe4cc;
  --radius: 18px;
  --shadow: 0 6px 24px rgba(60, 40, 10, .12);
}
* { box-sizing: border-box; }
html, body { min-height: 100%; }
body {
  margin: 0; font-family: 'Fredoka', system-ui, sans-serif; color: var(--ink);
  background:
    radial-gradient(circle at 8% 10%, #ffe3a8 0 7%, transparent 7.5%),
    radial-gradient(circle at 94% 85%, #c9efd9 0 9%, transparent 9.5%),
    var(--bg);
  background-attachment: fixed;
}
[hidden] { display: none !important; }
a { color: var(--green); }

/* ---------- Tombol ---------- */
.btn-play {
  border: 0; border-radius: 999px; padding: 13px 30px; background: var(--green); color: #fff; font-weight: 700;
  font-size: 1.15rem; box-shadow: 0 5px 0 var(--green-d); transition: transform .08s, box-shadow .08s; font-family: inherit; cursor: pointer;
}
.btn-play:hover { filter: brightness(1.06); color: #fff; }
.btn-play:active { transform: translateY(4px); box-shadow: 0 1px 0 var(--green-d); }
.btn-play:disabled { background: #cfc5b3; box-shadow: 0 5px 0 #a99d88; cursor: not-allowed; }
.btn-play.small { font-size: 1rem; padding: 9px 22px; }
.btn-ghost {
  border: 2px solid #e2d6bb; background: #fff; color: var(--ink); border-radius: 12px; padding: 7px 12px;
  font-family: inherit; font-weight: 600; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; gap: 6px; justify-content: center;
}
.btn-ghost:hover { background: #fff7e4; color: var(--ink); }
.btn-ghost.sm { padding: 5px 10px; font-size: .9rem; }
.btn-ghost.wide { padding: 9px 18px; border-radius: 999px; }
.btn-ghost.danger { color: var(--red); border-color: #f3c6c7; }
.btn-link-sm { background: none; border: 0; color: var(--muted); font-size: .85rem; padding: 4px 0; cursor: pointer; font-family: inherit; }
.btn-link-sm:hover { color: var(--ink); text-decoration: underline; }
.btn-link-sm.danger { color: var(--red); }
.mini {
  border: 1.5px solid #e2d6bb; background: #fff; border-radius: 8px; padding: 2px 7px; font-size: .78rem; font-weight: 600;
  cursor: pointer; font-family: inherit; color: var(--ink); white-space: nowrap;
}
.mini:hover { background: #fff7e4; }
.mini.ok { border-color: #9fd8b9; color: var(--green-d); background: #effaf3; }
.mini.danger { border-color: #f3c6c7; color: var(--red); }

/* ---------- Kartu & halaman awal ---------- */
.center-screen { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px 16px; }
.setup-card { width: 100%; background: var(--card); border-radius: 26px; padding: 26px; box-shadow: var(--shadow); border: 3px solid #f1e3c2; }
.setup-card.narrow { max-width: 560px; }
.logo { text-align: center; font-size: clamp(2rem, 6vw, 3.2rem); font-weight: 700; line-height: 1.1; }
.logo.small { font-size: clamp(1.6rem, 5vw, 2.2rem); }
.logo span { color: var(--green); }
.tagline { text-align: center; color: var(--muted); margin: 10px auto 18px; max-width: 560px; }
.home { width: 100%; max-width: 900px; }
.home-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.home-grid .setup-card { display: flex; flex-direction: column; gap: 6px; }
.hero-chars { display: flex; justify-content: center; gap: 4px; flex-wrap: wrap; margin-bottom: 18px; }
.hero-char { width: 56px; }
.hero-char svg { width: 100%; display: block; overflow: visible; }
.code-input { text-transform: uppercase; letter-spacing: .3em; font-weight: 700; text-align: center; }
.room-chip { text-align: center; margin: 6px auto; background: #fff3df; border-radius: 999px; padding: 6px 16px; width: fit-content; }
.leader-table, .win-table { width: 100%; font-size: .95rem; }
.leader-table td, .leader-table th, .win-table td, .win-table th { padding: 6px 4px; border-bottom: 1px solid #f1e8d6; }

/* pemilih karakter */
.char-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.char-grid.mini { grid-template-columns: repeat(5, 1fr); gap: 4px; margin-top: 8px; }
.char-opt {
  border: 2px solid var(--line); background: #fffaf0; border-radius: 14px; padding: 6px 2px 4px; cursor: pointer; font-family: inherit;
  display: flex; flex-direction: column; align-items: center; gap: 2px; color: var(--orange); transition: transform .1s;
}
.char-opt:hover { transform: translateY(-2px); }
.char-opt.on { border-color: var(--green); background: #e7f7ee; box-shadow: 0 0 0 3px rgba(31,138,91,.15); }
.char-pic { width: 44px; display: block; }
.char-grid.mini .char-pic { width: 32px; }
.char-pic svg { width: 100%; display: block; overflow: visible; }
.char-name { font-size: .7rem; color: var(--ink); line-height: 1.1; text-align: center; }

/* ---------- Bar atas ---------- */
.topbar {
  display: flex; align-items: center; gap: 12px; padding: 10px 16px; background: rgba(255,255,255,.85);
  backdrop-filter: blur(6px); box-shadow: 0 2px 10px rgba(0,0,0,.05); position: sticky; top: 0; z-index: 50;
}
.brand { font-size: 1.6rem; text-decoration: none; }
.tb-title { flex: 1; font-weight: 600; font-size: 1.1rem; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; min-width: 0; }
.tb-actions { display: flex; gap: 6px; align-items: center; }
.code-pill { background: #fff3df; color: var(--orange-d); border-radius: 8px; padding: 1px 8px; font-weight: 700; font-size: .9rem; letter-spacing: .05em; }
.host-badge { background: var(--ink); color: #fff; border-radius: 8px; padding: 2px 8px; font-size: .75rem; letter-spacing: .05em; }
.conn { width: 12px; height: 12px; border-radius: 50%; background: #2ecc71; box-shadow: 0 0 0 3px rgba(46,204,113,.25); }
.conn.off { background: var(--red); box-shadow: 0 0 0 3px rgba(224,71,76,.25); animation: pulse .8s infinite; }

/* ---------- Tata letak permainan ---------- */
.game-wrap {
  display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 18px;
  max-width: 1320px; margin: 0 auto; padding: 14px 16px 24px; align-items: start;
}
.game-wrap.host { grid-template-columns: minmax(0, 1fr) 380px; }
.board-wrap { display: flex; justify-content: center; position: sticky; top: 64px; }

/* ---------- Papan + tema ---------- */
.board {
  --cell-a: #fff8e7; --cell-b: #ffe9b8; --cell-num: #8b6b3b; --board-border: #7a4e25;
  position: relative; width: min(100%, calc(100vh - 96px)); aspect-ratio: 1; border-radius: 20px; overflow: hidden;
  box-shadow: var(--shadow); border: 7px solid var(--board-border); background: var(--board-border);
}
.cells { position: absolute; inset: 0; display: grid; grid-template-columns: repeat(10, 1fr); grid-template-rows: repeat(10, 1fr); }
.cell {
  position: relative; background: var(--cell-a); display: flex; align-items: flex-start; padding: 3px 5px;
  font-weight: 600; font-size: clamp(.55rem, 1.35vw, .9rem); color: var(--cell-num);
}
.cell.alt { background: var(--cell-b); }
.cell.finish { background: linear-gradient(135deg, #ffd23f, #ffb000) !important; color: #6b4a00; }
.cell.start { background: linear-gradient(135deg, #9be7b9, #5bc98a) !important; color: #0f5132; }
.cell .tag { position: absolute; bottom: 2px; right: 4px; font-size: .6em; opacity: .85; }
.cell .qbadge {
  position: absolute; top: 3px; right: 3px; width: 1.4em; height: 1.4em; border-radius: 50%; background: var(--orange); color: #fff;
  display: grid; place-items: center; font-size: .75em; box-shadow: 0 2px 0 var(--orange-d); animation: pulse 1.6s infinite;
}
.cell.flash { animation: flash .5s 3; }
@keyframes flash { 50% { background: #fff; } }
@keyframes pulse { 50% { transform: scale(1.18); } }

/* dekorasi tema */
.board[data-theme="angkasa"] { background:
  radial-gradient(1.5px 1.5px at 10% 20%, #fff 50%, transparent 51%), radial-gradient(1px 1px at 30% 70%, #fff 50%, transparent 51%),
  radial-gradient(2px 2px at 55% 35%, #ffeaa7 50%, transparent 51%), radial-gradient(1px 1px at 75% 85%, #fff 50%, transparent 51%),
  radial-gradient(1.5px 1.5px at 85% 15%, #a5d8ff 50%, transparent 51%), radial-gradient(1px 1px at 45% 92%, #fff 50%, transparent 51%),
  radial-gradient(circle at 80% 20%, #4b2a7a 0, transparent 40%), radial-gradient(circle at 20% 80%, #123a6b 0, transparent 45%), #070a1f; }
.board[data-theme="angkasa"] .cells::after { /* kerlip ringan: hanya opacity (tanpa filter yang berat) */
  content: ''; position: absolute; inset: 0; pointer-events: none; background: rgba(255,255,255,.06);
  opacity: 0; animation: twinkleBg 6s ease-in-out infinite; will-change: opacity;
}
@keyframes twinkleBg { 50% { opacity: 1; } }
.board[data-theme="neon"] .cell { box-shadow: inset 0 0 0 1px rgba(88,166,255,.12); }
.board[data-theme="neon"] { box-shadow: 0 0 0 2px #1f6feb, 0 0 24px rgba(57,255,20,.25), var(--shadow); }
.board[data-theme="neon"] .cells::after { /* garis scan: digeser dengan transform (GPU), bukan background-position */
  content: ''; position: absolute; left: 0; right: 0; top: 0; height: 12%; pointer-events: none;
  background: linear-gradient(transparent, rgba(57,255,20,.07) 50%, transparent); animation: scan 5s linear infinite; will-change: transform;
}
@keyframes scan { from { transform: translateY(-100%); } to { transform: translateY(840%); } }
.board[data-theme="laut"] .cell.alt { background: linear-gradient(180deg, #d8f3fa, #bfe7f3); }
.board[data-theme="hutan"] .cell::before {
  content: ''; position: absolute; inset: 0; opacity: .25; pointer-events: none;
  background: radial-gradient(circle at 80% 85%, #8dc26f 0 18%, transparent 19%);
}
.board[data-theme="kota"] .cell { box-shadow: inset 0 0 0 1px rgba(0,0,0,.04); }
.board.dark .cell.finish, .board.dark .cell.start { opacity: .95; }

/* ---------- Ular & tangga (SVG) ---------- */
.overlay { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.overlay { will-change: transform; } /* lapisan statis & lapisan animasi dipisah oleh GPU */
/* Performa: tidak ada CSS filter / animasi warna per anak tangga (dulu penyebab utama lag papan). */
.ladder { transition: opacity .5s; }
.ladder .ladder-focus { opacity: 0; transition: opacity .3s; }
.ladder.glow .ladder-focus { opacity: 1; animation: ladderBob .7s ease-in-out infinite alternate; }
@keyframes ladderBob { from { opacity: .45; } to { opacity: 1; } }
.spark { transform-box: fill-box; transform-origin: center; animation: spark 2.2s ease-in-out infinite; }
@keyframes spark { 0%, 100% { transform: scale(.2) rotate(0); opacity: 0; } 40% { transform: scale(1) rotate(45deg); opacity: 1; } 70% { opacity: .2; } }
.ladder.broken { opacity: .12; }
.snake-head { transform-box: fill-box; transform-origin: 20% 50%; animation: sHead 1.8s ease-in-out infinite; }
@keyframes sHead { 0%, 100% { transform: rotate(-9deg); } 50% { transform: rotate(9deg); } }
.tongue { transform-box: fill-box; transform-origin: 0 50%; animation: tongue 1.6s ease-in-out infinite; }
@keyframes tongue { 0%, 55%, 100% { transform: scaleX(0); } 65%, 85% { transform: scaleX(1); } 75% { transform: scaleX(.75); } }
.snake-eye { transform-box: fill-box; transform-origin: center; animation: blink 4.5s infinite; }
@keyframes blink { 0%, 94%, 100% { transform: scaleY(1); } 97% { transform: scaleY(.1); } }
.snake-temp { animation: snakeIn .7s ease-out both; }
@keyframes snakeIn { from { opacity: 0; } to { opacity: 1; } }

/* ---------- Pion karakter ---------- */
.pawns { position: absolute; inset: 0; pointer-events: none; }
/* Pion digeser dengan transform (diatur room.js) → tidak memicu layout ulang di setiap langkah. */
.pawn {
  position: absolute; left: 0; top: 0; width: 6.2%; aspect-ratio: 60 / 80; transform-origin: 50% 94%;
  transition: transform .18s ease, width .25s ease; will-change: transform; contain: layout style;
}
.pawn svg { position: relative; width: 100%; height: 100%; display: block; overflow: visible; }
.pawn::before { /* bayangan murah pengganti filter: drop-shadow */
  content: ''; position: absolute; left: 12%; right: 12%; bottom: 0; height: 12%; border-radius: 50%;
  background: rgba(0,0,0,.35); transform: translateY(35%);
}
.pawn.no-trans { transition: none; }
.pawn.active::before { /* cahaya giliran (statis, tanpa filter) */
  left: -30%; right: -30%; height: 46%; bottom: -14%; transform: none;
  background: radial-gradient(closest-side, rgba(255,210,63,.95), rgba(255,176,0,.45) 55%, transparent);
}
.pawn.active::after {
  content: '▼'; position: absolute; left: 50%; top: -28%; transform: translateX(-50%); color: #ffb000;
  font-size: clamp(.6rem, 1.4vw, 1rem); text-shadow: 0 1px 0 #fff; animation: arrow .8s ease-in-out infinite alternate;
}
.pawn.me .c-base { stroke: #ffd23f; stroke-width: 3; }
@keyframes arrow { to { transform: translate(-50%, -30%); } }

/* animasi karakter (dipakai di pion & ikon pengguna) */
.char-svg .fig { transform-box: fill-box; transform-origin: 50% 100%; animation: breathe 2.6s ease-in-out infinite; animation-delay: var(--d, 0s); }
.char-svg .c-head { transform-box: fill-box; transform-origin: 50% 85%; animation: headTilt 3.4s ease-in-out infinite; animation-delay: var(--d, 0s); }
.char-svg .c-arm { transform-box: fill-box; transform-origin: 50% 12%; }
.char-svg .c-arm.l { animation: armSwing 2.6s ease-in-out infinite; animation-delay: var(--d, 0s); }
.char-svg .c-eyes { transform-box: fill-box; transform-origin: center; animation: blink 5s infinite; animation-delay: var(--d, 0s); }
@keyframes breathe { 0%, 100% { transform: scale(1, 1); } 50% { transform: scale(1.035, .965); } }
@keyframes headTilt { 0%, 100% { transform: rotate(0); } 25% { transform: rotate(-6deg); } 75% { transform: rotate(6deg); } }
@keyframes armSwing { 0%, 100% { transform: rotate(0); } 50% { transform: rotate(8deg); } }
.pawn.active .c-arm.r, .avatar-turn .c-arm.r, .me-av .c-arm.r, .win-avatar .c-arm.r, .char-opt.on .c-arm.r, .hero-char:hover .c-arm.r {
  animation: wave .45s ease-in-out infinite alternate;
}
@keyframes wave { from { transform: rotate(-15deg); } to { transform: rotate(-150deg); } }
.pawn.active .fig { animation: jumpy .9s ease-in-out infinite; }
@keyframes jumpy { 0%, 100% { transform: translateY(0) scale(1, 1); } 40% { transform: translateY(-14%) scale(.96, 1.04); } 55% { transform: translateY(0) scale(1.06, .94); } }
.pawn.hop .fig { animation: hop .19s ease-out; }
@keyframes hop { 50% { transform: translateY(-22%) scale(.95, 1.05); } }
.hero-char .fig { animation: jumpy 1.8s ease-in-out infinite; animation-delay: var(--d, 0s); }

/* ---------- Pesan di atas papan ---------- */
.board-msg { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(0,0,0,.18); z-index: 3000; }
.bm-card { background: rgba(255,255,255,.95); border-radius: 18px; padding: 16px 24px; text-align: center; box-shadow: var(--shadow); max-width: 80%; }
.bm-ico { font-size: 2rem; animation: pulse 1.4s infinite; }

/* ---------- Panel samping ---------- */
.side { display: flex; flex-direction: column; gap: 12px; }
.panel { background: var(--card); border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow); }
.panel-title { font-weight: 600; margin-bottom: 8px; color: var(--muted); }
.count { background: #fff3df; color: var(--orange-d); border-radius: 999px; padding: 0 8px; font-size: .8rem; }
.turn-panel { text-align: center; }
.turn-label { color: var(--muted); font-size: .85rem; }
.turn-name { font-size: 1.45rem; font-weight: 700; display: flex; align-items: center; justify-content: center; gap: 4px; min-height: 2.6rem; }
.avatar-turn { display: inline-block; width: 38px; }
.avatar-turn svg, .avatar-sm svg, .avatar-lg svg, .avatar-xs svg, .win-avatar svg { width: 100%; height: auto; display: block; overflow: visible; }
.dice-area { display: flex; align-items: center; justify-content: center; gap: 14px; margin: 10px 0 6px; }
.btn-roll {
  border: 0; border-radius: 14px; padding: 12px 16px; background: var(--orange); color: #fff; font-weight: 700;
  box-shadow: 0 4px 0 var(--orange-d); font-family: inherit; cursor: pointer; font-size: 1rem;
}
.btn-roll:disabled { background: #cfc5b3; box-shadow: 0 4px 0 #a99d88; cursor: not-allowed; }
.btn-roll.pulse { animation: rollPulse 1s infinite; }
@keyframes rollPulse { 50% { transform: scale(1.07); box-shadow: 0 4px 0 var(--orange-d), 0 0 0 8px rgba(240,138,36,.2); } }
.status-text { min-height: 2.4em; color: var(--muted); font-size: .95rem; }
.auto-roll { font-size: .8rem; color: var(--orange-d); }
.dice {
  width: 62px; height: 62px; background: #fff; border-radius: 14px; position: relative; flex: none;
  box-shadow: inset 0 -5px 0 #e6dccb, 0 4px 10px rgba(0,0,0,.18); border: 2px solid #eee3cf;
}
.dice.rolling { animation: shake .12s infinite; }
@keyframes shake { 0% { transform: rotate(-12deg); } 50% { transform: rotate(12deg) scale(1.05); } 100% { transform: rotate(-12deg); } }
.dice .pip { position: absolute; width: 12px; height: 12px; border-radius: 50%; background: var(--ink); transform: translate(-50%, -50%); }

.player-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 6px; max-height: 360px; overflow-y: auto; }
.player-list li {
  display: flex; align-items: center; gap: 7px; padding: 5px 8px; border-radius: 12px; background: #fbf6ea; border: 2px solid transparent;
}
.player-list li.active { border-color: var(--orange); background: #fff3df; }
.player-list li.me { box-shadow: inset 4px 0 0 #ffd23f; }
.player-list li.want { background: #fff8d6; border-color: #ffe08a; }
.player-list li.empty { color: var(--muted); font-size: .9rem; background: none; }
.player-list .pname { font-weight: 600; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.player-list .pname small { color: var(--muted); font-weight: 400; }
.player-list .pos { font-weight: 700; background: #fff; border-radius: 8px; padding: 1px 8px; min-width: 34px; text-align: center; }
.player-list .score { font-size: .78rem; color: var(--muted); white-space: nowrap; }
.player-list.guests { max-height: 220px; }
.avatar-sm { width: 30px; flex: none; margin: -4px 0; }
.avatar-xs { display: inline-block; width: 22px; vertical-align: middle; }
.avatar-lg { width: 54px; flex: none; }
.online { width: 9px; height: 9px; border-radius: 50%; background: #c9c2b2; flex: none; }
.online.on { background: #2ecc71; }
.want-badge { font-size: .72rem; background: #ffe08a; border-radius: 999px; padding: 1px 7px; white-space: nowrap; }

.log-panel { max-height: 260px; display: flex; flex-direction: column; }
.log { list-style: none; padding: 0; margin: 0; overflow-y: auto; font-size: .86rem; }
.log li { padding: 4px 0; border-bottom: 1px dashed #eee2c8; }
.rules-box { list-style: none; padding: 0; margin: 0; font-size: .86rem; }
.rules-box li { padding: 3px 0; }

/* kartu "aku" */
.me-row { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.me-av { color: var(--orange); }
.me-name { font-weight: 700; font-size: 1.15rem; }
.role-badge { display: inline-block; border-radius: 999px; padding: 2px 10px; font-size: .8rem; font-weight: 600; }
.role-badge.player { background: #dcf5e7; color: var(--green-d); }
.role-badge.guest { background: #eef0f4; color: #4a5262; }
.btn-want {
  width: 100%; border: 0; border-radius: 12px; padding: 10px; font-family: inherit; font-weight: 700; font-size: 1rem; cursor: pointer;
  background: #ffd23f; color: #5a4300; box-shadow: 0 4px 0 #c9a200; margin-bottom: 6px;
}
.btn-want.sent { background: #f1ead9; color: var(--muted); box-shadow: 0 4px 0 #d8ccb2; }
.me-edit summary { cursor: pointer; font-size: .85rem; color: var(--muted); }

/* ---------- Admin ---------- */
.join-panel { text-align: center; background: linear-gradient(135deg, #1f8a5b, #146b45); color: #fff; }
.join-panel .text-muted { color: rgba(255,255,255,.75) !important; }
.big-code { font-size: 2.6rem; font-weight: 700; letter-spacing: .25em; line-height: 1.1; }
.join-url { font-size: .78rem; display: flex; gap: 6px; align-items: center; justify-content: center; word-break: break-all; }
.join-panel .mini { background: rgba(255,255,255,.15); color: #fff; border-color: rgba(255,255,255,.3); }
.host-tabs { display: flex; gap: 6px; list-style: none; padding: 0; margin: 0; }
.host-tabs li { flex: 1; }
.host-tabs button {
  width: 100%; border: 0; border-radius: 12px; padding: 9px 4px; background: #efe6d2; font-family: inherit; font-weight: 600; color: var(--muted); cursor: pointer; position: relative;
}
.host-tabs button.active { background: #fff; color: var(--ink); box-shadow: var(--shadow); }
.tab-badge { position: absolute; top: -6px; right: 4px; background: var(--red); color: #fff; border-radius: 999px; font-size: .7rem; padding: 0 6px; animation: pulse 1s infinite; }
.tab-pane-x { display: flex; flex-direction: column; gap: 12px; }
.host-controls { display: flex; flex-direction: column; gap: 8px; }
.ctl-info { font-size: .92rem; }
.rules-form .panel-title { margin-top: 2px; }
.theme-pick { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.theme-opt input { display: none; }
.theme-opt span {
  display: block; border-radius: 12px; padding: 9px 10px; font-weight: 600; font-size: .88rem; cursor: pointer;
  border: 2px solid transparent; box-shadow: inset 0 0 0 1px rgba(0,0,0,.06);
}
.theme-opt input:checked + span { border-color: var(--ink); box-shadow: 0 0 0 3px rgba(43,42,51,.15); }
.t-klasik span { background: linear-gradient(135deg, #fff8e7 50%, #ffe9b8 50%); color: #7a4e25; }
.t-hutan span { background: linear-gradient(135deg, #e6f3d6 50%, #c7e3a9 50%); color: #2f4a1e; }
.t-angkasa span { background: linear-gradient(135deg, #283062 50%, #12163a 50%); color: #cfd6ff; }
.t-laut span { background: linear-gradient(135deg, #fdf3d8 50%, #cdeef6 50%); color: #16557d; }
.t-kota span { background: linear-gradient(135deg, #eceff3 50%, #d5dae2 50%); color: #2f3542; }
.t-neon span { background: linear-gradient(135deg, #111827 50%, #0b1220 50%); color: #39ff14; }
.cat-checks { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { border: 2px solid #e8dcc0; border-radius: 999px; padding: 4px 10px; background: #fffaf0; cursor: pointer; font-size: .85rem; margin: 0; }
.chip.on { background: #e3f6ec; border-color: var(--green); color: var(--green-d); }
.chip small { color: var(--muted); }
.tgl { display: flex; gap: 10px; align-items: flex-start; padding: 7px 0; border-top: 1px dashed var(--line); cursor: pointer; }
.tgl input { display: none; }
.tgl-ui { width: 40px; height: 22px; border-radius: 999px; background: #d8cfbd; position: relative; flex: none; transition: background .2s; margin-top: 2px; }
.tgl-ui::after { content: ''; position: absolute; width: 18px; height: 18px; border-radius: 50%; background: #fff; top: 2px; left: 2px; transition: left .2s; box-shadow: 0 1px 2px rgba(0,0,0,.25); }
.tgl input:checked + .tgl-ui { background: var(--green); }
.tgl input:checked + .tgl-ui::after { left: 20px; }
.tgl small { display: block; color: var(--muted); font-size: .78rem; }
.saved-note { font-size: .82rem; color: var(--green-d); opacity: 0; transition: opacity .3s; text-align: center; }
.saved-note.show { opacity: 1; }
.room-list { display: flex; flex-direction: column; gap: 8px; }
.room-item { display: flex; align-items: center; gap: 8px; padding: 10px 12px; background: #fbf6ea; border-radius: 14px; }
.qr-box { display: flex; justify-content: center; margin: 12px 0; }
.qr-box img, .qr-box canvas { border: 8px solid #fff; border-radius: 8px; }

/* ---------- Jendela melayang ---------- */
.ov { position: fixed; inset: 0; background: rgba(30, 24, 10, .45); display: grid; place-items: center; z-index: 4000; padding: 16px; }
.ov.solid { background: var(--bg); }
.ov-card { background: #fff; border-radius: 24px; box-shadow: 0 20px 60px rgba(0,0,0,.3); width: 100%; max-width: 640px; padding: 22px; animation: popIn .25s ease-out; }
@keyframes popIn { from { transform: scale(.92); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.q-card { padding: 0; overflow: hidden; max-width: 760px; }
.q-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 20px 10px; }
.q-badge { background: var(--green); color: #fff; border-radius: 999px; padding: 4px 12px; font-weight: 600; font-size: .9rem; }
.q-badge.light { background: #eef7f2; color: var(--green-d); }
.q-timer { font-weight: 700; font-size: 1.2rem; }
.q-timer.danger { color: var(--red); animation: pulse .5s infinite; }
.timer-bar { height: 6px; background: #f1ead9; }
.timer-bar div { height: 100%; width: 100%; background: var(--orange); transition: width .25s linear; }
.q-body { padding: 16px 22px 22px; }
.q-intro { font-size: .95rem; color: var(--muted); margin-bottom: 6px; }
.q-who { font-weight: 700; }
.q-text { font-size: 1.35rem; font-weight: 600; margin-bottom: 16px; }
.q-options { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.opt {
  display: flex; align-items: center; gap: 10px; text-align: left; border: 2px solid #eadfc6; background: #fffaf0; color: var(--ink);
  border-radius: 14px; padding: 12px 14px; font-family: inherit; font-size: 1.05rem; cursor: pointer; transition: transform .1s;
}
.opt:disabled { cursor: default; opacity: 1; color: var(--ink); }
#qModal.mine .opt:not(:disabled):hover { transform: translateY(-2px); border-color: var(--orange); }
#qModal.mine .q-card { box-shadow: 0 0 0 4px #ffd23f, 0 20px 60px rgba(0,0,0,.3); }
.opt .letter { width: 30px; height: 30px; border-radius: 50%; background: #fff; border: 2px solid #eadfc6; display: grid; place-items: center; font-weight: 700; flex: none; }
.opt.picked { border-color: var(--orange); background: #fff3df; }
.opt.correct { background: #dcf5e7; border-color: var(--green); }
.opt.correct .letter { background: var(--green); color: #fff; border-color: var(--green); }
.opt.wrong { background: #fde2e2; border-color: var(--red); }
.opt.wrong .letter { background: var(--red); color: #fff; border-color: var(--red); }
.q-result { margin-top: 14px; padding: 12px 16px; border-radius: 14px; font-size: 1rem; }
.q-result.ok { background: #e3f6ec; color: #0f5132; }
.q-result.bad { background: #fdecec; color: #842029; }
.win-card { text-align: center; max-width: 520px; }
.trophy { font-size: 3rem; }
.win-avatar { width: 90px; margin: -10px auto 4px; }
#winModal.pop .trophy { animation: pulse 1s infinite; }
#winStats { max-height: 300px; overflow-y: auto; }
.rules ol { padding-left: 1.2rem; } .rules li { margin-bottom: 6px; }
.qmark { display: inline-grid; place-items: center; width: 1.3em; height: 1.3em; border-radius: 50%; background: var(--orange); color: #fff; font-size: .8em; }
.toast-msg {
  position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%); background: var(--ink); color: #fff;
  padding: 10px 18px; border-radius: 12px; z-index: 5000; box-shadow: var(--shadow); max-width: 90vw; text-align: center;
}

/* ---------- Responsif ---------- */
@media (max-width: 980px) {
  .game-wrap, .game-wrap.host { grid-template-columns: 1fr; }
  .board-wrap { position: static; }
  .board { width: 100%; }
  .log-panel { max-height: 180px; }
}
@media (max-width: 640px) {
  .home-grid { grid-template-columns: 1fr; }
  .setup-card { padding: 18px 14px; }
  .q-options { grid-template-columns: 1fr; }
  .q-text { font-size: 1.12rem; }
  .game-wrap { padding: 8px; }
  .board { border-width: 4px; border-radius: 14px; }
  .char-grid { grid-template-columns: repeat(5, 1fr); gap: 4px; }
  .char-pic { width: 36px; }
  .char-name { font-size: .6rem; }
  .big-code { font-size: 2rem; }
  .topbar { padding: 8px 10px; }
  .tb-title { font-size: .95rem; }
  .hero-char { width: 40px; }
}
@media (prefers-reduced-motion: reduce) {
  .char-svg *, .snake-head, .tongue, .snake-eye, .spark, .cells::after, .qbadge { animation: none !important; }
}
/* Avatar di daftar pemain/tamu tidak dianimasikan: bisa sampai 60 orang → berat bila semua bergerak. */
.avatar-sm .char-svg *, .avatar-xs .char-svg * { animation: none !important; }
/* Mode hemat (otomatis di perangkat lemah, atau tombol ⚡): matikan semua animasi dekorasi. */
.lite .snake-head, .lite .tongue, .lite .snake-eye, .lite .spark, .lite .board .cells::after,
.lite .cell .qbadge, .lite .pawn:not(.active) .char-svg *, .lite .bm-ico { animation: none !important; }
.lite .ladder.glow .ladder-focus { animation: none; }
.lite .ov { backdrop-filter: none !important; }
#liteBtn.on { background: #ffd23f; border-color: #e0b000; color: #2b2a33; }
.home-grid .setup-card > a.btn-play { align-self: flex-start; }
