/* Estilos base */
:root {
    --bg-dark: #0f0e0f;
    --gold: #d7b65d;
    --gold-soft: #f2db98;
    --gold-dim: rgba(217, 170, 81, 0.4);
    --gold-glow: rgba(217, 170, 81, 0.2);
    --bg-panel: rgba(15, 14, 15, 0.82);
    --text-main: #f8f1df;
    --text-muted: #afa99d;
    --card-bg: #120f09;
}

body {
    background-color: #0c0b0a;
    color: var(--text-main);
    font-family: 'Inter', ui-sans-serif, system-ui, sans-serif;
    margin: 0;
    padding: 0;
    padding-bottom: 100px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
}

.hidden {
    display: none !important;
}

/* Pantalla de Bienvenida */
.welcome-screen {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background-image: url('../img/hero.png');
    background-size: cover;
    background-position: center;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.welcome-content {
    background: rgba(15, 14, 15, 0.65);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(217, 170, 81, 0.2);
    border-radius: 24px;
    padding: 4rem 3rem;
    text-align: center;
    max-width: 600px;
    box-shadow: 0 30px 60px rgba(0,0,0,0.9), inset 0 0 20px rgba(217, 170, 81, 0.05);
}

.welcome-title {
    font-family: Georgia, serif;
    color: var(--gold-bright);
    font-size: 2.8rem;
    margin-bottom: 0.5rem;
    text-shadow: 0 2px 4px rgba(0,0,0,0.8);
}

.welcome-subtitle {
    color: var(--text-main);
    font-size: 1.2rem;
    margin-bottom: 2rem;
}

.welcome-instructions {
    color: var(--text-muted);
    font-size: 1rem;
    line-height: 1.6;
    margin-bottom: 2.5rem;
}

/* Header (used in Menu) */
.header {
    text-align: center;
    margin-bottom: 2rem;
    padding-top: 2rem;
}

.title {
    font-size: 3rem;
    color: #fff;
    margin: 0 0 0.5rem 0;
    font-family: Georgia, serif;
    font-weight: 400;
}

.subtitle {
    font-size: 1rem;
    color: #b5a995;
    font-weight: 400;
    letter-spacing: 0.15em;
    text-transform: uppercase;
}

/* Menú y Niveles */
#menu-screen {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem;
}

.stats-bar {
    display: flex;
    gap: 3rem;
    margin-bottom: 4rem;
    padding: 1.5rem 0;
    border-top: 1px solid rgba(217, 170, 81, 0.1);
    border-bottom: 1px solid rgba(217, 170, 81, 0.1);
    align-items: center;
    justify-content: center;
    width: 100%;
    max-width: 800px;
}

.stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
}

