:root {
    --bg: #0f172a;
    --card: rgba(255, 255, 255, 0.92);
    --text: #0f172a;
    --muted: #64748b;
    --line: rgba(15, 23, 42, 0.12);
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --danger: #dc2626;
    --ok: #16a34a;
    --shadow: 0 22px 70px rgba(2, 6, 23, 0.30);
}

* { box-sizing: border-box; }

body {
    margin: 0;
    min-height: 100vh;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    color: var(--text);
    background:
        radial-gradient(circle at 20% 20%, rgba(239, 68, 68, .38), transparent 30%),
        radial-gradient(circle at 80% 20%, rgba(59, 130, 246, .36), transparent 32%),
        radial-gradient(circle at 20% 85%, rgba(34, 197, 94, .32), transparent 30%),
        radial-gradient(circle at 85% 85%, rgba(250, 204, 21, .30), transparent 33%),
        var(--bg);
}

button, input, select {
    font: inherit;
}

button {
    border: 0;
    border-radius: 14px;
    padding: 12px 16px;
    cursor: pointer;
    font-weight: 800;
    transition: transform .12s ease, opacity .12s ease, box-shadow .12s ease, background .12s ease;
}

button:hover { transform: translateY(-1px); }
button:disabled { cursor: not-allowed; opacity: .50; transform: none; }

input, select {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 12px 14px;
    background: white;
    color: var(--text);
    outline: none;
}

input:focus, select:focus {
    border-color: rgba(37, 99, 235, .75);
    box-shadow: 0 0 0 4px rgba(37, 99, 235, .14);
}

label {
    display: grid;
    gap: 7px;
    color: #334155;
    font-weight: 750;
    font-size: 14px;
}

.card {
    border: 1px solid rgba(255,255,255,.50);
    background: var(--card);
    box-shadow: var(--shadow);
    backdrop-filter: blur(14px);
}

.hidden { display: none !important; }

.landing {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
}

.hero {
    width: min(1050px, 100%);
    border-radius: 34px;
    padding: clamp(24px, 4vw, 44px);
}

.brand-badge {
    display: inline-flex;
    gap: 8px;
    align-items: center;
    padding: 8px 12px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: white;
    font-weight: 900;
}

h1, h2, p { margin-top: 0; }
h1 { font-size: clamp(34px, 6vw, 72px); line-height: .96; letter-spacing: -0.06em; margin: 18px 0 14px; }
h2 { font-size: 22px; margin-bottom: 16px; }
.lead { font-size: clamp(17px, 2vw, 22px); color: var(--muted); max-width: 720px; }

.panels {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px;
    margin-top: 30px;
}

.panel {
    display: grid;
    gap: 14px;
    padding: 20px;
    border: 1px solid var(--line);
    border-radius: 24px;
    background: rgba(255,255,255,.64);
}

