@keyframes slowShow {
    from { opacity: 0; transform: scale(0.9); }
    to { opacity: 1; transform: scale(1); }
}

:root {
    /* Domyślna wysokość dla ekranów 1920x1080 i mniejszych */
    --header-height: 120px; 
    /* Czas trwania płynnego przejścia motywów */
    --transition-speed: 0.2s ease-in-out;
}

/* Zmiana wysokości dla dużych ekranów (np. 3440x1440px) */
@media (min-width: 2560px) {
    :root {
        --header-height: 190px; 
    }
}

/* --- RESPONSYWNOŚĆ (Telefony) --- */
@media (max-width: 768px) {
    #glowny {
        flex-direction: column !important;
        display: flex !important;
    }

    /* 1. CZARNY PASEK KONTROLEK */
    #controls-wrapper {
        position: static !important;
        width: 100% !important;
        background-color: #000 !important;
        display: flex !important;
        justify-content: center !important;
        padding: 10px 0 !important;
        margin: 0 !important;
        border-top: none !important; 
    }

    .mode, .lang {
        display: flex;
        align-items: center;
        float: none !important;
        position: static !important;
        margin: 0 !important;
        cursor: pointer;
        user-select: none;
        color: #fff !important;
    }

    /* 2. MENU ROZWIJANE */
    #menu {
        width: 100% !important;
        min-height: auto !important;
        padding: 0 !important;
        margin: 0 !important;
        text-align: center; 
    }

    #menuText {
        display: block !important;
        width: 100%;
        padding: 15px 0;
        cursor: pointer;
        font-size: 35px;
        font-weight: bold;
    }

    /* Dodanie strzałki (rozwinięte/zwinięte) */
    #menuText::after {
        content: ' \25BE'; /* Strzałka w dół domyślnie */
    }
    #menu.active #menuText::after {
        content: ' \25B4'; /* Strzałka w górę po kliknięciu/rozwinięciu */
    }

    #menu-list {
        display: none;
        width: 100%;
        padding-bottom: 20px;
        font-size: 30px;
    }

    #menu.active #menu-list {
        display: block !important;
    }

    /* 3. SKONDENSOWANE I WYŚRODKOWANE LINKI */
    
    #menu-list a {
        font-size: 25px;
        line-height: 1.2;
    }

    /* Nagłówki sekcji (Obliczenia, Gry) */
    #menu-list > a[data-i18n^="Menu_OBL"], 
    #menu-list > a[data-i18n^="Menu_GRY"] {
        font-weight: bold;
    }

    #menu-list ul {
        text-align: center !important; 
        list-style-type: none !important; /* Wyłączamy domyślne kropki */
        padding: 0 !important;
        margin: 0 !important;
    }

    #menu-list li {
        margin: 0 !important;
        padding: 0 !important;
        text-align: center !important; 
        line-height: 1.2;
    }

    /* Link staje się punktem odniesienia dla kropki */
    #menu-list li a {
        display: inline-block !important; /* Zmiana na inline-block */
        position: relative !important;    /* Niezbędne do absolutnej kropki */
        padding: 0 !important;
    }

    /* Tworzymy własną, absolutną kropkę */
    #menu-list li a::before {
        content: '\2022';     /* Znak kropki */
        position: absolute;
        left: -15px;          /* Przesunięcie kropki w lewo (możesz dostosować tę wartość) */
        top: 0;
        color: inherit;       /* Kropka przejmie kolor linku */
        pointer-events: none; /* Kropka nie będzie blokować kliknięć */
    }

    /* 4. TREŚĆ I ZEGAR */
    #tekst {
        width: 100% !important;
        padding: 20px 10px !important;
        display: flex !important;
        justify-content: center !important;
    }

    #zegar {
        position: absolute;
        top: 2px;
        right: 10px;
        font-size: 14px;
        z-index: 110;
    }

    .card { 
        height: auto !important;
    }
}
/* Na komputerach menu-list musi być zawsze widoczne */
@media (min-width: 769px) {
    #menu-list {
        display: block !important;
    }
}

