/* --- Reset i Tło --- */
body {
    font-family: 'Roboto', sans-serif;
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    margin: 0;
    background-color: #dcdcdc;
    overflow: hidden; /* Zapobiega paskom przewijania na desktopie */
}

/* --- KONTENER ZESZYTU --- */
#notebookContainer {
    position: relative;
    width: 460px;         
    height: 95vh; 
    background-color: #fff;
    box-shadow: 0 15px 30px rgba(0, 0, 0, 0.2), 0 5px 10px rgba(0, 0, 0, 0.1);
    border-radius: 8px;
    display: flex;
    overflow: hidden; 
    transition: width 0.8s cubic-bezier(0.645, 0.045, 0.355, 1.000);
}

#notebookContainer.book-open {
    width: 1000px; 
    max-width: 98vw; /* Zabezpieczenie na mniejsze ekrany */
}

/* --- OKŁADKA --- */
#coverPage {
    position: absolute; top: 0; left: 0; width: 100%; height: 100%;
    display: flex; flex-direction: column; justify-content: center; align-items: center;     
    text-align: center; z-index: 10; background-color: #fff;
    transition: opacity 0.5s ease, transform 0.8s ease; transform-origin: left center;
    background-image: radial-gradient(#f0f0f0 1px, transparent 1px); background-size: 10px 10px;
}

#coverPage::before {
    content: ''; position: absolute; top: 0; left: 0; width: 10px; height: 100%;
    background: linear-gradient(to right, #ccc, #eee); border-right: 1px solid #bbb; 
    z-index: 11; opacity: 1; transition: opacity 0.3s ease;
}

#coverPage.hidden::before { opacity: 0; }

.menu-content { width: 100%; padding: 20px; position: relative; z-index: 12; }

.handwritten-title {
    font-family: 'Indie Flower', cursive; font-size: 4.5em; margin: 0;
    color: #2c3e50; text-shadow: 2px 2px 0px rgba(0,0,0,0.05);
}

.handwritten-subtitle {
    font-family: 'Indie Flower', cursive; font-size: 1.5em; color: #7f8c8d; margin-bottom: 50px;
}

.main-menu { display: flex; flex-direction: column; gap: 20px; width: 100%; align-items: center; }

.menu-item {
    font-family: 'Indie Flower', cursive; font-size: 2em; background: none;
    border: none; border-bottom: 2px solid transparent; padding: 5px 20px;
    cursor: pointer; color: #333; transition: all 0.3s;
}

.menu-item:hover { color: #2980b9; border-bottom: 2px solid #2980b9; transform: scale(1.1); }

#coverPage.hidden { opacity: 0; transform: rotateY(-90deg); pointer-events: none; }

/* --- WNĘTRZE (GRA) --- */
#innerPages {
    display: flex; width: 100%; height: 100%; opacity: 0;
    transition: opacity 0.5s ease 0.4s; padding-left: 0; transform-origin: center;
}

@keyframes pageFlip {
    0% { opacity: 1; transform: scale(1); }
    50% { opacity: 0; transform: scale(0.95) rotate(-1deg); }
    100% { opacity: 1; transform: scale(1); }
}

#innerPages.resetting { animation: pageFlip 0.6s ease-in-out; }

#innerPages::before {
    content: ''; position: absolute; top: 0; left: 0; width: 10px; height: 100%;
    background: linear-gradient(to right, #ccc, #eee); border-right: 1px solid #bbb; z-index: 11;
}

#innerPages.visible { opacity: 1; }

#leftPage, #rightPage {
    position: relative; padding: 10px; display: flex; flex-direction: column;
    align-items: center; background-color: #fff;
    background-image: linear-gradient(#e0e0e0 1px, transparent 1px),
                      linear-gradient(90deg, #e0e0e0 1px, transparent 1px);
    background-size: 20px 20px;
}

#leftPage {
    flex: 0 0 340px; border-right: 1px solid #ddd; justify-content: center; 
}

