/* ============================================
   Global Styles
   ============================================ */

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

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    padding: 0;
    min-height: 100vh;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: url('aassets/tweedbackground.webp') center/cover no-repeat fixed;
    color: #f8f5f0;
    overflow-x: hidden;
}

/* ============================================
   Background Overlay
   ============================================ */

.bg-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 0;
}

/* ============================================
   Page Wrapper
   ============================================ */

.page-wrapper {
    position: relative;
    z-index: 1;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    padding: 3rem 1.5rem;
}

/* ============================================
   Header / Name Section
   ============================================ */

.site-header {
    text-align: center;
    margin-bottom: 2.5rem;
}

.site-name {
    font-family: 'Old English Text MT', 'UnifrakturCook', 'Times New Roman', serif;
    font-size: 3.5rem;
    font-weight: normal;
    margin: 0 0 0.5rem 0;
    color: #f8f5f0;
    letter-spacing: 0.04em;
    text-shadow: 0 4px 20px rgba(0, 0, 0, 0.6);
}

.site-tagline {
    font-family: 'Inter', sans-serif;
    font-size: 1rem;
    font-weight: 400;
    margin: 0;
    color: #a0a0a0;
    letter-spacing: 0.1em;
    text-transform: lowercase;
}

/* ============================================
   Navigation Menu
   ============================================ */

.nav-menu {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    margin-bottom: 2rem;
    flex-wrap: wrap;
    opacity: 0;
    animation: fadeIn 0.8s ease 0.3s forwards;
    background: rgba(255, 255, 255, 0.06);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 50px;
    padding: 0.6rem 1.25rem;
}

.nav-link {
    color: #d0d0d0;
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 500;
    letter-spacing: 0.03em;
    padding: 0.4rem 0.75rem;
    border-radius: 50px;
    transition: color 0.25s ease, background 0.25s ease;
}

.nav-link:hover {
    color: #ffffff;
    background: rgba(248, 245, 240, 0.12);
}

.nav-divider {
    color: rgba(200, 200, 200, 0.25);
    font-size: 0.5rem;
    user-select: none;
}

.game-hint {
    font-size: 0.85rem;
    color: #808080;
    letter-spacing: 0.04em;
    margin-bottom: 1rem;
    font-style: italic;
    opacity: 0;
    animation: fadeIn 0.8s ease 0.6s forwards;
}

/* ============================================
   Game Container
   ============================================ */

.game-container {
    background: transparent;
    padding: 1rem;
    text-align: center;
    max-width: 700px;
    width: 100%;
}

/* ============================================
   Game Title / Description / Stats
   ============================================ */

.game-title {
    font-family: 'Inter', sans-serif;
    font-size: 1.25rem;
    font-weight: 500;
    margin: 0 0 0.5rem 0;
    color: #e8e5e0;
}

.game-description {
    font-size: 0.85rem;
    color: #808080;
    margin: 0 0 1.5rem 0;
}

.stats {
    font-size: 0.9rem;
    color: #b0b0b0;
    margin-bottom: 1.25rem;
    letter-spacing: 0.02em;
}

#move-count,
#match-count {
    color: #d0d0d0;
    font-weight: 500;
}

/* ============================================
   Reset Button
   ============================================ */

#reset-button {
    padding: 0.7rem 1.75rem;
    margin-bottom: 1.75rem;
    font-family: 'Inter', sans-serif;
    font-size: 0.9rem;
    font-weight: 500;
    color: #f0f0f0;
    background: linear-gradient(135deg, #3a3a3a, #2a2a2a);
    border: none;
    border-radius: 50px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

#reset-button:hover {
    background: linear-gradient(135deg, #4a4a4a, #3a3a3a);
    transform: scale(1.05);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4);
}

#reset-button:active {
    transform: scale(0.98);
}

/* ============================================
   Game Grid
   ============================================ */

.game-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    grid-template-rows: repeat(2, 1fr);
    gap: 1rem;
}

/* ============================================
   Cards - Dark Red with White Border
   ============================================ */

