:root {
    --game-width: 1280px;
    --primary-color: #ffc107;
    --secondary-color: #28a745;
    --dark-blue: #1a1a2e;
    --blue-button: #3498db;
    --allegro-orange: #ff5a00;
}

body, html {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    background-color: var(--dark-blue);
    font-family: 'Bangers', cursive;
    display: flex;
    justify-content: center;
    align-items: center;
}

#game-container {
    position: relative;
    width: 100%;
    max-width: var(--game-width);
    aspect-ratio: 16 / 9;
    background-color: #2c3e50;
    background-image: url('https://cyferlandia.pl/multimedia/bacground.webp');
    background-size: cover;
    background-position: center;
    overflow: hidden;
    box-shadow: 0 0 30px rgba(0, 0, 0, 0.5);
    border-radius: 20px;
}

/**
 * ===================================================================
 *  1. KONTROLA POZYCJI PRZYCISKU NA PC
 * ===================================================================
 *  Zmieniaj wartości w pikselach (px), aby przesuwać przyciskiem.
 */
#intro-action-wrapper {
    position: absolute;

    /* POZYCJA PIONOWA (WYSOKOŚĆ): */
    /* Większa wartość px przesuwa przycisk WYŻEJ. */
    /* Mniejsza/ujemna wartość px przesuwa przycisk NIŻEJ. */
    bottom: calc(50% + -150px);

    /* POZYCJA POZIOMA (OD ŚRODKA): */
    /* Dodatnia wartość (np. + 200px) przesuwa w PRAWO. */
    /* Ujemna wartość (np. - 150px) przesuwa w LEWO. */
    left: calc(50% + 150px);

    transform: translateX(-50%);
    width: 60px;
    height: 60px;
    cursor: pointer;
    z-index: 155;
}

#intro-action-btn {
    position: relative;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: rgba(4, 20, 40, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    transition: transform 0.2s ease;
    z-index: 10;
}

#intro-action-wrapper:hover #intro-action-btn {
    transform: scale(1.1);
}

#intro-action-btn::before {
    content: '';
    position: absolute;
    top: -4px; left: -4px;
    width: calc(100% + 8px);
    height: calc(100% + 8px);
    border-radius: 50%;
    background: linear-gradient(90deg, #ff0000, #ff7300, #fffb00, #48ff00, #00ffd5, #002bff, #7a00ff, #ff00c8, #ff0000);
    background-size: 200% 100%;
    animation: rainbow-bg 4s linear infinite;
    z-index: -1;
    filter: blur(5px);
}

#intro-action-btn .fas {
    font-size: 1.8rem;
    color: white;
    text-shadow: 0 0 5px black;
}

#loading-overlay {
    position: absolute;
    top: 0; left: 0;
    width: 100%;
    height: 100%;
    background: var(--dark-blue);
    z-index: 200;
    display: flex;
    justify-content: center;
    align-items: center;
    flex-direction: column;
    transition: opacity 0.5s ease;
}
#loading-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}
.loader {
    border: 8px solid #f3f3f3;
    border-radius: 50%;
    border-top: 8px solid var(--primary-color);
    width: 60px;
    height: 60px;
    animation: spin 1.5s linear infinite;
}

.decorative-gif {
    position: absolute;
    pointer-events: none;
}

/**
 * ===================================================================
 *  2. KONTROLA POZYCJI SŁONECZKA NA PC
 * ===================================================================
 *  Zmieniaj wartości X i Y w pikselach (px), aby przesuwać słoneczkiem.
 */
#sun {
    position: absolute;
    top: 50%;
    left: 50%;

    /* POZYCJA POZIOMA (X) i PIONOWA (Y): */
    /* Wartość X: dodatnia = w PRAWO, ujemna = w LEWO. */
    /* Wartość Y: dodatnia = w DÓŁ, ujemna = w GÓRĘ. */
    transform: translate(calc(-50% - 230px), calc(-50% + 0px));

    width: 17.5%;
    z-index: 11;
    filter: drop-shadow(0 0 20px var(--primary-color));
    animation: golden-glow 3s infinite alternate;
}