/* Zamiast samego *, ograniczamy transition do elementów interfejsu */
body, #menu, #tekst, #nazwa, #zegar, a, select, .mode, .controls-wrapper {
    box-sizing: border-box;
    transition: background-color var(--transition-speed), 
                color var(--transition-speed), 
                border-color var(--transition-speed), 
                background var(--transition-speed),
                text-shadow var(--transition-speed);
}

/* Pozostałe elementy zachowują box-sizing, ale bez transition */
*:not(body, #menu, #tekst, #nazwa, #zegar, a, select, .mode, .controls-wrapper) {
    box-sizing: border-box;
}

/* Jednocześnie zachowujemy animacje zdefiniowane przez @keyframes (R oraz L) */
figure, figure *, .c, .c2, .c3, .c4, .c5, .c6, i {
    transition: none !important;
}

/* Upewniamy się, że transformacje 3D i animacje obrotu nadal działają */
figure {
    transition: transform 1.4s !important; /* Zachowuje płynny powrót z hovera */
    transform-style: preserve-3d;
}

::selection {
    background-color: aquamarine;
    color: #000;
}

body {
    background-color: rgb(255, 255, 255); 
    margin: 0;
    font-family: 'Noto Sans Display', sans-serif;
    display: flex;
    flex-direction: column;
    min-height: 100vh; /* Zapewnia wysokość na cały ekran */
    overflow-x: hidden;
}

#glowny {
    display: flex;
    flex: 1; /* Rozciąga się do dołu okna */
    width: 100%;
    position: relative;
    min-height: calc(100vh - var(--header-height));
}

/* --- KONTENER PRZYCISKÓW (Zmieniony na układ poziomy) --- */
#controls-wrapper {
    display: flex;
    flex-direction: row; /* Ustawia elementy w poziomie */
    align-items: center; /* Centruje elementy pionowo względem siebie */
    justify-content: flex-end; /* Przesuwa zawartość do prawej */
    gap: 15px; /* Odstęp między trybem a językiem */
    position: absolute;
    top: 2px;
    right: 5px;
    z-index: 105;
    white-space: nowrap; /* Zapobiega łamaniu tekstu do nowej linii */
}

/* Reset i ustawienie dzieci */
.mode, .lang {
    display: flex;
    align-items: center;
    float: none !important;
    position: static !important;
    margin: 0 !important;
    cursor: pointer;
    user-select: none;
}

select.lang, select.lang option {
    background: rgba(49, 49, 49, 0.4);
    color: inherit;
    border: 1px solid currentColor;
    border-radius: 4px;
}

/* --- LINKI --- */
a:link, a:visited, a:active { 
    color: #000000; 
    text-decoration: none;
}
a:hover { 
    color: #2c7ffb;
}

.dark a:link, .dark a:visited, .dark a:active { color: #ffffff; }
.dark a:hover { color: #4d94ff; }

.dark_snow a:link, .dark_snow a:visited, .dark_snow a:active { 
    color: #ffffff; 
    text-shadow: 2px 2px #000000;
}

/* --- NAGŁÓWEK --- */
#nazwa {
    width: 100%;
    height: var(--header-height);
    background-color: rgb(0, 0, 0);
    padding: 0; 
    text-align: center;
    font-size: clamp(14px, 4vw, 28px);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    z-index: 100; 
    user-select: none;
}

/* --- ZEGAR --- */
#zegar {
    position: absolute;
    right: 10px;
    top: 5px;
    color: rgb(255, 255, 255);
    font-size: 20px;
    cursor: pointer;
    z-index: 101;
    pointer-events: auto;
    transform-origin: right top; 
    white-space: nowrap;
    transition: transform 0.2s ease, color 0.2s ease;
    user-select: none;
}

