@import url('https://fonts.googleapis.com/css2?family=Caveat:wght@600;700&family=Poppins:wght@400;600;700&display=swap');

/* ===========================
   CSS Variables - Design System
   =========================== */
:root {
    /* Colors */
    --color-primary: #ff4500;
    --color-primary-light: #ff6347;
    --color-primary-dark: #cc3700;
    --color-secondary: #00ffff;
    --color-secondary-dark: #00cccc;
    --color-accent: #9b59b6;
    --color-success: #adff2f;
    --color-warning: #ffa500;
    
    /* Backgrounds */
    --bg-dark: rgba(25, 25, 112, 0.95);
    --bg-darker: rgba(15, 15, 70, 0.98);
    --bg-light: rgba(255, 255, 255, 0.1);
    --bg-card: rgba(255, 255, 255, 0.95);
    
    /* Borders */
    --border-radius-sm: 12px;
    --border-radius-md: 20px;
    --border-radius-lg: 30px;
    --border-radius-xl: 40px;
    
    /* Spacing */
    --spacing-xs: 0.5rem;
    --spacing-sm: 1rem;
    --spacing-md: 1.5rem;
    --spacing-lg: 2rem;
    --spacing-xl: 3rem;
    
    /* Transitions */
    --transition-fast: 0.2s ease;
    --transition-normal: 0.3s ease;
    --transition-slow: 0.5s ease;
    --transition-bounce: 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    
    /* Shadows */
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.15);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.2);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.3);
    --shadow-glow: 0 0 20px rgba(0, 255, 255, 0.5);
    --shadow-glow-orange: 0 0 20px rgba(255, 69, 0, 0.5);
}

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

body {
    min-height: 100vh;
    font-family: 'Poppins', sans-serif;
    background: url(wireframe/album-cover.jpg) center/cover fixed;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--spacing-md);
    position: relative;
}

body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: radial-gradient(circle at center, rgba(0,0,0,0.3) 0%, rgba(0,0,0,0.7) 100%);
    pointer-events: none;
    z-index: 0;
}

/* Animated color overlay */
body::after {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(
        45deg,
        rgba(255, 69, 0, 0.15),
        rgba(0, 255, 255, 0.15),
        rgba(155, 89, 182, 0.15),
        rgba(255, 69, 0, 0.15)
    );
    background-size: 400% 400%;
    animation: colorShift 15s ease infinite;
    pointer-events: none;
    z-index: 0;
    mix-blend-mode: overlay;
}

@keyframes colorShift {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

/* ===========================
   Container Wrapper
   =========================== */
.container-wrapper {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 1200px;
    display: flex;
    flex-direction: column;
    gap: var(--spacing-lg);
    animation: fadeInUp 0.8s ease;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ===========================
   Header Section
   =========================== */
.game-header {
    text-align: center;
    animation: slideDown 0.6s ease;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.game-title {
    font-family: 'Caveat', cursive;
    font-size: clamp(2rem, 6vw, 4rem);
    font-weight: 700;
    color: var(--color-primary);
    text-shadow: 
        0 0 10px rgba(255, 69, 0, 0.5),
        0 0 20px rgba(255, 69, 0, 0.3),
        3px 3px 6px rgba(0, 0, 0, 0.5);
    margin-bottom: var(--spacing-sm);
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.title-word {
    display: inline-block;
    animation: bounce 1s ease infinite;
}

.title-word:nth-child(1) { animation-delay: 0s; }
.title-word:nth-child(2) { animation-delay: 0.1s; }
.title-word:nth-child(3) { animation-delay: 0.2s; }

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

.game-instructions {
    font-size: clamp(0.9rem, 2.5vw, 1.1rem);
    color: var(--color-secondary);
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.7);
    line-height: 1.6;
}

.instruction-label {
    color: #32cd32;
    font-weight: 600;
    font-size: 1.1em;
    display: inline-block;
    margin-right: 0.5rem;
}

/* ===========================
   Game Controls - Flexbox Layout
   =========================== */
.game-controls {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-md);
    animation: fadeIn 0.8s ease 0.2s both;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.control-panel {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: var(--spacing-md);
    flex-wrap: wrap;
}

/* Stat Boxes */
.stat-box {
    background: var(--bg-dark);
    backdrop-filter: blur(10px);
    border: 2px solid var(--color-accent);
    border-radius: var(--border-radius-lg);
    padding: var(--spacing-md);
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    min-width: 150px;
    box-shadow: var(--shadow-md);
    transition: all var(--transition-normal);
    position: relative;
    overflow: hidden;
}

.stat-box::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: linear-gradient(45deg, transparent, rgba(255, 255, 255, 0.1), transparent);
    transform: rotate(45deg);
    transition: all 0.5s;
}

.stat-box:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-lg), var(--shadow-glow);
    border-color: var(--color-secondary);
}

