/* ===========================
   RESET Y VARIABLES
   =========================== */
* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
    --color-primary: #4a90d9;
    --color-secondary: #e74c3c;
    --color-success: #27ae60;
    --color-warning: #f39c12;
    --color-dark: #2c3e50;
    --color-bg: #1a1a2e;
    --color-card: #16213e;
    --color-text: #eee;
    --color-ladder: #27ae60;
    --color-slide: #e74c3c;
    --shadow: 0 4px 15px rgba(0,0,0,0.3);
    --radius: 12px;
    --transition: all 0.3s ease;
    --cell-size: 68px;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: var(--color-bg);
    color: var(--color-text);
    min-height: 100vh;
    overflow-x: hidden;
}

.hidden { display: none !important; }

.btn-start {
    background: linear-gradient(135deg, var(--color-primary), #357abd);
    color: white; border: none; padding: 16px 50px;
    font-size: 1.3em; font-weight: bold; border-radius: 50px;
    cursor: pointer; transition: var(--transition); margin-top: 10px;
}
.btn-start:hover { transform: translateY(-3px); box-shadow: 0 8px 25px rgba(74,144,217,0.4); }

/* ===========================
   PANTALLA DEL JUEGO
   =========================== */
#pantalla-juego { padding: 10px; min-height: 100vh; }
.game-header { text-align: center; margin-bottom: 10px; }
.game-header h1 { font-size: 1.4em; margin-bottom: 6px; }

.turn-indicator {
    font-size: 1.15em; padding: 10px 25px;
    border-radius: 25px; display: inline-block;
    font-weight: bold; transition: var(--transition);
}

.game-layout {
    display: flex; gap: 18px;
    justify-content: center; align-items: flex-start;
}

/* ===========================
   TABLERO
   =========================== */
.board-viewport {
    flex-shrink: 0;
    max-width: 100%;
    max-height: min(78vh, 950px);
    overflow: auto;
    border-radius: var(--radius);
    scrollbar-width: thin;
}
.board-container { position: relative; width: max-content; }

.game-board {
    display: grid;
    grid-template-columns: repeat(10, var(--cell-size));
    grid-template-rows: repeat(var(--board-rows, 20), var(--cell-size));
    gap: 2px;
    background: rgba(0,0,0,0.4);
    border: 3px solid rgba(255,255,255,0.12);
    border-radius: var(--radius);
    padding: 4px;
}

.cell {
    width: var(--cell-size); height: var(--cell-size);
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    font-weight: bold; position: relative;
    border-radius: 6px; transition: var(--transition);
    cursor: default;
}

.cell-number {
    font-size: 1.2em; z-index: 1;
    text-shadow: 0 1px 3px rgba(0,0,0,0.5);
}

.cell-icon {
    position: absolute; top: 2px; right: 3px;
    font-size: 1.3em; z-index: 2;
}

/* SVG overlay para escaleras y toboganes visuales */
.board-svg-overlay {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    pointer-events: none;
    z-index: 5;
}

.cell-tokens {
    position: absolute; bottom: 3px;
    display: flex; gap: 3px; z-index: 3;
}

.cell-token {
    width: 14px; height: 14px;
    border-radius: 50%;
    border: 2px solid rgba(0,0,0,0.4);
    box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

/* Colores de casillas */
.cell-normal { background: #2d3436; color: #ddd; }

.cell-ladder {
    background: rgba(39,174,96,0.35);
    color: #2ecc71;
    border: 1px solid rgba(39,174,96,0.5);
}

.cell-slide {
    background: rgba(231,76,60,0.35);
    color: #e74c3c;
    border: 1px solid rgba(231,76,60,0.5);
}

.cell-challenge {
    background: rgba(243,156,18,0.35);
    color: #f39c12;
    border: 1px solid rgba(243,156,18,0.5);
    animation: pulse-challenge 2s infinite;
}

.cell-start {
    background: rgba(74,144,217,0.45);
    color: white;
}

.cell-finish {
    background: rgba(243,156,18,0.5);
    color: gold;
}

@keyframes pulse-challenge {
    0%, 100% { box-shadow: 0 0 5px rgba(243,156,18,0.3); }
    50% { box-shadow: 0 0 18px rgba(243,156,18,0.7); }
}

.cell.highlight-ladder {
    box-shadow: 0 0 14px rgba(39,174,96,0.9) !important;
    transform: scale(1.08); z-index: 10;
}

.cell.highlight-slide {
    box-shadow: 0 0 14px rgba(231,76,60,0.9) !important;
    transform: scale(1.08); z-index: 10;
}

/* ===========================
   DADO 3D
   =========================== */
.dice-section { text-align: center; }

.dice-scene {
    width: 90px; height: 90px;
    perspective: 300px;
    margin: 0 auto 8px;
}

.dice-cube {
    width: 90px; height: 90px;
    position: relative;
    transform-style: preserve-3d;
    transform: rotateX(-25deg) rotateY(25deg);
    transition: transform 0.1s;
}

.dice-cube.rolling {
    animation: dice-spin 0.8s ease-out;
}

@keyframes dice-spin {
    0%   { transform: rotateX(0deg) rotateY(0deg) rotateZ(0deg); }
    20%  { transform: rotateX(200deg) rotateY(100deg) rotateZ(50deg); }
    40%  { transform: rotateX(400deg) rotateY(250deg) rotateZ(120deg); }
    60%  { transform: rotateX(600deg) rotateY(400deg) rotateZ(200deg); }
    80%  { transform: rotateX(720deg) rotateY(500deg) rotateZ(300deg); }
    100% { transform: rotateX(720deg) rotateY(500deg) rotateZ(360deg); }
}

.dice-face {
    position: absolute;
    width: 90px; height: 90px;
    background: linear-gradient(145deg, #ffffff, #e6e6e6);
    border: 2px solid #bbb;
    border-radius: 10px;
    display: grid;
    padding: 14px;
    box-shadow: inset 0 0 10px rgba(0,0,0,0.05);
}

/* Posicionamiento de las 6 caras */
.dice-face.front  { transform: translateZ(45px); }
.dice-face.back   { transform: rotateY(180deg) translateZ(45px); }
.dice-face.right  { transform: rotateY(90deg) translateZ(45px); }
.dice-face.left   { transform: rotateY(-90deg) translateZ(45px); }
.dice-face.top    { transform: rotateX(90deg) translateZ(45px); }
.dice-face.bottom { transform: rotateX(-90deg) translateZ(45px); }

/* Layout de puntos por cara */
.dice-face[data-face="1"] { grid-template: 1fr / 1fr; place-items: center; }
.dice-face[data-face="2"] { grid-template: 1fr 1fr / 1fr; }
.dice-face[data-face="2"] .top-right { grid-area: 1/1; justify-self: end; align-self: start; }
.dice-face[data-face="2"] .bottom-left { grid-area: 2/1; justify-self: start; align-self: end; }

.dice-face[data-face="3"] { grid-template: 1fr 1fr 1fr / 1fr; }
.dice-face[data-face="3"] .top-right { grid-area: 1/1; justify-self: end; align-self: start; }
.dice-face[data-face="3"] .center { grid-area: 2/1; justify-self: center; align-self: center; }
.dice-face[data-face="3"] .bottom-left { grid-area: 3/1; justify-self: start; align-self: end; }

.dice-face[data-face="4"] { grid-template: 1fr 1fr / 1fr 1fr; }
.dice-face[data-face="4"] .top-left { grid-area: 1/1; justify-self: start; align-self: start; }
.dice-face[data-face="4"] .top-right { grid-area: 1/2; justify-self: end; align-self: start; }
.dice-face[data-face="4"] .bottom-left { grid-area: 2/1; justify-self: start; align-self: end; }
.dice-face[data-face="4"] .bottom-right { grid-area: 2/2; justify-self: end; align-self: end; }

.dice-face[data-face="5"] { grid-template: 1fr 1fr 1fr / 1fr 1fr; }
.dice-face[data-face="5"] .top-left { grid-area: 1/1; justify-self: start; align-self: start; }
.dice-face[data-face="5"] .center { grid-area: 2 / 1 / 3 / 3; justify-self: center; align-self: center; }
.dice-face[data-face="5"] .bottom-left { grid-area: 3/1; justify-self: start; align-self: end; }
.dice-face[data-face="5"] .top-right { grid-area: 1/2; justify-self: end; align-self: start; }
.dice-face[data-face="5"] .bottom-right { grid-area: 3/2; justify-self: end; align-self: end; }

.dice-face[data-face="6"] { grid-template: 1fr 1fr 1fr / 1fr 1fr; }
.dice-face[data-face="6"] .top-left { grid-area: 1/1; justify-self: start; align-self: start; }
.dice-face[data-face="6"] .center-left { grid-area: 2/1; justify-self: start; align-self: center; }
.dice-face[data-face="6"] .bottom-left { grid-area: 3/1; justify-self: start; align-self: end; }
.dice-face[data-face="6"] .top-right { grid-area: 1/2; justify-self: end; align-self: start; }
.dice-face[data-face="6"] .center-right { grid-area: 2/2; justify-self: end; align-self: center; }
.dice-face[data-face="6"] .bottom-right { grid-area: 3/2; justify-self: end; align-self: end; }

/* Puntos del dado */
.dot {
    width: 14px; height: 14px;
    background: radial-gradient(circle at 35% 35%, #555, #1a1a1a);
    border-radius: 50%;
    display: inline-block;
    box-shadow: 0 2px 3px rgba(0,0,0,0.3);
}

.dice-result {
    font-size: 1.3em; font-weight: bold;
    margin-bottom: 8px; color: var(--color-text);
    min-height: 30px;
}

.btn-roll {
    background: linear-gradient(135deg, #e74c3c, #c0392b);
    color: white; border: none;
    padding: 12px 30px; font-size: 1.1em; font-weight: bold;
    border-radius: 25px; cursor: pointer;
    transition: var(--transition); width: 100%;
}
.btn-roll:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(231,76,60,0.4);
}
.btn-roll:disabled { opacity: 0.5; cursor: not-allowed; }

/* ===========================
   PANEL LATERAL
   =========================== */
.side-panel {
    display: flex; flex-direction: column;
    gap: 12px; min-width: 230px;
}

.panel-section {
    background: var(--color-card);
    padding: 14px; border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.panel-section h3 {
    font-size: 0.95em; margin-bottom: 10px;
    color: var(--color-primary);
}

/* Jugadores */
.player-status-card {
    display: flex; align-items: center; gap: 10px;
    padding: 8px; border-radius: 8px;
    margin-bottom: 5px; transition: var(--transition);
}
.player-status-card.active-turn {
    background: rgba(74,144,217,0.15);
    border-left: 3px solid var(--color-primary);
}
.player-color-dot { width: 16px; height: 16px; border-radius: 50%; flex-shrink: 0; }
.player-status-info { flex: 1; }
.player-status-name { font-weight: bold; font-size: 0.9em; }
.player-status-pos { font-size: 0.8em; color: #aaa; }

/* Leyenda */
.legend-section { font-size: 0.85em; }
.legend-item { display: flex; align-items: center; gap: 8px; margin-bottom: 5px; }
.legend-icon {
    display: inline-flex; align-items: center; justify-content: center;
    width: 24px; height: 24px; border-radius: 4px;
    font-weight: bold; font-size: 0.9em;
}
.legend-icon.ladder { background: rgba(39,174,96,0.3); color: #2ecc71; }
.legend-icon.slide { background: rgba(231,76,60,0.3); color: #e74c3c; }
.legend-icon.challenge { background: rgba(243,156,18,0.3); color: #f39c12; }
.legend-icon.normal { background: rgba(127,140,141,0.3); color: #95a5a6; }

/* Rutas */
.routes-section { font-size: 0.85em; max-height: 170px; overflow-y: auto; }
.routes-list { display: flex; flex-direction: column; gap: 3px; }
.route-item {
    display: flex; align-items: center; gap: 6px;
    padding: 4px 8px; border-radius: 6px;
    transition: var(--transition); cursor: pointer;
}
.route-item:hover { transform: scale(1.03); }
.route-item.route-ladder { background: rgba(39,174,96,0.1); border-left: 3px solid var(--color-ladder); }
.route-item.route-ladder:hover { background: rgba(39,174,96,0.25); }
.route-item.route-slide { background: rgba(231,76,60,0.1); border-left: 3px solid var(--color-slide); }
.route-item.route-slide:hover { background: rgba(231,76,60,0.25); }
.route-from { font-weight: bold; min-width: 24px; }
.route-arrow { font-size: 1.1em; }
.route-arrow.arrow-up { color: var(--color-ladder); }
.route-arrow.arrow-down { color: var(--color-slide); }
.route-to { font-weight: bold; min-width: 24px; }
.route-diff { margin-left: auto; font-size: 0.85em; opacity: 0.7; }

/* Reglas */
.rules-section { max-height: 300px; overflow-y: auto; }
.rules-table { width: 100%; border-collapse: collapse; font-size: 0.88em; }
.rules-table th {
    text-align: left; padding: 6px 8px;
    background: rgba(74,144,217,0.15); color: var(--color-primary);
    border-bottom: 1px solid rgba(255,255,255,0.1); font-size: 0.9em;
}
.rules-table td {
    padding: 5px 8px;
    border-bottom: 1px solid rgba(255,255,255,0.05);
    color: #ccc; line-height: 1.3;
}
.rules-table tr:hover td { background: rgba(255,255,255,0.03); }

.questions-counter {
    margin-top: 10px; padding: 8px 10px;
    background: rgba(243,156,18,0.1); border-radius: 6px;
    font-size: 0.88em; color: #f39c12; text-align: center;
}

/* ===========================
   MODAL
   =========================== */
.modal {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.75);
    display: flex; align-items: center; justify-content: center;
    z-index: 1000; backdrop-filter: blur(5px);
    animation: fadeIn 0.3s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal-content {
    background: var(--color-card); border-radius: var(--radius);
    padding: 28px; max-width: 560px; width: 92%;
    box-shadow: 0 20px 60px rgba(0,0,0,0.5);
    animation: slideUp 0.3s ease;
}
@keyframes slideUp {
    from { transform: translateY(30px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.modal-header {
    display: flex; justify-content: space-between;
    align-items: center; margin-bottom: 18px;
}
.modal-header h2 { color: var(--color-warning); }
.modal-player {
    background: rgba(255,255,255,0.1);
    padding: 5px 15px; border-radius: 20px;
    font-size: 0.9em; font-weight: bold;
}

.modal-question {
    font-size: 1.15em; line-height: 1.6;
    margin-bottom: 18px; padding: 15px;
    background: rgba(255,255,255,0.05);
    border-radius: 8px;
    border-left: 3px solid var(--color-warning);
}

.modal-options { display: flex; flex-direction: column; gap: 10px; margin-bottom: 15px; }

.option-btn {
    padding: 14px 20px; border: 2px solid rgba(255,255,255,0.1);
    background: rgba(255,255,255,0.03); color: var(--color-text);
    border-radius: 8px; cursor: pointer; transition: var(--transition);
    font-size: 1em; text-align: left;
}
.option-btn:hover:not(:disabled) {
    border-color: var(--color-primary); background: rgba(74,144,217,0.1);
}
.option-btn.correct { border-color: var(--color-success) !important; background: rgba(39,174,96,0.2) !important; color: #2ecc71 !important; }
.option-btn.incorrect { border-color: var(--color-secondary) !important; background: rgba(231,76,60,0.2) !important; color: #e74c3c !important; }
.option-btn:disabled { cursor: not-allowed; opacity: 0.7; }

.modal-input-section { display: flex; gap: 10px; margin-bottom: 15px; }
.modal-input {
    flex: 1; padding: 12px 16px;
    border: 2px solid rgba(255,255,255,0.15);
    background: rgba(255,255,255,0.05); color: var(--color-text);
    border-radius: 8px; font-size: 1em; outline: none; transition: var(--transition);
}
.modal-input:focus { border-color: var(--color-primary); }

.btn-submit {
    padding: 12px 24px; background: var(--color-primary);
    color: white; border: none; border-radius: 8px;
    font-weight: bold; cursor: pointer; transition: var(--transition);
}
.btn-submit:hover { background: #357abd; }

.modal-feedback {
    text-align: center; padding: 12px;
    border-radius: 8px; font-weight: bold; font-size: 1.05em;
}
.modal-feedback.correct { background: rgba(39,174,96,0.2); color: #2ecc71; }
.modal-feedback.incorrect { background: rgba(231,76,60,0.2); color: #e74c3c; }

/* ===========================
   MODAL GANADOR
   =========================== */
.modal-winner-content { text-align: center; }
.winner-animation { font-size: 5em; animation: bounce 1s infinite; }
@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-20px); }
}
.modal-winner-content h2 { font-size: 2em; margin: 15px 0; color: gold; }
.winner-name { font-size: 1.5em; margin-bottom: 10px; }
.winner-subtitle { color: #aaa; margin-bottom: 25px; }

/* ===========================
   RESPONSIVE
   =========================== */
@media (max-width: 1050px) {
    :root { --cell-size: 55px; }
}
@media (max-width: 900px) {
    :root { --cell-size: 48px; }
    .game-layout { flex-direction: column; align-items: center; }
    .side-panel { flex-direction: row; flex-wrap: wrap; justify-content: center; min-width: unset; }
    .panel-section { flex: 1; min-width: 200px; }
}
@media (max-width: 560px) {
    :root { --cell-size: 36px; }
    .cell-number { font-size: 0.9em; }
    .board-svg-overlay { /* se adapta automaticamente */ }
    .cell-icon { font-size: 1em; }
    .cell-token { width: 10px; height: 10px; }
}

:root {
    --color-primary: #7f6fff;
    --color-bg: #111329;
    --color-card: #1d2040;
    --color-ladder: #23764a;
    --color-slide: #a63552;
}

.game-header h1 { color: #d8fa77; }
.cell-normal { background: #282c50; color: #f0efff; }
.cell-normal:nth-child(even) { background: #30345b; }
.cell-number {
    position: absolute;
    left: 4px;
    top: 3px;
}
.cell-icon { font-size: 0.9rem; }
.cell-tokens { z-index: 6; flex-wrap: wrap; justify-content: center; width: 100%; gap: 1px; }
.cell-token { border-color: #fff; }
.route-token { position: absolute; left: 0; top: 0; z-index: 7; pointer-events: none; }
.snake-body { fill: none; stroke: #ff6a8a; stroke-width: 5; stroke-linecap: round; }
.snake-head { fill: #ff6a8a; }
#modal-stakes { margin-top: 1rem; color: #ffd599; }
.skip-button {
    background: transparent;
    border: 1px solid #aaa6ce;
    border-radius: 8px;
    padding: 0.5rem 0.75rem;
    margin-top: 0.65rem;
    color: #f3f0ff;
    cursor: pointer;
}
.skip-button:disabled { opacity: 0.55; cursor: default; }
@media (max-width: 560px) {
    :root { --cell-size: min(36px, calc((100vw - 52px) / 10)); }
    .cell-number { font-size: 0.68rem; }
    .cell-icon { font-size: 0.65rem; }
}
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

.cell-token {
    --pawn-size: clamp(17px, calc(var(--cell-size) * 0.57), 35px);
    flex: 0 0 var(--pawn-size);
    width: var(--pawn-size);
    height: calc(var(--pawn-size) * 1.12);
    display: grid;
    place-items: center;
    border: 0;
    border-radius: 0;
    clip-path: polygon(23% 0, 77% 0, 100% 25%, 93% 70%, 50% 100%, 7% 70%, 0 25%);
    background: linear-gradient(145deg, #fff 5%, var(--pawn-color) 41%, var(--pawn-color) 68%, #12152d);
    color: #0d1128;
    font-size: calc(var(--pawn-size) * 0.68);
    font-weight: 900;
    line-height: 1;
    padding: 0 0 2px;
}
.cell-tokens:has(.cell-token:nth-child(3)) .cell-token { --pawn-size: clamp(12px, calc(var(--cell-size) * 0.34), 22px); }
.player-color-dot { display: grid; place-items: center; color: #0d1128; font-size: 0.65rem; font-weight: 900; }
.ladder-outline, .ladder-steps, .ladder-rails { fill: none; stroke-linecap: round; }
.ladder-outline { stroke: #2b193b; stroke-width: 8; }
.ladder-steps { stroke: #f8c883; stroke-width: 4; }
.ladder-rails { stroke: #ffe49f; stroke-width: 4; }
@media (max-width: 560px) {
    .ladder-outline { stroke-width: 5; }
    .ladder-steps, .ladder-rails { stroke-width: 2.5; }
}

@media (max-width: 900px) {
    .board-viewport { max-height: 52svh; }
    .side-panel { order: 1; }
}
@media (max-width: 560px) {
    :root { --cell-size: min(36px, calc((100vw - 55px) / 10)); }
}

#online-game-message { color: #fce0a0; margin: 8px 0; }

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
}

.menu-screen {
    --menu-bg: #102621;
    --menu-surface: #19342c;
    --menu-stroke: #3a5749;
    --menu-ink: #fff7e3;
    --menu-muted: #b9cec0;
    --menu-gold: #f5d775;
    display: grid;
    min-height: 100vh;
    min-height: 100svh;
    place-items: center;
    padding: clamp(20px, 5vw, 72px);
    color: var(--menu-ink);
    background: radial-gradient(ellipse at 65% 15%, #214737, transparent 65%), var(--menu-bg);
    font-family: system-ui, sans-serif;
    color-scheme: dark;
}
.menu-screen button, .menu-screen input { font: inherit; }
.menu-screen button { cursor: pointer; }
.menu-screen button:disabled { opacity: 0.5; cursor: default; }
.menu-screen :is(button, input):focus-visible { outline: 2px solid var(--menu-gold); outline-offset: 3px; }
.menu-title:focus { outline: none; }

.menu-home {
    width: min(100%, 520px);
    display: grid;
    gap: 30px;
}
.menu-intro { text-align: center; }
.menu-title {
    font-size: clamp(2rem, 4.7vw, 4.6rem);
    line-height: 1;
    font-weight: 760;
    letter-spacing: -0.06em;
}
.menu-title em { color: var(--menu-gold); font-family: Georgia, serif; font-weight: 400; }
.menu-description {
    margin-top: 18px;
    color: var(--menu-muted);
    font-size: clamp(1rem, 1.6vw, 1.2rem);
    line-height: 1.55;
}
.menu-options { display: grid; gap: 10px; }
.menu-option {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    gap: 15px;
    align-items: center;
    text-align: left;
    border: 1px solid var(--menu-stroke);
    border-radius: 12px;
    min-height: 73px;
    padding: 12px 15px;
    background: var(--menu-surface);
    color: var(--menu-ink);
    transition: background-color 160ms, border-color 160ms;
}
.menu-option:hover { background: #234839; border-color: #799782; }
.menu-option strong, .menu-option small { display: block; }
.menu-option strong { font-size: 1.09rem; font-weight: 720; }
.menu-option small { color: var(--menu-muted); font-size: 0.88rem; line-height: 1.35; margin-top: 3px; }
.menu-icon {
    display: grid;
    position: relative;
    place-items: center;
    width: 43px;
    height: 43px;
    border-radius: 10px;
    background: var(--menu-gold);
    color: #243322;
}
.menu-icon-dice span {
    display: grid;
    place-items: center;
    width: 19px;
    height: 19px;
    border: 2px solid currentColor;
    border-radius: 5px;
    transform: rotate(-10deg);
}
.menu-icon-dice span::after {
    content: '';
    width: 3px;
    height: 3px;
    border-radius: 50%;
    background: currentColor;
    box-shadow: -4px -4px currentColor, 4px 4px currentColor;
}
.menu-icon-link { background: #ebaa94; }
.menu-icon-link::before, .menu-icon-link::after {
    content: '';
    position: absolute;
    left: 13px;
    top: 15px;
    width: 13px;
    height: 8px;
    border: 2px solid currentColor;
    border-radius: 6px;
    transform: translate(-4px, 5px) rotate(-45deg);
}
.menu-icon-link::after { transform: translate(4px, -3px) rotate(-45deg); }

.menu-panel {
    width: min(100%, 520px);
    padding: clamp(19px, 4vw, 36px);
    border: 1px solid var(--menu-stroke);
    border-radius: 18px;
    background: var(--menu-surface);
    box-shadow: 0 18px 44px #0a171166;
}
.menu-back {
    margin-bottom: 17px;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: var(--menu-muted);
    min-height: 44px;
    padding: 0 5px;
}
.menu-back:hover { color: var(--menu-gold); }
.menu-panel .menu-title { font-size: clamp(2rem, 4.6vw, 3.12rem); margin: 0 0 26px; }
.menu-form { display: grid; gap: 15px; }
.player-settings { border: 0; min-width: 0; }
.player-settings legend, .menu-field label { font-weight: 650; font-size: 0.92rem; margin-bottom: 8px; }
.player-select, .online-modes {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 5px;
    padding: 4px;
    background: var(--menu-bg);
    border: 1px solid var(--menu-stroke);
    border-radius: 11px;
}
.player-btn, .online-modes button {
    border: 0;
    border-radius: 7px;
    color: var(--menu-muted);
    background: transparent;
    min-height: 44px;
}
.menu-screen :is(.player-btn, .online-modes button)[aria-pressed="true"] {
    color: var(--menu-bg);
    background: var(--menu-gold);
    font-weight: 750;
}
.board-size { margin-top: 8px; font-size: 0.88rem; color: var(--menu-muted); }
#player-names-container, .menu-field { display: grid; gap: 7px; }
.player-name-input {
    display: grid;
    grid-template-columns: 28px minmax(0, 1fr);
    align-items: center;
    gap: 9px;
}
.player-name-number {
    display: grid;
    width: 25px;
    height: 28px;
    place-items: center;
    clip-path: polygon(20% 0, 80% 0, 100% 24%, 90% 73%, 50% 100%, 10% 73%, 0 24%);
    color: #101627;
    font-weight: 850;
    font-size: 0.81rem;
}
.menu-form input {
    width: 100%;
    min-width: 0;
    min-height: 44px;
    padding: 10px 12px;
    border: 1px solid var(--menu-stroke);
    border-radius: 8px;
    color: var(--menu-ink);
    background: var(--menu-bg);
    font-size: 1rem;
}
.menu-form input::placeholder { color: var(--menu-muted); opacity: 1; }
.menu-field label { margin-bottom: 0; }
#online-code { text-transform: uppercase; letter-spacing: 0.09em; }
#online-code::placeholder { text-transform: none; letter-spacing: normal; }
.menu-screen .menu-primary, .menu-screen .menu-secondary {
    min-height: 46px;
    border-radius: 9px;
    padding: 10px 15px;
    font-weight: 720;
}
.menu-primary { color: #1c2b20; background: var(--menu-gold); border: 1px solid transparent; width: 100%; }
.menu-primary:hover:not(:disabled) { background: #ffe9a3; }
.menu-secondary { color: var(--menu-ink); background: var(--menu-surface); border: 1px solid var(--menu-stroke); }
.menu-secondary:hover { border-color: var(--menu-gold); }
.online-modes { grid-template-columns: repeat(2, minmax(0, 1fr)); margin-bottom: 16px; }
.room-pass {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 9px 14px;
    padding: 14px;
    border: 1px solid var(--menu-stroke);
    border-radius: 11px;
    background: var(--menu-bg);
}
.menu-label { color: var(--menu-muted); font-size: 0.83rem; }
#room-label { display: block; color: var(--menu-gold); font-size: 1.38rem; letter-spacing: 0.11em; }
#online-players { list-style: none; display: grid; gap: 6px; margin: 16px 0; }
#online-players li { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 10px; }
.room-role { color: var(--menu-muted); font-size: 0.83rem; }
#local-name-error:empty { display: none; }
#local-name-error:not(:empty) { color: #ffb6a7; line-height: 1.4; }
#online-message:not(:empty) { color: var(--menu-gold); line-height: 1.4; margin-top: 12px; }

@media (max-width: 720px) {
    .menu-screen { padding: 22px 18px; }
    .menu-home { max-width: 460px; gap: 23px; }
    .menu-intro .menu-title { font-size: clamp(2.45rem, 9.8vw, 3.65rem); }
    .menu-description { margin-top: 9px; }
}

.music-toggle {
    margin-inline-start: 0.4rem;
    min-height: 44px;
    padding: 0.45rem 0.8rem;
    border: 1px solid #a49ad5;
    border-radius: 0.7rem;
    background: var(--color-card);
    color: var(--color-text);
    font: inherit;
    cursor: pointer;
}
.music-toggle[aria-pressed="true"] { border-color: #d8fa77; color: #d8fa77; }
.music-toggle:focus-visible { outline: 2px solid #d8fa77; outline-offset: 2px; }

/* Web game refresh: shared colors, accessible controls and a phone-first play layout. */
:root {
    color-scheme: dark;
    --color-bg: #121229;
    --color-card: #1e1d3b;
    --color-text: #f9f7ff;
    --color-primary: #c5b7ff;
    --color-success: #a0e9c5;
    --color-secondary: #ff9fa9;
    --color-warning: #ffd78b;
    --color-ladder: #83d9b1;
    --color-slide: #ff9dbb;
    --muted: #c3bddb;
    --line: #403b62;
    --mint: #c7f5ac;
    --ink: #1c2530;
    --radius: 18px;
    --shadow: 0 12px 28px #07061a4d;
}
body { font-family: system-ui, -apple-system, sans-serif; }
button, input { font: inherit; }
:focus-visible { outline: 2px solid var(--mint); outline-offset: 3px; }
.menu-screen {
    --menu-bg: #14132c;
    --menu-surface: #232042;
    --menu-stroke: #564d78;
    --menu-ink: #f9f7ff;
    --menu-muted: #cec7e7;
    --menu-gold: var(--mint);
    background: radial-gradient(ellipse at 18% 5%, #393066 0, transparent 59%),
                radial-gradient(ellipse at 93% 96%, #283759 0, transparent 45%), var(--menu-bg);
}
.menu-home {
    width: min(100%, 1090px);
    grid-template-columns: minmax(0, 1.1fr) minmax(0, .9fr);
    gap: clamp(28px, 6.5vw, 100px);
    align-items: center;
}
.menu-intro { text-align: left; }
.game-kicker {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    color: var(--menu-muted);
    font-size: .875rem;
    font-weight: 750;
    letter-spacing: .12em;
    text-transform: uppercase;
    margin-bottom: 20px;
}
.club-mark {
    display: inline-flex;
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    padding: 5px;
    gap: 2px;
    align-items: end;
    border-radius: 8px;
    vertical-align: middle;
    background: var(--mint);
}
.club-mark i { width: 4px; height: 6px; border-radius: 1px; background: #2c2950; }
.club-mark i:nth-child(2) { height: 11px; }
.club-mark i:nth-child(3) { height: 17px; }
.menu-intro .menu-title {
    font-size: clamp(3rem, 7.3vw, 7rem);
    font-weight: 850;
    letter-spacing: -.085em;
    line-height: .91;
}
.menu-title em {
    display: block;
    margin-top: .12em;
    color: var(--mint);
    font: inherit;
    letter-spacing: -.07em;
}
.menu-description { max-width: 33ch; margin-top: 26px; }
.menu-options {
    gap: 13px;
    border: 1px solid #51486c;
    border-radius: 29px;
    padding: clamp(17px, 3vw, 32px);
    background: #1b1936;
    box-shadow: 0 24px 65px #08071b60;
}
.menu-options h2 {
    font-size: clamp(1.2rem, 2.3vw, 1.55rem);
    letter-spacing: -.035em;
    margin: 0 0 6px;
}
.menu-option {
    min-height: 76px;
    border-radius: 15px;
    color: var(--menu-ink);
    gap: 12px;
}
#open-local { background: var(--mint); color: #172821; border-color: transparent; }
#open-local small { color: #374d3f; }
#open-local:hover { background: #d9ffc3; }
#open-online { background: #2d284c; border-color: #5e5484; }
#open-online:hover { background: #3a325f; border-color: #aea0e0; }
.menu-icon { width: 42px; height: 42px; background: #202d28; color: var(--mint); }
.menu-icon-link { background: #d9cdff; color: #372d5e; }
.game-facts {
    list-style: none;
    display: flex;
    flex-wrap: wrap;
    column-gap: 13px;
    row-gap: 6px;
    margin-top: 6px;
    padding-top: 14px;
    border-top: 1px solid #463f67;
    color: var(--muted);
    font-size: .875rem;
}
.game-facts strong { color: var(--color-text); }
.menu-panel { border-radius: 24px; box-shadow: var(--shadow); }
.menu-primary:hover:not(:disabled) { background: #dcffd0; }
#local-name-error:not(:empty) { color: #ffb4bc; }
#pantalla-juego { padding: clamp(10px, 2.2vw, 28px); max-width: 1320px; margin-inline: auto; }
.game-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    padding: 9px 0 14px;
    gap: 9px 14px;
    margin: 0 0 12px;
    text-align: left;
    border-bottom: 1px solid var(--line);
}
.game-header h1 { color: var(--color-text); margin: 0; font-size: clamp(1.06rem, 2.7vw, 1.6rem); letter-spacing: -.045em; }
.game-header h1 > span:not(.club-mark) { color: var(--mint); }
.game-header h1 .club-mark { margin-inline-end: 4px; }
.game-toolbar { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }
.turn-indicator { font-size: .875rem; line-height: 1.25; padding: 8px 13px; }
.music-toggle { margin: 0; border-color: var(--line); font-size: .875rem; }
.music-toggle[aria-pressed="true"] { border-color: var(--mint); color: var(--mint); }
#online-game-message { flex-basis: 100%; margin: 0; }
.game-layout {
    flex-direction: row;
    align-items: flex-start;
    gap: clamp(10px, 1.8vw, 22px);
}
.board-shell {
    min-width: 0;
    border-radius: var(--radius);
    border: 1px solid var(--line);
    background: #191832;
    padding: 7px;
    box-shadow: var(--shadow);
}
.board-heading { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 5px 8px 9px; }
.board-heading h2 { font-size: 1rem; }
.board-heading > span { color: var(--muted); font-size: .875rem; }
.board-viewport { max-height: min(74svh, 860px); border-radius: 12px; scrollbar-color: #8d82b3 #201e3d; }
.game-board { background: #201e3d; border: 0; border-radius: 0; padding: 3px; gap: 2px; }
.cell { border-radius: 4px; }
.cell-number { font-size: clamp(.7rem, 1.4vw, .95rem); text-shadow: none; }
.cell-normal { background: #e7e1fa; color: #282443; }
.cell-normal:nth-child(even) { background: #d6cdeb; }
.cell-ladder { background: #bbedd5; color: #123d35; border-color: #79c9a7; }
.cell-slide { background: #f9c2d1; color: #652443; border-color: #e798ae; }
.cell-challenge { background: #ffd990; color: #58391a; border-color: #e1af62; animation: none; }
.cell-start, .cell-finish { background: #b9adff; color: #291c54; }
.snake-body { stroke: #9c255a; }
.snake-head { fill: #9c255a; }
.ladder-outline { stroke: #1f473d; }
.ladder-steps { stroke: #b3f7d7; }
.ladder-rails { stroke: #7febbe; }
.side-panel { flex-direction: column; flex-wrap: nowrap; flex: 0 0 clamp(230px, 26%, 315px); min-width: 0; }
.panel-section {
    flex: none;
    min-width: 0;
    border: 1px solid var(--line);
    background: var(--color-card);
    box-shadow: none;
}
.panel-section h3 { font-size: 1rem; color: var(--color-text); }
.player-status-card { border: 1px solid var(--line); gap: 7px; }
.player-status-card.active-turn { border: 1px solid #9d8ed1; background: #352d57; }
.player-status-name { font-size: .9rem; overflow-wrap: anywhere; }
.player-status-pos, .rules-table td { color: var(--muted); font-size: .875rem; }
.player-color-dot { width: 21px; height: 21px; }
.dice-section { background: linear-gradient(145deg, #282247, #1f1f3c); }
.btn-roll, .btn-start, .btn-submit {
    background: var(--mint);
    color: var(--ink);
    border-radius: 12px;
    min-height: 46px;
    box-shadow: none;
}
.btn-roll:hover:not(:disabled), .btn-start:hover, .btn-submit:hover { background: #dfffcc; box-shadow: none; }
.dice-result { color: var(--mint); }
.legend-item, .route-item { font-size: .875rem; }
.route-item { min-height: 30px; }
.modal { padding: 12px; }
.modal-content { border: 1px solid #675e90; max-height: 92svh; overflow-y: auto; color: var(--color-text); }
.modal-header { gap: 10px; flex-wrap: wrap; }
.modal-player { color: #151527; }
.modal-input { min-width: 0; font-size: 1rem; }
.option-btn, .skip-button { min-height: 44px; }
@media (max-width: 720px) {
    .menu-screen { padding: 24px 17px; }
    .menu-home { grid-template-columns: 1fr; width: min(100%, 480px); gap: 26px; }
    .menu-intro .menu-title { font-size: clamp(3.25rem, 12vw, 5.55rem); }
    .game-kicker { margin-bottom: 15px; }
    .menu-description { margin-top: 14px; }
}
@media (max-width: 850px) {
    :root { --cell-size: min(61px, calc((100vw - 65px) / 10)); }
    .game-layout { display: grid; grid-template-columns: minmax(0, 1fr); width: fit-content; max-width: 100%; margin-inline: auto; }
    .side-panel { display: contents; }
    .players-section { grid-row: 1; padding: 9px; }
    #players-status { display: flex; gap: 5px; overflow-x: auto; }
    .players-section h3 { margin-bottom: 6px; }
    .player-status-card { flex: 0 0 auto; min-width: 95px; margin: 0; padding: 5px 7px; }
    .dice-section { grid-row: 2; display: grid; align-items: center; grid-template-columns: auto minmax(24px, auto) minmax(90px, 1fr); gap: 6px 10px; padding: 9px 11px; text-align: left; }
    .dice-section h3 { margin: 0; }
    .dice-scene { display: none; }
    .dice-result { margin: 0; min-height: auto; text-align: center; }
    .btn-roll { padding: 7px 10px; font-size: 1rem; }
    .board-shell { grid-row: 3; }
    .board-viewport { max-height: 51svh; }
    .route-item { min-height: 44px; }
    .modal-content { padding: 17px; }
    .modal-question { padding: 10px; }
    .btn-submit { padding-inline: 12px; }
}
@media (max-width: 850px) {
    .dice-section { grid-template-columns: minmax(0, auto) 34px minmax(18px, auto) minmax(90px, 1fr); }
    .dice-scene { display: block; margin: 0; zoom: .38; }
}
@media (min-width: 851px) {
    .dice-section h3 { margin-bottom: 25px; }
    .dice-scene { margin-bottom: 18px; }
}
@media (max-width: 850px) {
    .game-layout { width: min(100%, 690px); }
    .board-shell { container-type: inline-size; }
    .board-viewport { --cell-size: min(65px, calc((100cqw - 40px) / 10)); }
}
