/* RESET Y BASE */
* {
    box-sizing: border-box;
}

body {
    background-color: #2c2c2c;
    margin: 0;
    padding: 20px 10px;
    font-family: 'Georgia', serif;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: flex-start;
}

.container {
    background-color: #f4e4bc;
    width: 100%;
    max-width: 600px;
    padding: 25px;
    border: 8px double #5d4037; 
    box-shadow: 0 0 20px rgba(0,0,0,0.5);
    color: #2b1d0e;
}

/* TIPOGRAFÍA */
header {
    text-align: center;
    border-bottom: 2px solid #5d4037;
    margin-bottom: 25px;
    padding-bottom: 10px;
}

h1 {
    font-size: 2.5rem;
    margin: 0;
    letter-spacing: 2px;
    text-transform: uppercase;
    line-height: 1.1;
}

h2 {
    font-style: italic;
    font-weight: normal;
    color: #721c24;
    margin-top: 5px;
    font-size: 1.2rem;
}

.subtitle {
    font-size: 0.9rem;
    opacity: 0.8;
    margin-bottom: 10px;
}

h3 {
    background-color: #e3d3aa;
    padding: 10px;
    border-left: 5px solid #721c24;
    text-transform: uppercase;
    font-size: 1rem;
    margin-top: 30px;
    letter-spacing: 1px;
}

h4 {
    text-decoration: underline;
    margin-bottom: 5px;
    color: #4a3b32;
}

ul, ol {
    line-height: 1.5;
    padding-left: 20px;
}

li {
    margin-bottom: 8px;
}

.alert {
    background-color: rgba(114, 28, 36, 0.1);
    border: 1px dashed #721c24;
    padding: 15px;
    margin-top: 20px;
    font-size: 0.95rem;
}

footer {
    margin-top: 40px;
    text-align: center;
    font-size: 0.8rem;
    border-top: 1px solid #5d4037;
    padding-top: 15px;
    font-style: italic;
    opacity: 0.8;
}

/* =========================================
   ESTILOS DEL DADO 3D (CORREGIDO PARA MÓVIL)
========================================= */
.dado-section {
    text-align: center;
    margin-top: 40px;
    border-top: 2px solid #5d4037;
    padding-top: 20px;
    /* Esto asegura que la sección esté por encima del fondo */
    position: relative; 
    z-index: 5;
}

.scene {
    width: 100px;
    height: 100px;
    margin: 30px auto;
    perspective: 600px; /* Aumentado un poco para mejor visión en móvil */
    position: relative;
    z-index: 10; /* Forzamos a que esté muy por encima */
}

.cube {
    width: 100%;
    height: 100%;
    position: relative;
    transform-style: preserve-3d;
    -webkit-transform-style: preserve-3d; /* Vital para iOS */
    
    /* Posición inicial */
    transform: translateZ(-50px);
    -webkit-transform: translateZ(-50px);
}

/* Animación corregida con prefijos */
@keyframes rodar {
    0% { transform: translateZ(-50px) rotateX(0deg) rotateY(0deg); }
    100% { transform: translateZ(-50px) rotateX(720deg) rotateY(1080deg); }
}

@-webkit-keyframes rodar {
    0% { -webkit-transform: translateZ(-50px) rotateX(0deg) rotateY(0deg); }
    100% { -webkit-transform: translateZ(-50px) rotateX(720deg) rotateY(1080deg); }
}

.cube__face {
    position: absolute;
    width: 100px;
    height: 100px;
    background-color: #e8dab2;
    border: 2px solid #bda87f;
    box-shadow: inset 0 0 10px rgba(93, 64, 55, 0.3);
    border-radius: 10px;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(3, 1fr);
    padding: 8px;
    
    /* Importante: backface-visibility a veces da problemas en móvil, 
       pero visible asegura que no desaparezcan */
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
}

/* POSICIONAMIENTO CON PREFIJOS */
.cube__face--1  { transform: rotateY(  0deg) translateZ(50px); -webkit-transform: rotateY(  0deg) translateZ(50px); }
.cube__face--2  { transform: rotateY( 90deg) translateZ(50px); -webkit-transform: rotateY( 90deg) translateZ(50px); }
.cube__face--3  { transform: rotateY(180deg) translateZ(50px); -webkit-transform: rotateY(180deg) translateZ(50px); }
.cube__face--4  { transform: rotateY(-90deg) translateZ(50px); -webkit-transform: rotateY(-90deg) translateZ(50px); }
.cube__face--5  { transform: rotateX( 90deg) translateZ(50px); -webkit-transform: rotateX( 90deg) translateZ(50px); }
.cube__face--6  { transform: rotateX(-90deg) translateZ(50px); -webkit-transform: rotateX(-90deg) translateZ(50px); }

/* Resto de estilos del dado (puntos y botón) igual... */
.dot {
    display: block;
    width: 16px;
    height: 16px;
    background-color: #2b1d0e;
    border-radius: 50%;
    align-self: center;
    justify-self: center;
    box-shadow: inset 1px 1px 2px rgba(0,0,0,0.5);
}

.center { grid-area: 2 / 2; }
.top-left { grid-area: 1 / 1; }
.top-right { grid-area: 1 / 3; }
.bottom-left { grid-area: 3 / 1; }
.bottom-right { grid-area: 3 / 3; }
.mid-left { grid-area: 2 / 1; }
.mid-right { grid-area: 2 / 3; }

#btnLanzar {
    background-color: #721c24;
    color: #f4e4bc;
    border: none;
    padding: 15px 30px;
    font-family: 'Georgia', serif;
    font-size: 1rem;
    text-transform: uppercase;
    cursor: pointer;
    border-radius: 5px;
    box-shadow: 0 4px #4a1217;
    transition: all 0.1s;
    margin-top: 20px; /* Un poco de aire extra */
}