:root {
    --text-color: #FFF9E6;
    --button-bg: #FF8C6B;
    --button-hover: #FF7145;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    background: linear-gradient(135deg, #FFB3C6, #9EF7B1);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    font-family: 'Balsamiq Sans', cursive;
    position: relative;
}

.book-container {
    width: 100%;
    max-width: 600px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.welcome-title {
    font-size: 2.5rem;
    color: var(--text-color);
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
    margin-bottom: 20px;
    text-align: center;
    background: rgba(255, 181, 158, 0.7);
    padding: 5px 15px;
    border-radius: 10px;
}

.welcome-text {
    font-size: 1.5rem;
    color: #D81E5B;
    font-weight: bold;
    text-shadow: 1px 1px 2px rgba(255, 255, 255, 0.5);
    margin-bottom: 10px;
    text-align: center;
    position: relative;
    z-index: 2;
}

.tutorial-text {
    font-size: 1.2rem;
    color: #FF7145;
    text-shadow: 1px 1px 2px rgba(255, 255, 255, 0.5);
    margin-bottom: 20px;
    text-align: center;
    position: relative;
    z-index: 2;
}

.page[data-page="-1"] {
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: center; /* Centra verticalmente */
    align-items: center; /* Centra horizontalmente */
    min-height: 400px; /* Mantiene la altura mínima consistente */
}

h2 {
    font-size: 1.2rem;
    color: #000;
    margin-bottom: 15px;
    text-align: center;
}

.page[data-page="8"] h2,
.page[data-page="9"] h2,
.page[data-page="10"] h2 {
    color: #FFF;
}

p {
    font-size: 1rem;
    color: #000;
    margin-bottom: 15px;
    text-align: center;
}

.score-container {
    display: flex;
    justify-content: space-around;
    width: 100%;
    max-width: 400px;
    padding: 10px;
    background: rgba(255, 181, 158, 0.9);
    border-radius: 15px;
    margin-bottom: 15px;
}

.score-item {
    font-size: 1.2rem;
    color: var(--text-color);
    background: rgba(255, 140, 107, 0.8);
    padding: 5px 10px;
    border-radius: 10px;
}

.page {
    width: 100%;
    min-height: 400px;
    border: 3px dashed #FF7145;
    border-radius: 10px;
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 20px;
    background: #FFF;
    position: relative;
    opacity: 0;
    transition: opacity 0.5s ease-in-out;
}

.page.active {
    display: flex;
    opacity: 1;
}

.page[data-page="8"],
.page[data-page="9"],
.page[data-page="10"] {
    background: #000;
}

.page[data-page="11"] {
    background: #FFF;
    color: #000;
}

.page[data-page="11"] h1 {
    color: #000;
}

.game-area {
    display: flex;
    gap: 15px;
    justify-content: center;
    align-items: center;
    width: 100%;
    position: relative;
}

.overlay-message {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    padding: 20px 40px;
    border: 4px solid #000;
    border-radius: 15px;
    background: rgba(255, 255, 255, 0.3);
    text-align: center;
    z-index: 10;
    animation: fadeIn 0.5s ease-in-out;
}

.overlay-message span {
    font-size: 1.8rem;
    font-weight: bold;
    letter-spacing: 2px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
}

@keyframes fadeIn {
    from { opacity: 0; transform: translate(-50%, -60%); }
    to { opacity: 1; transform: translate(-50%, -50%); }
}

.gradient-container {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.gradient-bar {
    border-radius: 5px;
    background: linear-gradient(to top, #000, #FFF);
}

.gradient-container::after {
    content: '⬆️';
    font-size: 1.2rem;
    color: var(--text-color);
    margin-top: 5px;
}

.gradient-marks {
    position: absolute;
    left: 40px;
    top: 0;
    width: 50px;
}

.mark {
    width: 8px;
    height: 8px;
    background: #FFF;
    position: absolute;
}

.star-container {
    position: relative;
    flex-grow: 1;
}

.star {
    width: 36px;
    height: 36px;
    position: absolute;
    clip-path: polygon(50% 0%, 61% 35%, 98% 35%, 68% 57%, 79% 91%, 50% 70%, 21% 91%, 32% 57%, 2% 35%, 39% 35%);
    cursor: pointer;
    transition: transform 0.3s ease;
}

.star.circle {
    clip-path: none;
    border-radius: 50%;
}

.star:hover { transform: scale(1.1); }

.page[data-page="0"] .star::after {
    content: attr(data-number);
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #FFF;
    font-size: 1rem;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
}

button {
    padding: 8px 15px;
    background: var(--button-bg);
    color: var(--text-color);
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: background 0.3s ease, transform 0.3s ease;
    margin: 5px;
    position: relative;
    z-index: 2;
}

button:hover {
    background: var(--button-hover);
    transform: scale(1.05);
}

.external-link {
    margin-top: 15px;
    display: flex;
    gap: 10px;
}

.mondrian-container {
    width: 100%;
    max-width: 300px;
    height: 200px;
    background: #FFF;
    border: 4px solid #000;
    position: relative;
    overflow: hidden;
    margin: 10px 0;
}

.mondrian-rect,
.mondrian-circle,
.mondrian-triangle {
    position: absolute;
    border: 2px solid #000;
}

.mondrian-circle { border-radius: 50%; }

.mondrian-triangle {
    border: none;
    clip-path: polygon(50% 0%, 0% 100%, 100% 100%);
}

.mondrian-star {
    width: 20px;
    height: 20px;
    position: absolute;
    clip-path: polygon(50% 0%, 61% 35%, 98% 35%, 68% 57%, 79% 91%, 50% 70%, 21% 91%, 32% 57%, 2% 35%, 39% 35%);
    background: #FFD700;
    border: 1px solid #DAA520;
}

.datetime {
    color: #000;
    font-size: 0.9rem;
    text-align: center;
    margin: 10px 0;
}

.serial-number, .hash {
    font-family: 'Arial', sans-serif;
    font-size: 0.7rem;
    color: #000;
    margin-top: 5px;
}

.compass-container {
    position: fixed;
    bottom: 20px;
    left: 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    z-index: 100;
}

.compass {
    font-size: 2rem;
    cursor: pointer;
    transition: transform 0.5s ease;
    line-height: 2rem;
}

.compass.active {
    animation: spinCounterClockwise 3s linear 1;
}

.shape-toggle {
    width: 2rem;
    height: 2rem;
    background: var(--button-bg);
    color: var(--text-color);
    cursor: pointer;
    transition: background 0.3s ease, transform 0.3s ease;
    position: relative;
    z-index: 101;
}

.shape-toggle::before {
    content: '⚪';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 1.5rem;
}

.shape-toggle.star::before {
    content: '⭐';
}

.shape-toggle:hover {
    background: var(--button-hover);
    transform: scale(1.1);
}

@keyframes spinCounterClockwise {
    from { transform: rotate(0deg); }
    to { transform: rotate(-360deg); }
}

@media (orientation: landscape) {
    .game-area { flex-direction: row; }
    .gradient-container { height: 220px; width: 40px; }
    .gradient-bar { width: 30px; height: 200px; }
    .gradient-marks { height: 200px; }
    .star-container { width: 300px; height: 200px; }
}

@media (orientation: portrait) {
    .game-area { flex-direction: column; }
    .gradient-container { height: 40px; width: 220px; }
    .gradient-bar { width: 200px; height: 30px; background: linear-gradient(to right, #000, #FFF); }
    .gradient-container::after { content: '➡️'; margin-top: 0; margin-left: 5px; }
    .gradient-marks { left: 0; top: 40px; height: 50px; width: 200px; }
    .mark { left: auto; top: 0; }
    .star-container { width: 200px; height: 300px; }
    
    .compass-container {
        bottom: 70px;
    }
    
    button#restart {
        position: relative;
        z-index: 50;
    }
}