.stat-box:hover::before {
    left: 100%;
}

.stat-icon {
    font-size: 2rem;
    animation: pulse 2s ease infinite;
}

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

.stat-content {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.stat-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--color-secondary);
    font-weight: 600;
}

.stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: white;
}

.timer-box {
    border-color: var(--color-secondary);
}

.score-box {
    border-color: var(--color-warning);
}

/* Reset Button */
.reset-button {
    background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-primary-dark) 100%);
    color: white;
    border: none;
    border-radius: var(--border-radius-lg);
    padding: var(--spacing-md) var(--spacing-lg);
    font-size: 1rem;
    font-weight: 600;
    font-family: 'Poppins', sans-serif;
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
    cursor: pointer;
    box-shadow: var(--shadow-md);
    transition: all var(--transition-normal);
    position: relative;
    overflow: hidden;
}

.reset-button::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

.reset-button:hover::before {
    width: 300px;
    height: 300px;
}

.reset-button:hover {
    transform: translateY(-3px) scale(1.05);
    box-shadow: var(--shadow-lg), var(--shadow-glow-orange);
}

.reset-button:active {
    transform: translateY(-1px) scale(1.02);
}

.button-icon {
    font-size: 1.2rem;
    animation: rotate 2s linear infinite;
}

@keyframes rotate {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.reset-button:hover .button-icon {
    animation-duration: 0.5s;
}

/* Message Display */
.message-display {
    min-height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: clamp(1.2rem, 4vw, 2rem);
    font-weight: 700;
    color: var(--color-success);
    text-shadow: 
        0 0 10px rgba(173, 255, 47, 0.5),
        2px 2px 4px rgba(0, 0, 0, 0.7);
    text-align: center;
    animation: messageGlow 1.5s ease-in-out infinite;
}

@keyframes messageGlow {
    0%, 100% { text-shadow: 0 0 10px rgba(173, 255, 47, 0.5), 2px 2px 4px rgba(0, 0, 0, 0.7); }
    50% { text-shadow: 0 0 20px rgba(173, 255, 47, 0.8), 2px 2px 4px rgba(0, 0, 0, 0.7); }
}

/* ===========================
   Game Board - CSS Grid Layout
   =========================== */
.game-board-wrapper {
    display: flex;
    justify-content: center;
    animation: scaleIn 0.6s var(--transition-bounce) 0.3s both;
}

@keyframes scaleIn {
    from {
        opacity: 0;
        transform: scale(0.8);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.game-board {
    background: url(wireframe/background-img/mojo-verse.jpg) center/cover, var(--bg-darker);
    backdrop-filter: blur(10px);
    border: 4px solid var(--color-primary);
    border-radius: var(--border-radius-xl);
    padding: 1.5rem;
    box-shadow: 
        var(--shadow-lg),
        inset 0 0 30px rgba(0, 0, 0, 0.3);
    position: relative;
    box-sizing: border-box;
    overflow: hidden;
    
    /* CSS Grid Layout */
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.75rem;
    max-width: 600px;
    width: 600px;
    height: 600px;
}

.game-board::before {
    content: '';
    position: absolute;
    top: -2px;
    left: -2px;
    right: -2px;
    bottom: -2px;
    background: linear-gradient(45deg, 
        var(--color-primary), 
        var(--color-secondary), 
        var(--color-accent), 
        var(--color-primary));
    border-radius: var(--border-radius-xl);
    z-index: -1;
    opacity: 0;
    transition: opacity var(--transition-normal);
    animation: borderRotate 3s linear infinite;
    background-size: 300% 300%;
}

@keyframes borderRotate {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

.game-board:hover::before {
    opacity: 0.7;
}

/* Victory reveal - show mojo-verse background clearly */
.game-board.victory-reveal {
    backdrop-filter: blur(0px);
    animation: victoryPulse 2s ease-in-out infinite;
}

.game-board.victory-reveal::before {
    opacity: 1;
    animation: borderRotate 1.5s linear infinite, victoryGlow 2s ease-in-out infinite;
}

@keyframes victoryPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1); }
}

@keyframes victoryGlow {
    0%, 100% { box-shadow: 0 0 20px var(--color-primary), 0 0 40px var(--color-secondary); }
    50% { box-shadow: 0 0 40px var(--color-primary), 0 0 60px var(--color-secondary); }
}

/* ===========================
   Cards - Advanced Animations
   =========================== */
.card {
    aspect-ratio: 1;
    position: relative;
    cursor: pointer;
    transform-style: preserve-3d;
    transition: transform var(--transition-fast);
    animation: cardEntrance 0.5s ease backwards;
}

.card:nth-child(1) { animation-delay: 0.05s; }
.card:nth-child(2) { animation-delay: 0.1s; }
.card:nth-child(3) { animation-delay: 0.15s; }
.card:nth-child(4) { animation-delay: 0.2s; }
.card:nth-child(5) { animation-delay: 0.25s; }
.card:nth-child(6) { animation-delay: 0.3s; }
.card:nth-child(7) { animation-delay: 0.35s; }
.card:nth-child(8) { animation-delay: 0.4s; }
.card:nth-child(9) { animation-delay: 0.45s; }
.card:nth-child(10) { animation-delay: 0.5s; }
.card:nth-child(11) { animation-delay: 0.55s; }
.card:nth-child(12) { animation-delay: 0.6s; }
.card:nth-child(13) { animation-delay: 0.65s; }
.card:nth-child(14) { animation-delay: 0.7s; }
.card:nth-child(15) { animation-delay: 0.75s; }
.card:nth-child(16) { animation-delay: 0.8s; }

@keyframes cardEntrance {
    from {
        opacity: 0;
        transform: translateY(50px) rotateY(-90deg);
    }
    to {
        opacity: 1;
        transform: translateY(0) rotateY(0deg);
    }
}

.card:hover {
    transform: translateY(-4px) scale(1.02);
}

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

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

.card.matched {
    animation: matchSuccess 0.5s ease forwards;
    pointer-events: none;
}

@keyframes matchSuccess {
    0% {
        transform: scale(1);
    }
    25% {
        transform: scale(1.2) rotate(5deg);
    }
    50% {
        transform: scale(1.1) rotate(-5deg);
    }
    75% {
        transform: scale(1.15) rotate(3deg);
    }
    100% {
        transform: scale(0);
        opacity: 0;
    }
}

/* Card Faces */
.card img {
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
    border-radius: 30px;
    backface-visibility: hidden;
    box-shadow: var(--shadow-md);
    transition: all var(--transition-normal);
    border: 8px solid var(--color-primary);
    outline: 6px solid var(--color-accent);
    outline-offset: -14px;
    background: white;
}

.front {
    background: white;
}

.back {
    transform: rotateY(180deg);
    background: white;
}

/* ===========================
   Footer - Audio Player
   =========================== */
.game-footer {
    display: flex;
    justify-content: center;
    animation: fadeIn 0.8s ease 0.5s both;
}

.audio-player {
    background: var(--bg-dark);
    backdrop-filter: blur(10px);
    border: 2px solid var(--color-accent);
    border-radius: var(--border-radius-lg);
    padding: var(--spacing-md) var(--spacing-lg);
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
    box-shadow: var(--shadow-md);
    transition: all var(--transition-normal);
}

.audio-player:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-lg), var(--shadow-glow);
}