.stat-label {
    font-size: 0.75rem;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.stat-val {
    font-size: 1.25rem;
    color: #fff;
    font-weight: 500;
    font-family: Georgia, serif;
}

.level-list {
    display: flex;
    flex-direction: column;
    gap: 0;
    width: 100%;
    max-width: 800px;
    border-top: 1px solid rgba(217, 170, 81, 0.15);
}

.level-btn {
    background: transparent;
    border-bottom: 1px solid rgba(217, 170, 81, 0.15);
    padding: 1.5rem 1rem;
    text-align: left;
    cursor: pointer;
    transition: background 0.2s ease, padding-left 0.2s ease;
    display: grid;
    grid-template-columns: 80px 1fr;
    align-items: baseline;
    gap: 1.5rem;
}

.level-num {
    font-size: 0.9rem;
    color: var(--gold-dim);
    font-weight: 500;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

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

.level-name {
    font-family: Georgia, serif;
    font-size: 1.25rem;
    color: #fff;
    font-weight: 400;
}

.level-desc {
    font-size: 0.9rem;
    color: #888;
}

.level-btn.unlocked:hover {
    background: rgba(217, 170, 81, 0.02);
    padding-left: 1.5rem;
}

.level-btn.locked {
    opacity: 0.4;
    cursor: not-allowed;
    animation: matchGlow 1s ease-out forwards;
}

.level-num {
    font-size: 0.9rem;
    color: var(--gold);
    text-transform: uppercase;
    letter-spacing: 2px;
}

.level-name {
    font-size: 1.5rem;
    font-weight: bold;
}

/* Tablero de Juego */
#game-screen {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 7rem 1rem 1rem 1rem; /* Added top padding to prevent overlap with fixed nav */
    max-width: 1200px;
    margin: 0 auto;
    width: 100%;
}

.game-hud {
    display: flex;
    justify-content: space-between;
    width: 100%;
    margin-bottom: 2rem;
    padding: 0 1rem;
    color: var(--text-muted);
    font-family: 'Georgia', serif;
    letter-spacing: 0.05em;
}

.board {
    display: grid;
    gap: 1rem;
    perspective: 1000px;
    width: 100%;
    margin: 0 auto;
}

.board-cols-4 { grid-template-columns: repeat(4, 1fr); max-width: 800px; }
.board-cols-5 { grid-template-columns: repeat(5, 1fr); max-width: 1000px; }
.board-cols-6 { grid-template-columns: repeat(6, 1fr); max-width: 1200px; }

@media (max-width: 768px) {
    .board-cols-5, .board-cols-6 {
        grid-template-columns: repeat(5, 1fr);
    }
}

@media (max-width: 600px) {
    .board-cols-4, .board-cols-5, .board-cols-6 {
        grid-template-columns: repeat(4, 1fr);
        gap: 0.5rem;
    }
}

/* Cartas */
.memory-card {
    position: relative;
    width: 100%;
    height: 100%;
    aspect-ratio: 3/4;
    cursor: pointer;
    background: transparent;
}

.memory-card:hover {
    filter: drop-shadow(0 10px 20px rgba(0,0,0,0.7));
}

.memory-card.flipped {
    /* Clases manejadas en las caras (faces) */
}

.memory-card.flipped:hover {
    filter: drop-shadow(0 10px 20px rgba(0,0,0,0.7));
}

.memory-card.matched {
    pointer-events: none;
    filter: drop-shadow(0 0 15px rgba(217, 170, 81, 0.9));
    transform: scale(1.02);
    transition: all 0.3s ease;
}

.memory-card.matched-hidden {
    animation: matchFadeOut 0.8s ease-in forwards;
}

@keyframes matchFadeOut {
    0% {
        filter: drop-shadow(0 0 15px rgba(217, 170, 81, 0.9));
        transform: scale(1.05);
        opacity: 1;
    }
    50% {
        filter: drop-shadow(0 0 20px rgba(217, 170, 81, 1));
        transform: scale(1.1);
        opacity: 0.8;
    }
    100% {
        transform: scale(0.5);
        opacity: 0;
        visibility: hidden;
    }
}

.card-face {
    position: absolute;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
    background-color: transparent;
    border: none;
}

/* Truco 2D para simular 3D sin bugs de Safari + Animación Pop */
.card-back {
    background-image: url('../img/back.png');
    background-size: 100% 100%;
    background-position: center;
    background-repeat: no-repeat;
    transform: scale(1) scaleX(1);
    opacity: 1;
    transition: transform 0.3s cubic-bezier(0.4, 0.0, 0.2, 1), opacity 0s 0.3s;
    z-index: 2;
}

.card-front {
    background-image: url('../img/front.png');
    background-size: 100% 100%;
    background-position: center;
    background-repeat: no-repeat;
    transform: scale(1.1) scaleX(0);
    opacity: 0;
    transition: transform 0.3s cubic-bezier(0.4, 0.0, 0.2, 1), opacity 0s 0s;
    z-index: 1;
}

.memory-card.flipped .card-back {
    transform: scale(1.1) scaleX(0);
    opacity: 0;
    transition: transform 0.3s cubic-bezier(0.4, 0.0, 0.2, 1), opacity 0s 0.3s;
}

.memory-card.flipped .card-front {
    transform: scale(1) scaleX(1);
    opacity: 1;
    transition: transform 0.3s cubic-bezier(0.4, 0.0, 0.2, 1) 0.3s, opacity 0s 0.3s;
}

.card-content-wrapper {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 10%;
    z-index: 2;
}

.seal-img {
    width: 70%;
    height: auto;
    object-fit: contain;
    filter: drop-shadow(0 0 10px rgba(0,0,0,0.5));
}

.card-number {
    position: absolute;
    top: 5px;
    left: 8px;
    font-size: 0.8rem;
    color: var(--gold);
    font-weight: bold;
}

.card-text {
    font-size: 1.2rem;
    text-align: center;
    padding: 10px;
    color: var(--gold-bright);
}

.card-title {
    font-family: Georgia, serif;
    font-size: 0.9rem;
    font-weight: bold;
    color: #2a1f14;
    line-height: 1;
    margin-bottom: 5px;
}

.card-prop-main {
    font-size: 0.55rem;
    color: #4a3622;
    font-weight: bold;
    margin-bottom: 3px;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    font-family: 'Inter', sans-serif;
}

.card-prop-sub {
    font-size: 0.55rem;
    color: #5a4632;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    font-family: 'Inter', sans-serif;
}

@media (max-width: 600px) {
    .card-text {
        font-size: 0.9rem;
    }
    .card-title {
        font-size: 0.58rem; /* 35% reduction from 0.9rem */
    }
    .card-prop-main, .card-prop-sub {
        font-size: 0.35rem; /* 35% reduction from 0.55rem */
    }
}

/* Elegant Audio Player */
.elegant-audio-player {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    background: rgba(15, 14, 15, 0.8);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(217, 170, 81, 0.2);
    border-radius: 30px;
    display: flex;
    align-items: center;
    padding: 0.5rem 1rem;
    gap: 1rem;
    z-index: 1000;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
    transition: all 0.3s ease;
}

.elegant-audio-player:hover {
    border-color: rgba(217, 170, 81, 0.5);
    box-shadow: 0 4px 25px rgba(217, 170, 81, 0.2);
}

.audio-toggle-btn {
    background: transparent;
    border: none;
    color: var(--gold);
    font-size: 1.2rem;
    cursor: pointer;
    transition: transform 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.audio-toggle-btn:hover {
    transform: scale(1.1);
}

.audio-toggle-btn.muted {
    opacity: 0.6;
}

.elegant-track-select {
    background: transparent;
    border: none;
    color: var(--text-light);
    font-family: 'Inter', sans-serif;
    font-size: 0.9rem;
    outline: none;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    padding-right: 1.2rem;
    background-image: url("data:image/svg+xml;charset=US-ASCII,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%2214%22%20height%3D%2214%22%20viewBox%3D%220%200%2024%2024%22%20fill%3D%22none%22%20stroke%3D%22%23d7b65d%22%20stroke-width%3D%222%22%20stroke-linecap%3D%22round%22%20stroke-linejoin%3D%22round%22%3E%3Cpolyline%20points%3D%226%209%2012%2015%2018%209%22%3E%3C%2Fpolyline%3E%3C%2Fsvg%3E");
    background-repeat: no-repeat;
    background-position: right center;
}

.elegant-track-select option {
    background: var(--bg-dark);
    color: var(--text-main);
}

.copyright-mini {
    font-size: 0.75rem;
    color: var(--text-muted);
    border-left: 1px solid rgba(217, 170, 81, 0.2);
    padding-left: 1rem;
    font-family: 'Inter', sans-serif;
}

@media (max-width: 768px) {
    .elegant-audio-player {
        bottom: 1rem;
        right: 50%;
        transform: translateX(50%);
        width: 90%;
        justify-content: center;
        padding: 0.8rem 1rem;
    }
    .copyright-mini {
        display: none;
    }
}

/* Modal Result */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.85);
    backdrop-filter: blur(5px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
}

.modal-content {
    background: var(--card-bg);
    border: 1px solid var(--gold);
    padding: 3rem;
    border-radius: 16px;
    text-align: center;
    max-width: 400px;
    width: 90%;
    box-shadow: 0 0 50px rgba(217, 170, 81, 0.2);
}

.modal-content h2 {
    color: var(--gold-bright);
    margin-top: 0;
}

.btn-primary {
    background: var(--gold);
    border: none;
    color: #0c0b0a;
    padding: 1rem 2.5rem;
    font-family: 'Inter', sans-serif;
    font-size: 1rem;
    font-weight: 500;
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.2s ease, transform 0.1s ease;
    margin-top: 2rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.btn-primary:hover {
    background: var(--gold-bright);
}

.btn-primary:active {
    transform: scale(0.98);
}

.btn-secondary:active {
    transform: scale(0.98);
}

.hub-back-link {
    position: absolute;
    top: 2rem;
    left: 2rem;
    color: var(--gold-dim);
    text-decoration: none;
    font-family: 'Inter', sans-serif;
    font-size: 0.9rem;
    letter-spacing: 0.05em;
    transition: color 0.2s ease;
    z-index: 10;
}

.hub-back-link:hover {
    color: var(--gold-bright);
}

/* Loading Overlay */
#loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #0f0e0f;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    transition: opacity 0.5s ease;
}

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

.loader-content {
    text-align: center;
    color: var(--gold-bright);
    font-family: 'Inter', sans-serif;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    font-size: 0.9rem;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 3px solid rgba(217, 170, 81, 0.2);
    border-top: 3px solid var(--gold-bright);
    border-radius: 50%;
    margin: 0 auto 1.5rem auto;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.btn-secondary {
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: #888;
    padding: 0.6rem 1.2rem;
    font-family: inherit;
    border-radius: 4px;
    cursor: pointer;
    transition: color 0.2s ease, border-color 0.2s ease;
    font-size: 0.85rem;
}

.btn-secondary:hover {
    color: #fff;
    border-color: rgba(255, 255, 255, 0.3);
}

/* Top Nav */
.top-nav {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    display: flex;
    justify-content: flex-end;
    align-items: center;
    padding: 1rem 2rem;
    z-index: 200;
    background: rgba(15, 14, 15, 0.8);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(217, 170, 81, 0.1);
}

.nav-logo img {
    max-width: 120px;
    filter: drop-shadow(0 0 10px rgba(217, 170, 81, 0.3));
}

.nav-links {
    display: flex;
    gap: 1rem;
}

.btn-glass {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(217, 170, 81, 0.2);
    color: var(--gold-dim);
    padding: 0.3rem 1rem;
    border-radius: 4px; /* Square and elegant */
    text-decoration: none;
    font-family: 'Inter', sans-serif;
    font-size: 0.75rem;
    transition: all 0.3s ease;
    backdrop-filter: blur(5px);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.btn-glass:hover {
    background: rgba(217, 170, 81, 0.1);
    color: var(--gold-bright);
    border-color: rgba(217, 170, 81, 0.4);
    transform: none;
}

.hamburger {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    flex-direction: column;
    gap: 5px;
}

.hamburger span {
    display: block;
    width: 25px;
    height: 2px;
    background-color: var(--gold-dim);
    transition: 0.3s;
}

/* Mobile Nav */
@media (max-width: 768px) {
    .hamburger {
        display: flex;
    }
    
    .nav-links {
        display: none;
        position: absolute;
        top: 100%;
        left: 0;
        width: 100%;
        flex-direction: column;
        background: rgba(15, 14, 15, 0.95);
        backdrop-filter: blur(10px);
        padding: 1rem;
        border-bottom: 1px solid rgba(217, 170, 81, 0.2);
    }
    
    .nav-links.active {
        display: flex;
    }
}

/* Hero Section */
.hero-section {
    position: relative;
    width: 100%;
    margin: 0 0 3rem 0;
    border-radius: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    min-height: 60vh;
    border: none;
    border-bottom: 1px solid rgba(217, 170, 81, 0.2);
}

.hero-bg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    opacity: 0.5;
    z-index: 1;
}

.hero-content {
    position: relative;
    z-index: 2;
    text-align: center;
    padding: 8rem 2rem 4rem 2rem;
    background: linear-gradient(to bottom, rgba(10, 10, 10, 0.2), rgba(10, 10, 10, 1));
    width: 100%;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
}

.hero-kicker {
    color: var(--gold-dim);
    font-size: 0.75rem;
    font-family: 'Inter', sans-serif;
    text-transform: uppercase;
    letter-spacing: 0.2em;
    margin-bottom: 1rem;
    font-weight: 600;
}

.hero-title {
    color: #ffffff;
    font-family: 'Playfair Display', 'Georgia', serif;
    font-size: 4rem;
    margin: 0 0 1rem 0;
    text-shadow: 0 2px 10px rgba(0,0,0,0.8);
    font-weight: 400;
}

.hero-subtitle {
    color: #cccccc;
    font-size: 1.1rem;
    margin: 0 auto;
    max-width: 650px;
    font-family: 'Inter', sans-serif;
    text-shadow: 0 1px 5px rgba(0,0,0,0.8);
    line-height: 1.6;
}

@media (max-width: 768px) {
    .hero-content {
        padding: 5rem 1rem 3rem 1rem;
    }
    
    .hero-title {
        font-size: 2.5rem;
    }
    
    .hero-subtitle {
        font-size: 0.95rem;
    }
    
    .hero-kicker {
        font-size: 0.65rem;
    }
}
