body:has(.ludo-page) {
    color: #f3f7ff;
    background: #0a1531 radial-gradient(ellipse at 42% 12%, #214986 0%, #101f45 43%, #081229 82%);
}

.ludo-page {
    min-height: 100vh;
    max-width: 1080px;
    margin: auto;
    padding: .75rem clamp(1rem, 4vw, 2.5rem) 1.5rem;
    --red: #f64058;
    --green: #16c286;
    --yellow: #ffca42;
    --blue: #36a7fc;
    --turn: var(--red);
}
.ludo-page[data-turn-color="green"] { --turn: var(--green); }
.ludo-page[data-turn-color="yellow"] { --turn: var(--yellow); }
.ludo-page[data-turn-color="blue"] { --turn: var(--blue); }
.ludo-header { display: grid; justify-items: start; gap: .25rem; margin-bottom: .65rem; }
.ludo-back { color: #c5d6f3; text-decoration: none; font-size: .875rem; }
.ludo-back:hover { color: white; text-decoration: underline; }
.ludo-header h1 { margin: 0; font-size: clamp(1.4rem, 3vw, 1.75rem); line-height: 1.15; font-weight: 850; letter-spacing: -.04em; }
.ludo-header-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .75rem; width: 100%; }
.ludo-header-actions { display: flex; flex-wrap: wrap; gap: .45rem; }
.ludo-header-actions .ludo-secondary { padding: .35rem .65rem; font-size: .8125rem; line-height: 1.4; }
.ludo-invitation { display: grid; grid-template-columns: minmax(0, 1fr); gap: .45rem; padding: .75rem; border: 1px solid #7691b847; border-radius: .8rem; background: #122142; }
.ludo-invitation label, #ludo-copy-status { grid-column: 1 / -1; font-size: .85rem; color: #c3d3ee; }
.ludo-invitation label { font-weight: 700; }
.ludo-invitation input { min-width: 0; width: 100%; border: 1px solid #7798cd80; border-radius: .65rem; padding: .45rem .65rem; color: #f3f7ff; background: #0e1b36; }
#ludo-copy { justify-self: start; }
.ludo-invite-apps { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: .45rem; }
.ludo-invite-apps a { text-decoration: none; }
.ludo-invite-apps a:hover { color: #fff; }
.ludo-layout { display: grid; grid-template-columns: minmax(0, 580px) minmax(235px, 1fr); gap: clamp(1rem, 4vw, 2rem); align-items: start; }
.ludo-page[data-settings-open="false"] .ludo-layout { grid-template-columns: minmax(0, 580px); justify-content: center; }
.ludo-arena {
    display: grid;
    grid-template-areas:
        "red green"
        "board board"
        "blue yellow"
        "controls controls";
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: .65rem;
    min-width: 0;
}
.ludo-scores { display: contents; list-style: none; }
.ludo-page[data-settings-open="true"] .ludo-scores { display: none; }
.ludo-page[data-settings-open="true"] .ludo-arena { grid-template-areas: "board board" "controls controls"; }
.ludo-red { --pawn: var(--red); --shade: var(--red-shade, #a51135); }
.ludo-green { --pawn: var(--green); --shade: var(--green-shade, #006a4b); }
.ludo-yellow { --pawn: var(--yellow); --shade: var(--yellow-shade, #a75500); }
.ludo-blue { --pawn: var(--blue); --shade: var(--blue-shade, #164aaf); }

.ludo-seat {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    align-content: center;
    gap: .32rem;
    min-width: 0;
    min-height: 3.2rem;
    padding: .4rem .6rem .4rem .8rem;
    border: 2px solid #6281b34d;
    border-radius: .8rem;
    background: #102041;
    box-shadow: inset 4px 0 var(--pawn);
}
.ludo-seat strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .95rem; }
.ludo-seat[aria-current] { border-color: var(--pawn); background: #233a64; }
.ludo-page[data-timed-turn="true"] .ludo-seat[aria-current] {
    border-color: transparent;
    background: linear-gradient(#233a64, #233a64) padding-box,
        conic-gradient(var(--pawn) 0 var(--ludo-turn-progress), #526687 var(--ludo-turn-progress) 100%) border-box;
    box-shadow: none;
}
.ludo-seat[data-occupied="false"] { opacity: .38; }
.ludo-penalty-dots { display: flex; align-items: center; gap: .35rem; min-height: .625rem; }
.ludo-penalty-dots > span { display: block; flex: none; width: .625rem; height: .625rem; border-radius: 50%; background: #4ae292; }
.ludo-penalty-dots > .is-penalty { background: #ff5d6e; box-shadow: inset 0 0 0 1px #ffa5af; }
.ludo-seat.ludo-red { grid-area: red; }
.ludo-seat.ludo-green { grid-area: green; }
.ludo-seat.ludo-blue { grid-area: blue; }
.ludo-seat.ludo-yellow { grid-area: yellow; }

.ludo-board {
    rotate: var(--ludo-board-rotation, 0deg);
    grid-area: board;
    position: relative;
    isolation: isolate;
    display: grid;
    grid-template: repeat(15, minmax(0, 1fr)) / repeat(15, minmax(0, 1fr));
    aspect-ratio: 1;
    width: 100%;
    min-width: 0;
    overflow: hidden;
    border: clamp(3px, 1vw, 8px) solid #111d36;
    border-radius: clamp(10px, 2vw, 22px);
    background: #f4f7fd;
    box-shadow: 0 0 0 1px #6f90c880, 0 16px 40px #02081f9c;
    container-type: inline-size;
}
.ludo-cell { position: relative; display: flex; flex-wrap: wrap; justify-content: center; align-content: center; }
.ludo-base-art {
    position: absolute;
    width: 40%;
    height: 40%;
    z-index: -1;
    background: linear-gradient(145deg, var(--pawn), var(--shade));
}
.ludo-base-art::before {
    position: absolute;
    content: "";
    inset: 14%;
    border-radius: 12%;
    background: linear-gradient(145deg, white, #eaf0f9);
    box-shadow: 0 3px 12px #10182f55, inset 0 1px 0 white;
}
.ludo-base-art.ludo-red { top: 0; left: 0; }
.ludo-base-art.ludo-green { top: 0; right: 0; }
.ludo-base-art.ludo-blue { bottom: 0; left: 0; }
.ludo-base-art.ludo-yellow { bottom: 0; right: 0; }
.ludo-base-art.is-active { filter: brightness(1.15); }
.ludo-base-art.is-active::after {
    content: "";
    position: absolute;
    inset: 3%;
    border: 3px solid #fff;
    border-radius: 10%;
    box-shadow: 0 0 14px #fff, inset 0 0 18px #ffffffb3;
    pointer-events: none;
    animation: ludo-active-base 1.6s ease-in-out infinite;
}
@keyframes ludo-active-base {
    0%, 100% { opacity: 1; }
    50% { opacity: .4; }
}
@media (prefers-reduced-motion: reduce) {
    .ludo-base-art.is-active::after { animation: none; }
}
.ludo-nest::before { content: ""; position: absolute; inset: 13%; border-radius: 50%; border: 1px solid var(--shade); background: var(--pawn); box-shadow: inset 0 2px 3px #16213b66; }
.ludo-track, .ludo-lane { box-shadow: inset 0 0 0 .5px #50607870; }
.ludo-lane { background: var(--pawn); }
.ludo-finish-art {
    position: absolute;
    inset: 40%;
    z-index: -1;
    background: conic-gradient(from -45deg, var(--green) 25%, var(--yellow) 0 50%, var(--blue) 0 75%, var(--red) 0);
}
.ludo-board .ludo-lane.ludo-goal { background: transparent; box-shadow: none; }
.ludo-star { position: absolute; inset: 0; display: grid; place-items: center; color: #293d61; font-size: 4.1cqw; line-height: 1; pointer-events: none; }

.ludo-pawn {
    rotate: calc(-1 * var(--ludo-board-rotation, 0deg));
    position: relative;
    width: 88%;
    height: 94%;
    padding: 0;
    z-index: 1;
    border: 0;
    background: radial-gradient(ellipse at 50% 78%, var(--shade) 0 34%, var(--pawn) 35% 51%, #1a254264 53% 58%, transparent 62%) center bottom / 100% 43% no-repeat;
}
.ludo-pawn::before {
    content: "";
    position: absolute;
    top: 1%;
    left: 14%;
    width: 72%;
    aspect-ratio: 1;
    border: 1px solid #718096;
    border-radius: 53% 53% 53% 7%;
    background: linear-gradient(140deg, #fbfdff 18%, #e5edf7 45%, #94a5bc 100%);
    box-shadow: -1px 2px 3px #14213daf, inset 0 0 1px #fff;
    transform: rotate(-45deg);
}
.ludo-pawn::after {
    content: "";
    position: absolute;
    top: 10%;
    left: 25%;
    width: 50%;
    aspect-ratio: 1;
    border-radius: 50%;
    background: radial-gradient(circle at 28% 24%, #fff9, transparent 34%), linear-gradient(145deg, var(--pawn) 28%, var(--shade));
    box-shadow: inset 0 0 0 1px #13233960;
}
.ludo-nest .ludo-pawn { width: 100%; height: 111%; transform: translateY(-9%); }
.ludo-cell:has(.ludo-pawn ~ .ludo-pawn) .ludo-pawn { width: 47%; height: 47%; }
.ludo-cell:has(.ludo-pawn ~ .ludo-pawn ~ .ludo-pawn ~ .ludo-pawn ~ .ludo-pawn) .ludo-pawn { width: 25%; height: 25%; }
button.ludo-pawn { cursor: pointer; z-index: 2; filter: drop-shadow(0 0 2px #143163); }
button.ludo-pawn:focus-visible, button.ludo-pawn:hover { outline: 2px solid #163763; outline-offset: 1px; border-radius: .25rem; z-index: 3; }

.ludo-board > .ludo-moving-pawn {
    position: absolute;
    width: calc(88% / 15);
    height: calc(94% / 15);
    z-index: 5;
    pointer-events: none;
    filter: drop-shadow(0 2px 2px #14213b80);
}
.ludo-page[data-animating="true"] .ludo-moves { pointer-events: none; }
.ludo-landing-effect {
    position: absolute;
    width: calc(100% / 15);
    height: calc(100% / 15);
    z-index: 6;
    pointer-events: none;
    color: var(--pawn);
}
.ludo-landing-effect::before {
    content: "";
    position: absolute;
    inset: -18%;
    border: 3px solid currentColor;
    border-radius: 50%;
    box-shadow: 0 0 12px currentColor;
    animation: ludo-landing-ring .56s ease-out both;
}
.ludo-landing-effect > span {
    position: absolute;
    left: 44%;
    top: 44%;
    width: 12%;
    height: 12%;
    border-radius: 2px;
    background: currentColor;
    animation: ludo-landing-spark .56s ease-out both;
}
.ludo-effect-capture { color: #ff784e; }
.ludo-effect-capture::before { border-style: dashed; }
.ludo-effect-safe { color: #31d7ff; }
.ludo-effect-safe::before { border-radius: 45% 45% 55% 55%; }
.ludo-effect-finish { color: #ffd45a; }
@keyframes ludo-landing-ring {
    from { transform: scale(.45); opacity: 1; }
    to { transform: scale(1.85); opacity: 0; }
}
@keyframes ludo-landing-spark {
    from { transform: rotate(var(--spark-angle)) translateX(0) scale(1.3); opacity: 1; }
    to { transform: rotate(var(--spark-angle)) translateX(7cqw) scale(.25); opacity: 0; }
}
@media (prefers-reduced-motion: reduce) {
    .ludo-landing-effect::before, .ludo-landing-effect > span { animation: none; }
    .ludo-landing-effect > span { display: none; }
}

.ludo-panel { display: grid; gap: .85rem; min-width: 0; scroll-margin-block-start: .75rem; }
.ludo-panel[hidden] { display: none; }
.ludo-settings-close { display: none; }
.ludo-turn, .ludo-setup, .ludo-panel details, .ludo-online {
    padding: 1rem;
    border: 1px solid #7691b847;
    border-radius: 1rem;
    background: #122142;
}
.ludo-turn { grid-area: controls; display: grid; gap: .85rem; border-top: 3px solid var(--turn); box-shadow: 0 12px 34px #050d2655; }
.ludo-dice-row { display: flex; align-items: center; gap: .8rem; }
.ludo-sound { flex: 0 0 auto; min-width: 2.8rem; min-height: 2.8rem; margin-inline-start: auto; }
.ludo-die {
    width: 3.3rem;
    height: 3.3rem;
    flex: 0 0 auto;
    padding: .59rem;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: .19rem;
    transform: rotate(-6deg);
    border-radius: .75rem;
    background: linear-gradient(155deg, #fff, #dce5f6);
    box-shadow: 0 4px 0 #8799b8, 0 7px 14px #020922a8;
}
.ludo-die span { aspect-ratio: 1; border-radius: 50%; }
.ludo-die .is-pip { background: #162743; box-shadow: inset 0 1px 1px #0009; }
.ludo-die[data-face="0"] span:nth-child(5) { background: #7386a8; }
.ludo-die.is-rolling { animation: ludo-tumble .48s cubic-bezier(.24, .7, .38, 1); }
.ludo-die.is-rolling span { animation: ludo-show-face .48s linear; }
@keyframes ludo-tumble {
    0% { transform: translateY(0) rotate(-6deg); }
    35% { transform: translateY(-1.05rem) rotate(145deg) scale(.93); }
    70% { transform: translateY(.1rem) rotate(290deg) scale(1.04); }
    100% { transform: translateY(0) rotate(354deg); }
}
@keyframes ludo-show-face { 0%, 55% { opacity: 0; } 85%, 100% { opacity: 1; } }
@media (prefers-reduced-motion: reduce) {
    .ludo-die.is-rolling, .ludo-die.is-rolling span { animation: none; }
}
#ludo-status { margin: 0; min-width: 0; overflow-wrap: anywhere; color: #f3f7ff; font-weight: 700; }
.ludo-action, .ludo-secondary, .ludo-setup select { border-radius: .65rem; padding: .46rem .75rem; font: inherit; font-weight: 700; }
.ludo-action { border: none; background: var(--turn); color: #0c1833; padding: .75rem; }
.ludo-action:disabled { opacity: .42; }
.ludo-action[hidden] { display: none; }
.ludo-action:not(:disabled):hover { filter: brightness(1.13); }
.ludo-secondary, .ludo-setup select { color: #f3f7ff; border: 1px solid #7798cd80; background: #23385f; }
.ludo-secondary:hover { background: #314b7c; }
.ludo-moves { display: flex; flex-wrap: wrap; gap: .45rem; }
.ludo-moves:empty { display: none; }
.ludo-turn .game-countdown { margin: 0; text-align: center; font-weight: 700; }
.ludo-turn .game-countdown strong { font-size: 1.6em; color: var(--turn); }
.ludo-setup { display: flex; flex-wrap: wrap; align-items: end; gap: .55rem; }
.ludo-setup label { display: block; margin-bottom: .28rem; font-size: .78rem; color: #c3d3ee; }
.ludo-local-names { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .5rem; flex-basis: 100%; }
.ludo-local-names input { display: block; width: 100%; margin-top: .2rem; border-radius: .55rem; border: 1px solid #7798cd80; padding: .38rem .48rem; color: #f3f7ff; background: #0e1b36; }
.ludo-panel summary { cursor: pointer; font-weight: 700; }
.ludo-panel details p { color: #d0ddf4; font-size: .9rem; }
.ludo-online { display: grid; gap: .6rem; }
.ludo-online h2 { margin: 0; font-size: 1.12rem; font-weight: 800; }
.ludo-online input { width: 100%; min-width: 0; border-radius: .65rem; padding: .5rem .65rem; color: #f3f7ff; background: #0e1b36; border: 1px solid #7798cd80; }
.ludo-online label { color: #c3d3ee; font-size: .83rem; }
.ludo-online a { text-decoration: none; text-align: center; }
.ludo-online a:hover { color: white; }
.ludo-online-form { display: grid; gap: .45rem; }
.ludo-intro { margin: 0 0 1rem; color: #d0ddf4; font-size: .95rem; }
.ludo-join {
    max-width: 32rem;
    margin: clamp(1rem, 4vw, 2.5rem) auto;
    gap: 0;
    border: 1px solid #7798cd80;
    border-radius: 1.15rem;
    background: #122142;
    box-shadow: 0 1.25rem 3rem #050c2080;
}
.ludo-join-cover { display: block; width: 100%; height: auto; border-radius: calc(1.15rem - 1px) calc(1.15rem - 1px) 0 0; }
.ludo-join-content { display: grid; gap: .85rem; padding: clamp(1rem, 4vw, 1.65rem); }
.ludo-join .ludo-join-content h2 { font-size: clamp(1.3rem, 4vw, 1.65rem); }
.ludo-join-intro { margin: 0; color: #d0ddf4; }
.ludo-join-form .ludo-action { margin-top: .25rem; }
.ludo-error { color: #ffc4ce; margin: 0; }
#ludo-copy-status:empty { display: none; }
.ludo-clock { justify-self: start; color: var(--turn); font-weight: 800; font-variant-numeric: tabular-nums; }
.ludo-clock[data-urgent="true"] { color: #ff9caa; }
.ludo-timers { display: flex; flex-wrap: wrap; gap: .4rem .9rem; }
.ludo-timers:has(> [hidden] + [hidden]) { display: none; }
.ludo-roll-clock { color: #c3d3ee; }
.ludo-history { display: grid; gap: .55rem; list-style: none; margin: .8rem 0 0; padding: 0; }
.ludo-history:empty { margin: 0; }
.ludo-history li { padding-top: .45rem; border-top: 1px solid #7691b847; }
.ludo-history strong, .ludo-history small { display: block; }
.ludo-history small { color: #c3d3ee; overflow-wrap: anywhere; }
.ludo-seat[data-banned="true"] strong { text-decoration: line-through; }

@media (max-width: 767.98px) {
    .ludo-page { min-height: 100dvh; padding: .85rem clamp(.5rem, 2.7vw, 1rem) 1.5rem; }
    .ludo-header { margin-block-end: .85rem; }
    .ludo-layout { grid-template-columns: minmax(0, 580px); justify-content: center; }
    .ludo-header { max-width: 580px; margin-inline: auto; }
    .ludo-arena { gap: .45rem; }
    .ludo-seat { min-height: 2.85rem; padding: .3rem .45rem .3rem .7rem; }
    .ludo-turn, .ludo-online, .ludo-setup, .ludo-panel details { padding: .75rem; }
    .ludo-turn { gap: .65rem; }
    .ludo-settings-close { display: block; justify-self: start; }
    .ludo-moves > button { flex: 1 1 9rem; overflow-wrap: anywhere; }
    .ludo-action, .ludo-secondary, .ludo-setup select { min-height: 44px; }
    .ludo-invite-apps a { display: inline-flex; align-items: center; gap: .3rem; }
    .ludo-online input, .ludo-local-names input, .ludo-invitation input { font-size: 1rem; }
}

@media (max-width: 420px) {
    .ludo-header-row { column-gap: .5rem; }
    .ludo-header-actions > button { padding-inline: .55rem; }
    .ludo-dice-row { gap: .55rem; }
    .ludo-die { width: 2.8rem; height: 2.8rem; padding: .5rem; }
}