.audio-toggle {
    background: linear-gradient(135deg, var(--color-accent), #8e44ad);
    border: none;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1.5rem;
    box-shadow: var(--shadow-sm);
    transition: all var(--transition-normal);
    position: relative;
}

.audio-toggle:hover {
    transform: scale(1.1) rotate(5deg);
    box-shadow: var(--shadow-md);
}

.audio-toggle:active {
    transform: scale(0.95);
}

.audio-icon {
    position: absolute;
    transition: all var(--transition-fast);
}

.audio-toggle.playing .paused {
    opacity: 0;
    transform: scale(0);
}

.audio-toggle:not(.playing) .playing {
    opacity: 0;
    transform: scale(0);
}

.audio-toggle.playing .playing {
    animation: musicPulse 1s ease infinite;
}

@keyframes musicPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.2); }
}

.audio-info {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.audio-title {
    font-size: 1rem;
    font-weight: 600;
    color: white;
}

.audio-artist {
    font-size: 0.85rem;
    color: var(--color-secondary);
}

audio {
    display: none;
}

.volume-control {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-left: 1.5rem;
}

.volume-icon {
    font-size: 1.25rem;
    transition: transform 0.2s ease;
}

.volume-control:hover .volume-icon {
    transform: scale(1.1);
}

.volume-slider {
    width: 100px;
    height: 6px;
    -webkit-appearance: none;
    appearance: none;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 10px;
    outline: none;
    cursor: pointer;
    transition: all 0.3s ease;
}

.volume-slider:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Slider thumb - Webkit (Chrome, Safari) */
.volume-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    background: var(--color-secondary);
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0, 255, 255, 0.4);
    transition: all 0.2s ease;
}

