/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Poppins', sans-serif;
    background: linear-gradient(135deg, #6a11cb 0%, #2575fc 100%);
    color: #333;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
    overflow-x: hidden;
}

.container {
    width: 100%;
    max-width: 1200px;
    background-color: rgba(255, 255, 255, 0.95);
    border-radius: 20px;
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.2);
    overflow: hidden;
    padding: 25px;
    position: relative;
}

/* Header Styles */
.game-header {
    text-align: center;
    margin-bottom: 25px;
    padding-bottom: 20px;
    border-bottom: 2px solid #f0f0f0;
}

.game-header h1 {
    font-family: 'Fredoka One', cursive;
    color: #2575fc;
    font-size: 2.8rem;
    margin-bottom: 10px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.1);
}

.game-header .tagline {
    color: #666;
    font-size: 1.2rem;
    font-weight: 500;
}

/* Game Info and Controls */
.game-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: 25px;
    gap: 20px;
}

.stats-container {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
}

.stat-box {
    background: linear-gradient(135deg, #6a11cb 0%, #2575fc 100%);
    color: white;
    padding: 15px 20px;
    border-radius: 12px;
    text-align: center;
    min-width: 100px;
    box-shadow: 0 5px 15px rgba(37, 117, 252, 0.3);
    transition: transform 0.3s ease;
}

.stat-label {
    display: block;
    font-size: 0.9rem;
    opacity: 0.9;
    margin-bottom: 5px;
}

.stat-value {
    display: block;
    font-size: 1.8rem;
    font-weight: 700;
}

.controls {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
}

.btn {
    padding: 14px 24px;
    border: none;
    border-radius: 50px;
    font-family: 'Poppins', sans-serif;
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    transition: all 0.3s ease;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
}

.btn i {
    font-size: 1.1rem;
}

.btn-primary {
    background: linear-gradient(to right, #6a11cb, #2575fc);
    color: white;
}

.btn-secondary {
    background: #f0f0f0;
    color: #333;
}

.btn-hint {
    background: linear-gradient(to right, #FF9A00, #FF5E00);
    color: white;
}

.btn-success {
    background: linear-gradient(to right, #00b09b, #96c93d);
    color: white;
}

.btn-dice {
    background: linear-gradient(to right, #9C27B0, #673AB7);
    color: white;
    font-size: 1.1rem;
    padding: 16px 28px;
}

.btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 15px rgba(0, 0, 0, 0.2);
}

.btn:active {
    transform: translateY(1px);
}

/* Level Info */
.level-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
    background-color: #f8f9ff;
    padding: 15px 20px;
    border-radius: 12px;
    border-left: 5px solid #2575fc;
}

.level-progress {
    flex: 1;
    max-width: 500px;
}

.progress-bar {
    height: 12px;
    background-color: #e0e0e0;
    border-radius: 6px;
    overflow: hidden;
    margin-bottom: 8px;
}

.progress-fill {
    height: 100%;
    width: 20%;
    background: linear-gradient(to right, #6a11cb, #2575fc);
    border-radius: 6px;
    transition: width 0.5s ease;
}

.level-text {
    font-weight: 600;
    color: #2575fc;
    font-size: 1.1rem;
}

.cards-count {
    font-weight: 600;
    font-size: 1.1rem;
    color: #333;
}

/* Game Board */
.game-board {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 15px;
    margin-bottom: 30px;
    justify-content: center;
    min-height: 400px;
}

.card {
    aspect-ratio: 3/4;
    border-radius: 12px;
    cursor: pointer;
    position: relative;
    transform-style: preserve-3d;
    transition: transform 0.3s;
    box-shadow: 0 8px 15px rgba(0, 0, 0, 0.1);
}

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

.card.matched {
    cursor: default;
    box-shadow: 0 0 15px rgba(0, 200, 0, 0.5);
}

.card-front, .card-back {
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 12px;
    backface-visibility: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 2.5rem;
}

.card-front {
    background: linear-gradient(135deg, #6a11cb 0%, #2575fc 100%);
    color: white;
    transform: rotateY(180deg);
}

.card-back {
    background: linear-gradient(135deg, #ff9a9e 0%, #fad0c4 100%);
    color: #333;
}

.card-back i {
    font-size: 2.2rem;
    color: rgba(255, 255, 255, 0.9);
}

/* Level Up Screen */
.level-up-screen, .game-complete-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.85);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.5s ease, visibility 0.5s ease;
}

.level-up-screen.active, .game-complete-screen.active {
    opacity: 1;
    visibility: visible;
}

.level-up-content, .game-complete-content {
    background: white;
    padding: 40px;
    border-radius: 20px;
    text-align: center;
    max-width: 500px;
    width: 90%;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
    animation: popIn 0.6s ease-out forwards;
}

@keyframes popIn {
    0% { transform: scale(0.5); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}

.level-up-content h2, .game-complete-content h2 {
    color: #2575fc;
    margin-bottom: 20px;
    font-family: 'Fredoka One', cursive;
    font-size: 2.2rem;
}

.level-stats, .final-stats {
    background-color: #f8f9ff;
    padding: 20px;
    border-radius: 12px;
    margin: 25px 0;
    text-align: left;
}

.level-stats p, .final-stats p {
    margin-bottom: 10px;
    font-size: 1.1rem;
}

.level-stats i, .final-stats i {
    color: #6a11cb;
    margin-right: 10px;
}

/* Dice Roll Container */
.dice-roll-container {
    background: linear-gradient(135deg, #f8f9ff 0%, #eef1ff 100%);
    padding: 25px;
    border-radius: 15px;
    margin: 25px 0;
    border: 2px dashed #6a11cb;
}

.dice {
    width: 100px;
    height: 100px;
    margin: 20px auto;
    position: relative;
    transform-style: preserve-3d;
    transition: transform 1s ease;
}

.dice-face {
    width: 100%;
    height: 100%;
    background: white;
    border-radius: 15px;
    position: absolute;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: inset 0 0 15px rgba(0, 0, 0, 0.1), 0 10px 20px rgba(0, 0, 0, 0.2);
    border: 3px solid #6a11cb;
}

.dice.rolling {
    animation: rollDice 1s ease-in-out;
}

@keyframes rollDice {
    0% { transform: rotateX(0) rotateY(0); }
    25% { transform: rotateX(180deg) rotateY(90deg); }
    50% { transform: rotateX(360deg) rotateY(180deg); }
    75% { transform: rotateX(540deg) rotateY(270deg); }
    100% { transform: rotateX(720deg) rotateY(360deg); }
}

.dot {
    width: 20px;
    height: 20px;
    background-color: #333;
    border-radius: 50%;
    position: absolute;
}

.dot.center {
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.dot.top-left {
    top: 20%;
    left: 20%;
}

.dot.top-right {
    top: 20%;
    right: 20%;
}

.dot.middle-left {
    top: 50%;
    left: 20%;
    transform: translateY(-50%);
}

.dot.middle-right {
    top: 50%;
    right: 20%;
    transform: translateY(-50%);
}

.dot.bottom-left {
    bottom: 20%;
    left: 20%;
}

.dot.bottom-right {
    bottom: 20%;
    right: 20%;
}

.dice-result {
    margin-top: 20px;
    font-size: 1.2rem;
    font-weight: 600;
    color: #2575fc;
    min-height: 30px;
}

/* Footer */
.game-footer {
    margin-top: 30px;
    padding-top: 20px;
    border-top: 2px solid #f0f0f0;
    text-align: center;
    color: #666;
}

.game-footer p {
    margin-bottom: 20px;
    font-size: 1rem;
    line-height: 1.6;
}

.instructions {
    text-align: left;
    background-color: #f8f9ff;
    padding: 20px;
    border-radius: 12px;
}

.instructions h3 {
    color: #2575fc;
    margin-bottom: 15px;
    font-size: 1.3rem;
}

.instructions ul {
    list-style-type: none;
    padding-left: 0;
}

.instructions li {
    margin-bottom: 10px;
    padding-left: 25px;
    position: relative;
}

.instructions li:before {
    content: "✓";
    color: #6a11cb;
    font-weight: bold;
    position: absolute;
    left: 0;
}

/* Responsive Design */
@media (max-width: 1024px) {
    .game-board {
        grid-template-columns: repeat(4, 1fr);
        gap: 12px;
    }
}

@media (max-width: 768px) {
    .container {
        padding: 15px;
    }
    
    .game-header h1 {
        font-size: 2.2rem;
    }
    
    .game-info {
        flex-direction: column;
        align-items: stretch;
    }
    
    .stats-container {
        justify-content: center;
    }
    
    .controls {
        justify-content: center;
    }
    
    .game-board {
        grid-template-columns: repeat(3, 1fr);
        gap: 10px;
        min-height: 350px;
    }
    
    .level-info {
        flex-direction: column;
        gap: 15px;
        align-items: flex-start;
    }
    
    .level-progress {
        max-width: 100%;
    }
    
    .btn {
        padding: 12px 20px;
        font-size: 0.95rem;
    }
    
    .level-up-content, .game-complete-content {
        padding: 30px 20px;
    }
}

@media (max-width: 480px) {
    .game-board {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
        min-height: 300px;
    }
    
    .stat-box {
        min-width: 80px;
        padding: 12px 15px;
    }
    
    .stat-value {
        font-size: 1.5rem;
    }
    
    .card-front, .card-back {
        font-size: 2rem;
    }
    
    .card-back i {
        font-size: 1.8rem;
    }
    
    .game-header h1 {
        font-size: 1.8rem;
    }
    
    .level-up-content h2, .game-complete-content h2 {
        font-size: 1.8rem;
    }
    
    .dice {
        width: 80px;
        height: 80px;
    }
    
    .dot {
        width: 15px;
        height: 15px;
    }
}