.card {
    width: 100%;
    aspect-ratio: 2 / 3;
    display: flex;
    justify-content: center;
    align-items: center;
    background: linear-gradient(180deg, #5a1a1d 0%, #4b1114 50%, #3d0d10 100%);
    border: 3px solid #f8f5f0;
    border-radius: 16px;
    font-size: 0.85rem;
    cursor: pointer;
    user-select: none;
    position: relative;
    transform-style: preserve-3d;
    transition: transform 0.3s ease, box-shadow 0.3s ease, background 0.3s ease, border-color 0.3s ease;
    box-shadow:
        0 6px 20px rgba(0, 0, 0, 0.5),
        inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

/* Hide label on card back */
.card .card-content {
    opacity: 0;
    transform: scale(0.8);
    transition: opacity 0.3s ease, transform 0.3s ease;
    color: #f8f5f0;
    font-family: 'Inter', sans-serif;
    font-weight: 500;
    letter-spacing: 0.03em;
    text-align: center;
    padding: 0.25rem;
}

/* Hover state for face-down cards */
.card:not(.flipped):not(.matched):hover {
    transform: translateY(-4px) scale(1.03);
    box-shadow:
        0 8px 25px rgba(0, 0, 0, 0.5),
        0 0 15px rgba(248, 245, 240, 0.15);
    background: linear-gradient(180deg, #6a2225 0%, #5a1a1d 50%, #4b1114 100%);
}

/* Flipped state */
.card.flipped {
    background: linear-gradient(180deg, #7a2a2d 0%, #6a2225 50%, #5a1a1d 100%);
    border-color: #ffffff;
    cursor: default;
    transform: rotateY(180deg);
}

.card.flipped .card-content {
    opacity: 1;
    transform: scale(1) rotateY(180deg);
}

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

/* Matched state */
.card.matched {
    background: linear-gradient(180deg, #8a3a3d 0%, #7a2a2d 50%, #6a2225 100%);
    border-color: #d4af37;
    box-shadow:
        0 4px 12px rgba(0, 0, 0, 0.4),
        0 0 20px rgba(212, 175, 55, 0.3);
    pointer-events: none;
    animation: matchPulse 0.5s ease;
}

.card.matched .card-content {
    opacity: 1;
    transform: scale(1) rotateY(180deg);
}

@keyframes matchPulse {
    0% {
        transform: rotateY(180deg) scale(1);
        box-shadow: 0 0 0 0 rgba(212, 175, 55, 0.5);
    }
    50% {
        transform: rotateY(180deg) scale(1.05);
        box-shadow: 0 0 25px 10px rgba(212, 175, 55, 0.4);
    }
    100% {
        transform: rotateY(180deg) scale(1);
        box-shadow:
            0 4px 12px rgba(0, 0, 0, 0.4),
            0 0 20px rgba(212, 175, 55, 0.3);
    }
}

/* ============================================
   Win Message
   ============================================ */

.win-message {
    margin-top: 1.5rem;
    padding: 1rem;
    background: rgba(212, 175, 55, 0.15);
    border: 1px solid rgba(212, 175, 55, 0.3);
    border-radius: 8px;
    color: #d4af37;
    font-size: 0.95rem;
    animation: fadeIn 0.5s ease;
}

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

/* ============================================
   Music Notification
   ============================================ */

.music-notification {
    position: fixed;
    bottom: 2rem;
    left: 2rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    z-index: 100;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.5s ease, transform 0.5s ease;
    pointer-events: none;
}

.music-notification.show {
    opacity: 1;
    transform: translateY(0);
}

.music-notification.fade-out {
    opacity: 0;
    transform: translateY(20px);
}

.vinyl-gif {
    width: 50px;
    height: 50px;
    border-radius: 50%;
}

.music-text {
    font-size: 0.9rem;
    color: #f8f5f0;
    font-style: italic;
    letter-spacing: 0.05em;
}

.timeout-gif {
    position: fixed;
    left: 3rem;
    top: 50%;
    transform: translateY(-50%) scale(0.8);
    width: 350px;
    height: auto;
    opacity: 0;
    transition: opacity 0.5s ease, transform 0.5s ease;
    z-index: 200;
}

.timeout-gif.show {
    opacity: 1;
    transform: translateY(-50%) scale(1);
}

/* ============================================
   Responsive Design
   ============================================ */

@media (max-width: 600px) {
    .page-wrapper {
        padding: 2rem 1rem;
    }

    .site-name {
        font-size: 2.5rem;
    }

    .site-tagline {
        font-size: 0.85rem;
    }

    .nav-menu {
        gap: 0.2rem;
        margin-bottom: 1.5rem;
        padding: 0.5rem 0.75rem;
    }

    .nav-link {
        font-size: 0.7rem;
        padding: 0.3rem 0.5rem;
    }

    .nav-divider {
        font-size: 0.4rem;
    }

    .game-hint {
        font-size: 0.75rem;
    }

    .game-container {
        padding: 1.75rem;
        border-radius: 20px;
    }

    .game-grid {
        gap: 0.6rem;
    }

    .card {
        border-radius: 10px;
        font-size: 0.7rem;
    }
}

@media (max-width: 400px) {
    .site-name {
        font-size: 2rem;
    }

    .game-container {
        padding: 1.25rem;
    }

    .game-grid {
        gap: 0.5rem;
    }

    .card {
        border-radius: 8px;
        font-size: 0.65rem;
    }
}

/* ============================================
   Volume Controls (Top Right)
   ============================================ */

.volume-controls {
    position: fixed;
    top: 1.5rem;
    right: 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    z-index: 1000;
    background: rgba(255, 255, 255, 0.08);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 50px;
    padding: 0.4rem 0.75rem;
}

.mute-btn {
    background: none;
    border: none;
    color: #a0a0a0;
    font-size: 1.1rem;
    cursor: pointer;
    padding: 0.2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.3s ease;
    line-height: 1;
}

.mute-btn:hover {
    color: #f8f5f0;
}

.volume-slider {
    -webkit-appearance: none;
    appearance: none;
    width: 80px;
    height: 4px;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 2px;
    outline: none;
    cursor: pointer;
}

.volume-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 14px;
    height: 14px;
    background: #d0d0d0;
    border-radius: 50%;
    cursor: pointer;
    transition: background 0.2s ease;
}

.volume-slider::-webkit-slider-thumb:hover {
    background: #f8f5f0;
}

.volume-slider::-moz-range-thumb {
    width: 14px;
    height: 14px;
    background: #d0d0d0;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    transition: background 0.2s ease;
}

.volume-slider::-moz-range-thumb:hover {
    background: #f8f5f0;
}

/* ============================================
   Prefers Reduced Motion
   ============================================ */

@media (prefers-reduced-motion: reduce) {
    .card {
        transition: none;
    }

    .card.matched {
        animation: none;
    }
}