.primary {
    background: var(--primary);
    color: white;
    box-shadow: 0 12px 28px rgba(37, 99, 235, .25);
}
.primary:hover { background: var(--primary-dark); }
.secondary {
    background: #111827;
    color: white;
    box-shadow: 0 12px 28px rgba(17, 24, 39, .20);
}
.danger {
    background: var(--danger);
    color: white;
    box-shadow: 0 12px 28px rgba(220, 38, 38, .22);
}
.danger:hover { background: #b91c1c; }
.ghost {
    background: white;
    border: 1px solid var(--line);
    color: #0f172a;
}
.small { padding: 8px 10px; border-radius: 10px; font-size: 13px; }
.link { color: #1d4ed8; font-weight: 800; text-decoration: none; }

.message {
    padding: 12px 14px;
    border: 1px solid rgba(37, 99, 235, .20);
    border-radius: 16px;
    background: rgba(37, 99, 235, .08);
    color: #1e3a8a;
    font-weight: 750;
}
.message.error {
    background: rgba(220, 38, 38, .09);
    color: #991b1b;
    border-color: rgba(220, 38, 38, .25);
}
.hint { color: var(--muted); font-size: 13px; margin-bottom: 0; }

.app-shell {
    display: grid;
    grid-template-columns: 360px minmax(0, 1fr);
    gap: 20px;
    padding: 20px;
    min-height: 100vh;
}

.sidebar, .board-card {
    border-radius: 28px;
}
.sidebar {
    padding: 18px;
    display: flex;
    flex-direction: column;
    gap: 18px;
    align-self: start;
    position: sticky;
    top: 20px;
}

.top-row, .board-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}
.status-pill {
    border-radius: 999px;
    padding: 6px 10px;
    font-size: 12px;
    font-weight: 900;
    background: #fef3c7;
    color: #92400e;
}
.status-pill.ok { background: #dcfce7; color: #166534; }
.status-pill.err { background: #fee2e2; color: #991b1b; }

.room-code-box {
    display: grid;
    gap: 8px;
    padding: 16px;
    border-radius: 20px;
    border: 1px solid var(--line);
    background: white;
}
.room-code-box span { color: var(--muted); font-size: 13px; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; }
.room-code-box strong { font-size: 34px; letter-spacing: .14em; }

.players-list {
    display: grid;
    gap: 10px;
}
.player-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 10px;
    border: 1px solid var(--line);
    border-radius: 16px;
    background: white;
}
.player-left {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}
.player-name {
    font-weight: 900;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.color-dot {
    width: 18px;
    height: 18px;
    border-radius: 999px;
    border: 2px solid rgba(0,0,0,.18);
    flex: 0 0 auto;
}
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    border-radius: 999px;
    padding: 5px 8px;
    font-size: 12px;
    font-weight: 900;
    background: #f1f5f9;
    color: #475569;
    white-space: nowrap;
}
.badge.ready { background: #dcfce7; color: #166534; }
.badge.host { background: #e0e7ff; color: #3730a3; }

.actions-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
    margin-top: 12px;
}

.board-card {
    padding: 20px;
    min-width: 0;
}
.board-header h1 { font-size: 34px; margin: 0 0 4px; letter-spacing: -0.04em; }
.board-header p { margin: 0; color: var(--muted); font-weight: 750; }
.rules-chip {
    border: 1px solid var(--line);
    background: white;
    border-radius: 999px;
    padding: 9px 12px;
    color: #334155;
    font-size: 13px;
    font-weight: 900;
    white-space: nowrap;
}
.board {
    width: 100%;
    min-height: calc(100vh - 154px);
    display: grid;
    place-items: center;
    overflow: hidden;
}
.board svg {
    width: min(100%, 860px);
    height: auto;
    display: block;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.turn-info {
    display: grid;
    gap: 8px;
    padding: 12px;
    border-radius: 16px;
    background: white;
    border: 1px solid var(--line);
    font-weight: 800;
}

.dice-button {
    width: 100%;
    margin-top: 12px;
    background: linear-gradient(135deg, #ef4444, #f97316);
    color: white;
    font-size: 18px;
}
.dice-box {
    width: 78px;
    height: 78px;
    margin: 14px auto;
    display: grid;
    place-items: center;
    border-radius: 22px;
    border: 3px solid #111827;
    background: white;
    font-size: 42px;
    font-weight: 950;
    box-shadow: 0 14px 30px rgba(15, 23, 42, .17);
}

.piece {
    cursor: pointer;
    filter: drop-shadow(0 6px 7px rgba(0,0,0,.24));
    transition: transform .12s ease, filter .12s ease;
}
.piece.valid {
    stroke: #111827;
    stroke-width: 4;
    filter: drop-shadow(0 0 12px rgba(37, 99, 235, .65));
}
.piece.current { stroke: #111827; stroke-width: 3; }
.piece:hover { transform: scale(1.03); }
.track-cell { fill: rgba(255,255,255,.86); stroke: rgba(15,23,42,.24); stroke-width: 1.2; }
.track-cell.safe { fill: #fff7ed; stroke: #fb923c; stroke-width: 2; }
.track-cell.start { stroke-width: 3; }
.home-lane { opacity: .82; stroke: rgba(15,23,42,.24); stroke-width: 1.1; }
.player-base { opacity: .16; }
.center-goal { fill: white; stroke: rgba(15,23,42,.16); stroke-width: 2; }

@media (max-width: 980px) {
    .app-shell { grid-template-columns: 1fr; }
    .sidebar { position: static; }
    .board { min-height: 520px; }
    .panels { grid-template-columns: 1fr; }
    .board-header { align-items: flex-start; flex-direction: column; }
}

@media (max-width: 560px) {
    .landing, .app-shell { padding: 10px; }
    .hero, .sidebar, .board-card { border-radius: 22px; }
    .room-code-box strong { font-size: 26px; }
    .rules-chip { white-space: normal; }
}

.classic-base-area {
    stroke: rgba(15, 23, 42, .32);
    stroke-width: 1.5;
}
.classic-base-disc {
    stroke: #111827;
    stroke-width: 2.2;
    filter: drop-shadow(0 6px 8px rgba(15,23,42,.16));
}
.classic-base-ring {
    stroke: rgba(255, 255, 255, .82);
    stroke-width: 4;
}
.classic-home-slot {
    fill: rgba(255,255,255,.64);
    stroke: rgba(255,255,255,.92);
    stroke-width: 3;
}
.classic-track-cell,
.classic-lane-cell {
    stroke: rgba(15, 23, 42, .42);
    stroke-width: 1.15;
}
.classic-track-cell.start {
    stroke: #111827;
    stroke-width: 2.2;
}
.classic-track-cell.safe:not(.start) {
    filter: drop-shadow(0 1px 1px rgba(15,23,42,.10));
}
.classic-lane-cell {
    opacity: .94;
}
.classic-cell-number {
    user-select: none;
}
.classic-center-triangle {
    stroke: #111827;
    stroke-width: 1.3;
}

.sound-toggle {
    width: 100%;
}

.dice-box.rolling {
    animation: diceShake .55s ease-in-out infinite;
}

.dice-box.landed {
    animation: diceLand .38s ease-out 1;
}

@keyframes diceShake {
    0%, 100% { transform: translate(0, 0) rotate(0deg); }
    20% { transform: translate(-3px, 2px) rotate(-7deg); }
    40% { transform: translate(4px, -2px) rotate(6deg); }
    60% { transform: translate(-2px, -3px) rotate(4deg); }
    80% { transform: translate(3px, 2px) rotate(-5deg); }
}

@keyframes diceLand {
    0% { transform: scale(.86) rotate(-9deg); }
    60% { transform: scale(1.12) rotate(4deg); }
    100% { transform: scale(1) rotate(0deg); }
}

.piece-group {
    cursor: default;
    filter: drop-shadow(0 6px 7px rgba(0,0,0,.24));
}

.piece-group.valid {
    cursor: pointer;
    filter: drop-shadow(0 0 12px rgba(37, 99, 235, .65));
}

.piece-group.valid .piece {
    stroke: #111827;
    stroke-width: 4;
}

.piece-group.current .piece {
    stroke: #111827;
    stroke-width: 3;
}

.piece-group:hover .piece {
    transform: scale(1.05);
}

.piece-group .piece {
    cursor: inherit;
    transform-box: fill-box;
    transform-origin: center;
}
.piece-hit {
    pointer-events: all;
    cursor: inherit;
}
.piece-group.valid .piece-hit {
    fill: rgba(37, 99, 235, 0.001);
}
.piece-group.valid:focus-visible .piece,
.piece-group.valid:active .piece {
    transform: scale(1.08);
    filter: drop-shadow(0 0 12px rgba(37, 99, 235, .75));
}

.player-row.current-turn {
    border-color: color-mix(in srgb, var(--player-color) 72%, #111827 12%);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--player-color) 22%, transparent), 0 10px 24px rgba(15,23,42,.10);
}
.badge.turn {
    background: color-mix(in srgb, var(--player-color) 18%, #ffffff);
    color: #111827;
    border: 1px solid color-mix(in srgb, var(--player-color) 52%, #111827 10%);
}

#gameControls {
    --turn-color: #2563eb;
    padding: 14px;
    border: 2px solid color-mix(in srgb, var(--turn-color) 75%, #111827 10%);
    border-radius: 22px;
    background: linear-gradient(180deg, color-mix(in srgb, var(--turn-color) 14%, #ffffff), #ffffff 44%);
    box-shadow: 0 0 0 4px color-mix(in srgb, var(--turn-color) 18%, transparent), 0 18px 36px rgba(15, 23, 42, .12);
}
#gameControls.my-turn {
    animation: turnPulse 1.45s ease-in-out infinite;
}
#gameControls.other-turn {
    opacity: .96;
}
.turn-info {
    border-color: color-mix(in srgb, var(--turn-color) 42%, var(--line));
}
.turn-banner {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 10px;
    border-radius: 13px;
    border: 1px solid color-mix(in srgb, var(--turn-color) 42%, var(--line));
    background: color-mix(in srgb, var(--turn-color) 12%, #ffffff);
}
.turn-banner.mine {
    color: #14532d;
}
.turn-banner.waiting {
    color: #7f1d1d;
}
.turn-dot {
    width: 18px;
    height: 18px;
    border-radius: 999px;
    border: 2px solid rgba(15,23,42,.24);
    box-shadow: 0 0 0 3px rgba(255,255,255,.8);
    flex: 0 0 auto;
}
.dice-button {
    border: 2px solid transparent;
}
.dice-button.is-my-turn {
    background: linear-gradient(135deg, #16a34a, color-mix(in srgb, var(--turn-color) 82%, #16a34a));
    box-shadow: 0 13px 26px color-mix(in srgb, var(--turn-color) 28%, transparent), 0 0 0 4px rgba(22,163,74,.16);
}
.dice-button.is-waiting-turn {
    background: linear-gradient(135deg, #991b1b, #ef4444);
    color: #fff;
}
.dice-box {
    border-color: color-mix(in srgb, var(--turn-color) 80%, #111827);
    box-shadow: 0 14px 30px rgba(15, 23, 42, .17), 0 0 0 5px color-mix(in srgb, var(--turn-color) 18%, transparent);
}

@keyframes turnPulse {
    0%, 100% { box-shadow: 0 0 0 4px color-mix(in srgb, var(--turn-color) 18%, transparent), 0 18px 36px rgba(15, 23, 42, .12); }
    50% { box-shadow: 0 0 0 7px color-mix(in srgb, var(--turn-color) 26%, transparent), 0 22px 42px rgba(15, 23, 42, .16); }
}

.classic-start-arrow {
    user-select: none;
}

.extended-board-frame {
    filter: drop-shadow(0 12px 18px rgba(15,23,42,.14));
}
.extended-sector-bg {
    stroke: rgba(15,23,42,.30);
    stroke-width: 1.15;
    stroke-linejoin: round;
}
.extended-sector-divider {
    stroke: rgba(15,23,42,.24);
    stroke-width: 1.25;
    stroke-linecap: round;
}
.extended-home-wedge {
    stroke: #111827;
    stroke-width: 1.1;
}
.extended-center-hole {
    filter: none;
}

.extended-track-block {
    fill: #ffffff;
    stroke: #111827;
    stroke-width: 1.15;
    stroke-linejoin: round;
}

.extended-base-pad {
    opacity: 1;
    stroke: #111827;
    stroke-width: 1.15;
    stroke-linejoin: round;
}
.extended-base-disc {
    stroke: #111827;
    stroke-width: 2.1;
    filter: drop-shadow(0 7px 9px rgba(15,23,42,.18));
}
.extended-base-inner {
    stroke: rgba(15,23,42,.26);
    stroke-width: 1.1;
}
.extended-home-slot {
    fill: rgba(255,255,255,.70);
    stroke: rgba(255,255,255,.92);
    stroke-width: 2.4;
}
.extended-track-cell,
.extended-home-lane {
    stroke-linejoin: miter;
    filter: none;
}
.extended-track-cell {
}
.extended-track-cell.safe:not(.start) {
    filter: drop-shadow(0 1px 1px rgba(15,23,42,.10));
}
.extended-track-cell.start {
    filter: drop-shadow(0 3px 4px rgba(15,23,42,.18));
}
.extended-home-lane {
    opacity: .94;
}
.extended-center-triangle {
    stroke: #111827;
    stroke-width: 1.2;
    filter: drop-shadow(0 2px 3px rgba(15,23,42,.12));
}
.extended-safe-star,
.extended-start-arrow {
    user-select: none;
}

.move-preview {
    opacity: 0;
    transition: opacity .12s ease;
    pointer-events: none;
}
.move-preview.active {
    opacity: 1;
}
.move-preview-path {
    fill: none;
    stroke: rgba(37, 99, 235, .45);
    stroke-width: 6;
    stroke-linecap: round;
    stroke-linejoin: round;
}
.move-preview-step {
    fill: rgba(37, 99, 235, .16);
    stroke: rgba(37, 99, 235, .48);
    stroke-width: 2;
}
.move-preview-step.target {
    fill: rgba(34, 197, 94, .20);
    stroke: rgba(22, 163, 74, .72);
    stroke-width: 2.5;
}
.move-preview-ring {
    fill: none;
    stroke: rgba(22, 163, 74, .80);
    stroke-width: 3;
    stroke-dasharray: 5 4;
}

/* Dados dobles visuales */
.dice-box {
    width: min(100%, 218px);
    min-height: 116px;
    height: auto;
    padding: 12px;
    gap: 8px;
    grid-template-rows: auto auto;
    border-radius: 24px;
}

.dice-pair {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    flex-wrap: wrap;
}

.dice-pair.is-double .die-face {
    box-shadow: 0 10px 26px rgba(15, 23, 42, .18), 0 0 0 4px color-mix(in srgb, var(--turn-color) 24%, transparent);
}

.die-face {
    position: relative;
    width: 62px;
    height: 62px;
    border-radius: 15px;
    background: linear-gradient(145deg, #ffffff, #f1f5f9);
    border: 2px solid rgba(15, 23, 42, .86);
    box-shadow: inset 0 2px 0 rgba(255,255,255,.85), 0 8px 18px rgba(15, 23, 42, .14);
    flex: 0 0 auto;
}

.die-face.unknown {
    display: grid;
    place-items: center;
    color: #64748b;
    font-size: 26px;
    font-weight: 950;
}
.bonus-die {
    display: grid;
    place-items: center;
    align-content: center;
    gap: 2px;
    background: linear-gradient(145deg, #fef3c7, #ffffff);
    border-color: #92400e;
}
.bonus-die strong {
    font-size: 20px;
    line-height: 1;
    color: #78350f;
}
.bonus-die small {
    font-size: 9px;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: #92400e;
    font-weight: 950;
}

.pip {
    position: absolute;
    width: 10px;
    height: 10px;
    border-radius: 999px;
    background: #111827;
    box-shadow: inset 0 1px 1px rgba(255,255,255,.22);
}

.pip.tl { left: 13px; top: 13px; }
.pip.tr { right: 13px; top: 13px; }
.pip.ml { left: 13px; top: 26px; }
.pip.mr { right: 13px; top: 26px; }
.pip.c { left: 50%; top: 50%; transform: translate(-50%, -50%); }
.pip.bl { left: 13px; bottom: 13px; }
.pip.br { right: 13px; bottom: 13px; }

.dice-total {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 24px;
    font-size: 15px;
    line-height: 1;
    font-weight: 950;
    color: #0f172a;
}

.double-chip {
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    padding: 5px 8px;
    background: color-mix(in srgb, var(--turn-color) 18%, #ffffff);
    border: 1px solid color-mix(in srgb, var(--turn-color) 48%, #111827 10%);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .05em;
}

.identity-banner {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) minmax(0, 1fr);
    align-items: center;
    gap: 10px;
    padding: 10px;
    border-radius: 14px;
    background: linear-gradient(135deg, color-mix(in srgb, var(--my-color) 18%, #ffffff), #ffffff 65%);
    border: 1px solid color-mix(in srgb, var(--my-color) 48%, var(--line));
    box-shadow: inset 0 0 0 1px rgba(255,255,255,.7);
}

.identity-banner span:not(.turn-dot) {
    display: block;
    font-size: 11px;
    line-height: 1.1;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: .06em;
    font-weight: 950;
}

.identity-banner strong {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 14px;
}

@media (max-width: 520px) {
    .identity-banner {
        grid-template-columns: auto 1fr;
    }
    .identity-banner > div:last-child {
        grid-column: 2;
    }
    .die-face {
        width: 54px;
        height: 54px;
        border-radius: 13px;
    }
    .pip.tl { left: 11px; top: 11px; }
    .pip.tr { right: 11px; top: 11px; }
    .pip.ml { left: 11px; top: 22px; }
    .pip.mr { right: 11px; top: 22px; }
    .pip.bl { left: 11px; bottom: 11px; }
    .pip.br { right: 11px; bottom: 11px; }
}

.player-row {
    display: grid;
    grid-template-columns: 1fr;
}
.player-main-line {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}
.player-progress {
    width: 100%;
    margin-top: 8px;
}
.progress-label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 5px;
    font-size: 11px;
    line-height: 1.1;
    font-weight: 900;
    color: #64748b;
}
.progress-label strong {
    color: #0f172a;
}
.progress-detail {
    margin: -1px 0 5px;
    color: #94a3b8;
    font-size: 10px;
    font-weight: 850;
    line-height: 1.2;
    word-break: break-word;
}
.progress-bar {
    width: 100%;
    height: 7px;
    border-radius: 999px;
    background: #e2e8f0;
    overflow: hidden;
    border: 1px solid rgba(15,23,42,.08);
}
.progress-bar span {
    display: block;
    height: 100%;
    border-radius: inherit;
    background: var(--player-color);
    box-shadow: 0 0 10px color-mix(in srgb, var(--player-color) 50%, transparent);
}

.die-face.selectable {
    cursor: pointer;
    outline: 3px solid color-mix(in srgb, var(--turn-color) 28%, transparent);
    outline-offset: 3px;
}
.die-face.selectable:hover {
    transform: translateY(-2px) scale(1.04);
}
.die-face.selected {
    outline: 4px solid color-mix(in srgb, var(--turn-color) 82%, #111827 8%);
    box-shadow: inset 0 2px 0 rgba(255,255,255,.85), 0 10px 24px rgba(15,23,42,.18), 0 0 0 6px color-mix(in srgb, var(--turn-color) 20%, transparent);
}
.die-face.used {
    opacity: .34;
    filter: grayscale(.7);
}
.dice-remaining {
    font-size: 12px;
    font-weight: 900;
    color: #475569;
    text-align: center;
}

/* Selector de color */
.color-select {
    --selected-color: #64748b;
    border-left: 12px solid var(--selected-color);
    font-weight: 850;
}
.color-select option:disabled {
    color: #94a3b8;
}

/* Tablero más adaptable a PC, tablet y móvil */
.app-shell {
    grid-template-columns: minmax(300px, 360px) minmax(0, 1fr);
    align-items: start;
}
.board-card {
    overflow: hidden;
}
.board {
    --board-max: min(100%, calc(100vh - 145px));
    min-height: min(760px, calc(100vh - 145px));
    overflow: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-x pan-y pinch-zoom;
}
.board svg {
    width: min(100%, 960px, calc(100vh - 150px));
    max-height: calc(100vh - 150px);
    height: auto;
}

@media (min-width: 1500px) {
    .app-shell {
        grid-template-columns: 380px minmax(0, 1fr);
    }
    .board svg {
        width: min(100%, 1060px, calc(100vh - 130px));
        max-height: calc(100vh - 130px);
    }
}

@media (max-width: 980px) {
    .app-shell {
        grid-template-columns: 1fr;
        gap: 12px;
        padding: 12px;
    }
    .sidebar {
        position: static;
        top: auto;
    }
    .board-card {
        padding: 12px;
    }
    .board {
        min-height: min(92vw, 760px);
        align-items: start;
        padding: 6px 0;
    }
    .board svg {
        width: min(100%, 94vh);
        max-height: none;
    }
}

@media (max-width: 640px) {
    .panels {
        grid-template-columns: 1fr;
    }
    .board-header {
        gap: 8px;
    }
    .board-header h1 {
        font-size: 26px;
    }
    .board-header p,
    .rules-chip {
        font-size: 12px;
    }
    .board {
        min-height: 88vw;
        place-items: start center;
    }
    .board svg {
        width: 100%;
        min-width: 0;
    }
    .sidebar,
    .board-card {
        border-radius: 18px;
    }
}

.dice-combo-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 2px;
}

.combo-die {
    width: auto;
    min-width: 108px;
    height: 48px;
    display: grid;
    place-items: center;
    align-content: center;
    gap: 1px;
    padding: 6px 10px;
    background: linear-gradient(145deg, #dcfce7, #ffffff);
    border-color: #166534;
}

.combo-die strong {
    font-size: 15px;
    line-height: 1;
    color: #14532d;
}

.combo-die small {
    font-size: 9px;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: #166534;
    font-weight: 950;
}

.die-face.selectable {
    cursor: pointer;
}

.die-face.selectable.selected,
.combo-die.selected {
    outline: 3px solid color-mix(in srgb, var(--turn-color) 70%, #111827 10%);
    outline-offset: 3px;
    transform: translateY(-2px);
}

/* Interacción táctil estable: el SVG no debe comerse el scroll de la página ni provocar doble toque. */
.board svg {
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}


/* Refinado tablero ampliado basado en referencia 6/8 jugadores */
.extended-track-block { fill: #ffffff; stroke: #111827; stroke-width: 1.15; stroke-linejoin: round; }
.extended-base-pad { opacity: 1; stroke: #111827; stroke-width: 1.15; stroke-linejoin: round; }
.extended-home-wedge { stroke: #111827; stroke-width: 1.1; }
.extended-center-hole { filter: none; }
.extended-track-cell, .extended-home-lane { stroke-linejoin: miter; filter: none; }
.extended-home-slot { fill: rgba(255,255,255,.18); stroke: rgba(15,23,42,.26); stroke-width: .8; }


/* Triangulos laterales y de entrada a meta mas parecidos a la referencia */
.extended-base-pad, .extended-home-wedge { stroke-linejoin: miter; }

/* Refuerzo visual para paneles numericos y triangulos */
.extended-track-block, .extended-base-pad, .extended-home-wedge { stroke-linejoin: miter; }

/* Las casillas protegidas ampliadas usan el fill/stroke inline calculado en JS. */
.extended-track-cell.safe, .extended-track-cell.start { filter: drop-shadow(0 1px 1px rgba(15,23,42,.14)); }

/* Las casillas protegidas clásicas usan fill/stroke inline calculado en JS. */
.classic-track-cell.safe, .classic-track-cell.start { filter: drop-shadow(0 1px 1px rgba(15,23,42,.14)); }

/* Tablero clásico con grid rectangular tipo tablero físico de referencia. */
.classic-track-cell,
.classic-lane-cell {
    shape-rendering: crispEdges;
}
.classic-cell-number,
.classic-start-arrow,
.classic-safe-star {
    dominant-baseline: central;
    alignment-baseline: central;
}

/* Ajuste fino de numeración clásica: alineación derecha y orientación por tramo. */
.classic-cell-number {
    dominant-baseline: central;
    alignment-baseline: central;
}
.classic-start-arrow {
    fill: #64748b;
}

/* Carriles de llegada: siempre coloreados y visibles en las 7 casillas. */
.classic-lane-cell,
.extended-home-lane {
    stroke: #111827;
    stroke-width: 1.05;
    shape-rendering: crispEdges;
}

/* Ajuste de numeración interior junto a la meta. */
.classic-cell-number {
    letter-spacing: 0;
}

/* Corrección: los números interiores rotados quedan dentro de la celda. */
.classic-cell-number {
    overflow: visible;
}

/* Corrección: numeración 18-25 y 52-59 a izquierda-centro. */
.classic-cell-number {
    dominant-baseline: central;
    alignment-baseline: central;
}

/* Ajuste: 18-25 y 52-59 en centro-izquierda. */
.classic-cell-number {
    dominant-baseline: central;
    alignment-baseline: central;
}

/* 18-25 y 52-59: izquierda horizontal + centro vertical dentro de la celda. */
.classic-cell-number {
    dominant-baseline: central;
    alignment-baseline: central;
}

/* 18-25 y 52-59: centrados horizontalmente y arriba dentro de la celda. */
.classic-cell-number { dominant-baseline: central; alignment-baseline: central; }

/* Ajuste fino: 52-59 con margen superior y 18-25 igual que 43-50. */
.classic-cell-number {
    dominant-baseline: central;
    alignment-baseline: central;
}

/* Ajuste fino: 18-25 y 52-59 mantienen alineación de referencia con lectura invertida. */
.classic-cell-number {
    dominant-baseline: central;
    alignment-baseline: central;
}

/* Ajuste fino: separación extra respecto a la línea de celda en 18-25 y 52-59. */
.classic-cell-number {
    dominant-baseline: central;
    alignment-baseline: central;
}

/* Ajuste fino: más margen en 18-25 y 52-59; más separación entre fichas apiladas. */
.classic-cell-number {
    dominant-baseline: central;
    alignment-baseline: central;
}

/* Ajuste fino: +5px de separación en 18-25 y 52-59 respecto a la línea de celda. */
.classic-cell-number {
    dominant-baseline: central;
    alignment-baseline: central;
}

/* Casas del tablero clásico: círculos de color un 20% más grandes. */
.classic-base-disc,
.classic-base-ring {
    shape-rendering: geometricPrecision;
}

/* Casas del tablero clásico: círculos y contenido interno otro 20% más grandes. */
.classic-base-disc,
.classic-base-ring,
.classic-home-slot {
    shape-rendering: geometricPrecision;
}

/* Texto del color dentro del círculo de casa: +50%. */
.classic-base-area + .classic-base-disc + .classic-base-ring {
    shape-rendering: geometricPrecision;
}

/* Fix: animación también para jugadores observadores; no cambia estilos visuales. */

/* Fix v2: animación robusta también en clientes observadores. */

/* Motor de movimiento v3: ficha temporal durante la animación de cualquier jugador. */
.piece-group-temp {
    pointer-events: none;
}
.piece-group-temp .piece {
    filter: drop-shadow(0 5px 8px rgba(15, 23, 42, .35));
}

/* Motor v4: animación por diferencia de render para fichas locales y remotas. */
.piece-group {
    will-change: transform;
}


.variant-settings {
    margin: 16px 0;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 18px;
    background: rgba(255,255,255,.72);
}

.variant-settings h3 {
    margin: 0 0 6px;
    font-size: 16px;
}

.variant-grid {
    display: grid;
    gap: 8px;
    max-height: 360px;
    overflow: auto;
    padding-right: 4px;
}

.variant-toggle {
    display: grid;
    grid-template-columns: 48px 1fr;
    gap: 12px;
    align-items: center;
    padding: 10px;
    border: 1px solid rgba(15,23,42,.10);
    border-radius: 14px;
    background: rgba(248,250,252,.85);
    cursor: pointer;
}

.variant-switch-input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.variant-switch {
    width: 46px;
    height: 26px;
    border-radius: 999px;
    background: #cbd5e1;
    border: 1px solid rgba(15,23,42,.16);
    position: relative;
    box-shadow: inset 0 1px 2px rgba(15,23,42,.12);
    transition: background .18s ease, border-color .18s ease, box-shadow .18s ease;
}

.variant-switch::after {
    content: '';
    position: absolute;
    top: 3px;
    left: 3px;
    width: 18px;
    height: 18px;
    border-radius: 999px;
    background: #ffffff;
    box-shadow: 0 2px 7px rgba(15,23,42,.28);
    transition: transform .18s ease;
}

.variant-switch-input:checked + .variant-switch {
    background: var(--primary);
    border-color: var(--primary-dark);
    box-shadow: inset 0 1px 2px rgba(15,23,42,.18), 0 0 0 3px rgba(37,99,235,.12);
}

.variant-switch-input:checked + .variant-switch::after {
    transform: translateX(20px);
}

.variant-switch-input:focus-visible + .variant-switch {
    outline: 3px solid rgba(37,99,235,.28);
    outline-offset: 2px;
}

.variant-toggle-text {
    display: grid;
    gap: 2px;
}

.variant-toggle strong {
    font-size: 13px;
    color: #0f172a;
}

.variant-toggle small {
    font-size: 12px;
    line-height: 1.25;
    color: #64748b;
}

/* Corrección de sala: evita saltos visuales al re-renderizar por polling. */
.sidebar,
.board-card,
.variant-grid {
    overflow-anchor: none;
}

/* Render parcial: el polling ya no reconstruye secciones sin cambios. */


.rules-card {
    margin-top: 24px;
    padding: clamp(18px, 3vw, 26px);
    border: 1px solid var(--line);
    border-radius: 26px;
    background: rgba(255,255,255,.72);
}

.rules-header {
    display: grid;
    gap: 8px;
    margin-bottom: 18px;
}

.rules-kicker {
    width: fit-content;
    padding: 6px 10px;
    border-radius: 999px;
    background: rgba(37,99,235,.10);
    color: #1d4ed8;
    font-size: 12px;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: .04em;
}

.rules-card h2 {
    margin: 0;
}

.rules-card h3 {
    margin: 0 0 6px;
    font-size: 15px;
}

.rules-card p {
    margin-bottom: 0;
    color: #475569;
}

.rules-card a {
    color: #1d4ed8;
    font-weight: 850;
    text-decoration: none;
}

.rules-card a:hover {
    text-decoration: underline;
}

.rules-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
}

.rules-grid article {
    padding: 14px;
    border: 1px solid rgba(15,23,42,.10);
    border-radius: 18px;
    background: rgba(248,250,252,.86);
}

.rules-source {
    margin-top: 14px;
    font-size: 13px;
}

@media (max-width: 820px) {
    .rules-grid {
        grid-template-columns: 1fr;
    }
}


.score-board-box {
    margin-top: 14px;
}

.score-final-card {
    border: 1px solid rgba(15,23,42,.12);
    border-radius: 18px;
    background: rgba(248,250,252,.92);
    padding: 14px;
    overflow-x: auto;
}

.score-final-header {
    display: flex;
    align-items: start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
}

.score-final-header h3 {
    margin: 4px 0 0;
    font-size: 18px;
}

.score-final-header strong {
    white-space: nowrap;
    color: #0f172a;
    font-size: 13px;
}

.score-kicker {
    display: inline-flex;
    padding: 5px 9px;
    border-radius: 999px;
    background: rgba(22,163,74,.11);
    color: #15803d;
    font-size: 11px;
    font-weight: 950;
    text-transform: uppercase;
    letter-spacing: .04em;
}

.score-final-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.score-final-table th,
.score-final-table td {
    padding: 9px 8px;
    border-top: 1px solid rgba(15,23,42,.10);
    text-align: left;
    vertical-align: middle;
}

.score-final-table th {
    color: #64748b;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .04em;
}

.score-final-table tr.winner {
    background: rgba(250,204,21,.16);
}

.score-final-table td strong {
    display: block;
    font-size: 14px;
}

.score-final-table td small {
    display: block;
    color: #64748b;
    margin-top: 2px;
}

.score-color-dot {
    display: inline-block;
    width: 11px;
    height: 11px;
    border-radius: 999px;
    margin-right: 6px;
    vertical-align: -1px;
    box-shadow: 0 0 0 2px rgba(255,255,255,.85);
}

@media (max-width: 720px) {
    .score-final-header {
        display: grid;
    }

    .score-final-table {
        min-width: 560px;
    }
}

/* Fix: evita reinicios de animación y desbloquea controles tras dobles sin F5. */

/* Selección manual de dado: el jugador elige dado y luego ficha. */
.die-face.selectable {
    cursor: pointer;
}

.die-face.selected {
    outline: 4px solid var(--turn-color, #2563eb);
    outline-offset: 3px;
    transform: translateY(-2px) scale(1.04);
    box-shadow: 0 14px 30px rgba(37,99,235,.28), 0 0 0 5px rgba(255,255,255,.90);
}

.turn-info strong {
    font-weight: 950;
}

/* Popup de aviso para movimientos no permitidos. */
.rule-popup {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: grid;
    place-items: start center;
    padding: 18px;
    pointer-events: none;
}

.rule-popup.hidden {
    display: none;
}

.rule-popup-card {
    width: min(430px, calc(100vw - 28px));
    margin-top: 16px;
    padding: 18px 18px 16px;
    border-radius: 22px;
    border: 1px solid rgba(220,38,38,.28);
    background: rgba(255,255,255,.97);
    box-shadow: 0 24px 80px rgba(15,23,42,.30);
    pointer-events: auto;
    animation: rulePopupIn .18s ease-out;
}

.rule-popup-card h3 {
    margin: 0 34px 8px 0;
    font-size: 18px;
    color: #991b1b;
}

.rule-popup-card p {
    margin: 0;
    color: #334155;
    line-height: 1.35;
}

.rule-popup-close {
    float: right;
    width: 30px;
    height: 30px;
    padding: 0;
    border-radius: 999px;
    background: #fee2e2;
    color: #991b1b;
    font-size: 22px;
    line-height: 1;
    box-shadow: none;
}

.piece-group.invalid-clickable {
    cursor: not-allowed;
    opacity: .88;
}

.piece-group.invalid-clickable .piece {
    stroke: rgba(220,38,38,.72);
    stroke-width: 2.3;
}

.piece-group.invalid-clickable:hover .piece {
    filter: drop-shadow(0 0 8px rgba(220,38,38,.45));
}

@keyframes rulePopupIn {
    from {
        opacity: 0;
        transform: translateY(-10px) scale(.98);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Los dados pendientes siempre son seleccionables; el popup explica por qué una ficha no puede moverse. */
.die-face.selectable {
    opacity: 1;
    cursor: pointer;
}
.die-face.selectable.blocked {
    opacity: 1;
}

/* Fix: los dados pendientes deben poder seleccionarse sin F5. */
#diceBox .die-face.selectable,
#diceBox .die-face.selectable.used,
#diceBox .die-face.selectable.blocked {
    opacity: 1 !important;
    filter: none !important;
    pointer-events: auto !important;
    cursor: pointer !important;
}

#diceBox .die-face[aria-disabled="false"] {
    opacity: 1 !important;
    filter: none !important;
    pointer-events: auto !important;
}

/* Fix visual: tras tirar, los dados pendientes nunca deben quedarse grises. */
#diceBox .die-face.selectable,
#diceBox .die-face.selectable.used,
#diceBox .die-face.selectable.blocked,
#diceBox .die-face[aria-disabled="false"] {
    opacity: 1 !important;
    filter: none !important;
    pointer-events: auto !important;
    cursor: pointer !important;
}

#diceBox .die-face.selectable {
    outline: 3px solid color-mix(in srgb, var(--turn-color, #2563eb) 28%, transparent);
    outline-offset: 3px;
}

/* Animación estable de ficha: overlay visual sin redibujar el tablero ni bloquear controles. */
.stable-move-piece {
    pointer-events: none;
    filter: drop-shadow(0 10px 14px rgba(15,23,42,.34));
}
.stable-move-piece .piece {
    stroke-width: 2.6;
}

/* Mensaje específico cuando hay que sacar ficha de casa con 5 antes de usar otro dado. */

/* Meta: fichas finales separadas por color y por ficha para evitar solapes entre jugadores. */
.piece-group[data-piece] {
    transform-box: fill-box;
}


/* Resultado final: popup/modal, no panel lateral. */
.final-score-popup {
    position: fixed;
    inset: 0;
    z-index: 10020;
    display: grid;
    place-items: center;
    padding: 18px;
    background: rgba(15, 23, 42, .52);
    backdrop-filter: blur(5px);
}

.final-score-popup.hidden {
    display: none;
}

.final-score-modal {
    position: relative;
    width: min(980px, calc(100vw - 28px));
    max-height: min(86vh, 820px);
    overflow: auto;
    border-radius: 28px;
    border: 1px solid rgba(255,255,255,.36);
    background: rgba(255,255,255,.98);
    box-shadow: 0 32px 110px rgba(15,23,42,.40);
    padding: clamp(16px, 2.4vw, 28px);
    animation: finalScoreModalIn .18s ease-out;
}

.final-score-close {
    position: sticky;
    top: 0;
    float: right;
    z-index: 2;
    width: 38px;
    height: 38px;
    padding: 0;
    border-radius: 999px;
    background: #fee2e2;
    color: #991b1b;
    font-size: 28px;
    line-height: 1;
    box-shadow: 0 8px 22px rgba(15,23,42,.16);
}

.final-score-titlebar {
    margin: 0 48px 16px 0;
    display: grid;
    gap: 7px;
}

.final-score-titlebar h2 {
    margin: 0;
    font-size: clamp(24px, 4vw, 38px);
}

.final-score-titlebar p {
    margin: 0;
    color: #475569;
}

.final-score-popup .score-final-card {
    margin-top: 8px;
    background: rgba(248,250,252,.96);
}

@keyframes finalScoreModalIn {
    from {
        opacity: 0;
        transform: translateY(12px) scale(.985);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@media (max-width: 720px) {
    .final-score-popup {
        padding: 10px;
        place-items: end center;
    }

    .final-score-modal {
        width: 100%;
        max-height: 90vh;
        border-radius: 24px 24px 0 0;
    }
}

/* Resultado final simplificado: sin fórmula de puntos ni columna Detalle. */
.final-score-titlebar {
    margin-bottom: 18px;
}

.score-final-header {
    margin-bottom: 10px;
}


/* Tablero ampliado 5-8: geometría tipo referencia, sin huecos blancos y con casas fuera del paso. */
.extended-board-frame {
    filter: drop-shadow(0 18px 28px rgba(15,23,42,.16));
}

.extended-base-pad {
    stroke: #111827;
    stroke-width: 1.35;
    stroke-linejoin: round;
}

.extended-track-block {
    fill: rgba(255,255,255,.96);
    stroke: #111827;
    stroke-width: 1.45;
    stroke-linejoin: round;
}

.extended-track-cell,
.extended-home-lane {
    stroke: #111827;
    stroke-width: 1.18;
    shape-rendering: geometricPrecision;
}

.extended-center-hole {
    fill: #d1d5db;
    stroke: #111827;
    stroke-width: 1.25;
}

.extended-home-slot {
    fill: rgba(255,255,255,.88);
    stroke: #111827;
    stroke-width: 1.4;
}

.extended-home-player-label {
    letter-spacing: .01em;
}


/* Tablero por imagen calibrada: fase 1 para 8 jugadores. */
.image-board {
    position: relative;
    width: min(100%, calc(100vh - 145px));
    max-width: 100%;
    aspect-ratio: var(--image-board-ratio, 1 / 1);
    margin: 0 auto;
    overflow: visible;
    border-radius: 18px;
}

.image-board > img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    user-select: none;
    pointer-events: none;
    -webkit-user-drag: none;
}

.image-board > .piece-layer {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    overflow: visible;
}

.image-board .piece-group .piece {
    stroke-width: 3;
}


/* Tableros por imagen de 5 a 8 jugadores */
.image-board > img {
    border-radius: 18px;
}


.reenter-box {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    margin-top: 18px;
    padding: 18px 20px;
    border: 1px solid var(--line);
    border-radius: 22px;
    background: rgba(255,255,255,.78);
}

.reenter-box p {
    margin: 6px 0 0;
}

.reenter-box .hint {
    font-size: 13px;
    color: var(--muted);
}

@media (max-width: 720px) {
    .reenter-box {
        align-items: stretch;
        flex-direction: column;
    }
}


/* Aviso de cookies técnicas, apoyo y banners propios */
.support-hero-banner,
.support-side-banner,
.cookie-policy-mini {
    border: 1px solid rgba(15, 23, 42, .12);
    background: linear-gradient(135deg, rgba(254, 243, 199, .86), rgba(219, 234, 254, .82));
    border-radius: 22px;
    box-shadow: 0 18px 42px rgba(15, 23, 42, .10);
}

.support-hero-banner {
    display: grid;
    grid-template-columns: minmax(160px, 300px) 1fr auto;
    gap: 18px;
    align-items: center;
    padding: 14px;
    margin: 22px 0 6px;
}

.support-hero-banner img {
    width: 100%;
    max-width: 300px;
    border-radius: 18px;
    display: block;
}

.support-hero-text {
    display: grid;
    gap: 5px;
}

.support-hero-text strong {
    font-size: clamp(1rem, 2vw, 1.28rem);
    color: #0f172a;
}

.support-hero-text span {
    color: #475569;
    font-weight: 700;
}

.support-hero-actions,
.support-side-actions,
.room-code-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

.cookie-policy-mini {
    margin-top: 18px;
    padding: 18px;
}

.cookie-policy-mini h2 {
    margin: 0 0 8px;
    font-size: 1.08rem;
}

.cookie-policy-mini p {
    margin: 0;
    color: #475569;
    line-height: 1.55;
}

.support-side-banner {
    display: grid;
    grid-template-columns: 76px 1fr;
    gap: 12px;
    padding: 12px;
    margin: 12px 0 16px;
}

.support-side-banner img {
    width: 76px;
    height: 76px;
    object-fit: cover;
    border-radius: 16px;
}

.support-side-banner strong {
    color: #0f172a;
}

.support-side-banner p {
    margin: 4px 0 8px;
    font-size: .86rem;
    color: #475569;
}

.room-code-box strong#roomCodeText {
    cursor: pointer;
    user-select: all;
}

.support-notice {
    position: fixed;
    inset: auto 16px 16px auto;
    width: min(560px, calc(100vw - 32px));
    z-index: 9999;
}

.support-notice.hidden {
    display: none;
}

.support-notice-card {
    position: relative;
    border: 1px solid rgba(15, 23, 42, .16);
    border-radius: 24px;
    background: rgba(255, 255, 255, .96);
    box-shadow: 0 28px 70px rgba(15, 23, 42, .24);
    padding: 22px;
    backdrop-filter: blur(12px);
}

.support-notice-close {
    position: absolute;
    top: 10px;
    right: 12px;
    border: 0;
    background: rgba(15, 23, 42, .06);
    width: 32px;
    height: 32px;
    border-radius: 999px;
    font-size: 22px;
    line-height: 28px;
    cursor: pointer;
}

.support-notice-kicker {
    display: inline-flex;
    width: fit-content;
    border-radius: 999px;
    padding: 5px 10px;
    background: rgba(34, 197, 94, .14);
    color: #166534;
    font-weight: 900;
    font-size: .78rem;
    margin-bottom: 10px;
}

.support-notice-card h2 {
    margin: 0 32px 10px 0;
    font-size: 1.2rem;
    color: #0f172a;
}

.support-notice-card p {
    margin: 0 0 10px;
    color: #475569;
    line-height: 1.48;
}

.support-notice-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 14px;
}

.danger-text {
    color: #b91c1c !important;
}

.legal-page .hero {
    max-width: 1080px;
}

.support-page-banner {
    grid-template-columns: minmax(180px, 360px) 1fr;
}

@media (max-width: 760px) {
    .support-hero-banner {
        grid-template-columns: 1fr;
    }

    .support-hero-banner img {
        max-width: none;
    }

    .support-notice {
        inset: auto 10px 10px 10px;
        width: auto;
    }

    .support-notice-card {
        padding: 18px;
    }
}


/* Reentrar sala destacado sobre crear partida */
.reenter-box {
    margin: 18px 0 18px;
    background: linear-gradient(135deg, rgba(236, 252, 203, .94), rgba(217, 249, 157, .82));
    border-color: rgba(101, 163, 13, .34);
    box-shadow: 0 18px 42px rgba(77, 124, 15, .14);
}

.reenter-box strong {
    color: #365314;
}

#reenterRoomBtn {
    background: #a3e635;
    color: #1a2e05;
    border-color: #65a30d;
    box-shadow: 0 12px 26px rgba(101, 163, 13, .28);
    font-weight: 950;
}

#reenterRoomBtn:hover {
    background: #84cc16;
    color: #ffffff;
    transform: translateY(-1px);
}

#reenterRoomBtn:focus-visible {
    outline: 3px solid rgba(132, 204, 22, .45);
    outline-offset: 2px;
}


/* Adsterra: slots no intrusivos */
.adsterra-slot {
    width: min(100%, var(--ad-width, 728px));
    min-height: var(--ad-height, 90px);
    margin: 18px auto;
    padding: 8px;
    border: 1px solid rgba(15, 23, 42, .10);
    border-radius: 18px;
    background: rgba(255, 255, 255, .76);
    box-shadow: 0 14px 34px rgba(15, 23, 42, .08);
    display: grid;
    justify-items: center;
    align-items: center;
    overflow: hidden;
}

.adsterra-inner {
    width: min(100%, var(--ad-width, 728px));
    min-height: var(--ad-height, 90px);
    display: grid;
    place-items: center;
    overflow: hidden;
}

.adsterra-label {
    display: block;
    justify-self: start;
    margin: 0 0 5px 4px;
    color: #64748b;
    font-size: 10px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: .08em;
}

.adsterra-sidebar-zone {
    --ad-width: 300px;
    --ad-height: 250px;
    margin: 12px auto 16px;
}

.adsterra-game-bottom-zone,
.adsterra-global-bottom {
    max-width: 760px;
}

@media (max-width: 820px) {
    .adsterra-slot {
        transform-origin: top center;
        width: 100%;
    }

    .adsterra-inner {
        transform-origin: top center;
        max-width: 100%;
    }
}


/* Adsterra visible: mantener el hueco de banner aunque tarde en cargar */
.adsterra-slot::after {
    content: " ";
    display: block;
    min-height: 1px;
}

.adsterra-home-top {
    margin-top: 16px;
    margin-bottom: 18px;
}


/* Sustitución de publicidad por apoyo comunitario */
.adsterra-fallback {
    width: min(100%, var(--ad-width, 728px));
    min-height: var(--ad-height, 90px);
    display: grid;
    grid-template-columns: minmax(150px, 260px) 1fr auto;
    align-items: center;
    gap: 12px;
    padding: 10px;
    border-radius: 16px;
    background: linear-gradient(135deg, rgba(254, 243, 199, .92), rgba(219, 234, 254, .86));
}

.adsterra-fallback img {
    width: 100%;
    max-height: 86px;
    object-fit: cover;
    border-radius: 14px;
}

.adsterra-fallback-text {
    display: grid;
    gap: 3px;
    color: #334155;
    font-size: .86rem;
    line-height: 1.25;
}

.adsterra-fallback-text strong {
    color: #0f172a;
    font-size: .98rem;
}

.adsterra-slot.adsterra-loaded .adsterra-label::after {
    content: " · Adsterra";
}

.adsterra-slot.adsterra-fallback-active .adsterra-label::after {
    content: " · apoyo comunitario";
}

.adsterra-slot.adsterra-loading .adsterra-label::after {
    content: " · cargando";
}

@media (max-width: 760px) {
    .adsterra-fallback {
        grid-template-columns: 1fr;
        text-align: center;
    }

    .adsterra-fallback img {
        max-height: 110px;
    }
}


/* Pie de página común */
.site-footer {
    width: min(1120px, calc(100% - 32px));
    margin: 22px auto 18px;
    padding: 14px 18px;
    text-align: center;
    color: #64748b;
    font-size: .92rem;
    font-weight: 800;
}

.app-shell + .site-footer {
    margin-top: 12px;
}

.legal-page + .site-footer,
.landing + .site-footer {
    margin-top: 18px;
}


/* Tablero clásico orientado por jugador:
   cada usuario ve su color abajo a la derecha. */
.classic-board-svg {
    transform: rotate(var(--classic-board-rotation, 0deg));
    transform-origin: 50% 50%;
    transform-box: fill-box;
    transition: transform .22s ease;
}

@media (prefers-reduced-motion: reduce) {
    .classic-board-svg {
        transition: none;
    }
}


/* Rotación clásica real aplicada con un grupo SVG, no con CSS sobre el <svg>.
   Esto evita que algunos navegadores ignoren o interpreten mal la rotación. */
.classic-board-svg {
    transform: none !important;
}

.classic-board-view {
    transform-origin: 50% 50%;
}


/* Rotación clásica por coordenadas:
   se recolocan casillas/fichas/casas en JS, sin depender de CSS transform. */
.classic-coordinate-rotated {
    transform: none !important;
}


/* Rotación visual del tablero clásico sin recalcular casillas:
   mantiene intactos números, tamaños y coordenadas internas. */
.board .classic-board-rotator {
    width: min(100%, 860px);
    margin: 0 auto;
    display: block;
    transform: rotate(var(--classic-board-rotation, 0deg));
    transform-origin: 50% 50%;
    transition: transform .18s ease;
}

.board .classic-board-rotator > svg.classic-board-svg {
    width: 100%;
    height: auto;
    display: block;
    transform: none !important;
}

@media (prefers-reduced-motion: reduce) {
    .board .classic-board-rotator {
        transition: none;
    }
}




/* Sin contorno blanco añadido: colores y textos como en la versión anterior */
.classic-player-label.keep-horizontal,
.piece-number.keep-horizontal {
    paint-order: normal;
    stroke: none;
    stroke-width: 0;
}


/* Notificaciones de partida centradas */
.game-notice-center {
    position: fixed;
    inset: 0;
    z-index: 9998;
    display: grid;
    place-items: center;
    pointer-events: none;
    padding: 24px;
}

.game-notice-card {
    min-width: min(420px, calc(100vw - 48px));
    max-width: min(560px, calc(100vw - 48px));
    padding: 20px 24px;
    border-radius: 24px;
    text-align: center;
    color: #0f172a;
    background: rgba(255, 255, 255, .96);
    border: 2px solid rgba(15, 23, 42, .12);
    box-shadow: 0 24px 70px rgba(15, 23, 42, .28);
    transform: translateY(0) scale(1);
    animation: gameNoticePop .22s ease-out both;
}

.game-notice-card strong {
    display: block;
    font-size: clamp(1.35rem, 4vw, 2rem);
    line-height: 1.1;
    font-weight: 950;
}

.game-notice-card span {
    display: block;
    margin-top: 8px;
    color: #475569;
    font-size: 1rem;
    font-weight: 800;
}

.game-notice-center.turn .game-notice-card {
    border-color: rgba(37, 99, 235, .35);
}

.game-notice-center.capture .game-notice-card {
    border-color: rgba(239, 68, 68, .42);
}

.game-notice-center.warning .game-notice-card {
    border-color: rgba(245, 158, 11, .45);
}

.game-notice-center.exit .game-notice-card {
    border-color: rgba(34, 197, 94, .42);
}

@keyframes gameNoticePop {
    from {
        opacity: 0;
        transform: translateY(12px) scale(.96);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}


/* Código de sala con icono de dos hojas */
.room-code-line {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.copy-code-icon {
    position: relative;
    width: 38px;
    height: 38px;
    flex: 0 0 38px;
    border: 1px solid rgba(148, 163, 184, .55);
    border-radius: 12px;
    background: #0f172a;
    cursor: pointer;
    box-shadow: 0 10px 18px rgba(15, 23, 42, .18);
}

.copy-code-icon span,
.copy-code-icon::before,
.copy-code-icon::after {
    content: "";
    position: absolute;
    display: block;
    width: 14px;
    height: 18px;
    border-radius: 3px;
    background: #ffffff;
    border: 1px solid rgba(203, 213, 225, .95);
}

.copy-code-icon::before {
    left: 10px;
    top: 9px;
    opacity: .88;
}

.copy-code-icon::after {
    left: 14px;
    top: 12px;
    box-shadow: 0 2px 3px rgba(15, 23, 42, .24);
}

.copy-code-icon.copied {
    background: #16a34a;
}

.copy-code-icon.copied::after {
    content: "✓";
    width: 18px;
    height: 18px;
    left: 10px;
    top: 9px;
    display: grid;
    place-items: center;
    color: #16a34a;
    font-size: 14px;
    font-weight: 950;
}

.copy-code-icon.copied::before,
.copy-code-icon.copied span {
    display: none;
}

.game-notice-emoji {
    display: block;
    font-size: clamp(2.8rem, 10vw, 5.2rem);
    line-height: 1;
    margin-bottom: 8px;
    filter: drop-shadow(0 10px 18px rgba(15, 23, 42, .24));
}


/* Copiar código: botón blanco junto al código */
.copy-code-icon {
    background: #ffffff;
    border-color: rgba(148, 163, 184, .85);
    box-shadow: 0 8px 16px rgba(15, 23, 42, .12);
}

.copy-code-icon span,
.copy-code-icon::before,
.copy-code-icon::after {
    background: #ffffff;
    border-color: #0f172a;
}

.copy-code-icon.copied {
    background: #ffffff;
    border-color: #16a34a;
}

.copy-code-icon.copied::after {
    color: #16a34a;
    border-color: #16a34a;
}

.kick-player-btn {
    margin-left: 8px;
    padding: 4px 8px;
    border: 1px solid rgba(239, 68, 68, .35);
    border-radius: 999px;
    background: #fff1f2;
    color: #b91c1c;
    font-size: 11px;
    font-weight: 950;
    cursor: pointer;
}

.kick-player-btn:hover {
    background: #fee2e2;
}

.kick-player-btn:disabled {
    opacity: .55;
    cursor: wait;
}

.game-notice-center.finish .game-notice-card {
    border-color: rgba(34, 197, 94, .42);
}

.game-notice-center.countdown .game-notice-card {
    border-color: rgba(59, 130, 246, .38);
}

.game-notice-center.countdown .game-notice-card span {
    font-size: clamp(2.8rem, 12vw, 5rem);
    line-height: 1;
    font-weight: 950;
    color: #0f172a;
}


/* Copiar código sin contorno */
.copy-code-icon {
    border: none !important;
    outline: none !important;
    box-shadow: none !important;
    background: #ffffff !important;
}

.copy-code-icon span,
.copy-code-icon::before,
.copy-code-icon::after {
    border: none !important;
    box-shadow: none !important;
}

.copy-code-icon:focus-visible {
    outline: 2px solid rgba(37, 99, 235, .55) !important;
    outline-offset: 3px;
}


/* Icono copiar código visible, sin contorno de botón */
.copy-code-icon {
    border: none !important;
    outline: none !important;
    box-shadow: none !important;
    background: transparent !important;
    padding: 0;
}

.copy-code-icon span,
.copy-code-icon::before,
.copy-code-icon::after {
    display: block !important;
    background: #ffffff !important;
    border: 1.8px solid #0f172a !important;
    box-shadow: 0 1px 2px rgba(15, 23, 42, .24) !important;
}

.copy-code-icon::before {
    left: 9px !important;
    top: 8px !important;
    opacity: .95 !important;
}

.copy-code-icon::after {
    left: 14px !important;
    top: 12px !important;
}

.copy-code-icon span {
    display: none !important;
}

.copy-code-icon.copied {
    background: transparent !important;
}

.copy-code-icon.copied::before,
.copy-code-icon.copied span {
    display: none !important;
}

.copy-code-icon.copied::after {
    content: "✓" !important;
    width: 22px !important;
    height: 22px !important;
    left: 8px !important;
    top: 8px !important;
    display: grid !important;
    place-items: center !important;
    color: #16a34a !important;
    border-color: #16a34a !important;
    background: #ffffff !important;
    font-size: 16px !important;
    font-weight: 950 !important;
}



.board .classic-board-rotator {
    transform: none !important;
    transform-origin: 50% 50% !important;
}

.board .classic-board-rotator > svg.classic-board-svg {
    width: 100%;
    height: auto;
    display: block;
    transform: rotate(var(--classic-board-rotation, 0deg)) !important;
    transform-origin: 50% 50% !important;
    transform-box: fill-box;
}




/* Banner inferior del tablero: evitar recorte del banner horizontal.
   El fallback debe comportarse como imagen horizontal completa, no como miniatura recortada. */
.adsterra-slot {
    box-sizing: border-box;
    max-width: 100%;
}

.adsterra-inner {
    box-sizing: border-box;
    width: 100%;
    max-width: var(--ad-width, 728px);
    overflow: visible;
}

.adsterra-inner iframe,
.adsterra-slot iframe {
    max-width: 100% !important;
    display: block;
}

.adsterra-game-bottom-zone {
    width: min(100%, 760px);
    max-width: 100%;
    overflow: visible;
}

.adsterra-game-bottom-zone .adsterra-fallback {
    width: 100%;
    max-width: 728px;
    min-height: 90px;
    grid-template-columns: 1fr;
    gap: 8px;
    text-align: center;
    overflow: visible;
}

.adsterra-game-bottom-zone .adsterra-fallback img {
    width: 100%;
    height: auto;
    max-height: none;
    aspect-ratio: 960 / 180;
    object-fit: contain;
    object-position: center;
    display: block;
}

/* Mantener el mismo criterio en banners horizontales de apoyo si aparecen fuera del tablero. */
.adsterra-home-top .adsterra-fallback img,
.adsterra-global-bottom .adsterra-fallback img {
    object-fit: contain;
    object-position: center;
}


/* Banner de apoyo más compacto, con altura parecida al bloque Adsterra 728x90. */
.adsterra-game-bottom-zone {
    padding: 6px;
}

.adsterra-game-bottom-zone .adsterra-fallback {
    min-height: 90px;
    grid-template-columns: minmax(260px, 480px) minmax(180px, 1fr) auto;
    gap: 10px;
    padding: 8px 10px;
    text-align: left;
    align-items: center;
}

.adsterra-game-bottom-zone .adsterra-fallback img {
    width: 100%;
    height: auto;
    max-height: 76px;
    aspect-ratio: 960 / 180;
    object-fit: contain;
    object-position: center;
    display: block;
}

.adsterra-game-bottom-zone .adsterra-fallback-text {
    font-size: .82rem;
    line-height: 1.18;
}

.adsterra-game-bottom-zone .adsterra-fallback-text strong {
    font-size: .92rem;
}

.adsterra-game-bottom-zone .adsterra-fallback .ghost.small {
    padding: 7px 9px;
    font-size: 12px;
}

/* La etiqueta debe quedarse solo como "Publicidad", sin añadir Adsterra ni otros sufijos. */
.adsterra-slot.adsterra-loaded .adsterra-label::after,
.adsterra-slot.adsterra-fallback-active .adsterra-label::after,
.adsterra-slot.adsterra-loading .adsterra-label::after {
    content: "" !important;
}

@media (max-width: 760px) {
    .adsterra-game-bottom-zone .adsterra-fallback {
        grid-template-columns: 1fr;
        text-align: center;
        gap: 6px;
    }

    .adsterra-game-bottom-zone .adsterra-fallback img {
        width: min(100%, 430px);
        max-height: 78px;
        margin: 0 auto;
    }

    .adsterra-game-bottom-zone .adsterra-fallback-text {
        font-size: .78rem;
    }
}


/* Cambio de color dentro de la sala/lobby */
.lobby-color-box {
    margin: 12px 0;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 18px;
    background: rgba(255, 255, 255, .82);
    display: grid;
    gap: 10px;
}

.lobby-color-box h3 {
    margin: 0;
    font-size: 1rem;
    letter-spacing: -.01em;
}

.lobby-color-box label {
    gap: 6px;
}

.lobby-color-box .color-select {
    min-height: 42px;
}


/* Intercambio de colores: estado temporal sin color en lobby */
.badge.no-color {
    background: #f1f5f9;
    color: #475569;
    border: 1px dashed rgba(71, 85, 105, .35);
}

.no-color-dot {
    background: repeating-linear-gradient(45deg, #cbd5e1 0 5px, #94a3b8 5px 10px) !important;
    border-style: dashed;
}

.image-board-player-label text{paint-order:stroke;stroke:rgba(255,255,255,.7);stroke-width:1px;}

.badge.team {
    background: rgba(59, 130, 246, .12);
    color: #1d4ed8;
    border: 1px solid rgba(59, 130, 246, .28);
}


/* Tableros ampliados SVG: cuadrícula geométrica real, sin imagen de fondo. */
.extended-track-cell,
.extended-home-lane {
    shape-rendering: geometricPrecision;
}

.extended-track-block {
    fill: #ffffff;
    stroke: #111827;
    stroke-width: 1.25;
    stroke-linejoin: miter;
}

.extended-cell-number {
    dominant-baseline: central;
    alignment-baseline: central;
    user-select: none;
}

.extended-home-player-label {
    pointer-events: none;
}

/* extended-grid-8x3-home-label-arrow-fix */

.extended-start-arrow {
    paint-order: stroke;
}

.extended-home-player-label {
    paint-order: stroke;
}


/* extended-grid-connector-angle-support-text-fix */
.extended-track-cell,
.extended-home-lane {
    shape-rendering: geometricPrecision;
}

.extended-grid-line {
    stroke: #111827;
    stroke-width: 1.12;
    stroke-linecap: square;
    shape-rendering: geometricPrecision;
}

.extended-grid-line.connector {
    stroke-width: 1.45;
}


/* cookies-reentry-start-diagonal-fix */
.extended-track-cell.connector-diagonal {
    shape-rendering: geometricPrecision;
}

.extended-grid-line.connector-diagonal {
    stroke-width: 1.7;
    stroke-linecap: square;
}


/* connector-gain-space-cells-fix */
.extended-track-cell.connector-gain-space {
    shape-rendering: geometricPrecision;
}

.extended-grid-line.connector-gain-space,
.extended-grid-line.connector-diagonal {
    stroke-width: 1.75;
    stroke-linecap: square;
}


/* connector-correct-side-gain-space-fix */
.extended-track-cell.connector-gain-space {
    shape-rendering: geometricPrecision;
}

.extended-grid-line.connector-diagonal {
    stroke-width: 1.75;
    stroke-linecap: square;
}

/* connector-remove-rect-overlap-fix */
.extended-track-block {
    stroke: transparent !important;
    stroke-width: 0 !important;
}

.extended-grid-line.connector-diagonal {
    stroke-width: 1.9;
    stroke-linecap: square;
}


/* Parchís Online WP: tirada inicial */
.opening-roll-mode {
    border: 2px solid var(--turn-color, #2563eb);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--turn-color, #2563eb) 18%, transparent);
}
.opening-roll-title { font-size: 1.25rem; font-weight: 800; margin-bottom: .5rem; }
.opening-roll-list { display: grid; gap: .35rem; margin: .8rem 0; }
.opening-roll-player { display:flex; align-items:center; justify-content:space-between; padding:.45rem .65rem; border-radius:.65rem; background:rgba(148,163,184,.12); }
.opening-roll-player strong { font-size:1.25rem; min-width:2rem; text-align:center; }
.opening-roll-message { font-weight:700; }
.opening-dice-box { min-height:110px; display:flex; align-items:center; justify-content:center; }
.opening-die { width:76px; height:76px; border-radius:16px; display:grid; place-items:center; background:#fff; color:#111827; border:4px solid var(--turn-color,#2563eb); box-shadow:0 8px 20px rgba(0,0,0,.18); font-size:2.2rem; font-weight:900; animation: parchisOpeningDie .35s ease-out; }
@keyframes parchisOpeningDie { from { transform:scale(.55) rotate(-12deg); opacity:.25; } to { transform:scale(1) rotate(0); opacity:1; } }


/* Caja de dados: layout vertical estable y texto legible (también dentro de temas de WordPress) */
#diceBox.dice-box:not(.opening-dice-box) {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
#diceBox .dice-pair {
    flex-direction: row;
    flex-wrap: nowrap;
}
#diceBox .dice-total {
    font-size: 18px;
    line-height: 1.2;
    white-space: nowrap;
    color: #0f172a;
    margin: 0;
}
#diceBox .dice-remaining {
    font-size: 14px;
    line-height: 1.3;
    font-weight: 800;
    color: #1e293b;
    background: color-mix(in srgb, var(--turn-color, #2563eb) 12%, #ffffff);
    border: 1px solid color-mix(in srgb, var(--turn-color, #2563eb) 35%, transparent);
    border-radius: 999px;
    padding: 4px 12px;
    white-space: nowrap;
    margin: 0;
}

/* Caja de sala compacta: aprox. la mitad de alto */
#roomApp .room-code-box {
    display: grid;
    grid-template-columns: 1fr 1fr;
    align-items: center;
    gap: 6px 8px;
    padding: 8px 10px;
    min-height: 0;
}
#roomApp .room-code-box > span {
    grid-column: 1 / -1;
    display: none;
}
#roomApp .room-code-line {
    grid-column: 1 / -1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin: 0;
}
#roomApp .room-code-line::before {
    content: "Sala";
    color: var(--muted, #64748b);
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: .08em;
}
#roomApp .room-code-box strong#roomCodeText {
    font-size: 20px;
    letter-spacing: .12em;
    line-height: 1.1;
}
#roomApp .room-code-actions {
    margin: 0;
    display: block;
}
#roomApp .room-code-actions button,
#roomApp .room-code-box .sound-toggle {
    width: 100%;
    margin: 0;
    min-height: 0;
    padding: 5px 8px;
    font-size: 12px;
    line-height: 1.2;
}
#roomApp .room-code-box #closeRoomBtn {
    grid-column: 1 / -1;
    margin: 0;
    padding: 5px 8px;
    font-size: 12px;
}

/* Banner de apoyo debajo del tablero */
.board-card .support-board-banner {
    grid-template-columns: 64px 1fr;
    align-items: center;
    max-width: 760px;
    margin: 14px auto 0;
    padding: 10px 14px;
}
.board-card .support-board-banner img {
    width: 64px;
    height: 64px;
}
.board-card .support-board-banner p {
    margin: 2px 0 6px;
}
@media (min-width: 640px) {
    .board-card .support-board-banner > div {
        display: grid;
        grid-template-columns: 1fr auto;
        grid-template-rows: auto auto;
        column-gap: 14px;
        align-items: center;
    }
    .board-card .support-board-banner .support-side-actions {
        grid-column: 2;
        grid-row: 1 / span 2;
    }
    .board-card .support-board-banner p { margin: 2px 0 0; }
}

.support-side-actions a { text-decoration: none; }

/* Selectores: anula la altura fija de 40px de Astra que corta el texto */
.landing select,
.app-shell select,
.landing select.color-select,
.app-shell select.color-select {
    height: auto !important;
    min-height: 46px;
    line-height: 1.35 !important;
    padding-top: 10px !important;
    padding-bottom: 10px !important;
    padding-right: 36px !important;
    box-sizing: border-box;
    text-overflow: ellipsis;
    white-space: nowrap;
}