.cloud {
    position: absolute;
    pointer-events: none;
    opacity: 0.8;
    width: 25%;
}
#cloud1 {
    top: calc(3% - 50px);
    left: 5%;
    transform: scale(1.2);
    animation: float 30s ease-in-out infinite;
}
#cloud2 {
    top: calc(2% - 50px);
    left: 65%;
    transform: scale(0.8);
    animation: float 40s ease-in-out infinite reverse;
}
#birds {
    top: 10%;
    left: 50%;
    width: 36%;
    transform: translateX(-50%);
    z-index: 20;
}
#eating-birds {
    position: absolute;
    bottom: 41%;
    right: 9%;
    width: 18%;
}

#cyferiusz-screen {
    position: absolute;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    width: 23.8%;
    height: 35%;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10;
}
#cyferiusz-video {
    width: 100%;
    height: 100%;
    object-fit: contain;
    filter: drop-shadow(5px 5px 15px rgba(0,0,0,0.5));
}

#ui-container {
    position: absolute;
    top: 75px;
    left: 0;
    right: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
    flex-direction: column;
    gap: 15px;
}

.ui-button {
    background: var(--primary-color);
    border: 5px solid white;
    border-radius: 50%;
    width: 80px;
    height: 80px;
    font-size: 2.5rem;
    color: white;
    cursor: pointer;
    text-shadow: 2px 2px 5px rgba(0,0,0,0.5);
    box-shadow: 0 5px 15px rgba(0,0,0,0.4);
    transition: transform 0.2s ease, background-color 0.2s ease;
    display: flex;
    justify-content: center;
    align-items: center;
    text-decoration: none;
}
.ui-button:hover {
    transform: scale(1.1);
}

#exit-button {
    position: absolute;
    top: 20px;
    right: 20px;
    z-index: 210;
    background-color: var(--blue-button);
}

#start-button {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 250px;
    height: 100px;
    border-radius: 50px;
    font-size: 3.5rem;
    z-index: 101;
    background: var(--secondary-color);
    visibility: hidden;
    opacity: 0;
    transition: opacity 0.5s ease, visibility 0.5s ease;
}
#start-button.visible {
    visibility: visible;
    opacity: 1;
}

#score-display {
    background: rgba(0,0,0,0.5);
    color: white;
    padding: 5px 20px;
    border-radius: 20px;
    font-size: 1.8rem;
    border: 3px solid var(--primary-color);
    animation: rainbow-border-glow 4s linear infinite;
}

#progress-bar-container {
    width: 70%;
    height: 20px;
    background-color: rgba(0, 0, 0, 0.5);
    border-radius: 10px;
    border: 3px solid #fff;
    overflow: visible;
    animation: levitate 3.5s ease-in-out infinite;
    position: relative;
}
#progress-bar {
    width: 0%;
    height: 100%;
    border-radius: 7px;
    background: linear-gradient(90deg, #ff0000, #ff7300, #fffb00, #48ff00, #00ffd5, #002bff, #7a00ff, #ff00c8, #ff0000);
    background-size: 200% 100%;
    transition: width 0.5s ease-out;
    animation: rainbow-bg 5s linear infinite;
}

#info-bar {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    width: 80%;
}

.level-button {
    background: rgba(0,0,0,0.5);
    padding: 5px 15px;
    border-radius: 20px;
    font-size: 1.5rem;
    border: 3px solid #555;
    color: #ccc;
    text-decoration: none;
    transition: all 0.3s ease;
}
.level-button:hover, .level-button:focus {
    color: white;
    border-color: var(--primary-color);
    transform: scale(1.05);
    cursor: pointer;
    outline: none;
}
.level-button.active-level {
    color: white;
    animation: rainbow-border-glow 4s linear infinite;
}

#bubble-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 150;
    pointer-events: none;
}

