/* Misteri Vila: meja kayu, lilin, hujan. Satu rupa gelap sahaja (sengaja). */
:root {
  --wood1: #3d2516; --wood2: #24150c; --wood3: #5a3a22;
  --paper: #efe3c8; --paper2: #dccaa3; --ink: #2a1d12;
  --gold: #e0b354; --gold2: #b98a35;
  --text: #f0e7d5; --muted: #a8998a;
  --red: #c9454a; --green: #3f9a5e;
  --serif: "Cormorant Garamond", Georgia, "Times New Roman", serif;
  --hand: "Caveat", "Bradley Hand", "Comic Sans MS", cursive;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --grain: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 .16 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  --woodgrain: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='400' height='400'%3E%3Cfilter id='w'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.012 .32' numOctaves='4' seed='7'/%3E%3CfeColorMatrix values='0 0 0 0 .1 0 0 0 0 .05 0 0 0 0 .02 0 0 0 .9 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23w)'/%3E%3C/svg%3E");
  color-scheme: dark;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body { background: var(--wood2); color: var(--text); font: 15px/1.38 var(--sans); overflow: hidden; overscroll-behavior: none; -webkit-user-select: none; user-select: none; }
button { font: inherit; color: inherit; cursor: pointer; }

/* ---------- Suasana ---------- */
.table-bg { position: fixed; inset: 0; z-index: 0;
  background: var(--woodgrain), linear-gradient(180deg, #3f2717, #2a180d 60%, #1c100a); background-size: 400px 400px, auto; }
.candle-light { position: fixed; inset: 0; z-index: 1; pointer-events: none;
  background: radial-gradient(ellipse 80% 55% at 50% 45%, rgba(255,170,80,.20), transparent 70%), radial-gradient(ellipse 130% 100% at 50% 50%, transparent 55%, rgba(0,0,0,.72));
  animation: candle 4s infinite ease-in-out; }
@keyframes candle { 0%,100% { opacity: 1 } 20% { opacity: .86 } 23% { opacity: .97 } 55% { opacity: .9 } 70% { opacity: 1 } 82% { opacity: .84 } }
.rain { position: fixed; inset: -120px 0 0; pointer-events: none; z-index: 1; opacity: .13;
  background-image: repeating-linear-gradient(103deg, transparent 0 26px, rgba(180,200,240,.5) 26px 27px, transparent 27px 53px);
  background-size: 160px 160px; animation: rain .45s linear infinite; }
@keyframes rain { to { background-position: -38px 160px; } }
.flash { position: fixed; inset: 0; background: #d6e0ff; opacity: 0; pointer-events: none; z-index: 30; }
body.lightning .flash { animation: flash 1.4s ease-out; }
@keyframes flash { 0% { opacity: 0 } 6% { opacity: .22 } 12% { opacity: 0 } 22% { opacity: .12 } 40% { opacity: 0 } }
@media (prefers-reduced-motion: reduce) { .rain, .candle-light, body.lightning .flash { animation: none; } }

#app { position: relative; z-index: 2; height: 100%; }
.screen { display: none; height: 100%; }
.screen.active { display: flex; flex-direction: column; }

/* ---------- Skrin mula ---------- */
#screen-start { overflow-y: auto; -webkit-overflow-scrolling: touch; }
.start-inner { width: 100%; max-width: 480px; margin: 0 auto; padding: calc(22px + env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) calc(30px + env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left)); }
.candle { width: 18px; height: 54px; margin: 6px auto 0; position: relative; border-radius: 4px 4px 2px 2px; background: linear-gradient(90deg, #d9cdb0, #f4ecd8 40%, #c7b994); box-shadow: 0 0 40px 10px rgba(255,170,70,.25); }
.flame { position: absolute; left: 50%; top: -22px; width: 12px; height: 22px; margin-left: -6px; border-radius: 50% 50% 45% 45% / 60% 60% 40% 40%;
  background: radial-gradient(ellipse at 50% 75%, #fff6c8, #ffc64a 45%, #ff7a1a 75%, transparent 80%); filter: blur(.4px); animation: flame 1.6s infinite ease-in-out; transform-origin: 50% 100%; }
@keyframes flame { 0%,100% { transform: scale(1) rotate(-2deg) } 40% { transform: scale(1.08, .94) rotate(3deg) } 70% { transform: scale(.95, 1.06) rotate(-1deg) } }
h1 { font: 700 38px/1.02 var(--serif); text-align: center; margin: 14px 0 10px; color: var(--gold); text-shadow: 0 2px 12px rgba(0,0,0,.8); text-wrap: balance; }
h2 { font: 600 12px var(--sans); text-transform: uppercase; letter-spacing: 1.6px; color: var(--muted); margin: 22px 0 10px; }
.story { color: #d9ccb6; font-size: 15px; text-align: center; margin: 0 4px; }
.char-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.char { border: 0; padding: 0; background: none; text-align: center; }
.char .frame { aspect-ratio: 3 / 4; border-radius: 10px; overflow: hidden; position: relative; box-shadow: 0 6px 14px rgba(0,0,0,.6), 0 0 0 3px #1a0f08, 0 0 0 5px #6b4a2a; transition: transform .2s, box-shadow .2s; }
.char.sel .frame { transform: translateY(-4px); box-shadow: 0 10px 22px rgba(0,0,0,.7), 0 0 0 3px #1a0f08, 0 0 0 5px var(--gold), 0 0 22px var(--c); }
.char .nm { margin-top: 8px; font: 700 15px/1.1 var(--serif); }
.char .rl { font-size: 11px; color: var(--muted); }
.seg { display: flex; gap: 6px; }
.seg button { flex: 1; padding: 11px 0; border-radius: 12px; background: rgba(0,0,0,.35); border: 1px solid rgba(255,255,255,.1); font-weight: 700; }
.seg button.sel { background: rgba(224,179,84,.16); border-color: var(--gold); color: var(--gold); }
.rules { margin-top: 18px; background: rgba(0,0,0,.35); border: 1px solid rgba(255,255,255,.08); border-radius: 14px; padding: 12px 14px; font-size: 14px; color: #ddd1bd; }
.rules summary { font-weight: 700; color: var(--gold); }
.rules ol { padding-left: 20px; margin: 10px 0 0; }
.rules li { margin-bottom: 6px; }

/* ---------- Butang ---------- */
.btn { border: 0; border-radius: 14px; padding: 14px 10px; font: 700 15px var(--sans); }
.btn.gold { color: #1b1208; background: linear-gradient(#efc96f, #c08d38); box-shadow: 0 4px 0 #6e4a1a, 0 8px 18px rgba(0,0,0,.5); }
.btn.red { color: #ffd9d2; background: linear-gradient(#6a2228, #43121a); box-shadow: 0 4px 0 #22080b, 0 8px 18px rgba(0,0,0,.5); }
.btn.dark { color: var(--text); background: linear-gradient(#3a2a1e, #24180f); box-shadow: 0 4px 0 #120a05, 0 8px 18px rgba(0,0,0,.5); }
.btn.big { width: 100%; margin-top: 24px; padding: 16px; font-size: 17px; }
.btn:disabled { opacity: .4; }
.btn:active:not(:disabled) { transform: translateY(3px); box-shadow: 0 1px 0 rgba(0,0,0,.6), 0 4px 10px rgba(0,0,0,.5); }
.ib { width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center; background: rgba(0,0,0,.38); border: 1px solid rgba(255,255,255,.09); font-size: 17px; padding: 0; flex: none; }

/* ---------- Potret (sementara atau gambar sebenar) ---------- */
.por { position: relative; overflow: hidden; width: 100%; height: 100%;
  background: radial-gradient(ellipse 70% 60% at 50% 30%, color-mix(in srgb, var(--c) 55%, #f3d9a8), color-mix(in srgb, var(--c) 60%, #120a05) 70%, #0d0805); }
.por::before { content: ""; position: absolute; left: 50%; top: 22%; width: 38%; aspect-ratio: 1 / 1.15; transform: translateX(-50%); border-radius: 50% 50% 46% 46%;
  background: radial-gradient(circle at 35% 30%, rgba(255,230,190,.35), transparent 55%), #1a100a; box-shadow: 0 0 0 1.5px color-mix(in srgb, var(--c) 40%, #ffcf8a); }
.por::after { content: ""; position: absolute; left: 50%; bottom: -16%; width: 92%; height: 48%; transform: translateX(-50%); border-radius: 50% 50% 0 0;
  background: radial-gradient(ellipse at 40% 20%, rgba(255,220,170,.18), transparent 60%), #160d08; box-shadow: 0 0 0 1.5px color-mix(in srgb, var(--c) 40%, #ffcf8a); }
.por .pi { position: absolute; right: 6%; bottom: 6%; z-index: 2; width: 34%; aspect-ratio: 1; border-radius: 50%; display: grid; place-items: center; font-size: clamp(10px, 4.2cqw, 22px);
  background: var(--c); box-shadow: 0 2px 6px rgba(0,0,0,.6), 0 0 0 2px rgba(255,240,210,.7); container-type: normal; }
.por img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; z-index: 3; }
.por { container-type: inline-size; }
.por .pi { font-size: 18cqw; }
.por .gl { position: absolute; inset: 0; z-index: 4; background: linear-gradient(160deg, rgba(255,240,210,.14), transparent 40%), radial-gradient(ellipse at 50% 120%, rgba(0,0,0,.5), transparent 60%); pointer-events: none; }

/* ---------- Meja ---------- */
.topbar { display: flex; align-items: center; gap: 8px; padding: calc(8px + env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) 4px max(12px, env(safe-area-inset-left)); }
.ttl { flex: 1; font: 700 19px var(--serif); color: var(--gold); text-shadow: 0 2px 6px #000; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.seats { display: flex; justify-content: space-evenly; padding: 4px 6px 0; position: relative; z-index: 6; flex: none; }
.seat { width: 62px; display: flex; flex-direction: column; align-items: center; position: relative; transition: opacity .4s, filter .4s; }
.seat .av { width: 50px; height: 50px; border-radius: 50%; overflow: hidden; box-shadow: 0 0 0 2.5px #1a0f08, 0 0 0 4.5px var(--c), 0 6px 12px rgba(0,0,0,.65); transition: box-shadow .3s, transform .3s; }
.seat.now .av { transform: scale(1.08); box-shadow: 0 0 0 2.5px #1a0f08, 0 0 0 4.5px var(--gold), 0 0 24px 6px rgba(224,179,84,.5); }
.seat .nm { margin-top: 6px; font: 700 11px/1.05 var(--sans); text-align: center; text-shadow: 0 1px 3px #000; }
.seat .cnt { position: absolute; top: -3px; right: 0; z-index: 2; min-width: 20px; height: 20px; padding: 0 4px; border-radius: 10px; display: grid; place-items: center;
  background: linear-gradient(#f6ecd6, #d8c5a0); color: var(--ink); font: 800 10.5px var(--sans); box-shadow: 0 2px 4px rgba(0,0,0,.6); }
.seat.out { opacity: .45; filter: grayscale(.85); }
.seat.out .nm::after { content: " ✗"; color: var(--red); }

.bubble { position: absolute; top: 76px; z-index: 20; width: max-content; max-width: 210px; padding: 8px 11px; border-radius: 14px;
  background: linear-gradient(#fbf4e4, #efe2c6); color: var(--ink); font: 650 13px/1.3 var(--sans); box-shadow: 0 8px 22px rgba(0,0,0,.6);
  animation: pop .22s cubic-bezier(.3,1.6,.5,1); }
.bubble::before { content: ""; position: absolute; top: -7px; border: 8px solid transparent; border-top: 0; border-bottom-color: #fbf4e4; }
.bubble.l { left: 0; } .bubble.l::before { left: 22px; }
.bubble.c { left: 50%; transform: translateX(-50%); } .bubble.c::before { left: 50%; margin-left: -8px; }
.bubble.r { right: 0; } .bubble.r::before { right: 22px; }
@keyframes pop { from { opacity: 0; scale: .7; } }
.bubble .mini { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 5px; }
.mini span, .chip { display: inline-flex; align-items: center; gap: 3px; font: 700 11px var(--sans); padding: 2px 7px 2px 4px; border-radius: 10px; background: rgba(255,255,255,.5); border: 1.5px solid var(--c); color: var(--ink); }
.dots span { display: inline-block; width: 6px; height: 6px; margin: 0 2px; border-radius: 50%; background: #6b5a44; animation: dot 1s infinite; }
.dots span:nth-child(2) { animation-delay: .15s } .dots span:nth-child(3) { animation-delay: .3s }
@keyframes dot { 0%,60%,100% { transform: translateY(0); opacity: .5 } 30% { transform: translateY(-4px); opacity: 1 } }

/* Papan 3D */
.boardwrap { flex: 1; min-height: 0; display: grid; place-items: center; padding: 14px 10px 0; perspective: 900px; }
.board { --s: min(calc(100vw - 20px), 370px, calc(100dvh - 400px)); width: var(--s); height: calc(var(--s) * 1.0); position: relative; border-radius: 12px; padding: 9px;
  transform: rotateX(14deg); transform-origin: 50% 60%; transform-style: preserve-3d;
  background: var(--woodgrain), linear-gradient(145deg, #6a4527, #3c2414); background-size: 300px, auto;
  box-shadow: 0 26px 40px rgba(0,0,0,.75), 0 6px 0 #2a170b, inset 0 0 0 2px #8a603b, inset 0 0 0 5px #2a180c; }
.plan { position: absolute; inset: 9px; display: grid; padding: 3px; border-radius: 4px; background: #150d08;
  grid-template-columns: repeat(13, 1fr); grid-template-rows: repeat(13, 1fr); gap: 0; box-shadow: inset 0 0 12px #000; }
.room { position: relative; border-radius: 3px; overflow: hidden; cursor: default; box-shadow: inset 0 0 0 2px rgba(0,0,0,.55), inset 0 0 20px rgba(0,0,0,.6); transition: box-shadow .3s, filter .3s; }
.room::after { content: ""; position: absolute; inset: 0; background: var(--grain); opacity: .35; mix-blend-mode: overlay; pointer-events: none; }
.room .lbl { position: absolute; left: 2px; right: 2px; bottom: 4px; text-align: center; font: 700 clamp(10px, 3.3vw, 13px)/1 var(--serif); color: #f6ead2; text-shadow: 0 1px 3px #000, 0 0 8px #000; z-index: 2; }
.room .ico { position: absolute; top: 4px; left: 5px; font-size: 13px; opacity: .85; filter: drop-shadow(0 1px 2px #000); z-index: 2; }
.room.here { box-shadow: inset 0 0 0 2px var(--gold), inset 0 0 28px rgba(255,190,90,.45); }
.room.pick { cursor: pointer; animation: pick 1.4s infinite; }
.room.pick:active { filter: brightness(1.3); }
.room.nopick { filter: brightness(.45) saturate(.5); }
@keyframes pick { 0%,100% { box-shadow: inset 0 0 0 2px rgba(224,179,84,.35), inset 0 0 20px rgba(0,0,0,.6); } 50% { box-shadow: inset 0 0 0 2px rgba(224,179,84,.95), inset 0 0 26px rgba(255,190,90,.35); } }
.room.flashsug { animation: sug 1.6s ease-out; }
@keyframes sug { 0% { box-shadow: inset 0 0 0 3px #fff3c4, inset 0 0 40px rgba(255,200,110,.8); } 100% { box-shadow: inset 0 0 0 2px rgba(0,0,0,.55), inset 0 0 20px rgba(0,0,0,.6); } }
/* Lantai */
.fl-kaca { background: linear-gradient(rgba(170,230,180,.2) 1px, transparent 1px) 0 0/14px 14px, linear-gradient(90deg, rgba(170,230,180,.2) 1px, transparent 1px) 0 0/14px 14px, radial-gradient(circle at 30% 30%, #47774d, #213d29); }
.fl-kayu { background: repeating-linear-gradient(90deg, #5d3b21 0 11px, #46291a 11px 12px, #66432a 12px 23px, #46291a 23px 24px); }
.fl-parket { background: repeating-linear-gradient(45deg, #43301f 0 8px, #36261a 8px 16px), #3a2a1d; }
.fl-jubin { background: conic-gradient(#8f816a 25%, #2c2520 0 50%, #8f816a 0 75%, #2c2520 0) 0 0/20px 20px; }
.fl-makan { background: radial-gradient(ellipse 34% 26% at 50% 46%, #2b170c 0 92%, #5b3a20 93% 100%, transparent 101%), radial-gradient(ellipse 62% 46% at 50% 46%, #6e1f22 0 60%, transparent 61%), repeating-linear-gradient(0deg, #5a3a22 0 10px, #4d311c 10px 11px); }
.fl-permaidani { background: radial-gradient(circle at 50% 50%, transparent 0 40%, rgba(224,179,84,.18) 41% 43%, transparent 44%), radial-gradient(circle at 50% 50%, #5e2532, #3a131c); }
.fl-batu { background: repeating-linear-gradient(103deg, transparent 0 9px, rgba(190,210,240,.22) 9px 10px), repeating-linear-gradient(90deg, #4e5662 0 18px, #3b424b 18px 19px); }
.fl-ungu { background: radial-gradient(ellipse 40% 30% at 50% 40%, #6d5079, transparent 70%), radial-gradient(circle at 50% 40%, #4a3352, #2a1c31); }
.fl-stor { background: radial-gradient(circle at 20% 30%, #3e3833 0 16%, transparent 17%), radial-gradient(circle at 72% 66%, #36312d 0 20%, transparent 21%), radial-gradient(circle at 75% 20%, #3a3430 0 10%, transparent 11%), #24201d; }

.pawnlayer { position: absolute; inset: 9px; pointer-events: none; }
.pawn { position: absolute; width: 21px; height: 21px; margin: -10.5px 0 0 -10.5px; border-radius: 50%; display: grid; place-items: center; font-size: 10px; z-index: 3;
  background: radial-gradient(circle at 35% 30%, color-mix(in srgb, var(--c) 55%, #fff), var(--c) 50%, color-mix(in srgb, var(--c) 45%, #000));
  box-shadow: 0 4px 3px rgba(0,0,0,.7), 0 0 0 1.5px rgba(255,255,255,.6), inset 0 -3px 4px rgba(0,0,0,.35);
  transition: left .75s cubic-bezier(.45,.05,.3,1), top .75s cubic-bezier(.45,.05,.3,1); }
.pawn.me { box-shadow: 0 4px 3px rgba(0,0,0,.7), 0 0 0 2px var(--gold), 0 0 10px var(--gold), inset 0 -3px 4px rgba(0,0,0,.35); }
.pawn.hop { animation: hop .75s ease-in-out; }
@keyframes hop { 0%,100% { translate: 0 0 } 25% { translate: 0 -8px } 50% { translate: 0 0 } 75% { translate: 0 -6px } }
.pawn.gone { opacity: .35; filter: grayscale(1); }

.status { flex: none; text-align: center; font-size: 13px; color: #eadfca; padding: 6px 16px 0; min-height: 26px; text-shadow: 0 1px 3px #000; position: relative; z-index: 4; }
.status b { color: var(--gold); }

/* ---------- Kad fizikal ---------- */
.card { --w: 66px; width: var(--w); height: calc(var(--w) * 1.42); position: relative; transform-style: preserve-3d; border-radius: calc(var(--w) * .12); }
.card .face, .card .back { position: absolute; inset: 0; border-radius: inherit; backface-visibility: hidden; -webkit-backface-visibility: hidden; overflow: hidden; }
.card .face { background: var(--grain), linear-gradient(170deg, #f6ecd6, #dfcda8); color: var(--ink);
  box-shadow: inset 0 0 0 1px rgba(0,0,0,.25), inset 0 0 0 calc(var(--w) * .055) #f4e9d2, inset 0 0 0 calc(var(--w) * .07) var(--c);
  display: flex; flex-direction: column; align-items: center; justify-content: space-between; padding: calc(var(--w) * .1) calc(var(--w) * .07); text-align: center; }
.card .back { transform: rotateY(180deg);
  background: radial-gradient(circle at 50% 50%, transparent 0 22%, rgba(224,179,84,.5) 23% 24%, transparent 25%), repeating-linear-gradient(45deg, #5c1820 0 5px, #4a1219 5px 10px);
  box-shadow: inset 0 0 0 calc(var(--w) * .05) #2a0a0e, inset 0 0 0 calc(var(--w) * .075) var(--gold); display: grid; place-items: center; }
.card .back b { font: 700 calc(var(--w) * .26) var(--serif); color: var(--gold); text-shadow: 0 1px 2px #000; }
.card.down { transform: rotateY(180deg); }
.card .k { font: 700 calc(var(--w) * .11) var(--sans); letter-spacing: 1px; text-transform: uppercase; color: #7d6b50; }
.card .art { width: 72%; aspect-ratio: 1; border-radius: 50%; display: grid; place-items: center; font-size: calc(var(--w) * .32); background: radial-gradient(circle at 40% 30%, color-mix(in srgb, var(--c) 60%, #fff), var(--c) 60%, color-mix(in srgb, var(--c) 55%, #000)); box-shadow: inset 0 -4px 8px rgba(0,0,0,.35), 0 1px 0 rgba(255,255,255,.6); overflow: hidden; }
.card .art.p { border-radius: 8%; width: 84%; aspect-ratio: 1 / 1.05; }
.card .n { font: 800 calc(var(--w) * .14)/1.05 var(--sans); max-width: 100%; overflow-wrap: anywhere; }
.card .shine { position: absolute; inset: 0; border-radius: inherit; pointer-events: none; z-index: 3; background: radial-gradient(circle at var(--gx, 30%) var(--gy, 20%), rgba(255,255,255,.45), transparent 45%); mix-blend-mode: soft-light; opacity: 0; transition: opacity .2s; }

.handzone { flex: none; position: relative; z-index: 5; }
.hand { height: 116px; position: relative; }
.hand .slot { position: absolute; left: 50%; bottom: 4px; transform-origin: 50% 160%; transition: transform .35s cubic-bezier(.2,.8,.3,1), filter .25s; touch-action: none; }
.hand .slot .card { --w: 68px; transition: transform .15s ease-out; box-shadow: 0 8px 14px rgba(0,0,0,.6); }
.hand .slot.lift .card { transform: translateY(-26px) scale(1.12) rotateX(var(--rx, 0deg)) rotateY(var(--ry, 0deg)); box-shadow: 0 22px 26px rgba(0,0,0,.55); }
.hand .slot.lift { z-index: 20; }
.hand .slot.lift .shine { opacity: 1; }
.hand.choosing .slot { filter: brightness(.4) saturate(.4); }
.hand.choosing .slot.can { filter: none; }
.hand.choosing .slot.can .card { animation: glow 1.1s infinite; }
@keyframes glow { 50% { box-shadow: 0 8px 14px rgba(0,0,0,.6), 0 0 0 3px var(--gold), 0 0 22px var(--gold); } }
.mebubble { position: absolute; left: 50%; transform: translateX(-50%); bottom: 112px; z-index: 25; max-width: 250px; width: max-content; padding: 8px 11px; border-radius: 14px;
  background: linear-gradient(#fbf4e4, #efe2c6); color: var(--ink); font: 650 13px/1.3 var(--sans); box-shadow: 0 8px 22px rgba(0,0,0,.6); animation: pop .22s; }
.mebubble::after { content: ""; position: absolute; bottom: -7px; left: 50%; margin-left: -8px; border: 8px solid transparent; border-bottom: 0; border-top-color: #efe2c6; }

.actions { flex: none; display: flex; gap: 8px; align-items: center; padding: 4px max(12px, env(safe-area-inset-right)) calc(12px + env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left)); position: relative; z-index: 6; }
.actions .btn { flex: 1; }
.actions .me { width: 46px; height: 46px; border-radius: 50%; overflow: hidden; flex: none; box-shadow: 0 0 0 2.5px #1a0f08, 0 0 0 4.5px var(--c); }
.actions .me.now { box-shadow: 0 0 0 2.5px #1a0f08, 0 0 0 4.5px var(--gold), 0 0 20px 4px rgba(224,179,84,.55); }
.actions .wait { flex: 1; text-align: center; color: var(--muted); font-size: 13px; }

/* ---------- Kesan terbang ---------- */
.fx { position: fixed; inset: 0; z-index: 40; pointer-events: none; perspective: 1000px; }
.fly { position: absolute; will-change: transform; }
.fly .card { --w: 50px; box-shadow: 0 10px 16px rgba(0,0,0,.6); }
.reveal { position: fixed; inset: 0; z-index: 45; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px; padding: 20px; background: rgba(8,5,3,.78); perspective: 1000px; animation: fade .25s; pointer-events: auto; }
@keyframes fade { from { opacity: 0 } }
.reveal h2 { margin: 0; font: 700 26px var(--serif); color: var(--gold); text-transform: none; letter-spacing: 0; text-align: center; }
.reveal p { margin: 0; text-align: center; max-width: 290px; color: #ecdfc8; }
.reveal .card { --w: 170px; transition: transform .8s cubic-bezier(.3,1.3,.5,1); box-shadow: 0 30px 40px rgba(0,0,0,.6); }
.reveal .card.down { transform: rotateY(180deg) scale(.6) translateY(-60px); }
.reveal .halo { position: absolute; width: 340px; height: 340px; border-radius: 50%; background: radial-gradient(circle, rgba(224,179,84,.32), transparent 65%); z-index: -1; }
.reveal .btn { width: 100%; max-width: 320px; }
.envelope-row { display: flex; gap: 10px; justify-content: center; }
.envelope-row .card { --w: 98px; }

/* ---------- Sheet ---------- */
.sheet-wrap { position: fixed; inset: 0; z-index: 50; background: rgba(0,0,0,.55); display: flex; align-items: flex-end; justify-content: center; }
.sheet-wrap[hidden] { display: none; }
.sheet { width: 100%; max-width: 520px; max-height: 90vh; overflow-y: auto; -webkit-overflow-scrolling: touch; border-radius: 20px 20px 0 0; padding: 16px max(14px, env(safe-area-inset-right)) calc(18px + env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left));
  background: var(--woodgrain), linear-gradient(#3a2416, #24150c); background-size: 400px, auto; box-shadow: 0 -10px 40px rgba(0,0,0,.7), inset 0 1px 0 rgba(255,255,255,.08); animation: up .25s ease-out; }
@keyframes up { from { transform: translateY(40px); opacity: 0; } }
.sheet h3 { margin: 0; font: 700 22px var(--serif); color: var(--gold); }
.sheet .head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 6px; }
.sheet .hint { font-size: 13px; color: #cdbfa8; margin: 2px 0 8px; }
.sheet .lbl { font: 700 11px var(--sans); text-transform: uppercase; letter-spacing: 1.5px; color: var(--muted); margin: 14px 0 6px; }
.cardrow { display: flex; gap: 8px; overflow-x: auto; padding: 6px 2px 12px; scroll-snap-type: x proximity; scrollbar-width: none; }
.cardrow::-webkit-scrollbar { display: none; }
.cardrow .card { --w: 76px; flex: none; scroll-snap-align: start; cursor: pointer; transition: transform .2s; box-shadow: 0 6px 10px rgba(0,0,0,.55); }
.cardrow .card.sel { transform: translateY(-8px); box-shadow: 0 0 0 3px var(--gold), 0 0 18px var(--gold), 0 12px 16px rgba(0,0,0,.6); }
.cardrow .card .tick { position: absolute; top: 2px; right: 6px; z-index: 4; font: 700 24px var(--hand); color: #8a1c22; }
.cardrow .card .tick.q { color: #b06d12; }
.cardrow .card .tick.s { color: #b3262d; }

/* Nota kertas */
.notes { position: relative; border-radius: 4px; padding: 14px 8px 18px; color: #2b2218; transform: rotate(-.4deg);
  background: linear-gradient(90deg, transparent 32px, rgba(200,60,60,.45) 32px 33px, transparent 33px), repeating-linear-gradient(180deg, transparent 0 27px, rgba(70,110,160,.25) 27px 28px), var(--grain), linear-gradient(#f1e7cf, #e3d4b2);
  box-shadow: 0 10px 24px rgba(0,0,0,.6); }
.notes h3 { margin: 0 0 0 30px; font: 700 28px var(--hand); color: #3a2a1a; }
.notes .sub { margin: 0 0 8px 30px; font: 500 15px var(--hand); color: #6b5a44; }
.notes .x-close { position: absolute; top: 10px; right: 10px; }
.nt { width: 100%; border-collapse: collapse; font-family: var(--hand); table-layout: fixed; }
.nt th { font: 700 10px var(--sans); color: #5b4a36; padding: 0 0 4px; }
.nt th:not(:first-child) { width: 36px; }
.nt th .d { width: 22px; height: 22px; border-radius: 50%; overflow: hidden; display: block; margin: 0 auto 2px; box-shadow: 0 0 0 1.5px var(--c); }
.nt td { height: 28px; border-bottom: 1px solid rgba(70,110,160,.22); }
.nt td.n { font-size: 19px; font-weight: 700; padding-left: 28px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nt tr.done td.n { text-decoration: line-through; text-decoration-color: rgba(40,30,20,.7); color: #857460; }
.nt tr.must td.n { color: #9a1c24; }
.nt tr.must td.n::after { content: " ★"; }
.nt td.c { text-align: center; font-size: 21px; font-weight: 700; border-left: 1px solid rgba(70,110,160,.18); cursor: pointer; }
.nt td.c.auto { cursor: default; }
.nt .v { color: #1f6b3a; } .nt .x { color: #3a3a3a; } .nt .q { color: #b06d12; }
.nt tr.cat td { font: 700 11px var(--sans); letter-spacing: 1.6px; text-transform: uppercase; color: #8a3b2a; padding-left: 28px; border: 0; height: 26px; vertical-align: bottom; }

.log .ev { font-size: 13.5px; color: #e3d6c0; padding: 5px 0; border-bottom: 1px solid rgba(255,255,255,.06); }
.log .ev.t { color: var(--gold); font-weight: 700; padding-top: 10px; }
.log .ev.p { color: #ffe1a3; }

.end p { text-align: center; color: #ecdfc8; margin: 8px 0; }
.end .big { font: 700 30px var(--serif); color: var(--gold); text-align: center; margin: 6px 0; }
.row2 { display: flex; gap: 8px; margin-top: 14px; }
.row2 .btn { flex: 1; }

.toast { position: fixed; left: 16px; right: 16px; bottom: calc(20px + env(safe-area-inset-bottom)); z-index: 60; background: #3a1517; border: 1px solid #7e2a2e; color: #ffd0cc; padding: 12px; border-radius: 12px; font-size: 14px; }
.toast[hidden] { display: none; }

/* ---------- Papan petak ---------- */
.room { margin: 1px; }
.cell { margin: .5px; border-radius: 2px; background: #5b4630; box-shadow: inset 0 0 0 1px rgba(0,0,0,.35), inset 0 1px 0 rgba(255,235,200,.08); position: relative; }
.cell.alt { background: #533f2b; }
.cell.start { background: radial-gradient(circle, rgba(224,179,84,.45) 0 30%, transparent 32%), #4a3826; }
.door { position: absolute; background: linear-gradient(#e7c27a, #a77b35); z-index: 2; box-shadow: 0 0 4px rgba(255,200,110,.6); }
.door.d-t { top: 0; height: 3px; transform: translateX(-50%); }
.door.d-b { bottom: 0; height: 3px; transform: translateX(-50%); }
.door.d-l { left: 0; width: 3px; transform: translateY(-50%); }
.door.d-r { right: 0; width: 3px; transform: translateY(-50%); }
.room .pass { position: absolute; top: 3px; right: 4px; font-size: 11px; z-index: 2; filter: drop-shadow(0 1px 2px #000); }
.cell.reach { cursor: pointer; background: radial-gradient(circle, rgba(255,214,130,.95) 0 22%, rgba(224,179,84,.25) 24%, transparent 60%), #6b5233; animation: pulse 1.1s infinite; }
.room.reach { cursor: pointer; animation: pick 1.2s infinite; }
@keyframes pulse { 50% { filter: brightness(1.35); } }
.pawn.npc { opacity: .82; box-shadow: 0 3px 3px rgba(0,0,0,.7), 0 0 0 1px rgba(255,255,255,.35), inset 0 -3px 4px rgba(0,0,0,.35); }
.pawn.pl { box-shadow: 0 3px 3px rgba(0,0,0,.7), 0 0 0 1.5px #fff, inset 0 -3px 4px rgba(0,0,0,.35); }

/* Dadu */
.dicewrap { position: absolute; inset: 0; display: grid; place-items: center; z-index: 8; perspective: 500px; pointer-events: none; transition: opacity .35s; }
.dicewrap.bye { opacity: 0; }
.dice { width: 64px; height: 64px; filter: drop-shadow(0 14px 10px rgba(0,0,0,.6)); }
.cube { width: 64px; height: 64px; position: relative; transform-style: preserve-3d; transition: transform .9s cubic-bezier(.2,.7,.25,1); }
.cube .face { position: absolute; inset: 0; border-radius: 12px; background: radial-gradient(circle at 30% 25%, #fffaf0, #e8dcc4); box-shadow: inset 0 0 0 1px rgba(0,0,0,.15), inset 0 -4px 8px rgba(0,0,0,.15);
  display: grid; grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(3, 1fr); padding: 9px; backface-visibility: hidden; }
.cube .face span { margin: auto; width: 11px; height: 11px; border-radius: 50%; }
.cube .face span.on { background: radial-gradient(circle at 35% 30%, #5a1820, #1a0507); box-shadow: inset 0 1px 1px rgba(0,0,0,.6); }
.cube .f1 { transform: translateZ(32px); }
.cube .f6 { transform: rotateY(180deg) translateZ(32px); }
.cube .f3 { transform: rotateY(90deg) translateZ(32px); }
.cube .f4 { transform: rotateY(-90deg) translateZ(32px); }
.cube .f5 { transform: rotateX(90deg) translateZ(32px); }
.cube .f2 { transform: rotateX(-90deg) translateZ(32px); }
.card .n.long { font-size: calc(var(--w) * .118); overflow-wrap: normal; }
.room.reach::before { content: "MASUK"; position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); z-index: 3; font: 800 10px var(--sans); letter-spacing: 1.5px; color: #1b1208; background: linear-gradient(#efc96f, #c08d38); padding: 3px 7px; border-radius: 8px; box-shadow: 0 2px 6px rgba(0,0,0,.6); }

/* ---------- Bilik online ---------- */
.joinrow { display: flex; gap: 8px; }
.joinrow input { flex: 1; min-width: 0; font: 700 22px var(--sans); letter-spacing: 8px; text-align: center; text-transform: uppercase; padding: 12px; border-radius: 12px; border: 1px solid rgba(255,255,255,.15); background: rgba(0,0,0,.4); color: var(--text); -webkit-user-select: text; user-select: text; }
.joinrow .btn { flex: 0 0 96px; }
.sheet .code { font: 700 54px/1 var(--serif); letter-spacing: 12px; text-align: center; color: var(--gold); margin: 10px 0 4px; text-shadow: 0 2px 12px rgba(224,179,84,.4); -webkit-user-select: text; user-select: text; }
.lob-list { display: flex; flex-direction: column; gap: 6px; }
.lob-p { display: flex; align-items: center; gap: 10px; padding: 6px 8px; border-radius: 12px; background: rgba(0,0,0,.3); border-left: 4px solid var(--c); }
.lob-p .av { width: 38px; height: 38px; border-radius: 50%; overflow: hidden; flex: none; background: #222; }
.lob-p .sub { font-size: 12px; color: var(--muted); }
.lob-pick { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; }
.lob-c { border: 0; padding: 0; background: none; text-align: center; font-size: 10px; font-weight: 700; color: var(--text); }
.lob-c .frame { aspect-ratio: 3 / 4; border-radius: 8px; overflow: hidden; box-shadow: 0 0 0 2px #1a0f08, 0 0 0 3px #6b4a2a; margin-bottom: 3px; }
.lob-c.sel .frame { box-shadow: 0 0 0 2px #1a0f08, 0 0 0 4px var(--gold), 0 0 14px var(--c); }
.lob-c:disabled { opacity: .3; }
