:root {
    --bg-gradient: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    --card-bg: rgba(255, 255, 255, 0.05);
    --card-border: rgba(255, 255, 255, 0.1);
    --accent-color: #4ecca3;
    --text-color: #ffffff;
    --danger-color: #e94560;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
}

body {
    min-height: 100vh;
    background: var(--bg-gradient);
    color: var(--text-color);
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 2rem;
    overflow-x: hidden;
}

.game-header {
    text-align: center;
    margin-bottom: 2rem;
    width: 100%;
    max-width: 600px;
}

.title {
    font-size: 3rem;
    font-weight: 800;
    margin-bottom: 0.5rem;
    background: linear-gradient(to right, #4ecca3, #45b7d1);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.stats-container {
    display: flex;
    justify-content: space-around;
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(10px);
    padding: 1rem;
    border-radius: 16px;
    border: 1px solid var(--card-border);
    margin-bottom: 1.5rem;
}

.stat-item {
    text-align: center;
}

.stat-label {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    opacity: 0.6;
}

.stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--accent-color);
}

.timer-bar-container {
    width: 100%;
    height: 8px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 2rem;
}

.timer-bar {
    height: 100%;
    background: var(--accent-color);
    width: 100%;
    transition: width 0.1s linear, background-color 0.3s ease;
}

.timer-bar.warning {
    background: var(--danger-color);
}

.game-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
    width: 100%;
    max-width: 600px;
    perspective: 1000px;
}

.memory-card {
    aspect-ratio: 1/1;
    position: relative;
    cursor: pointer;
    transform-style: preserve-3d;
    transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

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

.memory-card.matched {
    cursor: default;
    opacity: 0.8;
    transform: rotateY(0deg) scale(0.95);
}

.card-face {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    border-radius: 12px;
    display: flex;
    justify-content: center;
    align-items: center;
    border: 1px solid var(--card-border);
    overflow: hidden;
}

.card-back {
    background: #1a1a2e;
    background-image: radial-gradient(circle at center, rgba(255, 255, 255, 0.05) 0%, transparent 70%);
    box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.5);
}

.card-back::after {
    content: '?';
    font-size: 2.5rem;
    font-weight: 800;
    color: rgba(255, 255, 255, 0.2);
    transition: all 0.3s ease;
}

.memory-card.matched .card-back::after {
    content: '';
    width: 1.6rem;
    height: 3.2rem;
    border: solid var(--accent-color);
    border-width: 0 6px 6px 0;
    transform: rotate(45deg);
    margin-top: -12px;
    opacity: 1;
    box-shadow: 2px 2px 8px rgba(78, 204, 163, 0.4);
}

.card-front {
    background: #000;
    transform: rotateY(180deg);
}

.card-front img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Modal Overlay */
.overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(10px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
    opacity: 1;
    transition: opacity 0.5s ease;
}

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

.modal {
    background: rgba(255, 255, 255, 0.05);
    padding: 3rem;
    border-radius: 24px;
    border: 1px solid var(--card-border);
    text-align: center;
    max-width: 400px;
}

.btn {
    background: var(--accent-color);
    color: #1a1a2e;
    border: none;
    padding: 1rem 2rem;
    font-size: 1.2rem;
    font-weight: 700;
    border-radius: 12px;
    cursor: pointer;
    transition: transform 0.2s, background 0.2s;
    margin-top: 1.5rem;
}

.btn:hover {
    transform: translateY(-2px);
    background: #5dedb8;
}

.btn:active {
    transform: translateY(0);
}

@media (max-width: 500px) {
    .game-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}