#rightPage {
    flex: 1; justify-content: center; align-items: center; overflow: hidden;
}

/* UI Elementy */
#gameInfo {
    width: 90%; max-width: 280px; background: #fff;
    border: 2px solid #2c3e50; box-shadow: 3px 3px 0px #2c3e50; 
    padding: 15px; margin-bottom: 20px; text-align: center;
    transform: rotate(1deg); font-family: 'Indie Flower', cursive;
}

.info-header { font-size: 1.6em; margin: 0 0 10px 0; color: #2c3e50; font-weight: bold; }

.score-table {
    width: 100%; border-collapse: collapse; font-size: 1.3em; margin: 5px 0 15px 0;
}
.score-table th, .score-table td { padding: 5px; border: 1px solid #2c3e50; }
.score-table th { background-color: #f5f5f5; font-size: 0.9em; }
.p1-label { color: #3498db; }
.p2-label { color: #e74c3c; }
#player1Score { color: #3498db; font-weight: bold; }
#player2Score { color: #e74c3c; font-weight: bold; }

#turnInfo { font-size: 1.2em; color: #333; border-top: 1px dashed #ccc; padding-top: 10px; }
.turn-highlight { display: block; font-size: 1.5em; font-weight: bold; margin-top: 5px; }

.buttons-container { display: flex; flex-direction: column; width: 100%; align-items: center; gap: 15px; }
.action-button:not(.handwritten-button) { display: none !important; }

.handwritten-button {
    font-family: 'Indie Flower', cursive; font-size: 1.4em; background: #fff; color: #2c3e50;
    border: 2px solid #2c3e50; padding: 8px 20px; box-shadow: 3px 3px 0px #2c3e50; 
    transition: box-shadow 0.1s, transform 0.1s; width: 80%; max-width: 220px; cursor: pointer;
}
.handwritten-button:hover { box-shadow: 1px 1px 0px #2c3e50; transform: translate(2px, 2px); }

#gameCanvas { 
    cursor: crosshair; transform: rotate(-0.5deg) translate(3px, 3px);
    /* Ważne dla responsywności: Canvas może się zmniejszać */
    max-width: 100%; 
    max-height: 100%;
}

/* Modal */
.modal {
    position: absolute; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(255,255,255,0.9); display: flex; justify-content: center; align-items: center; z-index: 100;
}
.modal-content {
    padding: 30px; background: #fff; border: 1px solid #ccc;
    box-shadow: 0 10px 25px rgba(0,0,0,0.2); font-family: 'Indie Flower', cursive; font-size: 1.4em; 
    max-width: 80%; position: relative; text-align: center;
}
.close-btn { position: absolute; top: 10px; right: 20px; cursor: pointer; font-weight: bold; font-size: 1.5em; }
.hidden { display: none !important; }

/* --- MEDIA QUERIES (RESPONSYWNOŚĆ) --- */
@media (max-width: 1050px) {
    /* Zmieniamy zeszyt w pionowy układ na mniejszych ekranach */
    #notebookContainer.book-open {
        width: 95vw;
        height: auto;
        min-height: 90vh;
        flex-direction: column;
        overflow-y: auto; /* Pozwól przewijać jeśli trzeba */
    }

    #innerPages {
        flex-direction: column;
    }

    /* Ukrywamy spiralę na środku w trybie pionowym lub przenosimy (tu ukrywamy dla prostoty) */
    #innerPages::before { display: none; }

    #leftPage {
        flex: 0 0 auto; /* Auto wysokość */
        width: 100%;
        border-right: none;
        border-bottom: 1px solid #ddd;
        padding-bottom: 20px;
    }

    #rightPage {
        flex: 1;
        width: 100%;
        min-height: 400px; /* Zapewnij miejsce na boisko */
    }

    /* Układ menu poziomy na mobile */
    .buttons-container {
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: center;
    }
    
    .handwritten-button {
        width: auto;
        padding: 5px 15px;
        font-size: 1.2em;
    }
    
    #gameInfo {
        max-width: 90%;
    }
}