.number-bubble, .reward-bubble {
    position: absolute;
    pointer-events: all;
    cursor: pointer;
    transition: opacity 0.3s ease-out;
    will-change: transform;
    display: flex;
    justify-content: center;
    align-items: center;
}
.number-bubble:hover, .reward-bubble:hover, .number-bubble:focus, .reward-bubble:focus {
    transform: scale(1.1);
    filter: drop-shadow(0 0 20px var(--primary-color));
    outline: none;
}
.number-bubble {
    width: 240px;
    height: 240px;
}
.reward-bubble {
    opacity: 0.9;
}

.number-bubble img, .reward-bubble img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    animation: rainbow-glow-shadow 4s linear infinite;
}
.reward-bubble img {
    animation: rainbow-glow-shadow 4s linear infinite, pulse 2s infinite ease-in-out;
}
.reward-bubble-content {
    position: relative; z-index: 2; color: white; text-align: center;
    font-family: 'Bangers', cursive; text-shadow: 0 0 10px black, 0 0 10px black;
    display: flex; flex-direction: column; align-items: center; pointer-events: none;
}
.reward-text-main { font-size: 2rem; letter-spacing: 2px; }
.reward-text-sub { font-size: 1.5rem; letter-spacing: 1px; }
.reward-arrow { font-size: 2.5rem; margin-top: 5px; animation: float 2s infinite ease-in-out; }

#sparks-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
    pointer-events: none;
}

.zgubek-on-bar {
    position: absolute;
    bottom: 5px;
    width: 80px;
    height: 80px;
    transform: translateX(-50%);
    transition: opacity 0.5s, transform 0.5s ease-in-out;
    pointer-events: none;
}
.zgubek-on-bar.captured {
    opacity: 0;
    transform: translate(-50%, -100px) scale(0.5);
}

#captured-zgubki-container {
    position: absolute;
    right: 20px;
    bottom: 20px;
    display: flex;
    gap: 20px;
    z-index: 101;
}
.zgubek-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
}
.zgubek-captured-icon {
    width: 120px; height: 120px; background: rgba(0,0,0,0.4);
    border-radius: 15px; border: 2px solid var(--primary-color);
    opacity: 0; transform: scale(0.5);
    transition: opacity 0.5s, transform 0.5s;
}
.zgubek-captured-icon.visible {
    opacity: 1;
    transform: scale(1);
}
.zgubek-name {
    color: white; font-size: 1.8rem; margin-top: 5px; text-shadow: 2px 2px 4px #000;
    opacity: 0; transform: translateY(10px);
    transition: opacity 0.5s ease 0.2s, transform 0.5s ease 0.2s;
}
.zgubek-name.visible {
    opacity: 1;
    transform: translateY(0);
}

.zgubek-animation-clone {
    position: absolute;
    z-index: 999;
    width: 120px;
    height: 120px;
    transition: all 1s ease-in-out;
    pointer-events: none;
}

#zabka-container {
    position: absolute; bottom: 10px; left: 10px; width: 28%; height: 50%;
    z-index: 5; pointer-events: none;
}
#zabka-video {
    width: 100%; height: 100%; object-fit: contain;
}

#book-shelf {
    position: absolute;
    bottom: 15px;
    left: calc(50% - (23.8% / 2) - 10px);
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 155;
}

#reward-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.85);
    z-index: 160;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.5s ease-in-out;
    pointer-events: none;
    box-sizing: border-box;
    padding: 2vw;
}

#reward-overlay.visible {
    opacity: 1;
    pointer-events: all;
}

.reward-main-content {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    gap: 5vw;
    width: 100%;
    max-width: 1200px;
    height: auto;
}

.reward-video-with-books {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    flex-basis: 60%;
    flex-shrink: 1;
}

#reward-video {
    width: 100%;
    border: 5px solid var(--primary-color);
    border-radius: 20px;
    box-shadow: 0 0 30px var(--primary-color);
}

#reward-book-shelf {
    display: flex;
    gap: 20px;
    justify-content: center;
    margin-top: -65px;
    position: relative;
    z-index: 10;
}

#reward-book-shelf .shelf-book {
    width: clamp(100px, 12vw, 150px);
}