.volume-slider::-webkit-slider-thumb:hover {
    transform: scale(1.2);
    box-shadow: 0 3px 12px rgba(0, 255, 255, 0.6);
}

/* Slider thumb - Firefox */
.volume-slider::-moz-range-thumb {
    width: 16px;
    height: 16px;
    background: var(--color-secondary);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0, 255, 255, 0.4);
    transition: all 0.2s ease;
}

.volume-slider::-moz-range-thumb:hover {
    transform: scale(1.2);
    box-shadow: 0 3px 12px rgba(0, 255, 255, 0.6);
}

/* Slider track - Firefox */
.volume-slider::-moz-range-track {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 10px;
    height: 6px;
}

/* ===========================
   Responsive Design
   =========================== */
@media (max-width: 768px) {
    .container-wrapper {
        gap: var(--spacing-md);
    }
    
    .game-board {
        padding: var(--spacing-md);
        gap: var(--spacing-sm);
        grid-template-columns: repeat(4, 1fr);
    }
    
    .control-panel {
        gap: var(--spacing-sm);
    }
    
    .stat-box {
        min-width: 120px;
        padding: var(--spacing-sm);
    }
    
    .stat-icon {
        font-size: 1.5rem;
    }
    
    .stat-value {
        font-size: 1.2rem;
    }
}

@media (max-width: 480px) {
    body {
        padding: var(--spacing-sm);
    }
    
    .game-board {
        padding: var(--spacing-sm);
        gap: 0.5rem;
    }
    
    .control-panel {
        flex-direction: column;
        width: 100%;
    }
    
    .stat-box,
    .reset-button {
        width: 100%;
        justify-content: center;
    }
}

/* ===========================
   Utility Animations
   =========================== */
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-10px); }
    75% { transform: translateX(10px); }
}

.shake {
    animation: shake 0.5s ease;
}
