:root {
    --primary: #0069a7;
    --secondary: #002D74;
    --accent: #80BC00;
    --dark: #2d3436;
    --light: #f5f6fa;
    --success: #00b894;
    --warning: #fdcb6e;
    --danger: #e17055;
    --info: #0984e3;
    --shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    --transition: all 0.3s ease;
}

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

body {
    font-family: 'Poppins', sans-serif;
    background: linear-gradient(135deg, #002D74 0%, #0069A7 100%);
    color: var(--light);
    height: 100vh;
    overflow: hidden;
    line-height: 1.6;
}

.screen {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    height: 100vh;
    width: 100vw;
    position: absolute;
    top: 0;
    left: 0;
    transition: opacity 0.5s;
    padding: 20px;
    text-align: center;
}

.hidden {
    opacity: 0;
    pointer-events: none;
}

.control-button {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background-color: rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(10px);
    border: none;
    color: white;
    font-size: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    box-shadow: var(--shadow);
}

.control-button:hover {
    background-color: rgba(255, 255, 255, 0.3);
    transform: scale(1.1);
}

#fullscreenButton {
    background-color: var(--info);
}

.pause-menu {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
    backdrop-filter: blur(5px);
}

.pause-content {
    background: linear-gradient(135deg, rgba(0, 45, 116, 0.9) 0%, rgba(0, 105, 167, 0.9) 100%);
    padding: 30px;
    border-radius: 20px;
    text-align: center;
    width: 90%;
    max-width: 400px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
}

.pause-content h2 {
    color: white;
    margin-bottom: 20px;
    font-size: 28px;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.menu-button {
    padding: 15px 25px;
    font-size: 18px;
    background-color: rgba(255, 255, 255, 0.2);
    color: white;
    border: none;
    border-radius: 50px;
    cursor: pointer;
    margin: 10px 0;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    max-width: 250px;
    backdrop-filter: blur(5px);
    box-shadow: var(--shadow);
}

.menu-button:hover {
    background-color: rgba(255, 255, 255, 0.3);
    transform: translateY(-3px);
}

.menu-button i {
    font-size: 20px;
}

.pulse {
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

.loading-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    max-width: 300px;
}

.spinner {
    width: 80px;
    height: 80px;
    position: relative;
    margin-bottom: 20px;
}

.double-bounce1, .double-bounce2 {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background-color: var(--light);
    opacity: 0.6;
    position: absolute;
    top: 0;
    left: 0;
    animation: bounce 2.0s infinite ease-in-out;
}

.double-bounce2 {
    animation-delay: -1.0s;
}

@keyframes bounce {
    0%, 100% { transform: scale(0.0); }
    50% { transform: scale(1.0); }
}

.loading-text {
    font-size: 24px;
    font-weight: bold;
    margin-bottom: 10px;
}

.loading-bar {
    width: 100%;
    height: 10px;
    background-color: rgba(255, 255, 255, 0.2);
    border-radius: 5px;
    overflow: hidden;
    margin-bottom: 5px;
}

.loading-progress {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--accent), var(--primary));
    transition: width 0.3s;
    border-radius: 5px;
}

.loading-percent {
    font-size: 16px;
    color: rgba(255, 255, 255, 0.8);
}

.logo {
    margin-bottom: 40px;
    text-align: center;
}

.logo i {
    font-size: 60px;
    color: var(--light);
    margin-bottom: 15px;
}

.logo h1 {
    font-size: 36px;
    font-weight: 700;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.credits {
    position: absolute;
    bottom: 20px;
    font-size: 14px;
    opacity: 0.8;
}

.level-header {
    margin-bottom: 20px;
    width: 100%;
}

.level-header h1 {
    font-size: 32px;
    margin-bottom: 10px;
}

.level-progress {
    background-color: rgba(255, 255, 255, 0.1);
    padding: 10px 20px;
    border-radius: 50px;
    font-size: 16px;
    margin-bottom: 20px;
    display: inline-block;
}

.level-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(60px, 1fr));
    gap: 10px;
    margin: 20px 0;
    width: 100%;
    max-width: 400px;
}

.level-button {
    width: 60px;
    height: 60px;
    font-size: 22px;
    font-weight: bold;
    background-color: rgba(255, 255, 255, 0.2);
    color: white;
    border: none;
    border-radius: 15px;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow);
}

.level-button:hover {
    background-color: rgba(255, 255, 255, 0.3);
    transform: translateY(-3px);
}

.level-button.locked {
    background-color: rgba(255, 255, 255, 0.05);
    color: rgba(255, 255, 255, 0.5);
    cursor: not-allowed;
}

