/* Classic Modern Ludo: everything is scoped under .cml-ludo so it can't leak into the theme. */
.cml-ludo{
  --red:#e76d67;--green:#42aa91;--yellow:#efc05e;--blue:#638ed6;
  --red-hi:#fa9287;--red-lo:#d85a52;--green-hi:#6ac8a8;--green-lo:#2c9279;
  --yellow-hi:#ffda80;--yellow-lo:#dfad46;--blue-hi:#85afe9;--blue-lo:#4e7cbd;
  --ink:#192d37;--muted:#73847d;--rim:#274e42;--deep:#194e40;
  --ease:cubic-bezier(.2,.8,.2,1);
  --sans:'DM Sans',system-ui,-apple-system,'Segoe UI',Roboto,sans-serif;
  --display:Outfit,'DM Sans',system-ui,-apple-system,'Segoe UI',sans-serif;
  font-family:var(--sans);color:var(--ink);font-size:14px;line-height:1.4;text-align:left;
  container-type:inline-size;container-name:cmlludo;
  background:#e9eee9;border-radius:28px;padding:20px;margin:1.5em 0;width:100%;max-width:100%;
}
.cml-ludo *,.cml-ludo *:before,.cml-ludo *:after{box-sizing:border-box}
/* Neutralise common theme button/input styling */
.cml-ludo button{font:inherit;color:inherit;margin:0;text-transform:none;letter-spacing:normal;line-height:1.2;min-height:0;min-width:0;width:auto;text-decoration:none;cursor:pointer;background-image:none;text-shadow:none}
.cml-ludo input{font:inherit;color:var(--ink);margin:0;min-height:0;box-shadow:none}
.cml-ludo h1,.cml-ludo h2,.cml-ludo p,.cml-ludo ul,.cml-ludo ol{margin:0;padding:0;border:0;background:none}
.cml-ludo :focus-visible{outline:3px solid #1d6b55;outline-offset:2px}
.cml-ludo [hidden]{display:none!important}

.cml-ludo .cml-main{display:grid;grid-template-columns:minmax(0,1fr) 320px;gap:22px;align-items:start}
.cml-ludo .panel{background:#fff;border:1px solid #e2e9e3;border-radius:24px;box-shadow:0 12px 50px #163b2c0d,0 2px 8px #163b2c06}
.cml-ludo .boardpanel{padding:22px;background:linear-gradient(145deg,#fff,#f3f7f3);box-shadow:0 20px 55px #142d2b18,0 2px 8px #142d2b0b}
.cml-ludo .topline{display:flex;justify-content:space-between;align-items:center;margin-bottom:19px;gap:10px}
.cml-ludo .topline h2{font-family:var(--display);font-size:22px;letter-spacing:-.5px;line-height:1.15;color:var(--ink)}
.cml-ludo .eyebrow{font-size:10px;letter-spacing:2px;text-transform:uppercase;font-weight:850;color:#4b8a73;margin-bottom:7px}
.cml-ludo .sub{font-size:12px;color:#7b8b83}
.cml-ludo .turnlabel{font-size:12px;border:1px solid #e3e9e4;background:#f2f6f1;border-radius:50px;padding:8px 12px;font-weight:700;display:flex;align-items:center;gap:7px;white-space:nowrap}
.cml-ludo .turnlabel:before{content:'';width:9px;height:9px;border-radius:50%;background:var(--current,var(--red))}
.cml-ludo .legend{display:flex;gap:8px;flex-wrap:wrap;font-size:11px;color:#5d6d73;padding:4px 4px 0}
.cml-ludo .legend span{background:#f1f5f1;padding:7px 10px;border-radius:8px}
.cml-ludo .legend strong{color:#19333e}
.cml-ludo .sidebar{display:flex;flex-direction:column;gap:15px}
.cml-ludo .card{padding:22px}
.cml-ludo .card h2{margin:0 0 12px;font-family:var(--display);font-size:18px;letter-spacing:-.3px;line-height:1.2;display:flex;align-items:center;gap:8px;color:var(--ink)}
.cml-ludo .turntitle:before{content:'';width:10px;height:10px;border-radius:50%;background:var(--current,var(--red))}

/* ---------- Board ---------- */
.cml-ludo .board{--rot:0deg;position:relative;aspect-ratio:1;width:100%;border:9px solid var(--rim);border-radius:17px;background:var(--rim);
  box-shadow:0 4px 0 #1b382f,0 9px 0 #102b25,0 14px 0 #0b201c,0 22px 22px #102c2652,0 35px 48px #102c2630;
  transform:translateY(-4px);margin-bottom:22px;container-type:inline-size}
.cml-ludo .board.init *{transition:none!important}
.cml-ludo .board:before{content:"";pointer-events:none;position:absolute;inset:-8px;z-index:30;border-radius:14px;
  box-shadow:inset 0 2px 2px #ffffff85,inset 2px 0 2px #ffffff40,inset 0 -3px 4px #071e1b77}
.cml-ludo .stage{position:absolute;inset:0;transform:rotate(var(--rot));transition:transform .7s var(--ease)}
.cml-ludo .grid{position:absolute;inset:0;display:grid;grid-template-columns:repeat(15,1fr);grid-template-rows:repeat(15,1fr);border-radius:8px;overflow:hidden;background:#fff}
.cml-ludo .cell{position:relative;display:flex;align-items:center;justify-content:center;min-width:0;border:1px solid #dbe4df;background:linear-gradient(145deg,#fff,#f4f6f3);box-shadow:inset 0 1px 0 #ffffffa0}
.cml-ludo .red{--hi:var(--red-hi);--lo:var(--red-lo)}.cml-ludo .green{--hi:var(--green-hi);--lo:var(--green-lo)}
.cml-ludo .yellow{--hi:var(--yellow-hi);--lo:var(--yellow-lo)}.cml-ludo .blue{--hi:var(--blue-hi);--lo:var(--blue-lo)}
.cml-ludo .cell.lane,.cml-ludo .cell.start,.cml-ludo .yard{background:linear-gradient(145deg,var(--hi),var(--lo))}
.cml-ludo .cell.safe:not(.start){background:radial-gradient(circle at 45% 40%,#e3f4e9,#cce3d5);box-shadow:inset 0 0 0 1px #92bca4,inset 0 2px 3px #ffffffa0}
.cml-ludo .cell.safe:after{content:'★';rotate:calc(-1*var(--rot));transition:rotate .7s var(--ease);color:#17493e;font-size:clamp(10px,2.6cqi,19px);line-height:1;text-shadow:0 1px 1px #ffffff8c}
.cml-ludo .cell.start:after{color:#fff;text-shadow:0 1px 2px #0a312c7a}
.cml-ludo .yard{position:relative}
.cml-ludo .yard-inner{position:absolute;inset:16.667%;border-radius:13%;background:linear-gradient(150deg,#fff,#f2f5f0);box-shadow:inset 0 2px 5px #183a2e26,0 2px 1px #ffffffb8;border:1px solid #ffffff9c}
.cml-ludo .hole{position:absolute;width:22%;aspect-ratio:1;border-radius:50%;translate:-50% -50%;background:linear-gradient(145deg,var(--lo),var(--hi));opacity:.38;box-shadow:inset 0 3px 5px #123b3555,inset 0 -2px 2px #ffffff9c}
.cml-ludo .center{position:relative;background:#f9faf8}
.cml-ludo .center svg{position:absolute;inset:0;width:100%;height:100%;display:block}
.cml-ludo .center .label{position:absolute;inset:0;display:grid;place-items:center;pointer-events:none;rotate:calc(-1*var(--rot));transition:rotate .7s var(--ease);
  font-family:var(--display);font-weight:900;color:#fff;font-size:clamp(8px,2.1cqi,17px);letter-spacing:.5px;text-shadow:0 1px 2px #0006}

/* ---------- Tokens ---------- */
.cml-ludo .tokens{position:absolute;inset:0;pointer-events:none;z-index:20}
.cml-ludo .token{position:absolute;pointer-events:auto;width:var(--size,4.9%);height:auto;aspect-ratio:1;translate:-50% -50%;padding:0;margin:0;
  border-radius:50%;border:2px solid #ffffffef;display:flex;align-items:center;justify-content:center;
  color:#fff;font-family:var(--display);font-weight:800;font-size:clamp(8px,2.1cqi,15px);line-height:1;text-shadow:0 1px 2px #0005;
  background:radial-gradient(circle at 34% 23%,#ffffffa3 0%,#ffffff22 21%,transparent 40%),var(--color);
  box-shadow:inset 0 2px 2px #ffffff8a,inset 0 -5px 5px #00000038,0 3px 0 #16302a66,0 5px 6px #102a2966;
  rotate:calc(-1*var(--rot));
  transition:left .17s var(--ease),top .17s var(--ease),width .17s,filter .15s,scale .15s,rotate .7s var(--ease)}
.cml-ludo .token.small{font-size:clamp(6px,1.5cqi,11px);border-width:1px}
.cml-ludo .token.tiny{font-size:0;border-width:1px}
.cml-ludo .token.returning{transition:left .5s var(--ease),top .5s var(--ease),width .3s,rotate .7s var(--ease)}
.cml-ludo .token[aria-disabled=true]{cursor:default}
.cml-ludo .token.available{outline:2px solid #163e36;outline-offset:2px;filter:brightness(1.09);animation:cml-pulse 1s infinite alternate}
.cml-ludo .token.available:active{scale:.93}
.cml-ludo .token.moving{z-index:25!important;filter:brightness(1.12)}
@keyframes cml-pulse{to{outline-color:#c2a053;filter:brightness(1.18)}}

/* ---------- Mode / online setup ---------- */
.cml-ludo .tabs{display:flex;background:#f1f5f1;border-radius:12px;padding:4px;margin-bottom:14px}
.cml-ludo .tabs button{flex:1;border:0;background:transparent;border-radius:9px;padding:9px 10px;font-weight:750;font-size:13px;color:#5d6d73}
.cml-ludo .tabs button[aria-pressed=true]{background:#fff;color:var(--ink);box-shadow:0 1px 3px #163b2c22}
.cml-ludo .note{font-size:12px;color:#66747b;line-height:1.55}
.cml-ludo .field{display:flex;flex-direction:column;gap:6px;margin:12px 0}
.cml-ludo .field label{font-size:11px;font-weight:800;letter-spacing:1px;text-transform:uppercase;color:#6b7c74}
.cml-ludo .field input{border:1px solid #d6dfda;border-radius:10px;padding:10px 12px;background:#fbfcfb;width:100%;font-size:14px}
.cml-ludo .row{display:flex;gap:8px}
.cml-ludo .row input{flex:1;min-width:0;text-transform:uppercase;letter-spacing:2px}
.cml-ludo .or{display:flex;align-items:center;gap:10px;color:#93a29a;font-size:11px;font-weight:700;margin:14px 0 2px}
.cml-ludo .or:before,.cml-ludo .or:after{content:'';flex:1;height:1px;background:#e3e9e4}
.cml-ludo .invite{display:flex;gap:8px;align-items:center;background:#f1f6f2;border-radius:12px;padding:8px 8px 8px 12px;margin:10px 0}
.cml-ludo .invite code{flex:1;font-family:var(--display);font-weight:800;font-size:20px;letter-spacing:3px;color:var(--ink);background:none;padding:0}
.cml-ludo .error{color:#b2403a;font-size:12px;margin-top:8px;min-height:1em}

/* ---------- Players ---------- */
.cml-ludo .player{display:flex;align-items:center;justify-content:space-between;padding:12px 13px;border:2px solid #e8eeea;border-radius:12px;margin-bottom:8px;gap:8px;background:#fcfdfb}
.cml-ludo .player.active{border-color:var(--c);background:#fff;box-shadow:0 0 0 3px color-mix(in srgb,var(--c) 14%,transparent),inset 4px 0 0 var(--c)}
.cml-ludo .player.won{background:#fff7dd;border-color:#e2c26e}
.cml-ludo .player-left{display:flex;align-items:center;gap:9px;font-size:13px;font-weight:700;min-width:0}
.cml-ludo .player-left .pname{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.cml-ludo .dot{flex:none;width:13px;height:13px;border-radius:50%;background:var(--c);box-shadow:0 0 0 3px #fff}
.cml-ludo .player.active .dot{box-shadow:0 0 0 4px color-mix(in srgb,var(--c) 22%,transparent)}
.cml-ludo .player.thinking .dot{animation:cml-think .6s infinite alternate}
@keyframes cml-think{to{transform:scale(1.35)}}
.cml-ludo .player small{color:#7b878c;font-size:11px;white-space:nowrap}
.cml-ludo .player-right{display:flex;align-items:center;gap:8px;flex:none}
.cml-ludo .you{font-size:10px;font-weight:850;letter-spacing:.8px;text-transform:uppercase;color:#fff;background:var(--c);border-radius:6px;padding:2px 6px}
.cml-ludo .status{font-size:10px;font-weight:800;letter-spacing:.6px;text-transform:uppercase;border-radius:6px;padding:2px 6px;background:#eef3ef;color:#5d6d73}
.cml-ludo .status.online{background:#e1f3ea;color:#1f7a5c}
.cml-ludo .status.away{background:#fbeee0;color:#9a5b1b}
.cml-ludo .seat{border:1px solid #dce3e1;background:#fff;border-radius:40px;padding:4px 10px;font-size:11px;font-weight:750;color:#41574d;white-space:nowrap}
.cml-ludo .seat.cpu{background:#173c36;border-color:#173c36;color:#e4e9df}
.cml-ludo .seat.join{background:var(--deep);border-color:var(--deep);color:#fff}
.cml-ludo .playas{display:flex;align-items:center;justify-content:space-between;gap:10px;margin:0 0 14px;font-size:12px;color:#5d6d73;font-weight:700}
.cml-ludo .swatches{display:flex;gap:8px}
.cml-ludo .swatch{width:30px;height:30px;border-radius:50%;border:3px solid #fff;padding:0;background:radial-gradient(circle at 34% 25%,#ffffff90,transparent 45%),var(--c);
  box-shadow:0 0 0 1px #d6dfda,0 2px 4px #16302a33;transition:box-shadow .15s,scale .15s}
.cml-ludo .swatch:hover{scale:1.08}
.cml-ludo .swatch[aria-pressed=true]{box-shadow:0 0 0 2px var(--c),0 0 0 5px color-mix(in srgb,var(--c) 25%,transparent),0 2px 4px #16302a33}
.cml-ludo .level{display:flex;align-items:center;justify-content:space-between;gap:10px;margin:4px 0 14px;font-size:12px;color:#5d6d73;font-weight:700}
.cml-ludo .level div{display:flex;background:#f1f5f1;border-radius:10px;padding:3px}
.cml-ludo .level button{border:0;background:transparent;border-radius:8px;padding:6px 12px;font-size:12px;font-weight:750;color:#5d6d73}
.cml-ludo .level button[aria-pressed=true]{background:#fff;color:var(--ink);box-shadow:0 1px 3px #163b2c22}
.cml-ludo .actions{display:flex;gap:8px;flex-wrap:wrap}
.cml-ludo .actions button{flex:1}
.cml-ludo .secondary{background:#fff;border:1px solid #dce3e1;border-radius:12px;padding:10px 13px;font-weight:650;font-size:13px;color:var(--ink)}
.cml-ludo .secondary:disabled{opacity:.5;cursor:not-allowed}

/* ---------- Dice ---------- */
.cml-ludo .dice-area{text-align:center;padding:10px 0 3px}
.cml-ludo .dice{width:95px;height:95px;margin:0 auto 5px;padding:15px;border-radius:22px;display:grid;grid-template:repeat(3,1fr)/repeat(3,1fr);place-items:center;
  background:linear-gradient(145deg,#fafdf8,#d9e4dd);border:1px solid #fff;
  box-shadow:inset 0 2px 3px #fff,inset 0 -5px 7px #a5bcb080,0 7px 0 #9eafa5,0 15px 18px #17382e42}
.cml-ludo .pip{width:15px;height:15px;border-radius:50%;background:#20463b;box-shadow:inset 0 2px 2px #0007,0 1px 0 #fff;opacity:0;transition:opacity .08s}
.cml-ludo .pip.on{opacity:1}
.cml-ludo .dice.rolling{animation:cml-shake .13s ease-in-out infinite alternate}
@keyframes cml-shake{from{transform:rotate(-13deg) scale(1.06) translateY(-4px)}to{transform:rotate(13deg) scale(.94) translateY(3px)}}
.cml-ludo .dice-caption{font-size:10px;font-weight:850;letter-spacing:1.8px;color:#7b8f84;margin:14px 0 17px}
.cml-ludo .primary{border:0;width:100%;background:var(--deep);color:#fff;border-radius:12px;padding:14px 17px;font-weight:750;font-size:14px;
  box-shadow:0 6px 0 #0c3328;transition:transform .12s,box-shadow .12s}
.cml-ludo .primary.compact{width:auto;padding:10px 14px;box-shadow:0 4px 0 #0c3328}
.cml-ludo .primary:not(:disabled):active{transform:translateY(4px);box-shadow:0 2px 0 #0c3328}
.cml-ludo .primary:disabled{opacity:.4;cursor:not-allowed}
.cml-ludo .message{background:#f1f6f2;border-radius:12px;padding:13px;min-height:60px;color:#355c4c;font-size:13px;line-height:1.5;text-align:center;margin-top:16px}
.cml-ludo .hint{font-size:11px;color:#8a978f;text-align:center;margin-top:10px}
.cml-ludo .rules{font-size:12px;line-height:1.85;color:#66747b;padding-left:18px;list-style:disc}
.cml-ludo .rules li::marker{color:#379273}

/* ---------- Help dialog ---------- */
.cml-ludo dialog{border:0;border-radius:20px;padding:26px;max-width:440px;width:calc(100% - 32px);color:var(--ink);background:#fff;box-shadow:0 30px 80px #0b201c55}
.cml-ludo dialog::backdrop{background:#0b201c66}
.cml-ludo dialog h2{font-family:var(--display);font-size:22px;margin:0 0 10px}
.cml-ludo dialog p,.cml-ludo dialog li{font-size:14px;line-height:1.6;color:#41574d}
.cml-ludo dialog ol{padding-left:20px;margin:0 0 10px}

/* ---------- Fit-to-screen mode: [classic_modern_ludo fit="screen" offset="80"] ---------- */
.cml-ludo .dialog-rules{display:none;font-size:13px}
.cml-ludo.cml-fit .dialog-rules{display:block}
.cml-ludo.cml-fit{--fit-h:calc(100vh - var(--cml-offset,0px));margin:0;padding:14px;border-radius:20px}
@supports (height:100dvh){.cml-ludo.cml-fit{--fit-h:calc(100dvh - var(--cml-offset,0px))}}
@container cmlludo (min-width:861px){
  /* Board side = available height minus the board panel's own chrome (~124px) and our padding (28px) */
  .cml-ludo.cml-fit .cml-main{--board:max(320px,calc(var(--fit-h) - 152px));height:max(468px,calc(var(--fit-h) - 28px));
    grid-template-rows:minmax(0,1fr);max-width:calc(var(--board) + 40px + 18px + 300px);margin-inline:auto;gap:18px;grid-template-columns:minmax(0,1fr) 300px}
  .cml-ludo.cml-fit .boardpanel{padding:18px 20px 6px}
  .cml-ludo.cml-fit .topline{margin-bottom:12px}
  .cml-ludo.cml-fit .eyebrow{margin-bottom:4px}
  .cml-ludo.cml-fit .board{width:min(100%,var(--board));margin:0 auto 18px}
  .cml-ludo.cml-fit .legend{display:none}
  .cml-ludo.cml-fit .sidebar{max-height:100%;overflow-y:auto;scrollbar-width:thin;gap:12px;padding:0 4px 6px 0;border-radius:24px}
  .cml-ludo.cml-fit .rulescard{display:none}
  .cml-ludo.cml-fit .turncard{order:-1}
  .cml-ludo.cml-fit .card{padding:16px 18px}
  .cml-ludo.cml-fit .card h2{margin-bottom:8px}
  .cml-ludo.cml-fit .dice-area{padding:4px 0 0}
  .cml-ludo.cml-fit .dice{width:70px;height:70px;padding:11px;border-radius:17px;box-shadow:inset 0 2px 3px #fff,inset 0 -4px 6px #a5bcb080,0 5px 0 #9eafa5,0 10px 14px #17382e42}
  .cml-ludo.cml-fit .pip{width:11px;height:11px}
  .cml-ludo.cml-fit .dice-caption{margin:10px 0 12px}
  .cml-ludo.cml-fit .primary{padding:12px 15px}
  .cml-ludo.cml-fit .message{margin-top:12px;min-height:0;padding:10px 12px}
  .cml-ludo.cml-fit .hint{display:none}
  .cml-ludo.cml-fit .player{padding:8px 11px;margin-bottom:6px}
  .cml-ludo.cml-fit .playas{margin-bottom:10px}
  .cml-ludo.cml-fit .level{margin:2px 0 10px}
  .cml-ludo.cml-fit .tabs{margin-bottom:10px}
}

/* ---------- Responsive: based on the space the theme gives us, not the window ---------- */
@container cmlludo (max-width:860px){
  .cml-ludo .cml-main{grid-template-columns:1fr}
  .cml-ludo .sidebar{display:grid;grid-template-columns:1fr 1fr;align-items:start}
  .cml-ludo .turncard{order:-1}
}
@container cmlludo (max-width:560px){
  .cml-ludo .cml-main{gap:13px}
  .cml-ludo .boardpanel{padding:10px}.cml-ludo .topline{margin-bottom:12px}.cml-ludo .topline h2{font-size:18px}
  .cml-ludo .board{border-width:6px;border-radius:11px;margin-bottom:16px;box-shadow:0 3px 0 #1b382f,0 7px 0 #102b25,0 13px 15px #102c2652,0 20px 24px #102c2630}
  .cml-ludo .board:before{inset:-5px;border-radius:9px}.cml-ludo .grid{border-radius:6px}
  .cml-ludo .token{border-width:1px}.cml-ludo .sidebar{grid-template-columns:1fr}.cml-ludo .card{padding:17px}.cml-ludo .hint{display:none}
}
@media (max-width:560px){.cml-ludo{padding:8px;border-radius:18px}}
@media (prefers-reduced-motion:reduce){
  .cml-ludo .dice.rolling,.cml-ludo .token.available,.cml-ludo .player.thinking .dot{animation:none}
  .cml-ludo .token,.cml-ludo .token.returning,.cml-ludo .stage,.cml-ludo .center .label,.cml-ludo .cell.safe:after{transition:none}
}
