/* Afghan Ludo — mobile-first, RTL-aware (logical properties throughout). */
:root {
  --bg: #0b3d2a;
  --bg-deep: #072a1c;
  --card: #fff8e7;
  --ink: #1d2b24;
  --muted: #6d7b72;
  --line: #e6dab8;
  --gold: #f7b900;
  --gold-deep: #c98f00;
  --flag-red: #be0000;
  --good: #25d366;
  --radius: 16px;
}
.s0 { --c: #e53935; --cd: #a51c1c; --cl: #ffd9d6; }
.s1 { --c: #2e9e4f; --cd: #1b6b33; --cl: #d3f0dc; }
.s2 { --c: #f7b900; --cd: #b07f00; --cl: #fff0b3; }
.s3 { --c: #1e88e5; --cd: #0f5aa8; --cl: #d3e8fb; }

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; min-height: 100%; }
body {
  background-color: var(--bg);
  background-image:
    linear-gradient(180deg, rgba(0, 0, 0, 0) 0%, rgba(0, 0, 0, 0.38) 100%),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='64' height='64' viewBox='0 0 64 64'%3E%3Cg fill='none' stroke='%23ffffff' stroke-opacity='.06' stroke-width='1.5'%3E%3Crect x='14' y='14' width='36' height='36'/%3E%3Crect x='14' y='14' width='36' height='36' transform='rotate(45 32 32)'/%3E%3C/g%3E%3C/svg%3E");
  background-attachment: fixed;
  color: var(--ink);
  font: 16px/1.5 "Noto Naskh Arabic", "Noto Sans Arabic", "Vazirmatn", Tahoma, "Segoe UI", system-ui, -apple-system, sans-serif;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  overflow-x: hidden;
}
html[data-lang="en"] body { font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
#app { min-height: 100vh; min-height: 100dvh; display: flex; justify-content: center; }

/* ---------- shared pieces ---------- */
.dot { display: inline-block; width: 14px; height: 14px; border-radius: 50%; background: var(--c); border: 2px solid var(--cd); flex: none; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 46px; padding: 8px 18px; border: 0; border-radius: 14px;
  font-weight: 700; text-decoration: none; transition: transform .08s, filter .15s, opacity .15s;
  background: #e9e0c6; color: var(--ink);
}
.btn { white-space: nowrap; }
.btn:active:not(:disabled) { transform: scale(.97); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary { background: linear-gradient(180deg, #ffd24a, var(--gold)); color: #3a2a00; box-shadow: 0 3px 0 var(--gold-deep); }
.btn.gold { background: linear-gradient(180deg, #ffd24a, var(--gold)); color: #3a2a00; box-shadow: 0 3px 0 var(--gold-deep); }
.btn.primary.dim { background: #efe3bd; box-shadow: none; color: #6a5a20; }
.btn.ghost { background: transparent; border: 2px solid var(--line); color: inherit; }
.card .btn.ghost { color: var(--ink); }
.topbar .btn.ghost, .game > .topbar .btn.icon { color: #fff; border-color: rgba(255, 255, 255, .35); }
.btn.danger { background: var(--flag-red); color: #fff; }
.btn.wa { background: var(--good); color: #063d1a; }
.btn.big { width: 100%; min-height: 54px; font-size: 1.1rem; }
.btn.sm { min-height: 38px; padding: 4px 12px; border-radius: 12px; font-size: .9rem; }
.btn.icon { min-width: 46px; padding: 0 10px; background: #efe5c8; }
.btn.icon.sm { min-width: 38px; min-height: 38px; background: rgba(255, 255, 255, .12); border: 2px solid rgba(255, 255, 255, .25); position: relative; }

.card { background: var(--card); border-radius: 22px; padding: 18px; box-shadow: 0 10px 30px rgba(0, 0, 0, .3); }
.lbl { display: block; font-weight: 700; margin-block: 6px; color: var(--ink); }
p.hint { margin: 4px 0 0; color: var(--muted); font-size: .85rem; text-align: center; }
.input {
  width: 100%; min-height: 48px; padding: 8px 14px; background: #fff; color: var(--ink);
  border: 2px solid var(--line); border-radius: 14px; outline: none; font-size: 1rem;
}
.input:focus { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(247, 185, 0, .3); }
.pill {
  background: rgba(255, 255, 255, .12); color: #fff; border: 2px solid rgba(255, 255, 255, .25);
  border-radius: 999px; padding: 4px 14px; font-weight: 700; min-height: 36px;
}
.pill.on { background: var(--gold); color: #3a2a00; border-color: var(--gold); }

.modal {
  position: fixed; top: 0; right: 0; bottom: 0; left: 0; z-index: 60; display: flex; align-items: center; justify-content: center;
  padding: 16px; background: rgba(0, 0, 0, .6); animation: fade .2s;
}
.dialog { width: min(100%, 380px); text-align: center; }
.dialog p { margin: 0 0 16px; font-weight: 600; }
.dialog h2 { margin: 4px 0 12px; }
.row { display: flex; gap: 10px; justify-content: center; align-items: center; flex-wrap: wrap; }
@keyframes fade { from { opacity: 0 } }

#toast {
  position: fixed; inset-inline: 16px; bottom: calc(24px + env(safe-area-inset-bottom)); z-index: 80;
  margin-inline: auto; width: fit-content; max-width: 92vw; padding: 10px 18px; border-radius: 999px;
  background: rgba(15, 15, 15, .92); color: #fff; font-weight: 600; text-align: center;
  opacity: 0; transform: translateY(12px); transition: opacity .2s, transform .2s; pointer-events: none;
}
#toast.show { opacity: 1; transform: none; }
.net {
  position: fixed; top: 0; inset-inline: 0; z-index: 90; padding: 6px 12px; text-align: center;
  background: var(--flag-red); color: #fff; font-weight: 700; font-size: .9rem;
}
.net .btn { min-height: 26px; padding: 0 10px; margin-inline-start: 8px; }
body.offline .btn.primary:not(.send), body.offline .btn.gold { filter: grayscale(.6); }

/* ---------- home ---------- */
.home, .lobby { width: 100%; max-width: 460px; padding: 14px 16px calc(24px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 14px; }
.langs { display: flex; gap: 8px; justify-content: center; }
.hero { text-align: center; color: #fff; }
.hero h1 { margin: 6px 0 0; font-size: 2.3rem; line-height: 1.25; color: var(--gold); text-shadow: 0 2px 0 rgba(0, 0, 0, .3); }
.hero p { margin: 2px 0 0; opacity: .85; }
.home .card { display: flex; flex-direction: column; gap: 6px; }
.name-row, .join-row { display: flex; gap: 8px; }
.code-in { text-align: center; letter-spacing: .15em; font-size: 1.2rem; font-weight: 700; }
.invite { background: #e5f6e8; border: 2px solid #9bd7a8; border-radius: 12px; padding: 8px 12px; font-weight: 700; margin-bottom: 4px; text-align: center; }
.sep { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: .85rem; margin-block: 8px; }
.sep::before, .sep::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.cpu { display: flex; flex-direction: column; gap: 6px; }
.cpu-btns { display: flex; gap: 8px; }
.cpu-btns .btn { flex: 1; font-size: 1.1rem; }
.foot { text-align: center; color: rgba(255, 255, 255, .6); font-size: .85rem; margin: 0; }
.foot a { color: var(--gold); }

/* ---------- lobby ---------- */
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 8px; color: #fff; }
.topbar h2 { margin: 0; font-size: 1.15rem; }
.tools { display: flex; gap: 6px; align-items: center; }
.tools .pill, .topbar > .pill { min-height: 38px; padding: 2px 12px; font-size: .85rem; white-space: nowrap; }
.codecard { text-align: center; }
.code {
  display: block; width: 100%; margin: 2px 0; padding: 6px; background: #fff; border: 3px dashed var(--gold);
  border-radius: 16px; font-size: 2.6rem; font-weight: 800; letter-spacing: .12em; line-height: 1.2; color: var(--ink);
}
.share-row { display: flex; gap: 8px; margin-top: 10px; }
.share-row .btn { flex: 1; font-size: .92rem; padding-inline: 8px; }
.seats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.seat {
  background: var(--card); border-radius: 18px; padding: 10px 12px; display: grid; gap: 6px;
  grid-template-columns: auto 1fr; align-items: center; border-inline-start: 8px solid var(--c);
}
.seat.empty { background: rgba(255, 248, 231, .55); }
.seat.mine { outline: 3px solid var(--gold); }
.seat .who { min-width: 0; }
.seat .nm { font-weight: 800; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.seat.empty .nm { color: var(--muted); font-weight: 600; }
.seat .cn { font-size: .78rem; color: var(--muted); }
.badges, .acts { grid-column: 1 / -1; display: flex; gap: 6px; flex-wrap: wrap; }
.acts:empty, .badges:empty { display: none; }
.badge { background: #efe5c8; border-radius: 999px; padding: 0 10px; font-size: .78rem; font-weight: 700; }
.badge.me { background: var(--gold); color: #3a2a00; }
.badge.off { background: #f4c7c3; color: #7a1410; }
.mini { background: #fff; border: 2px solid var(--line); border-radius: 10px; padding: 2px 10px; font-size: .8rem; font-weight: 700; min-height: 32px; }
.mini.danger { color: var(--flag-red); border-color: #efb4b0; }
.actions { display: flex; flex-direction: column; gap: 6px; }
.wait { text-align: center; color: #fff; font-weight: 700; margin: 6px 0; }
.chat-slot .chat { height: 320px; }

/* ---------- Afghan look: hats, flag stripe, bubbles, gift ---------- */
/* the three colours of the Afghan flag as a thin strip across the top of every screen */
body::before {
  content: ""; position: fixed; top: 0; left: 0; right: 0; height: 5px; z-index: 100;
  background: linear-gradient(90deg, #0a0a0a 0 33.34%, #be0000 33.34% 66.67%, #007a36 66.67% 100%);
}
.hatico { flex: none; border-radius: 50%; overflow: visible; }
.speaking .hatico { filter: drop-shadow(0 0 4px rgba(37, 211, 102, .95)) drop-shadow(0 0 8px rgba(37, 211, 102, .7)); animation: talkhat .7s ease-in-out infinite; }
@keyframes talkhat { 50% { transform: scale(1.14); } }
.hatrow { display: flex; justify-content: center; gap: 4px; padding-block: 4px 0; }
.hatrow .hatico { filter: drop-shadow(0 5px 4px rgba(0, 0, 0, .35)); animation: bob 2.6s ease-in-out infinite; }
.hatrow .hatico:nth-child(2) { animation-delay: .35s; }
.hatrow .hatico:nth-child(3) { animation-delay: .7s; }
.hatrow .hatico:nth-child(4) { animation-delay: 1.05s; }
@keyframes bob { 50% { transform: translateY(-6px) rotate(-4deg); } }
.hero h1 { margin-top: 2px; }
.game.many { --extra: 52px; }
.strip.many { flex-wrap: wrap; }
.strip.many .chip { flex: 1 1 calc(50% - 3px); }
/* a captured hat spins as it flies back to its yard */
.tok.back .hatbody { transform-box: fill-box; transform-origin: center; animation: tumble .6s ease-out; }
@keyframes tumble { to { transform: rotate(720deg); } }

/* funny Pashto speech bubble over a captured piece */
.bubble {
  position: absolute; z-index: 5; max-width: 58%; padding: 6px 12px; text-align: center; pointer-events: none;
  background: #fff; color: #1d2b24; border: 3px solid var(--c, #333); border-radius: 16px; box-shadow: 0 6px 16px rgba(0, 0, 0, .4);
  transform: translate(-50%, -120%); animation: bubble 2.6s ease-out forwards;
}
.bubble::after {
  content: ""; position: absolute; left: 50%; bottom: -11px; width: 14px; height: 14px; background: #fff;
  border-right: 3px solid var(--c, #333); border-bottom: 3px solid var(--c, #333); transform: translateX(-50%) rotate(45deg);
}
.bubble .ps { font-weight: 800; font-size: .95rem; line-height: 1.4; }
.bubble .tr { font-size: .7rem; line-height: 1.3; color: var(--muted); margin-top: 2px; }
@keyframes bubble {
  0% { opacity: 0; transform: translate(-50%, -80%) scale(.3); }
  10% { opacity: 1; transform: translate(-50%, -120%) scale(1.12); }
  18% { transform: translate(-50%, -120%) scale(1); }
  85% { opacity: 1; transform: translate(-50%, -120%) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -150%) scale(1); }
}

/* winner's gift: the box opens and the hat pops out */
.dialog { max-height: 94vh; overflow-y: auto; }
.gift { display: block; width: 150px; height: 141px; margin: -6px auto 8px; overflow: visible; }
.gift .gift-lid { transform-box: fill-box; transform-origin: 15% 100%; animation: lid .7s .55s cubic-bezier(.3, 1.5, .5, 1) forwards; }
/* the lid pops up, then tips over and falls beside the box so the hat is fully visible */
@keyframes lid {
  45% { transform: translate(14px, -46px) rotate(-18deg); }
  100% { transform: translate(70px, -4px) rotate(30deg); }
}
.gift .gift-hat { opacity: 0; animation: rise .9s .95s cubic-bezier(.2, 1.3, .4, 1) forwards; }
@keyframes rise {
  from { opacity: 0; transform: translate(25px, 60px) scale(1.1); }
  to { opacity: 1; transform: translate(25px, -14px) scale(1.1); }
}
.giftline { margin: 0 0 12px !important; color: #8a5a00; font-weight: 800 !important; }

/* ---------- player menu: mute / report / host tools ---------- */
.chip .more {
  flex: none; width: 26px; height: 26px; padding: 0; border: 0; border-radius: 50%; background: rgba(0, 0, 0, .09);
  color: var(--ink); font-weight: 900; font-size: 1rem; line-height: 1;
}
.chip .more:active { background: rgba(0, 0, 0, .2); }
.msg button.who { background: none; border: 0; padding: 0; margin: 0; cursor: pointer; text-align: start; }
.msg .who .dots { margin-inline-start: 2px; color: var(--muted); font-weight: 900; }
.pmenu .dialog { text-align: start; }
.pm-head { display: flex; align-items: center; gap: 10px; font-size: 1.15rem; margin-bottom: 2px; }
.dialog .pm-note { margin: 0 0 12px; color: var(--muted); font-size: .85rem; font-weight: 500; }
.dialog .pm-why { margin: 8px 0 0; font-weight: 800; }
.pm-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 14px; }
.pm-row {
  display: flex; align-items: center; gap: 10px; width: 100%; min-height: 48px; padding: 6px 14px; text-align: start;
  background: #fff; border: 2px solid var(--line); border-radius: 14px; font-weight: 700; color: var(--ink);
}
.pm-row:active { background: #f4ecd2; }
.pm-row.warn { border-color: #e5c17a; background: #fff6e0; }
.pm-row.danger { border-color: #efb4b0; color: var(--flag-red); }
.pm-ico { width: 1.7rem; text-align: center; font-size: 1.2rem; }

/* ---------- voice chat ---------- */
.voicecard { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 14px; }
.voicecard .vh { font-size: .85rem; color: var(--muted); flex: 1; }
.voice-slot { display: flex; align-items: center; }
.voice { display: inline-flex; gap: 6px; align-items: center; }
.vbtn {
  display: inline-flex; align-items: center; gap: 6px; min-height: 40px; padding: 4px 14px; white-space: nowrap;
  border: 2px solid var(--line); border-radius: 999px; background: #fff; color: var(--ink); font-weight: 800; font-size: .9rem;
}
.vbtn.join { background: var(--good); border-color: var(--good); color: #063d1a; }
.voice.on .vbtn.mic { background: #e5f6e8; border-color: #9bd7a8; }
.voice.on.muted .vbtn.mic { background: #f4c7c3; border-color: #e59a95; color: #7a1410; }
.voice.on.talking:not(.muted) .vbtn.mic { box-shadow: 0 0 0 4px rgba(37, 211, 102, .55); }
.vbtn.leave { min-width: 40px; padding: 4px 10px; color: var(--flag-red); border-color: #efb4b0; }
/* in the game the controls are compact so the die stays centred: icon-only mic button, short join label */
.dicebar .voice-slot .vbtn { background: rgba(255, 255, 255, .92); min-height: 44px; font-size: .8rem; padding: 4px 10px; }
.dicebar .voice-slot .vbtn.join { background: var(--good); }
.dicebar .voice-slot .vbtn.leave { min-width: 38px; min-height: 38px; padding: 0 8px; }
.dicebar .voice-slot .vbtn.mic { min-width: 44px; justify-content: center; font-size: 1.15rem; }
.dicebar .voice-slot .vbtn.mic span { display: none; }
.dicebar .voice-slot { min-width: 0; }
/* whoever is talking gets a pulsing green ring around their colour dot */
.speaking .dot { box-shadow: 0 0 0 4px rgba(37, 211, 102, .7); animation: talk .7s ease-in-out infinite; }
@keyframes talk { 50% { box-shadow: 0 0 0 7px rgba(37, 211, 102, .25); } }

/* ---------- chat ---------- */
.chat { background: var(--card); border-radius: 20px; display: flex; flex-direction: column; overflow: hidden; box-shadow: 0 10px 30px rgba(0, 0, 0, .3); min-height: 0; }
.chat-head { display: flex; justify-content: space-between; align-items: center; padding: 8px 14px; background: #efe5c8; font-size: 1.05rem; }
.chat-head .x { border: 0; background: transparent; font-size: 1.2rem; padding: 4px 8px; }
.chat.inline .x { display: none; }
.chat-list { flex: 1; overflow-y: auto; padding: 8px; display: flex; flex-direction: column; gap: 6px; overscroll-behavior: contain; }
.msg { align-self: flex-start; max-width: 86%; background: #fff; border-radius: 14px; padding: 4px 10px 6px; border: 1px solid var(--line); }
.msg.mine { align-self: flex-end; background: #fff1bd; }
.msg .who { display: flex; align-items: center; gap: 6px; font-size: .75rem; font-weight: 800; color: var(--cd, var(--muted)); }
.msg .who .dot { width: 9px; height: 9px; border-width: 1px; }
.msg .txt { overflow-wrap: anywhere; }
.msg.sys { align-self: center; background: transparent; border: 0; color: var(--muted); font-size: .8rem; padding: 0; max-width: 100%; text-align: center; }
.chat-quick { display: flex; gap: 6px; overflow-x: auto; padding: 6px 8px; scrollbar-width: none; border-top: 1px solid var(--line); }
.chat-quick::-webkit-scrollbar { display: none; }
.qb { flex: none; background: #fff; border: 2px solid var(--line); border-radius: 999px; padding: 2px 12px; font-weight: 600; font-size: .85rem; white-space: nowrap; }
.qb.em { padding: 2px 8px; font-size: 1.1rem; }
.chat-form { display: flex; gap: 6px; padding: 8px; border-top: 1px solid var(--line); }
.chat-form .btn { min-height: 48px; }

/* ---------- game ---------- */
.game { width: 100%; max-width: 560px; padding: 8px 10px calc(10px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 8px; user-select: none; -webkit-user-select: none; }
.roomtag { color: #fff; font-weight: 800; opacity: .85; letter-spacing: .06em; white-space: nowrap; font-size: .9rem; }
.chat-btn .badge-n {
  position: absolute; top: -6px; inset-inline-end: -6px; min-width: 20px; height: 20px; padding: 0 5px; border-radius: 10px;
  background: var(--flag-red); color: #fff; font-size: .72rem; font-weight: 800; line-height: 20px; text-align: center;
}
.playfield { display: flex; flex-direction: column; gap: 8px; flex: 1; }
.main { display: flex; flex-direction: column; gap: 8px; align-items: center; width: 100%; }
.strip { display: flex; gap: 6px; width: 100%; }
.chip {
  flex: 1; min-width: 0; position: relative; display: flex; align-items: center; gap: 5px; flex-wrap: wrap;
  background: rgba(255, 248, 231, .92); border-radius: 12px; padding: 5px 8px 9px; border: 2px solid transparent; font-size: .82rem;
}
.chip .nm { font-weight: 800; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; min-width: 0; }
.chip .tags { font-size: .8rem; }
.chip.me .nm { text-decoration: underline; text-decoration-color: var(--c); text-underline-offset: 3px; }
.chip.done { opacity: .6; }
.chip.turn { border-color: var(--c); box-shadow: 0 0 0 3px rgba(255, 255, 255, .55), 0 4px 14px rgba(0, 0, 0, .35); transform: translateY(-2px); }
.chip .prog { display: flex; gap: 2px; width: 100%; }
.chip .prog i { flex: 1; height: 5px; border-radius: 3px; background: #d8ccaa; }
.chip .prog i.on { background: var(--c); }
.chip .bar { position: absolute; inset-inline: 8px; bottom: 2px; height: 4px; border-radius: 2px; overflow: hidden; background: transparent; }
.chip .bar b { display: block; height: 100%; width: 0; background: var(--c); }
.hurry .chip.turn .bar b { background: var(--flag-red); }
.hurry .chip.turn { animation: hurry .7s ease-in-out infinite; }
@keyframes hurry { 50% { transform: translateY(-2px) scale(1.03); } }

.boardwrap {
  position: relative;
  width: min(100%, 560px); width: clamp(280px, calc(100vh - 300px - var(--extra, 0px)), 100%); width: clamp(280px, calc(100dvh - 300px - var(--extra, 0px)), 100%);
  aspect-ratio: 1; max-width: 100%; border-radius: 18px;
  background: var(--card); box-shadow: 0 12px 30px rgba(0, 0, 0, .45); overflow: hidden;
}
.board { display: block; width: 100%; height: 100%; touch-action: manipulation; }
.tok { transition: transform .16s ease-out; }
.tok.back { transition: transform .6s cubic-bezier(.25, .8, .3, 1); }
.tok .ring { opacity: 0; transform-box: fill-box; transform-origin: center; }
.tok .hit { cursor: default; }
.tok.can .hit { cursor: pointer; }
.tok.can .ring { opacity: 1; animation: ring .8s ease-in-out infinite; }
@keyframes ring { 0%, 100% { transform: scale(.85); } 50% { transform: scale(1.15); } }
circle.hint { pointer-events: none; transform-box: fill-box; transform-origin: center; animation: hint 1s ease-in-out infinite; }
@keyframes hint { 50% { transform: scale(1.18); opacity: .6; } }

.status {
  display: flex; align-items: center; gap: 8px; justify-content: center; min-height: 40px; width: 100%;
  padding: 6px 14px; border-radius: 999px; background: rgba(255, 255, 255, .12); color: #fff; font-weight: 800; text-align: center;
}
.status .dot { width: 16px; height: 16px; border: 2px solid rgba(0, 0, 0, .3); }
.status.mine { background: var(--gold); color: #3a2a00; }
.dicebar { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); align-items: center; width: 100%; padding-block: 2px 4px; }
.dicebar .voice-slot { justify-self: end; }
.die {
  --dc: #888; width: 74px; height: 74px; padding: 8px; background: #fff; border: 4px solid var(--dc); border-radius: 18px;
  display: grid; grid-template: repeat(3, 1fr) / repeat(3, 1fr); place-items: center; box-shadow: 0 5px 0 rgba(0, 0, 0, .25), 0 8px 18px rgba(0, 0, 0, .35);
  cursor: default; transition: transform .1s;
}
.die:disabled { opacity: 1; }
.pip { width: 15px; height: 15px; border-radius: 50%; background: transparent; }
.pip.on { background: var(--dc); }
.die.idle .pip.on { opacity: .3; }
.die.ready { cursor: pointer; animation: ready 1s ease-in-out infinite; }
@keyframes ready { 0%, 100% { transform: translateY(0) rotate(0); box-shadow: 0 5px 0 rgba(0,0,0,.25), 0 0 0 0 rgba(255,255,255,.7); }
  50% { transform: translateY(-6px) rotate(-4deg); box-shadow: 0 11px 0 rgba(0,0,0,.2), 0 0 0 10px rgba(255,255,255,0); } }
.die.rolling { animation: roll .28s linear infinite; }
@keyframes roll { 0% { transform: rotate(0) scale(1.05); } 50% { transform: rotate(180deg) scale(.95); } 100% { transform: rotate(360deg) scale(1.05); } }

/* results */
.ranks { list-style: none; margin: 0 0 16px; padding: 0; display: flex; flex-direction: column; gap: 6px; text-align: start; }
.ranks li { display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-radius: 12px; background: #fff; border: 2px solid var(--line); font-weight: 700; }
.ranks li.me { border-color: var(--gold); background: #fff6d6; }
.ranks .nm { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ranks .pl { color: var(--muted); font-size: .85rem; }
.confetti { font-size: 2.4rem; animation: pop .6s cubic-bezier(.3, 1.6, .5, 1); }
@keyframes pop { from { transform: scale(0); } }

/* ---------- chat docking ---------- */
@media (max-width: 899px) {
  .chat.dock {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 40; height: min(72vh, 540px); height: min(72dvh, 540px); border-radius: 22px 22px 0 0;
    transform: translateY(110%); transition: transform .25s ease; box-shadow: 0 -10px 40px rgba(0, 0, 0, .45);
  }
  .chat.dock.open { transform: none; }
  .chat.dock .chat-form { padding-bottom: calc(8px + env(safe-area-inset-bottom)); }
}
@media (min-width: 900px) {
  .game { max-width: 1120px; }
  .playfield { flex-direction: row; align-items: flex-start; gap: 18px; }
  .main { flex: 1; }
  .boardwrap { width: clamp(300px, calc(100vh - 270px - var(--extra, 0px)), 100%); width: clamp(300px, calc(100dvh - 270px - var(--extra, 0px)), 100%); }
  .chat.dock { width: 340px; flex: none; height: min(660px, calc(100vh - 90px)); height: min(660px, calc(100dvh - 90px)); }
  .chat.dock .x, .chat-btn { display: none; }
  .home, .lobby { max-width: 520px; }
}
@media (max-width: 340px) {
  .seats { grid-template-columns: 1fr; }
  .code { font-size: 2.2rem; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