#purchase-links {
    display: flex;
    flex-direction: column;
    gap: 20px;
    align-items: center;
    flex-basis: 35%;
    flex-shrink: 0;
    opacity: 0;
    transition: opacity 0.5s ease-in-out;
}

#purchase-links.visible {
    opacity: 1;
}

.purchase-button {
    padding: 15px 25px;
    font-size: 1.3rem;
    color: white;
    text-decoration: none;
    background-color: var(--secondary-color);
    border: 5px solid var(--primary-color);
    border-radius: 30px;
    transition: transform 0.2s ease;
    text-align: center;
    box-shadow: 0 0 20px var(--primary-color);
    min-width: 280px;
    width: 100%;
    box-sizing: border-box;
}

a.purchase-button[href*="allegro.pl"] {
    background-color: var(--allegro-orange);
}

#play-again-btn {
    background-color: var(--blue-button);
}

.purchase-button:hover, .purchase-button:focus {
    transform: scale(1.05);
    outline: none;
}

.shelf-book {
    width: 100px; cursor: pointer;
    filter: drop-shadow(0 4px 10px rgba(0,0,0,0.4));
    transition: transform 0.3s ease;
    animation: levitate 4s ease-in-out infinite;
}
.shelf-book:nth-child(2) { animation-delay: -2s; }
.shelf-book:hover, .shelf-book:focus {
    transform: scale(1.15);
    filter: drop-shadow(0 8px 20px rgba(255,193,7,0.7));
    outline: none;
}

#book-modal {
    position: absolute; top: 0; left: 0; width: 100%; height: 100%;
    background-color: rgba(0,0,0,0.8); z-index: 170;
    display: flex; justify-content: center; align-items: center;
    opacity: 0; transition: opacity 0.4s ease;
    pointer-events: none;
}
#book-modal.visible {
    opacity: 1;
    pointer-events: all;
}
.book-modal-content {
    position: relative;
}
#book-modal-image {
    max-width: 80vw;
    max-height: 80vh;
}
.book-modal-button {
    position: absolute; bottom: 10%; left: 50%;
    transform: translateX(-50%); padding: 10px 25px;
    font-size: 2.5rem; color: white; text-decoration: none;
    background-color: var(--secondary-color); border: 3px solid white;
    border-radius: 30px; transition: transform 0.2s ease;
}
.book-modal-button:hover, .book-modal-button:focus {
    transform: translateX(-50%) scale(1.1);
    outline: none;
}
.book-modal-close {
    position: absolute; top: -20px; right: -20px;
    width: 50px; height: 50px; background: white; color: black;
    border: 3px solid black; border-radius: 50%;
    font-size: 2rem; font-weight: bold; cursor: pointer;
}

#rotate-device-overlay { display: none; }
@media (max-width: 768px) and (orientation: portrait) {
    body { align-items: initial; }
    #game-container { display: none; }
    #rotate-device-overlay {
        display: flex; position: fixed; top: 0; left: 0; width: 100%; height: 100%;
        z-index: 9999; flex-direction: column; justify-content: center; align-items: center;
        text-align: center; padding: 20px; box-sizing: border-box; background: var(--dark-blue);
    }
    #rotate-device-overlay img {
        width: 40vw; max-width: 180px; margin-bottom: 20px;
        animation: rotate-and-pulse 2.5s ease-in-out infinite;
    }
    #rotate-device-overlay p { font-size: 2.5rem; color: var(--primary-color); margin: 0; }
    #rotate-device-overlay span { font-size: 1.5rem; color: white; margin-top: 10px; }
}

