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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    overflow-x: hidden;
}

/* Screen Management */
.screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    z-index: 1;
}

.screen.active {
    opacity: 1;
    visibility: visible;
}

.screen.overlay {
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(10px);
    z-index: 10;
}

/* Container */
.container {
    max-width: 800px;
    padding: 2rem;
    text-align: center;
}

/* Typography */
.game-title {
    font-size: clamp(2.5rem, 8vw, 4rem);
    font-weight: 700;
    color: white;
    margin-bottom: 1rem;
    text-shadow: 0 2px 20px rgba(0, 0, 0, 0.3);
}

.game-subtitle {
    font-size: 1.2rem;
    color: rgba(255, 255, 255, 0.9);
    margin-bottom: 3rem;
    font-weight: 300;
}

/* Difficulty Selection */
.difficulty-selection h2 {
    color: white;
    font-size: 1.5rem;
    margin-bottom: 2rem;
    font-weight: 500;
}

    touch-action: manipulation;
.difficulty-buttons {
    display: flex;
    gap: 2rem;
    justify-content: center;
    flex-wrap: wrap;
    touch-action: manipulation;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
}

.difficulty-btn {
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 20px;
    padding: 2rem;
    min-width: 200px;
    color: white;
    cursor: pointer;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
    touch-action: manipulation;
}

.difficulty-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.4);
    transform: translateY(-5px);
}

.difficulty-btn.easy:hover {
    border-color: #4ade80;
    box-shadow: 0 10px 30px rgba(74, 222, 128, 0.3);
}

.difficulty-btn.hard:hover {
    border-color: #f59e0b;
    box-shadow: 0 10px 30px rgba(245, 158, 11, 0.3);
}

.difficulty-icon {
    display: block;
    font-size: 2rem;
    margin-bottom: 1rem;
}

.difficulty-name {
    display: block;
    font-size: 1.3rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.difficulty-desc {
    display: block;
    font-size: 0.9rem;
    opacity: 0.8;
}

/* Game Header */
.game-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 2rem;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    border-radius: 15px;
    margin-bottom: 2rem;
    color: white;
}

.game-info {
    display: flex;
    gap: 2rem;
}

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

.info-label {
    display: block;
    font-size: 0.8rem;
    opacity: 0.8;
    margin-bottom: 0.25rem;
}

.info-value {
    display: block;
    font-size: 1.5rem;
    font-weight: 700;
}

.timer {
    color: #fbbf24;
}

.timer.warning {
    color: #ef4444;
    animation: pulse 1s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.icon-btn {
    background: rgba(255, 255, 255, 0.1);
    border: none;
    border-radius: 10px;
    padding: 0.5rem;
    color: white;
    font-size: 1.2rem;
    cursor: pointer;
    transition: all 0.3s ease;
}

.icon-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Game Board */
#gameScreen {
    padding: 2rem;
    align-items: flex-start;
    justify-content: center;
    flex-direction: column;
}

.game-board {
    display: grid;
    gap: 0.75rem;
    margin: 0 auto;
    max-width: 100%;
    padding: 2rem;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 20px;
    backdrop-filter: blur(10px);
    grid-template-columns: repeat(4, 1fr);
    justify-items: center;
    align-items: center;
}

.game-board.cols-3 {
    grid-template-columns: repeat(3, 1fr);
}

.game-board.cols-4 {
    grid-template-columns: repeat(4, 1fr);
}

.game-board.cols-5 {
    grid-template-columns: repeat(5, 1fr);
}

.game-board.cols-6 {
    grid-template-columns: repeat(6, 1fr);
}

/* Card Styles */
.memory-card {
    aspect-ratio: 1;
    background: linear-gradient(145deg, #ffffff, #e6e6e6);
    border-radius: 15px;
    cursor: pointer;
    position: relative;
    transform-style: preserve-3d;
    transition: all 0.6s cubic-bezier(0.4, 0.0, 0.2, 1);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    min-width: 60px;
    min-height: 60px;
}

.memory-card:hover {
    transform: scale(1.05);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.2);
}

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

.memory-card.matched {
    opacity: 0;
    transform: scale(0);
    pointer-events: none;
}

.card-face {
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 15px;
    display: flex;
    align-items: center;
    justify-content: center;
    backface-visibility: hidden;
    font-size: clamp(1.5rem, 4vw, 2.5rem);
}

.card-front {
    background: linear-gradient(145deg, #667eea, #764ba2);
    color: white;
    font-weight: bold;
}

.card-front::before {
    content: '?';
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
}

.card-back {
    background: linear-gradient(145deg, #ffffff, #f0f0f0);
    transform: rotateY(180deg);
    border: 2px solid rgba(102, 126, 234, 0.3);
}

/* Controls */
.game-controls {
    display: flex;
    gap: 1rem;
    justify-content: center;
    margin-top: 2rem;
    flex-wrap: wrap;
}

.control-btn {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 25px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    min-width: 120px;
}

.control-btn.primary {
    background: linear-gradient(145deg, #4ade80, #22c55e);
    color: white;
    box-shadow: 0 4px 15px rgba(34, 197, 94, 0.3);
}

.control-btn.primary:hover {
    background: linear-gradient(145deg, #22c55e, #16a34a);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(34, 197, 94, 0.4);
}

.control-btn.secondary {
    background: rgba(255, 255, 255, 0.1);
    color: white;
    border: 2px solid rgba(255, 255, 255, 0.3);
    backdrop-filter: blur(10px);
}

.control-btn.secondary:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.5);
    transform: translateY(-2px);
}

/* Modal */
.modal {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px);
    border-radius: 20px;
    padding: 3rem;
    text-align: center;
    max-width: 400px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    color: #333;
}

/* Fix button visibility in modals */
.modal .control-btn.secondary {
    background: rgba(102, 126, 234, 0.1);
    color: #667eea;
    border: 2px solid #667eea;
    backdrop-filter: none;
}

.modal .control-btn.secondary:hover {
    background: #667eea;
    color: white;
    border-color: #667eea;
    transform: translateY(-2px);
}

.modal h2 {
    font-size: 2rem;
    margin-bottom: 2rem;
    color: #667eea;
}

.level-stats, .game-stats {
    margin-bottom: 2rem;
}

.level-stats p, .game-stats p {
    margin-bottom: 0.5rem;
    font-size: 1.1rem;
}

.level-stats span, .game-stats span {
    font-weight: 700;
    color: #667eea;
}

/* Animations */
@keyframes cardMatch {
    0% { transform: scale(1); }
    50% { transform: scale(1.1); }
    100% { transform: scale(0); }
}

.memory-card.matched {
    animation: cardMatch 0.6s ease-in-out forwards;
}

@keyframes levelComplete {
    0% { transform: scale(0.8) rotate(-5deg); opacity: 0; }
    50% { transform: scale(1.05) rotate(2deg); opacity: 1; }
    100% { transform: scale(1) rotate(0deg); opacity: 1; }
}

.modal {
    animation: levelComplete 0.6s ease-out;
}