:root { --bg: #2a0f1e; --card: #3b1830; --gold: #FFC94A; --saffron: #FF9933; --green: #2fbf71; --red: #e5484d; --ink: #fff6e8; --muted: #cbb1c0; }
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; min-height: 100%; background: radial-gradient(circle at 50% 0%, #4a1b3a, var(--bg) 70%); color: var(--ink); font-family: 'Noto Sans Devanagari','Noto Sans Telugu','Noto Sans Kannada','Noto Sans Tamil','Noto Sans Malayalam', system-ui, sans-serif; }
[hidden] { display: none !important; }
.screen { min-height: 100dvh; padding: 56px 12px 64px; display: flex; flex-direction: column; align-items: center; }
.card { width: min(440px, 100%); background: var(--card); border: 1.5px solid rgba(255,201,74,.4); border-radius: 20px; padding: 18px; }
.card.wide { width: min(720px, 100%); }
.logo { font-size: 30px; font-weight: 800; text-align: center; color: var(--gold); }
.logo.sm { font-size: 22px; margin-bottom: 8px; }
.sub { text-align: center; color: var(--muted); margin: 4px 0 14px; }
.lbl { font-size: 12px; letter-spacing: 1.4px; text-transform: uppercase; color: var(--muted); margin: 14px 0 6px; }
.editions { display: grid; gap: 8px; }
.edition { text-align: left; padding: 10px 14px; border-radius: 14px; background: rgba(255,255,255,.06); border: 1.5px solid rgba(255,255,255,.18); color: inherit; font: inherit; cursor: pointer; }
.edition b { display: block; font-size: 15px; } .edition small { color: var(--muted); }
.edition.on { border-color: var(--gold); background: rgba(255,201,74,.14); }
.count-row { display: flex; gap: 8px; }
.count-row button { flex: 1; padding: 8px; border-radius: 12px; border: 1.5px solid rgba(255,255,255,.18); background: rgba(255,255,255,.06); color: inherit; font: inherit; font-weight: 800; cursor: pointer; }
.count-row button.on { border-color: var(--gold); background: rgba(255,201,74,.14); }
.prow { display: flex; align-items: center; gap: 8px; margin-top: 8px; }
.prow .tok { width: 40px; height: 40px; border-radius: 50%; font-size: 22px; border: 2px solid var(--gold); background: rgba(0,0,0,.25); cursor: pointer; padding: 0; }
.prow input { flex: 1; min-width: 0; font: inherit; padding: 8px 10px; border-radius: 10px; border: 1px solid rgba(255,255,255,.25); background: rgba(0,0,0,.25); color: inherit; }
.prow .kind { font: inherit; font-size: 12px; font-weight: 700; padding: 8px 10px; border-radius: 10px; border: 1px solid rgba(255,255,255,.25); background: rgba(255,255,255,.06); color: inherit; cursor: pointer; white-space: nowrap; }
.check { display: flex; align-items: center; gap: 8px; margin: 14px 0 4px; font-size: 14px; }
button.primary { width: 100%; margin-top: 12px; padding: 13px; font: inherit; font-weight: 800; font-size: 17px; color: #2a0f1e; background: linear-gradient(180deg, #FFD466, var(--saffron)); border: 0; border-radius: 14px; cursor: pointer; box-shadow: 0 4px 0 #b3661a; }
button.primary:active { transform: translateY(2px); box-shadow: 0 2px 0 #b3661a; }
button.primary:disabled { opacity: .5; }
button.ghost { width: 100%; margin-top: 10px; padding: 10px; font: inherit; font-weight: 700; color: var(--gold); background: transparent; border: 1.5px solid rgba(255,201,74,.5); border-radius: 14px; cursor: pointer; }
button.ghost.sm { width: auto; padding: 6px 12px; font-size: 13px; margin: 0; }
.fine { font-size: 12px; color: var(--muted); margin: 12px 0 0; line-height: 1.45; }

/* ── game ── */
.game { padding-top: 48px; gap: 10px; }
.board-wrap { width: 100%; display: flex; justify-content: center; }
#board { position: relative; width: min(96vw, calc((100dvh - 250px) * var(--ar))); aspect-ratio: var(--cols) / var(--rows); border-radius: 12px; overflow: hidden; border: 3px solid var(--gold); box-shadow: 0 8px 30px rgba(0,0,0,.5); background: #5a2340; }
.cellv { position: absolute; display: flex; align-items: flex-start; justify-content: flex-start; font-size: clamp(7px, 1.9vw, 12px); font-weight: 800; color: rgba(255,255,255,.75); padding: 2px 3px; border: 1px solid rgba(0,0,0,.18); overflow: hidden; }
.cellv.a { background: #7a3557; } .cellv.b { background: #8d4666; }
.cellv.ladder { background: #2c7a55; } .cellv.snake { background: #8a2f3a; }
.cellv.start { background: #b3661a; } .cellv.goal { background: linear-gradient(135deg, #FFD466, #ff9933); color: #2a0f1e; }
#board { container-type: inline-size; }
.cellv { flex-direction: column; align-items: center; justify-content: center; padding: 0; cursor: pointer; }
.cellv .num { position: absolute; left: 2px; top: 1px; font-size: clamp(6px, 1.7vw, 11px); opacity: .9; }
.cellv .art { font-size: clamp(11px, 3.3vw, 22px); line-height: 1; margin-top: 4px; }
img.art { width: 62%; height: auto; max-height: 62%; object-fit: contain; }
.cellv .lbl { display: none; font-size: 10px; line-height: 1.1; font-weight: 700; text-align: center; max-width: 96%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: rgba(255,255,255,.9); }
.cellv.goal .lbl { color: #2a0f1e; }
@container (min-width: 520px) { .cellv .lbl { display: block; } .cellv .art { font-size: 22px; } }
.cellv.z0 { box-shadow: inset 0 0 0 100px rgba(90,160,90,.10); } .cellv.z1 { box-shadow: inset 0 0 0 100px rgba(120,180,200,.10); }
.cellv.z2 { box-shadow: inset 0 0 0 100px rgba(255,200,90,.10); } .cellv.z3 { box-shadow: inset 0 0 0 100px rgba(190,150,255,.10); }
.cellv.z4 { box-shadow: inset 0 0 0 100px rgba(255,140,170,.10); } .cellv.z5 { box-shadow: inset 0 0 0 100px rgba(255,120,60,.12); }
.cellv.z6 { box-shadow: inset 0 0 0 100px rgba(255,235,150,.14); }
svg#overlay { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.token { position: absolute; width: calc(100% / var(--cols) * .62); aspect-ratio: 1; display: grid; place-items: center; font-size: clamp(12px, 3.6vw, 24px); background: rgba(20,8,24,.85); border: 2px solid var(--c, var(--gold)); border-radius: 50%; transition: left .22s ease, top .22s ease; z-index: 5; box-shadow: 0 2px 6px rgba(0,0,0,.6); }
.token.slide { transition: left .7s ease-in-out, top .7s ease-in-out; }
.token.me { animation: hop .5s ease-in-out infinite alternate; }
@keyframes hop { to { transform: translateY(-14%) scale(1.06); } }
.hiss { position: absolute; z-index: 9; transform: translate(-50%, -110%); font-weight: 900; font-size: clamp(12px, 3.6vw, 20px); color: #fff; background: #b0263a; border: 2px solid #fff; border-radius: 12px 12px 12px 2px; padding: 2px 8px; animation: hissPop 1.4s ease-out forwards; pointer-events: none; white-space: nowrap; }
@keyframes hissPop { 0% { opacity: 0; transform: translate(-50%, -60%) scale(.4); } 15% { opacity: 1; transform: translate(-50%, -120%) scale(1.15); } 80% { opacity: 1; } 100% { opacity: 0; transform: translate(-50%, -170%) scale(1); } }
.snake-head .tongue { animation: flick .7s steps(2, end) infinite; transform-origin: center; }
@keyframes flick { 50% { opacity: 0; } }
.snake-lunge { animation: lunge .6s ease-in-out 2; transform-box: fill-box; transform-origin: center; }
@keyframes lunge { 50% { transform: scale(1.6); } }

.side { width: min(460px, 100%); display: flex; flex-direction: column; gap: 8px; }
.players { display: grid; grid-template-columns: repeat(auto-fit, minmax(105px, 1fr)); gap: 6px; }
.pchip { background: rgba(255,255,255,.07); border: 1.5px solid rgba(255,255,255,.15); border-radius: 12px; padding: 6px 8px; font-size: 12px; line-height: 1.3; }
.pchip.cur { border-color: var(--gold); background: rgba(255,201,74,.16); }
.pchip b { display: block; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msg { min-height: 40px; text-align: center; font-weight: 700; color: var(--gold); display: grid; place-items: center; }
.roll { display: flex; align-items: center; justify-content: center; gap: 10px; margin-top: 0; }
.die { display: inline-block; font-size: 26px; }
.die.rolling { animation: spin .35s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.row { display: flex; gap: 8px; justify-content: space-between; align-items: center; }

/* ── sheet ── */
.sheet { position: fixed; inset: 0; z-index: 50; display: flex; align-items: flex-end; justify-content: center; background: rgba(10,3,14,.6); padding: 12px; }
.sheet-card { width: min(460px, 100%); background: var(--card); border: 2px solid var(--gold); border-radius: 22px; padding: 18px; text-align: center; animation: rise .3s ease-out; }
@keyframes rise { from { transform: translateY(40px); opacity: 0; } }
.sheet-card.snake { border-color: var(--red); } .sheet-card.ladder { border-color: var(--green); }
.sheet-icon { font-size: 44px; } .sheet-tag { font-size: 12px; letter-spacing: 1.4px; text-transform: uppercase; color: var(--muted); }
.sheet-card h2 { margin: 4px 0 6px; color: var(--gold); } .sheet-card p { margin: 0 0 8px; line-height: 1.5; }
.sheet-move { color: var(--muted); font-size: 13px; }

/* ── learn ── */
.lgroup { margin: 10px 0; } .lgroup h3 { margin: 6px 0; color: var(--gold); }
.litem { display: grid; grid-template-columns: 44px 1fr; gap: 8px; padding: 8px 0; border-top: 1px solid rgba(255,255,255,.1); }
.litem .n { font-weight: 800; color: var(--muted); font-size: 12px; } .litem b { display: block; } .litem span { color: var(--muted); font-size: 13px; line-height: 1.45; }
.litem.v b { color: #7ee0a9; } .litem.s b { color: #ff8a92; }

#toasts { position: fixed; left: 50%; top: 56px; transform: translateX(-50%); z-index: 70; display: flex; flex-direction: column; gap: 6px; pointer-events: none; }
.toast { background: #1c1138; border: 1.5px solid rgba(255,201,74,.6); border-radius: 12px; padding: 8px 14px; font-weight: 700; font-size: 14px; }

@media (orientation: landscape) and (max-height: 520px) {
  .game { flex-direction: row; align-items: flex-start; justify-content: center; padding-top: 8px; }
  .board-wrap { width: auto; }
  #board { width: min(60vw, calc((100dvh - 24px) * var(--ar))); }
  .side { width: 300px; }
}

/* ── online ── */
button.primary.alt { background: linear-gradient(180deg, #7fe3c1, #2fbf71); box-shadow: 0 4px 0 #1c7f4a; }
.err { color: #ff8a92; min-height: 18px; font-size: 13px; margin-top: 8px; text-align: center; }
.code-in { text-transform: uppercase; letter-spacing: 6px; text-align: center; font-weight: 800; }
.room-code { display: flex; align-items: center; justify-content: center; gap: 10px; font-size: 40px; font-weight: 900; letter-spacing: 8px; color: var(--gold); }
.room-code .kind { letter-spacing: 0; font-size: 13px; }
.kind { font: inherit; font-size: 12px; font-weight: 700; padding: 8px 10px; border-radius: 10px; border: 1px solid rgba(255,255,255,.25); background: rgba(255,255,255,.06); color: inherit; cursor: pointer; white-space: nowrap; }
.lobby-players { display: grid; gap: 6px; margin: 12px 0; }
.lrow { display: flex; align-items: center; gap: 8px; background: rgba(255,255,255,.07); border-radius: 12px; padding: 8px 10px; }
.lrow.off { opacity: .45; } .lrow .tk { font-size: 22px; } .lrow b { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.badge { font-size: 10px; font-weight: 800; letter-spacing: 1px; color: #2a0f1e; background: var(--gold); border-radius: 8px; padding: 2px 6px; }
.fine.c { text-align: center; }
.dock { position: fixed; right: 10px; bottom: 64px; z-index: 60; display: none; flex-direction: column; gap: 8px; }
.vk-online .dock { display: flex; }
.dock-btn { position: relative; width: 48px; height: 48px; border-radius: 50%; border: 2px solid rgba(255,201,74,.6); background: #1c1138; font-size: 22px; cursor: pointer; padding: 0; box-shadow: 0 6px 16px rgba(0,0,0,.45); }
.unread { position: absolute; top: -4px; right: -4px; min-width: 18px; height: 18px; border-radius: 9px; background: var(--red); color: #fff; font-size: 11px; font-weight: 800; display: grid; place-items: center; }
#hearts { position: fixed; right: 0; bottom: 0; width: 120px; height: 60vh; pointer-events: none; z-index: 65; overflow: hidden; }
.float-heart { position: absolute; bottom: 60px; font-size: 26px; opacity: 0; animation: heartFloat 2.4s ease-out forwards; }
@keyframes heartFloat { 0% { opacity: 0; transform: translate(0, 0) scale(.5); } 12% { opacity: 1; } 100% { opacity: 0; transform: translate(var(--dx, 0), -55vh) scale(1.1) rotate(var(--rot, 0deg)); } }
.chat-panel { position: fixed; left: 8px; right: 8px; bottom: 8px; z-index: 80; max-width: 460px; margin: 0 auto; background: var(--card); border: 2px solid rgba(255,201,74,.5); border-radius: 18px; padding: 10px; display: flex; flex-direction: column; gap: 8px; max-height: 60vh; }
.chat-head { display: flex; justify-content: space-between; align-items: center; color: var(--gold); }
.chat-log { overflow-y: auto; min-height: 90px; display: flex; flex-direction: column; gap: 6px; }
.chat-empty { color: var(--muted); text-align: center; padding: 14px 0; font-size: 13px; }
.cmsg { display: flex; gap: 6px; align-items: flex-start; } .cmsg .tk { font-size: 20px; }
.cmsg .bub { background: rgba(255,255,255,.09); border-radius: 12px; padding: 5px 9px; font-size: 14px; overflow-wrap: anywhere; }
.cmsg.mine { flex-direction: row-reverse; } .cmsg.mine .bub { background: rgba(255,201,74,.18); }
.cmsg .bub b { display: block; font-size: 11px; color: var(--gold); }
.quick-row { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 2px; }
.quick-row button { flex: none; font: inherit; font-size: 12px; font-weight: 700; padding: 6px 10px; border-radius: 14px; border: 1px solid rgba(255,255,255,.25); background: rgba(255,255,255,.07); color: inherit; cursor: pointer; white-space: nowrap; }
.chat-in { display: flex; gap: 6px; } .chat-in input { flex: 1; min-width: 0; font: inherit; padding: 8px 10px; border-radius: 10px; border: 1px solid rgba(255,255,255,.25); background: rgba(0,0,0,.25); color: inherit; }
#chatPops { position: fixed; left: 10px; bottom: 132px; z-index: 66; display: flex; flex-direction: column; gap: 6px; pointer-events: none; max-width: min(300px, calc(100vw - 90px)); }
.chat-pop { display: flex; align-items: center; gap: 8px; background: rgba(28,17,56,.94); border: 1.5px solid rgba(255,213,74,.6); border-radius: 16px; padding: 6px 12px 6px 8px; box-shadow: 0 6px 18px rgba(0,0,0,.45); animation: chatPopLife 4.5s ease-out forwards; }
.chat-pop .tk { font-size: 24px; } .chat-pop b { display: block; font-size: 11px; color: var(--gold); } .chat-pop span.tx { font-size: 14px; font-weight: 700; overflow-wrap: anywhere; }
@keyframes chatPopLife { 0% { opacity: 0; transform: translateY(14px) scale(.9); } 8% { opacity: 1; transform: none; } 80% { opacity: 1; } 100% { opacity: 0; transform: translateY(-26px); } }

/* ── a flat 2D die: it tumbles through faces, then lands on the rolled number ── */
.dice-stage { height: 92px; display: grid; place-items: center; position: relative; }
.die2d { --s: 64px; width: var(--s); height: var(--s); border-radius: 14px; position: relative; display: grid; grid-template: repeat(3, 1fr) / repeat(3, 1fr); padding: 9px;
  background: linear-gradient(145deg, #ffffff, #efe7d8 70%, #d9cdb6); border: 2px solid rgba(150,120,70,.55);
  box-shadow: 0 5px 0 rgba(120,90,40,.55), 0 10px 14px rgba(0,0,0,.4), inset 0 0 8px rgba(255,255,255,.7); }
.die2d i { display: none; width: 13px; height: 13px; margin: auto; border-radius: 50%; background: radial-gradient(circle at 35% 30%, #ff6b6b, #b3121f 72%); box-shadow: inset 0 1px 2px rgba(0,0,0,.4); }
.die2d[data-v="1"] .p5 { display: block; width: 18px; height: 18px; }
.die2d[data-v="2"] .p1, .die2d[data-v="2"] .p9,
.die2d[data-v="3"] .p1, .die2d[data-v="3"] .p5, .die2d[data-v="3"] .p9,
.die2d[data-v="4"] .p1, .die2d[data-v="4"] .p3, .die2d[data-v="4"] .p7, .die2d[data-v="4"] .p9,
.die2d[data-v="5"] .p1, .die2d[data-v="5"] .p3, .die2d[data-v="5"] .p5, .die2d[data-v="5"] .p7, .die2d[data-v="5"] .p9,
.die2d[data-v="6"] .p1, .die2d[data-v="6"] .p3, .die2d[data-v="6"] .p4, .die2d[data-v="6"] .p6, .die2d[data-v="6"] .p7, .die2d[data-v="6"] .p9 { display: block; }
/* each pip sits in its own cell of the 3×3 grid (hidden pips must not collapse the layout) */
.die2d i.p1 { grid-area: 1 / 1; } .die2d i.p2 { grid-area: 1 / 2; } .die2d i.p3 { grid-area: 1 / 3; }
.die2d i.p4 { grid-area: 2 / 1; } .die2d i.p5 { grid-area: 2 / 2; } .die2d i.p6 { grid-area: 2 / 3; }
.die2d i.p7 { grid-area: 3 / 1; } .die2d i.p8 { grid-area: 3 / 2; } .die2d i.p9 { grid-area: 3 / 3; }
.dice-shadow { position: absolute; bottom: 4px; width: 62px; height: 11px; border-radius: 50%; background: radial-gradient(rgba(0,0,0,.5), transparent 70%); transition: transform .3s; }
.dice-stage.rolling .dice-shadow { animation: shadowBounce .28s ease-in-out infinite alternate; }
@keyframes shadowBounce { to { transform: scale(.6); opacity: .5; } }
.die2d.tumble { animation: tumble2d .5s ease-in-out infinite; }
@keyframes tumble2d { 0% { transform: translateY(0) rotate(0deg); } 25% { transform: translateY(-20px) rotate(100deg) scale(1.06); } 50% { transform: translateY(0) rotate(190deg); } 75% { transform: translateY(-11px) rotate(280deg) scale(1.03); } 100% { transform: translateY(0) rotate(360deg); } }
.die2d.land { animation: landDie .3s ease-out; }
@keyframes landDie { 0% { transform: scale(1.22) rotate(-8deg); } 55% { transform: scale(.94) rotate(3deg); } 100% { transform: scale(1) rotate(0); } }

/* the dice itself is the roll button */
.dice-btn { background: none; border: 0; padding: 0; margin: 0 auto; display: flex; flex-direction: column; align-items: center; gap: 2px; cursor: pointer; color: var(--gold); font: inherit; -webkit-user-select: none; user-select: none; }
.dice-btn .dice-stage { width: 150px; height: 100px; }
.dice-cap { font-weight: 800; font-size: 15px; letter-spacing: .3px; }
.dice-btn:not(:disabled) .dice-stage::before { content: ''; position: absolute; width: 96px; height: 96px; border-radius: 50%; background: radial-gradient(rgba(255,201,74,.35), transparent 70%); animation: dicePulse 1.4s ease-in-out infinite; }
@keyframes dicePulse { 50% { transform: scale(1.25); opacity: .55; } }
.dice-btn:not(:disabled):not(:active) .dice-stage:not(.rolling) .die2d:not(.land) { animation: diceBob 1.4s ease-in-out infinite; }
@keyframes diceBob { 50% { transform: translateY(-5px); } }
.dice-btn:not(:disabled):active .die2d { transform: scale(.94); }
.dice-btn:disabled { cursor: default; } .dice-btn:disabled .dice-cap { opacity: .45; }
.dice-btn:focus-visible { outline: 2px solid var(--gold); outline-offset: 4px; border-radius: 16px; }

/* shown only after a win — make it the obvious next step */
#sheetShare { background: linear-gradient(180deg, #7fe3c1, #2fbf71) !important; color: #0e2a1c !important; border: 0 !important; font-weight: 800; animation: winPulse 1.6s ease-in-out infinite; }
@keyframes winPulse { 50% { transform: scale(1.04); } }