#zegar:hover {
    transform: scale(1.01);
    color: #d3ffff;
}

/* --- MENU --- */
#menu {
    width: 270px;
    min-height: 100%; /* Zawsze minimum do dołu okna */
    overflow-wrap: break-word;
    padding: 15px 10px;
    font-size: 20px;
    background: linear-gradient(207deg, rgba(131, 58, 180, 1) 0%, rgba(255, 0, 0, 1) 50%, rgb(255, 255, 0) 100%);
    flex-shrink: 0;
    user-select: none;
}

.dark #menu {
    background: linear-gradient(207deg, rgba(81, 36, 111, 1) 0%, rgba(150, 0, 0, 1) 50%, rgba(160, 150, 0, 1) 100%);
}

.white_snow #menu {
    background: repeating-linear-gradient(207deg,#de0700 0%,#de0700 5%,#ffffff 5%,#ffffff 10%,#34a65f 10%,#34a65f 15%,#ffffff 15%,#ffffff 20%);
}

.dark_snow #menu {
    background: repeating-linear-gradient(207deg,#8b0000 0%,#8b0000 5%,#d0d0d0 5%,#d0d0d0 10%,#0b4d26 10%,#0b4d26 15%,#d0d0d0 15%, #d0d0d0 20%);
    text-shadow: 2px 2px #000000;
}

/* --- TREŚĆ --- */
#tekst {
    flex: 1;
    padding: 60px 25px 25px 25px; /* Padding góra robi miejsce na przyciski na PC */
    font-size: 25px;
    user-select: none; 
}

/* --- ELEMENTY DODATKOWE --- */
ul {
    display: block;
    list-style-type: disc;
    margin: 0;
    padding-left: 20px;
}

/* --- NAPRAWA: ZWIJANE PODKATEGORIE MENU --- */
.submenu-toggle {
    cursor: pointer;
    display: block;      /* TO NAPRAWIA: wymusza nową linię dla nagłówków */
    width: 100%;         /* Klikalne na całej szerokości */
    font-weight: bold;
}

.submenu-toggle::after {
    content: ' \25BE';       /* Strzałka w dół gdy zamknięte */
}

.submenu-toggle.active::after {
    content: ' \25B4';       /* Strzałka w górę gdy otwarte */
}

.submenu-list {
    display: none;
    list-style-type: none; /* Wyłączamy standardowe kropki */
    padding-left: 15px;
}

.submenu-list li {
    position: relative;
}

.submenu-toggle.active + .submenu-list {
    display: block;      /* Pokazuje listę gdy nagłówek ma klasę active */
}

.dark, .dark_snow {
    background-color: #202020;
    color: #ffffff;
}

button { 
    background: #000; 
    color: #fff; 
    font-weight: bold; 
    border: 2px solid #ffffff; 
    border-radius: 8px; 
    padding: 10px 20px; 
    cursor: pointer; 
    transition: background 0.2s, transform 0.1s; 
    user-select: none; 
}

button:hover { 
    background: #333; 
    transform: translateY(-1.5px);
}

button:active { 
    transform: scale(0.96); 
}

button.active-mode {
    background-color: #cccccc;
    color: #000;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.2);
    border: 0px solid #fff;
}

.matobl { 
    width: 100%; 
    border-radius: 8px; 
    border: 2px solid #eee; 
    padding: 10px; 
    box-sizing: border-box; 
    margin: 5px 0; 
    outline: none; 
    font-size: 1rem;
    font-family: inherit;
}

.card { 
    padding: 20px; 
    border-radius: 12px; 
    margin-bottom: 20px; 
    box-shadow: 0 10px 25px rgba(0,0,0,0.3); 
    animation: fadeIn 0.4s ease-out; 
    border: 1px solid #eee; 
    max-width: 800px; 
    margin-left: auto; 
    margin-right: auto;
}

