* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

body {
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    color: #fff;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px;
}

.container {
    max-width: 900px;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
}

header {
    text-align: center;
    margin-bottom: 25px;
    width: 100%;
}

h1 {
    font-size: 2.8rem;
    margin-bottom: 8px;
    background: linear-gradient(90deg, #ff9a00, #ff0058);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.subtitle {
    font-size: 1.2rem;
    color: #a9b7c6;
    margin-bottom: 20px;
}

.game-info {
    display: flex;
    justify-content: space-between;
    width: 100%;
    max-width: 800px;
    background-color: rgba(0, 0, 0, 0.3);
    border-radius: 15px;
    padding: 15px 25px;
    margin-bottom: 15px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
}

.info-box {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.info-label {
    font-size: 1rem;
    color: #a9b7c6;
    margin-bottom: 5px;
}

.info-value {
    font-size: 2rem;
    font-weight: bold;
}

.level-display {
    color: #4cc9f0;
}

.time-left {
    color: #ff9a00;
}

.moves {
    color: #00b4d8;
}

.score {
    color: #96c93d;
}

.level-progress {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-bottom: 20px;
    width: 100%;
    max-width: 800px;
}

.level-indicator {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background-color: rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 1.2rem;
    transition: all 0.3s ease;
}

.level-indicator.active {
    background: linear-gradient(145deg, #4cc9f0, #4361ee);
    transform: scale(1.1);
    box-shadow: 0 0 10px rgba(76, 201, 240, 0.5);
}

.level-indicator.completed {
    background: linear-gradient(145deg, #96c93d, #00b09b);
}

.game-board {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 15px;
    max-width: 800px;
    width: 100%;
    margin-bottom: 30px;
    perspective: 1000px;
    min-height: 300px;
}

.tile {
    height: 120px;
    background-color: #0f3460;
    border-radius: 10px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 3rem;
    cursor: pointer;
    transform-style: preserve-3d;
    transition: transform 0.5s, opacity 0.5s, visibility 0.5s;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
    position: relative;
}

.tile.flipped {
    transform: rotateY(180deg);
}

.tile.matched {
    opacity: 0;
    visibility: hidden;
    transform: scale(0.8) rotateY(180deg);
    pointer-events: none;
}

.tile-front, .tile-back {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    border-radius: 10px;
    display: flex;
    justify-content: center;
    align-items: center;
}

.tile-front {
    background: linear-gradient(145deg, #0f3460, #1a5f7a);
}

.tile-front i {
    color: rgba(255, 255, 255, 0.7);
    font-size: 2.5rem;
}

.tile-back {
    background: linear-gradient(145deg, #2a9d8f, #264653);
    transform: rotateY(180deg);
    color: white;
}

@keyframes vanish {
    0% { 
        transform: scale(1) rotateY(180deg);
        opacity: 1;
    }
    50% { 
        transform: scale(1.2) rotateY(180deg);
        opacity: 0.7;
    }
    100% { 
        transform: scale(0.5) rotateY(180deg);
        opacity: 0;
        visibility: hidden;
    }
}

@keyframes matchGlow {
    0% { box-shadow: 0 0 5px rgba(76, 201, 240, 0.5); }
    50% { box-shadow: 0 0 20px rgba(76, 201, 240, 0.8); }
    100% { box-shadow: 0 0 5px rgba(76, 201, 240, 0.5); }
}

.controls {
    display: flex;
    gap: 20px;
    margin-bottom: 25px;
    flex-wrap: wrap;
    justify-content: center;
}

button {
    padding: 12px 25px;
    font-size: 1.1rem;
    border: none;
    border-radius: 50px;
    cursor: pointer;
    font-weight: bold;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 10px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

button:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.3);
}

button:active {
    transform: translateY(0);
}

.start-btn {
    background: linear-gradient(90deg, #00b09b, #96c93d);
    color: white;
}

.restart-btn {
    background: linear-gradient(90deg, #ff9a00, #ff0058);
    color: white;
}

.highscore-btn {
    background: linear-gradient(90deg, #4361ee, #4cc9f0);
    color: white;
}

.next-level-btn {
    background: linear-gradient(90deg, #9d4edd, #c77dff);
    color: white;
    margin-top: 20px;
}

.close-btn {
    background: linear-gradient(90deg, #6c757d, #495057);
    color: white;
    margin-top: 20px;
}

.instructions {
    background-color: rgba(255, 255, 255, 0.08);
    border-radius: 15px;
    padding: 20px;
    max-width: 800px;
    width: 100%;
    margin-top: 10px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

.instructions h3 {
    margin-bottom: 10px;
    color: #4cc9f0;
    display: flex;
    align-items: center;
    gap: 10px;
}

.instructions p {
    line-height: 1.6;
    color: #c5c6c7;
    margin-bottom: 8px;
}

.level-complete, .game-over, .highscore-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.85);
    justify-content: center;
    align-items: center;
    z-index: 100;
    flex-direction: column;
    text-align: center;
}

.level-complete-content, .game-over-content, .highscore-modal-content {
    background: linear-gradient(145deg, #1a1a2e, #16213e);
    padding: 40px;
    border-radius: 20px;
    max-width: 500px;
    width: 90%;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    animation: popIn 0.5s;
}

@keyframes popIn {
    0% { transform: scale(0.5); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}

.level-complete h2 {
    font-size: 2.5rem;
    margin-bottom: 20px;
    color: #9d4edd;
}

.game-over h2 {
    font-size: 3rem;
    margin-bottom: 20px;
    color: #ff9a00;
}

.highscore-modal h2 {
    font-size: 2.5rem;
    margin-bottom: 20px;
    color: #ffd166;
}

.level-complete p, .game-over p {
    font-size: 1.3rem;
    margin-bottom: 30px;
    color: #a9b7c6;
}

.level-stats, .game-stats {
    background-color: rgba(255, 255, 255, 0.05);
    border-radius: 10px;
    padding: 15px;
    margin: 20px 0;
    text-align: left;
}

.level-stats p, .game-stats p {
    font-size: 1.1rem;
    margin-bottom: 10px;
    display: flex;
    justify-content: space-between;
}

.final-score {
    font-size: 2.5rem;
    color: #4cc9f0;
    margin: 20px 0;
}

.highscore-section {
    background-color: rgba(255, 215, 102, 0.1);
    border-radius: 10px;
    padding: 20px;
    margin: 20px 0;
}

.highscore-section h3 {
    color: #ffd166;
    margin-bottom: 15px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.highscore-display {
    font-size: 2rem;
    color: #ffd166;
    font-weight: bold;
    margin: 10px 0;
}

.new-highscore {
    font-size: 1.5rem;
    color: #9d4edd;
    font-weight: bold;
    margin: 15px 0;
    display: none;
}

.highscore-list {
    margin: 20px 0;
    max-height: 300px;
    overflow-y: auto;
}

.highscore-entry {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 15px;
    margin-bottom: 10px;
    background-color: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
}

.highscore-entry .rank {
    font-weight: bold;
    font-size: 1.2rem;
    color: #ffd166;
    width: 30px;
}

.highscore-entry .score-value {
    font-size: 1.5rem;
    font-weight: bold;
    color: #4cc9f0;
    flex-grow: 1;
    text-align: center;
}

.highscore-entry .date {
    color: #a9b7c6;
    font-size: 0.9rem;
    width: 100px;
    text-align: right;
}

.footer {
    margin-top: 20px;
    color: #a9b7c6;
    font-size: 0.9rem;
    text-align: center;
    width: 100%;
}

@media (max-width: 768px) {
    .game-board {
        grid-template-columns: repeat(4, 1fr);
        gap: 10px;
    }
    
    .tile {
        height: 85px;
    }
    
    .tile-front i, .tile-back {
        font-size: 2rem;
    }
    
    h1 {
        font-size: 2.2rem;
    }
    
    .game-info {
        flex-direction: column;
        gap: 15px;
    }
    
    .info-box {
        flex-direction: row;
        justify-content: space-between;
    }
    
    .controls {
        flex-direction: column;
        align-items: center;
    }
    
    button {
        width: 100%;
        max-width: 250px;
        justify-content: center;
    }
    
    .level-progress {
        gap: 5px;
    }
    
    .level-indicator {
        width: 35px;
        height: 35px;
        font-size: 1rem;
    }
}

@media (max-width: 480px) {
    .game-board {
        grid-template-columns: repeat(3, 1fr);
    }
    
    .tile {
        height: 80px;
    }
    
    .level-complete-content, .game-over-content, .highscore-modal-content {
        padding: 20px;
    }
    
    .level-complete h2, .game-over h2, .highscore-modal h2 {
        font-size: 2rem;
    }
}