/* Blok Geometri: tampilan. Aturan: window.BLOK (blok.js). Blok digambar dengan DOM dan CSS. */
.bk { --bk-1: #4338ca; --bk-2: #6366f1; --bk-3: #818cf8; --bk-ink: #1e1b4b; --bk-p0: #4338ca; --bk-p1: #ea580c; --bk-ok: #16a34a; --bk-gold: #fbbf24; }
.bk .t-goal { display: none; }
.bk-wrap { flex: 1; min-height: 0; display: flex; flex-direction: column; padding: clamp(6px, 1vw, 14px); overflow: hidden; position: relative; background: linear-gradient(135deg, #e0e7ff, #f5f3ff 55%, #dbeafe); }
.bk-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.bk-time { flex: none; min-width: 64px; text-align: center; font: 800 clamp(16px, 1.8vw, 24px) var(--font); color: var(--bk-1); background: #eef2ff; border: 3px solid var(--bk-3); border-radius: 999px; padding: 2px 12px; font-variant-numeric: tabular-nums; }
.bk-time[hidden] { display: none; }
.bk-time.low { background: #fee2e2; border-color: #ef4444; color: #b91c1c; }
.topbar .title { flex: 1; }

.bk-boards { flex: 1; min-height: 0; display: flex; gap: clamp(8px, 2vw, 28px); justify-content: center; align-items: stretch; }

/* panel pemain: kotak 3 bagian (atas, papan, nampan) */
.bp { --pc: var(--bk-p0); --B: 300px; --trayH: 130px; --tb: 44px; flex: 1 1 0; min-width: 0; min-height: 0; display: grid; gap: 6px; position: relative; }
.bp.p1 { --pc: var(--bk-p1); }
.bp[data-lay="stack"] { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr) var(--trayH); grid-template-areas: "top" "area" "tray"; }
.bp[data-lay="side"] { grid-template-columns: var(--B) minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); grid-template-areas: "area top" "area tray"; column-gap: clamp(8px, 1.6vw, 22px); }
.bk-top { grid-area: top; display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.bk-h { display: flex; align-items: center; justify-content: center; gap: 8px; flex-wrap: wrap; min-height: 28px; font-family: var(--font); }
.bk-h .nm { font-size: clamp(16px, 2vw, 28px); font-weight: 800; color: var(--pc); }
.bk-h .nm:empty { display: none; }
.bk-h .chip { font-weight: 700; font-size: clamp(13px, 1.5vw, 22px); background: #fff; border: 3px solid var(--pc); border-radius: 999px; padding: 1px 12px; color: #0f172a; font-variant-numeric: tabular-nums; white-space: nowrap; }
.bk-h .chip b { font-weight: 800; }
.bk-h .chip.kb { background: #fef3c7; border-color: #d97706; color: #92400e; }
.bk-h .chip.kb[hidden], .bk-h .chip.rk[hidden] { display: none; }
.bk-h .chip.sk { min-width: 5.5em; text-align: center; }
.bk-mis { display: flex; align-items: center; gap: 8px; background: #fff; border: 3px solid var(--bk-3); border-radius: 16px; padding: 4px 10px; min-height: 40px; box-shadow: 0 3px 0 rgba(67, 56, 202, .18); transition: background .2s; }
.bk-mis .ic { flex: none; width: 28px; height: 28px; color: var(--bk-1); }
.bk-mis .ic svg { width: 100%; height: 100%; display: block; }
.bk-mis .tx { flex: 1; min-width: 0; font: 800 clamp(14px, 1.7vw, 24px)/1.2 var(--font); color: var(--bk-ink); }
.bk-mis .pt { flex: none; font: 800 clamp(13px, 1.3vw, 18px) var(--font); color: #92400e; background: #fef3c7; border-radius: 999px; padding: 1px 9px; }
.bk-mis.ok { background: #dcfce7; border-color: var(--bk-ok); animation: bk-pulse .5s ease 2; }
.bk-info { min-height: 22px; font: 700 clamp(13px, 1.4vw, 19px)/1.25 var(--font); color: #475569; text-align: center; }
.bk-info b { color: var(--bk-ink); font-weight: 800; }
.bk-info[hidden], .bp[data-compact] .bk-info { display: none; }
.bp[data-compact] .bk-mis .tx { font-size: 12px; line-height: 1.15; }
.bp[data-compact] .bk-mis .ic { display: none; }
.bp[data-compact] .bk-mis .pt { font-size: 11px; padding: 0 6px; }
.bp[data-compact] .bk-mis { min-height: 28px; gap: 4px; }

/* papan */
.bk-area { grid-area: area; min-width: 0; min-height: 0; display: grid; place-items: center; overflow: visible; position: relative; }
.bk-board { position: relative; box-sizing: border-box; padding: 4px; border: 5px solid var(--pc); border-radius: 16px; background: #1e1b4b; user-select: none; -webkit-user-select: none; touch-action: none; box-shadow: 0 10px 26px rgba(67, 56, 202, .3); }
.bk-grid { width: 100%; height: 100%; display: grid; grid-template-columns: repeat(8, 1fr); grid-template-rows: repeat(8, 1fr); gap: 2px; }
.bk-grid .c { position: relative; border-radius: 17%; background: rgba(199, 210, 254, .1); box-sizing: border-box; min-width: 0; min-height: 0; }
.bk-grid .c:nth-child(16n+1), .bk-grid .c:nth-child(16n+3), .bk-grid .c:nth-child(16n+5), .bk-grid .c:nth-child(16n+7), .bk-grid .c:nth-child(16n+10), .bk-grid .c:nth-child(16n+12), .bk-grid .c:nth-child(16n+14), .bk-grid .c:nth-child(16n+16) { background: rgba(199, 210, 254, .16); }
.bk-grid .c.f { background: var(--cc, #a5b4fc); box-shadow: inset 0 0 0 2px rgba(15, 23, 42, .6), inset 0 3px 0 rgba(255, 255, 255, .42), inset 0 -4px 0 rgba(0, 0, 0, .16); }
.bk-grid .c.pv-ok { background: rgba(74, 222, 128, .78); box-shadow: inset 0 0 0 2px rgba(20, 83, 45, .65); }
.bk-grid .c.pv-no { background: rgba(251, 113, 133, .82); box-shadow: inset 0 0 0 2px rgba(136, 19, 55, .6); }
.bk-grid .c.pv-line { box-shadow: inset 0 0 0 3px var(--bk-gold), 0 0 8px 1px rgba(251, 191, 36, .85); filter: brightness(1.18); z-index: 2; }
.bk-grid .c.pv-line:not(.f):not(.pv-ok) { background: rgba(251, 191, 36, .35); }
.bk-grid .c.clr { animation: bk-clr .36s ease-out forwards; z-index: 3; }
.bk-grid .c.drop { animation: bk-drop .22s ease-out; }
.bk-board.over { opacity: .55; }
.bk-board.over::after { content: attr(data-msg); position: absolute; inset: 0; display: grid; place-items: center; text-align: center; font: 800 clamp(18px, 3vw, 34px) var(--font); color: #fff; text-shadow: 0 2px 6px rgba(0, 0, 0, .7); background: rgba(30, 27, 75, .5); border-radius: 10px; }
.bp.fin .bk-board { border-color: var(--bk-ok); }

/* efek */
.bk-pops { position: absolute; inset: 0; pointer-events: none; z-index: 8; overflow: visible; }
.bk-pop { position: absolute; left: 50%; top: 40%; transform: translate(-50%, 0); white-space: nowrap; font: 800 clamp(20px, 3.4vw, 44px) var(--font); color: #fff; -webkit-text-stroke: 1px rgba(30, 27, 75, .8); text-shadow: 0 3px 0 rgba(30, 27, 75, .85), 0 0 12px rgba(251, 191, 36, .9); animation: bk-pop 1.2s ease-out forwards; }
.bk-pop.m { color: #fde68a; }
.bk-pop.k { color: #fbbf24; }
.bk-star { position: absolute; left: 50%; top: 40%; width: 22px; height: 22px; margin: -11px 0 0 -11px; color: #fbbf24; animation: bk-star .9s ease-out forwards; }
.bk-star svg { width: 100%; height: 100%; display: block; filter: drop-shadow(0 1px 0 rgba(30, 27, 75, .8)); }

/* nampan */
.bk-tray { grid-area: tray; position: relative; min-width: 0; min-height: 0; display: grid; gap: clamp(4px, .8vw, 12px); }
.bp[data-lay="stack"] .bk-tray { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.bp[data-lay="side"] .bk-tray { grid-template-rows: repeat(3, minmax(0, 1fr)); }
.bk-slot { position: relative; min-width: 0; min-height: 0; display: flex; align-items: stretch; gap: 3px; background: rgba(255, 255, 255, .75); border: 3px solid #c7d2fe; border-radius: 16px; padding: 3px; box-sizing: border-box; }
.bk-slot.nofit { background: rgba(226, 232, 240, .7); border-style: dashed; }
.bk-slot.pick { border-color: var(--pc); box-shadow: 0 0 0 3px rgba(99, 102, 241, .35); }
.bk-slot.sel { border-color: var(--pc); }
.bk-pbox { flex: 1; min-width: 0; min-height: 0; display: grid; place-items: center; touch-action: none; cursor: grab; border-radius: 12px; -webkit-tap-highlight-color: transparent; }
.bk-pbox:focus-visible { outline: 3px solid var(--amber); outline-offset: 1px; }
.bk-slot.empty .bk-pbox { cursor: default; }
.bk-slot.held .bk-piece { opacity: .25; }
.bk-btns { flex: none; display: flex; flex-direction: column; justify-content: center; gap: 4px; }
.bp[data-brow] .bk-btns { flex-direction: row; align-items: center; }
.bk-sbtn { width: var(--tb); height: var(--tb); border-radius: 50%; border: 3px solid var(--bk-3); background: #fff; color: var(--bk-1); padding: 0; display: grid; place-items: center; cursor: pointer; -webkit-tap-highlight-color: transparent; }
.bk-sbtn svg { width: 60%; height: 60%; display: block; }
.bk-sbtn:hover { background: #eef2ff; }
.bk-sbtn:focus-visible { outline: 3px solid var(--amber); outline-offset: 2px; }
.bk-sbtn:disabled { opacity: .35; cursor: default; }
.bk-slot.empty .bk-btns { visibility: hidden; }
.bp.bot .bk-btns { display: none; }
.bp.bot .bk-pbox { cursor: default; }
.bk-piece { position: relative; flex: none; }
.pc { position: absolute; box-sizing: border-box; padding: 1px; }
.pc i { display: block; width: 100%; height: 100%; border-radius: 17%; background: var(--cc, #a5b4fc); box-shadow: inset 0 0 0 2px rgba(15, 23, 42, .6), inset 0 3px 0 rgba(255, 255, 255, .42), inset 0 -4px 0 rgba(0, 0, 0, .16); box-sizing: border-box; }
.bk-float { position: fixed; left: 0; top: 0; z-index: 60; pointer-events: none; will-change: transform; filter: drop-shadow(0 8px 8px rgba(30, 27, 75, .4)); }
.bk-float .bk-piece { opacity: .6; }
.bk-flabel { position: absolute; left: 50%; top: 100%; transform: translate(-50%, 6px); white-space: nowrap; background: #1e1b4b; color: #fff; border-radius: 10px; padding: 2px 9px; font: 700 14px/1.3 var(--font); }

/* soal kilat */
.bp[data-lay="side"]:not([data-compact]) .bk-quiz { left: calc(var(--B) + clamp(8px, 1.6vw, 22px)); }
.bp[data-compact] .bk-q-e { font-size: 12px; }
.bp[data-compact] .bk-q-t { font-size: 13px; }
.bp[data-compact] .bk-q-b { min-height: 34px; font-size: 14px; }
.bk-quiz { position: absolute; left: 0; right: 0; bottom: 0; z-index: 15; background: #fff; border: 4px solid var(--bk-2); border-radius: 18px; padding: 8px 10px 10px; box-shadow: 0 10px 30px rgba(30, 27, 75, .45); display: flex; flex-direction: column; gap: 6px; }
.bk-quiz[hidden] { display: none; }
.bk-q-h { display: flex; align-items: center; gap: 8px; }
.bk-q-h .tag { flex: none; background: #fef3c7; color: #92400e; border-radius: 999px; padding: 0 9px; font: 800 13px/22px var(--font); }
.bk-q-pic { flex: none; display: grid; place-items: center; min-width: 40px; padding: 4px; background: #1e1b4b; border-radius: 10px; }
.bp[data-compact] .bk-q-h .tag { display: none; }
.bk-q-t { flex: 1; font: 800 clamp(15px, 1.8vw, 24px)/1.25 var(--font); color: var(--bk-ink); }
.bk-q-skip { flex: none; min-width: 44px; min-height: 36px; padding: 0 10px; border-radius: 999px; border: 2px solid #cbd5e1; background: #fff; color: #475569; font: 700 14px var(--font); cursor: pointer; }
.bk-q-o { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.bk-q-b { min-height: 44px; border-radius: 14px; border: 3px solid var(--bk-3); background: #eef2ff; color: var(--bk-ink); font: 800 clamp(15px, 1.7vw, 22px) var(--font); cursor: pointer; padding: 2px 8px; }
.bk-q-b:hover { background: #e0e7ff; }
.bk-q-b.good { background: #dcfce7; border-color: var(--bk-ok); }
.bk-q-b.bad { background: #ffe4e6; border-color: #e11d48; }
.bk-q-b:disabled { cursor: default; }
.bk-q-e { font: 700 clamp(13px, 1.4vw, 18px)/1.3 var(--font); color: #334155; }
.bk-q-e b { color: var(--bk-ok); }
.bk-q-e:empty { display: none; }

/* popup */
.bk-how { text-align: left; margin-top: 10px; color: var(--muted); font-size: 15px; }
.bk-how summary { cursor: pointer; font-weight: 800; color: var(--ink); min-height: 32px; display: flex; align-items: center; }
.bk-how ol { margin: 6px 0 0; padding-left: 22px; line-height: 1.5; }
.op-desc { text-align: left; font-size: clamp(14px, 1.5vw, 17px); }
.bk-res .bk-stars { font-size: clamp(36px, 8vw, 56px); color: #f59e0b; line-height: 1; letter-spacing: 4px; margin-bottom: 6px; }
.bk-res .bk-stars[hidden] { display: none; }
.bk-res .winner.b { color: var(--bk-p1); }
.bk-res .bk-rek { font-weight: 800; color: #92400e; }
.bk-res .bk-rek:empty { display: none; }

@keyframes bk-pulse { 50% { transform: scale(1.04); } }
@keyframes bk-clr { 0% { filter: brightness(1); transform: scale(1); } 35% { filter: brightness(2.2); transform: scale(1.12); } 100% { filter: brightness(2.6); transform: scale(.2); opacity: 0; } }
@keyframes bk-drop { 0% { transform: scale(1.18); } 100% { transform: scale(1); } }
@keyframes bk-pop { 0% { opacity: 0; transform: translate(-50%, 10px) scale(.7); } 15% { opacity: 1; transform: translate(-50%, 0) scale(1.1); } 70% { opacity: 1; } 100% { opacity: 0; transform: translate(-50%, -60px) scale(1); } }
@keyframes bk-star { 0% { opacity: 1; transform: translate(0, 0) scale(.5); } 100% { opacity: 0; transform: translate(var(--dx), var(--dy)) rotate(200deg) scale(1.1); } }

/* HP portrait */
@media (max-width: 700px) and (orientation: portrait) {
  .bk-boards { flex-direction: column; gap: 6px; }
  .bk-h { gap: 5px; min-height: 24px; }
  .bk-h .nm { font-size: 15px; }
  .bk-h .chip { font-size: 13px; padding: 0 8px; border-width: 2px; }
  .bk-mis { min-height: 34px; padding: 2px 8px; border-width: 2px; border-radius: 14px; }
  .bk-mis .ic { width: 22px; height: 22px; }
  .bk-time { min-width: 0; font-size: 16px; padding: 0 9px; border-width: 2px; }
  #fullscreen { display: none; }
  .bk-wrap { padding: 6px; }
  .bk-slot { border-width: 2px; border-radius: 12px; }
}
@media (max-width: 520px) {
  .bk-sbtn { border-width: 2px; }
}

/* HP landscape (layar pendek) */
@media (max-height: 560px) {
  .topbar .title { display: block; flex: 1; min-width: 0; font-size: 14px; }
  .bk-wrap { padding: 3px 4px; }
  .bk-h { min-height: 22px; gap: 5px; }
  .bk-h .nm { font-size: 14px; }
  .bk-h .chip { font-size: 13px; padding: 0 8px; border-width: 2px; }
  .bk-mis { min-height: 30px; padding: 1px 8px; border-width: 2px; border-radius: 12px; }
  .bk-mis .tx { font-size: 14px; }
  .bk-mis .ic { width: 20px; height: 20px; }
  .bk-time { font-size: 15px; padding: 0 9px; border-width: 2px; min-width: 0; }
  .bk-board { border-width: 4px; border-radius: 12px; padding: 3px; }
  .bk-slot { border-width: 2px; border-radius: 12px; }
  .bk-sbtn { border-width: 2px; }
  .bk-res .trophy { display: none; }
  .bk-res .bk-stars { font-size: 34px; }
  .bk-how { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .bk-grid .c.clr, .bk-grid .c.drop, .bk-mis.ok { animation: none; }
  .bk-grid .c.clr { opacity: 0; }
  .bk-pop { animation: bk-pop-r 1.2s linear forwards; }
  .bk-star { display: none; }
}
@keyframes bk-pop-r { 0%, 80% { opacity: 1; } 100% { opacity: 0; } }