/* --- KARTA (Tryb Ciemny i Dark Snow) --- */
.dark .card {
    border: 1px solid #1d1d1d;      /* Ciemniejsza obramówka zamiast jasnej */
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.9); /* Znacznie mocniejszy cień, aby był widoczny na ciemnym tle */
}

h2 {
    margin-top: 0;
    text-align: center;
    user-select: none; 
}

/* --- TRYB TERMINALA (CMD) --- */
.mode-cmd, .mode-cmd * {
    background-color: #000000 !important;
    color: #00ff00 !important;
    font-family: 'Courier New', Courier, monospace !important;
    border-color: #00ff00 !important;
    box-shadow: none !important;
    text-shadow: none !important;
}

/* Opcjonalnie: sprawiamy, by przyciski też wyglądały jak w konsoli */
.mode-cmd button {
    border: 1px solid #00ff00 !important;
    background: transparent !important;
}

.mode-cmd input, .mode-cmd select, .mode-cmd #nazwa {
    background: #000 !important;
    border: 1px solid #00ff00 !important;
}

.mode-cmd #menu{
    background: #000 !important;
    border: 1px solid #00ff00 !important;
    width: 287px !important; /* Dostosowujemy szerokość menu, by uwzględnić obramowanie */
}

input:focus, select:focus { 
    border-color: #000; 
}

/* --- ANIMACJE --- */
@keyframes megaSpin {
    0% { transform: rotate(0deg) scale(1); }
    25% { transform: rotate(90deg) scale(0.7); filter: hue-rotate(90deg); }
    50% { transform: rotate(180deg) scale(0.4); filter: hue-rotate(180deg); }
    75% { transform: rotate(270deg) scale(0.7); filter: hue-rotate(270deg); }
    100% { transform: rotate(360deg) scale(1); filter: hue-rotate(0deg); }
}

.page-spin {
    animation: megaSpin 4s cubic-bezier(0.68, -0.55, 0.27, 1.55) forwards;
    overflow: hidden;
}