.level-button.completed {
    background-color: var(--success);
}

.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 20px 0;
    gap: 15px;
}

.page-button {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background-color: rgba(255, 255, 255, 0.2);
    color: white;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.page-button:hover {
    background-color: rgba(255, 255, 255, 0.3);
}

.page-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

#pageInfo {
    font-size: 16px;
    min-width: 100px;
    text-align: center;
}

.game-header {
    width: 100%;
    max-width: 600px;
    margin-bottom: 20px;
}

.gameInfo {
    display: flex;
    justify-content: space-between;
    width: 100%;
    gap: 10px;
    background-color: rgba(0, 0, 0, 0.2);
    padding: 10px 20px;
    border-radius: 10px;
}

.info-box {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 16px;
}

.info-box i {
    color: var(--accent);
    font-size: 18px;
}

.memory-game {
    width: 90vw;
    height: 90vw;
    max-width: 500px;
    max-height: 500px;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    grid-gap: 10px;
    place-items: center;
    margin: 10px auto;
}

.card {
    width: 100%;
    height: 100%;
    position: relative;
    transform: scale(1);
    transform-style: preserve-3d;
    transition: transform 0.5s, box-shadow 0.3s;
    cursor: pointer;
    border-radius: 10px;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.2);
}

.card.flip {
    transform: rotateY(180deg);
}

.card:active {
    transform: scale(0.97);
}

.front-face, .back-face {
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 10px;
    backface-visibility: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 10px;
}

.front-face {
    transform: rotateY(180deg);
    background-color: white;
}

.front-face img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.back-face {
    background: linear-gradient(45deg, var(--primary), var(--secondary));
    color: white;
}

.back-face img {
    width: 60%;
    height: 60%;
    object-fit: contain;
    opacity: 0.8;
}

.winning-message {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    backdrop-filter: blur(5px);
}

.winning-message.show {
    display: flex;
}

.winning-content {
    background: linear-gradient(135deg, rgba(0, 45, 116, 0.9) 0%, rgba(0, 105, 167, 0.9) 100%);
    padding: 30px;
    border-radius: 20px;
    text-align: center;
    width: 90%;
    max-width: 400px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

.winning-message.win .winning-content {
    background: linear-gradient(135deg, rgba(0, 184, 148, 0.9) 0%, rgba(0, 206, 158, 0.9) 100%);
}

.winning-message.lose .winning-content {
    background: linear-gradient(135deg, rgba(225, 112, 85, 0.9) 0%, rgba(255, 159, 128, 0.9) 100%);
}

#winningText {
    font-size: 32px;
    font-weight: bold;
    margin-bottom: 20px;
    color: white;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.winning-stats {
    display: flex;
    justify-content: space-around;
    margin: 20px 0;
    font-size: 18px;
}

.winning-stats div {
    background-color: rgba(255, 255, 255, 0.2);
    padding: 10px 15px;
    border-radius: 10px;
}

.winning-buttons {
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 100%;
    margin-top: 20px;
    align-items: center;
}

.winning-buttons .menu-button {
    width: 100%;
    max-width: 250px;
    margin: 5px 0;
}

#nextLevelButton {
    background-color: var(--success);
}

#restartLevelButton {
    background-color: var(--warning);
    color: var(--dark);
}

#homeFromWinButton {
    background-color: var(--danger);
}

#fullscreenButton {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 1000;
}

#gameControls {
    position: fixed;
    top: 20px;
    right: 70px;
    display: none;
    z-index: 1000;
}

#gameScreen #gameControls {
    display: flex;
}

#pauseButton {
    background-color: #fdcb6e;
}

@media (max-width: 600px) {
    .level-container {
        grid-template-columns: repeat(auto-fill, minmax(50px, 1fr));
    }
    
    .level-button {
        width: 50px;
        height: 50px;
        font-size: 20px;
    }
    
    .menu-button {
        padding: 12px 20px;
        font-size: 16px;
    }
    
    .info-box {
        font-size: 14px;
    }
    
    .memory-game {
        width: 95vw;
        height: 95vw;
        grid-gap: 5px;
    }
    
    .winning-buttons .menu-button {
        padding: 12px 20px;
        font-size: 16px;
        max-width: 200px;
    }
}

@media (max-width: 400px) {
    .level-container {
        grid-template-columns: repeat(auto-fill, minmax(40px, 1fr));
    }
    
    .level-button {
        width: 40px;
        height: 40px;
        font-size: 18px;
        border-radius: 10px;
    }
    
    .gameInfo {
        flex-direction: column;
        align-items: center;
        gap: 8px;
    }
}