@keyframes pulse { 0% {transform: scale(1);} 50% {transform: scale(1.1);} 100% {transform: scale(1);} }
@keyframes rainbow-border-glow { 0%,100%{border-color:#ff0000}16%{border-color:#ff7300}33%{border-color:#fffb00}50%{border-color:#48ff00}66%{border-color:#002bff}83%{border-color:#7a00ff} }
@keyframes rainbow-glow-shadow { 0%,100%{filter:drop-shadow(0 0 15px #ff0000)}16%{filter:drop-shadow(0 0 15px #ff7300)}33%{filter:drop-shadow(0 0 15px #fffb00)}50%{filter:drop-shadow(0 0 15px #48ff00)}66%{filter:drop-shadow(0 0 15px #002bff)}83%{filter:drop-shadow(0 0 15px #7a00ff)} }
@keyframes spin { 0% {transform: rotate(0deg);} 100% {transform: rotate(360deg);} }
@keyframes shake { 0%,100%{transform:translateX(0)}25%{transform:translateX(-10px)}75%{transform:translateX(10px)} }
@keyframes float { 0% {transform: translateY(0px);} 50% {transform: translateY(-10px);} 100% {transform: translateY(0px);} }
@keyframes levitate { 0% {transform: translateY(0px);} 50% {transform: translateY(-10px);} 100% {transform: translateY(0px);} }
@keyframes rotate-and-pulse { 0% {transform:rotate(0deg) scale(1)} 50% {transform:rotate(-90deg) scale(1.1)} 100% {transform:rotate(-90deg) scale(1)} }
@keyframes golden-glow { from {filter: drop-shadow(0 0 15px var(--primary-color));} to {filter: drop-shadow(0 0 30px gold);} }
@keyframes rainbow-bg { 0% {background-position: 0% 50%;} 100% {background-position: 200% 50%;} }

/**
 * ####################################################################
 * #                                                                  #
 * #  KONTROLA POZYCJI DLA SMARTFONÓW (W TRYBIE POZIOMYM)              #
 * #                                                                  #
 * ####################################################################
 */
@media (max-width: 900px) and (orientation: landscape) {
    .reward-main-content {
        gap: 2vw;
    }

    #reward-book-shelf {
        margin-top: -45px;
    }

    .purchase-button {
        min-width: 200px;
        font-size: 1rem;
        padding: 10px 15px;
    }

    .ui-button { width: 60px; height: 60px; font-size: 1.8rem; border-width: 3px; }
    #exit-button { top: 10px; right: 10px; width: 60px; height: 60px; }
    #start-button { width: 200px; height: 80px; font-size: 2.5rem; }
    #score-display { font-size: 1rem; padding: 2px 8px; }
    .number-bubble { width: 160px; height: 160px; }
    #ui-container { top: 50px; gap: 5px; }
    #progress-bar-container { width: 75%; height: 15px; }
    #info-bar { width: 90%; gap: 5px; flex-wrap: wrap; justify-content: center; }
    .level-button { font-size: 0.8rem; padding: 2px 6px; }

    #cyferiusz-screen { width: 29.14%; height: 42.85%; bottom: 5px; }
    
    /**
     * ===================================================================
     *  3. KONTROLA POZYCJI PRZYCISKU NA SMARTFONIE
     * ===================================================================
     */
    #intro-action-wrapper {
        width: 35px;
        height: 35px;
        
        /* POZYCJA PIONOWA (WYSOKOŚĆ): */
        bottom: calc(48% - 65px);
        
        /* POZYCJA POZIOMA (OD ŚRODKA): */
        left: calc(50% + 85px);
    }
    #intro-action-btn .fas {
        font-size: 1.3rem;
    }
    
    /**
     * ===================================================================
     *  4. KONTROLA POZYCJI SŁONECZKA NA SMARTFONIE
     * ===================================================================
     */
    #sun {
        /* POZYCJA POZIOMA (X) i PIONOWA (Y): */
        transform: translate(calc(-50% + 130px), calc(-50% - 30px));
    }

    .zgubek-on-bar { width: 60px; height: 60px; }
    #captured-zgubki-container { right: 10px; bottom: 10px; gap: 5px; }
    .zgubek-captured-icon { width: 90px; height: 90px; }
    .zgubek-name { font-size: 1.2rem; }
    #zabka-container { height: 60%; }

    #book-shelf {
        left: calc(50% - (29.14% / 2) - 30px);
    }
    #book-shelf .shelf-book {
        width: 75px;
    }

    .book-modal-button { font-size: 1.5rem; padding: 5px 15px; }
}