@keyframes rainbowGlitch {
    0% { background-color: #ff0000; color: #00ff00; }
    20% { background-color: #ffff00; color: #0000ff; }
    40% { background-color: #00ff00; color: #ff00ff; }
    60% { background-color: #00ffff; color: #ff0000; }
    80% { background-color: #0000ff; color: #ffff00; }
    100% { background-color: #ff00ff; color: #00ffff; }
}

.mode-glitch, .mode-glitch * {
    animation: rainbowGlitch 0.1s infinite !important;
    font-family: "Wingdings", "Webdings", "Comic Sans MS", cursive !important;
    transition: none !important;
}

@keyframes shakePage {
    0% { transform: translate(1px, 1px); }
    50% { transform: translate(-1px, -2px); }
    100% { transform: translate(1px, 1px); }
}

.mode-glitch {
    animation: rainbowGlitch 0.1s infinite, shakePage 0.05s infinite !important;
    overflow: hidden;
}

.barrel-roll-forward {
    animation: flipForward 1.8s cubic-bezier(0.45, 0.05, 0.55, 0.95) forwards;
    backface-visibility: visible !important; 
    transform-style: preserve-3d;
    will-change: transform;
}

@keyframes flipForward {
    0% { transform: perspective(2000px) rotateX(0deg) scale(1); }
    15% { transform: perspective(2000px) rotateX(-20deg) scale(0.95); }
    50% { transform: perspective(2000px) rotateX(180deg) scale(0.85); }
    100% { transform: perspective(2000px) rotateX(360deg) scale(1); }
}

body.barrel-roll-active {
    overflow: hidden;
    height: 100vh;
    width: 100vw;
}

/* --- WYGASZACZ --- */
#dvd-screensaver {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: black;
    z-index: 10000;
    cursor: none;
    user-select: none;
}

#dvd-logo {
    position: absolute;
    font-size: 100px;
    font-weight: bold;
    color: #00ff00;
    white-space: nowrap;
    user-select: none;
}

#menu-list > a {
    display: block; /* Wymusza przejście do nowej linii */
}

#menu-list .odstep-duzy {
    margin-bottom: 11px !important; 
}

.submenu-toggle {
    margin-bottom: 10px;
}

/* Klasa aktywowana przez skrypt */
.physics-enabled {
    overflow: hidden !important;
}

/* Wyłączamy animacje transition, które gryzłyby się z fizyką */
.physics-enabled body, 
.physics-enabled #menu, 
.physics-enabled #menu-list *, 
.physics-enabled .card,
.physics-enabled #nazwa,
.physics-enabled a,
.physics-enabled button {
    transition: none !important;
    user-select: none;
}

/* Styl dla elementów "spadających" */
.falling-element {
    position: fixed !important;
    margin: 0 !important;
    z-index: 9999;
    pointer-events: auto;
    /* Zapobiega migotaniu */
    backface-visibility: hidden;
}

/* Klasa aktywowana przez skrypt */
.physics-enabled {
    overflow-x: hidden !important;
}

/* Wyłączamy przejścia dla spadających elementów, by fizyka działała płynnie */
.falling-element {
    position: fixed !important;
    margin: 0 !important;
    z-index: 9999;
    transition: none !important;
    pointer-events: auto;
    backface-visibility: hidden;
    /* Zapobiega zaznaczaniu tekstu podczas przeciągania */
    user-select: none; 
}

/* Menu i Nazwa zostają na swoim miejscu - usuwamy im transition przy fizyce */
.physics-enabled #nazwa, .physics-enabled #menu {
    transition: none !important;
}

/* ============================================================
   EASTER EGG NOTIFICATION TOAST
============================================================ */
#egg-toast {
    position: fixed;
    bottom: 25px;
    right: -400px; /* Ukryte poza prawą krawędzią ekranu */
    width: 320px;
    background: linear-gradient(135deg, #FFD700, #FFA500);
    color: #000;
    padding: 15px 20px;
    border-radius: 12px;
    box-shadow: -5px 10px 20px rgba(0, 0, 0, 0.4);
    z-index: 100000; /* Musi być nad wszystkim */
    /* Animacja sprężynująca wysuwania */
    transition: right 0.6s cubic-bezier(0.68, -0.55, 0.27, 1.55);
    border: 2px solid #fff;
    font-family: inherit;
    pointer-events: none; /* Żeby nie przeszkadzało w klikaniu gry wysunięte */
}

/* Klasa aktywująca wysunięcie plakietki */
#egg-toast.show {
    right: 25px;
}

#egg-toast-title {
    font-weight: bold;
    font-size: 1.2rem;
    margin-bottom: 5px;
}

#egg-toast-msg {
    font-size: 0.95rem;
    margin-bottom: 12px;
    line-height: 1.3;
}

#egg-toast-progress {
    font-size: 0.85rem;
    font-weight: bold;
    text-align: right;
    border-top: 1px solid rgba(0, 0, 0, 0.2);
    padding-top: 8px;
}

/* --- Dopasowanie do trybów strony --- */
.dark #egg-toast, .dark_snow #egg-toast {
    background: linear-gradient(135deg, #8B6508, #CD950C);
    color: #fff;
    border-color: #333;
    box-shadow: -5px 10px 20px rgba(0, 0, 0, 0.8);
}

.dark #egg-toast-progress, .dark_snow #egg-toast-progress {
    border-top: 1px solid rgba(255, 255, 255, 0.2);
}

/* --- Responsywność dla telefonów --- */
@media (max-width: 768px) {
    #egg-toast {
        width: calc(100% - 40px);
        left: 20px; /* Centrowanie na telefonie */
        bottom: -150px; /* Ukryte u dołu ekranu zamiast po prawej */
        right: auto;
        transition: bottom 0.6s cubic-bezier(0.68, -0.55, 0.27, 1.55);
    }
    #egg-toast.show {
        bottom: 20px;
    }
}