:root {
    --bg-dark: #1a1a1a;
    --bg-green: #1e392a;
    --paper-color: #f4e4bc;
    --paper-dark: #e8d4a8;
    --text-color: #2c1810;
    --accent-color: #8b4513;
    --highlight-color: #d35400;
    --gold: #c9a227;
    --burgundy: #722f37;
    --forest-green: #1e392a;
    --success-green: #2ecc71;
    --font-title: 'Cinzel', serif;
    --font-body: 'Courier Prime', monospace;
    --font-hand: 'Dancing Script', cursive;
    --font-elegant: 'Playfair Display', serif;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    background: linear-gradient(135deg, #0d1b14 0%, #1e392a 50%, #0d1b14 100%);
    color: var(--paper-color);
    font-family: var(--font-body);
    min-height: 100vh;
    position: relative;
    overflow-x: hidden;
}

/* ========== SNOWFALL ANIMATION ========== */
.snowfall {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 500;
    overflow: hidden;
}

.snowflake {
    position: absolute;
    top: -20px;
    color: white;
    opacity: 0.8;
    font-size: 1rem;
    animation: fall linear infinite;
    text-shadow: 0 0 5px rgba(255, 255, 255, 0.5);
}

@keyframes fall {
    0% {
        transform: translateY(-20px) rotate(0deg);
        opacity: 1;
    }
    100% {
        transform: translateY(100vh) rotate(360deg);
        opacity: 0.3;
    }
}

/* ========== INTRO VIEW ========== */
#intro-view {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    padding: 2rem;
}

.intro-container {
    width: 100%;
    max-width: 800px;
    position: relative;
}

/* Grimoire Cover */
.grimoire-intro {
    perspective: 1500px;
    display: flex;
    justify-content: center;
    animation: float-book 3s ease-in-out infinite;
}

@keyframes float-book {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-15px); }
}

.book-cover {
    width: 320px;
    height: 420px;
    background: linear-gradient(145deg, #5c3d2e, #3d2518);
    border-radius: 5px 15px 15px 5px;
    position: relative;
    box-shadow: 
        -5px 5px 15px rgba(0, 0, 0, 0.5),
        inset -3px 0 10px rgba(0, 0, 0, 0.3),
        inset 0 0 30px rgba(201, 162, 39, 0.1);
    border: 3px solid var(--gold);
    cursor: pointer;
    transition: all 0.5s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.book-cover:hover {
    transform: rotateY(-15deg) scale(1.02);
    box-shadow: 
        -15px 10px 30px rgba(0, 0, 0, 0.6),
        inset -3px 0 10px rgba(0, 0, 0, 0.3);
}

.book-cover::before {
    content: '';
    position: absolute;
    left: 15px;
    top: 10px;
    bottom: 10px;
    width: 3px;
    background: linear-gradient(180deg, var(--gold), transparent, var(--gold));
    border-radius: 2px;
}

.book-ornament {
    position: absolute;
    font-size: 1.5rem;
    color: var(--gold);
    opacity: 0.7;
}

.book-ornament.top-left { top: 20px; left: 30px; transform: rotate(180deg); }
.book-ornament.top-right { top: 20px; right: 20px; transform: rotate(270deg); }
.book-ornament.bottom-left { bottom: 20px; left: 30px; transform: rotate(90deg); }
.book-ornament.bottom-right { bottom: 20px; right: 20px; }

.book-title-cover {
    text-align: center;
    padding: 2rem;
}

.book-title-cover .book-icon {
    font-size: 4rem;
    display: block;
    margin-bottom: 1rem;
    filter: drop-shadow(0 0 20px rgba(201, 162, 39, 0.5));
    animation: pulse-glow 2s ease-in-out infinite;
}

@keyframes pulse-glow {
    0%, 100% { filter: drop-shadow(0 0 20px rgba(201, 162, 39, 0.5)); }
    50% { filter: drop-shadow(0 0 40px rgba(201, 162, 39, 0.8)); }
}

.book-title-cover h2 {
    font-family: var(--font-title);
    font-size: 1.8rem;
    color: var(--gold);
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.8);
    margin-bottom: 0.5rem;
}

.book-title-cover p {
    font-family: var(--font-elegant);
    font-style: italic;
    color: var(--paper-color);
    opacity: 0.8;
    font-size: 1rem;
}

/* Grimoire opening animation */
.grimoire-intro.opening .book-cover {
    animation: open-book 1.5s ease-out forwards;
}

@keyframes open-book {
    0% { transform: rotateY(0); }
    100% { transform: rotateY(-180deg) scale(0.5); opacity: 0; }
}

/* Story Narrative */
.story-narrative {
    text-align: center;
    animation: fade-in-up 1s ease-out;
}

.story-narrative.hidden {
    display: none;
}

@keyframes fade-in-up {
    0% { opacity: 0; transform: translateY(30px); }
    100% { opacity: 1; transform: translateY(0); }
}

.narrative-content {
    background: rgba(0, 0, 0, 0.6);
    border: 2px solid rgba(201, 162, 39, 0.3);
    border-radius: 15px;
    padding: 3rem 2rem;
    position: relative;
    backdrop-filter: blur(10px);
}

.chapter-marker {
    font-family: var(--font-elegant);
    font-style: italic;
    color: var(--gold);
    font-size: 1rem;
    margin-bottom: 0.5rem;
    letter-spacing: 3px;
}

.narrative-title {
    font-family: var(--font-title);
    font-size: 2.5rem;
    color: var(--paper-color);
    margin-bottom: 2rem;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.8);
}

.narrative-text {
    max-width: 600px;
    margin: 0 auto;
}

.story-line {
    font-family: var(--font-elegant);
    font-size: 1.15rem;
    line-height: 1.8;
    color: rgba(244, 228, 188, 0.9);
    margin-bottom: 1rem;
    opacity: 0;
    transform: translateY(20px);
    animation: reveal-line 0.8s ease-out forwards;
}

.story-line.highlight-story {
    font-size: 1.4rem;
    color: var(--gold);
    font-weight: bold;
    margin: 1.5rem 0;
    padding: 1rem;
    background: rgba(201, 162, 39, 0.1);
    border-radius: 10px;
    border: 1px solid rgba(201, 162, 39, 0.3);
}

.story-line .golden {
    color: var(--gold);
}

@keyframes reveal-line {
    to { opacity: 1; transform: translateY(0); }
}

/* Coordinates Card */
.coordinates-reveal {
    margin-top: 2rem;
    animation: fade-in-up 1s ease-out;
}

.coordinates-reveal.hidden {
    display: none;
}

.coord-card {
    background: linear-gradient(145deg, rgba(30, 57, 42, 0.8), rgba(15, 30, 20, 0.9));
    border: 2px solid var(--gold);
    border-radius: 15px;
    padding: 2rem;
    max-width: 400px;
    margin: 0 auto;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5), 0 0 30px rgba(201, 162, 39, 0.1);
}

.coord-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
    animation: spin-compass 10s linear infinite;
}

@keyframes spin-compass {
    0% { transform: rotate(0deg); }
    10% { transform: rotate(15deg); }
    20% { transform: rotate(-10deg); }
    30% { transform: rotate(5deg); }
    40%, 100% { transform: rotate(0deg); }
}

.coord-card h3 {
    font-family: var(--font-title);
    color: var(--gold);
    margin-bottom: 1.5rem;
    font-size: 1.3rem;
}

.coord-values {
    background: rgba(0, 0, 0, 0.4);
    border-radius: 10px;
    padding: 1rem;
    margin-bottom: 1rem;
}

.coord-line {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0;
    border-bottom: 1px solid rgba(201, 162, 39, 0.2);
}

.coord-line:last-child {
    border-bottom: none;
}

.coord-label {
    font-family: var(--font-body);
    color: rgba(244, 228, 188, 0.6);
    font-size: 0.9rem;
}

.coord-value {
    font-family: var(--font-title);
    color: var(--gold);
    font-size: 1.2rem;
    letter-spacing: 2px;
}

.coord-hint {
    font-family: var(--font-elegant);
    font-style: italic;
    font-size: 0.9rem;
    color: rgba(244, 228, 188, 0.6);
    margin-top: 1rem;
}

/* Begin Button */
.begin-adventure-btn {
    margin-top: 2rem;
    padding: 1.2rem 3rem;
    background: linear-gradient(145deg, var(--gold), #a88620);
    border: none;
    border-radius: 50px;
    color: var(--bg-dark);
    font-family: var(--font-title);
    font-size: 1.2rem;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 0.8rem;
    box-shadow: 0 5px 30px rgba(201, 162, 39, 0.4);
    animation: pulse-btn 2s ease-in-out infinite;
}

.begin-adventure-btn.hidden {
    display: none;
}

@keyframes pulse-btn {
    0%, 100% { box-shadow: 0 5px 30px rgba(201, 162, 39, 0.4); }
    50% { box-shadow: 0 5px 50px rgba(201, 162, 39, 0.7); }
}

.begin-adventure-btn:hover {
    transform: scale(1.05);
    background: linear-gradient(145deg, #d4b32a, var(--gold));
}

.begin-adventure-btn .btn-icon {
    font-size: 1.5rem;
}

/* Decorative Elements */
.decorative-elements {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
}

.deco-leaf {
    position: absolute;
    font-size: 3rem;
    opacity: 0.3;
    animation: sway 5s ease-in-out infinite;
}

.deco-leaf.left { left: 5%; top: 20%; }
.deco-leaf.right { right: 5%; top: 30%; animation-delay: -2s; }

.deco-tree {
    position: absolute;
    font-size: 5rem;
    opacity: 0.15;
    bottom: 5%;
}

.deco-tree.left-tree { left: 3%; }
.deco-tree.right-tree { right: 3%; }

@keyframes sway {
    0%, 100% { transform: rotate(-5deg); }
    50% { transform: rotate(5deg); }
}

/* Sound Toggle Button */
.sound-toggle {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.6);
    border: 2px solid rgba(201, 162, 39, 0.4);
    color: var(--paper-color);
    font-size: 1.3rem;
    cursor: pointer;
    z-index: 1001;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.sound-toggle:hover {
    background: rgba(201, 162, 39, 0.2);
    border-color: var(--gold);
}

.sound-toggle .sound-off {
    display: none;
}

.sound-toggle.muted .sound-on {
    display: none;
}

.sound-toggle.muted .sound-off {
    display: inline;
}

/* ========== PASSWORD PROTECTION PAGE ========== */
#password-protection {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
}

.protection-container {
    width: 100%;
    max-width: 450px;
}

.protection-card {
    background: rgba(0, 0, 0, 0.7);
    border: 2px solid rgba(201, 162, 39, 0.3);
    border-radius: 20px;
    padding: 3rem 2rem;
    text-align: center;
    backdrop-filter: blur(10px);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.lock-icon {
    font-size: 4rem;
    margin-bottom: 1.5rem;
    animation: pulse-lock 2s ease-in-out infinite;
}

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

.protection-title {
    font-family: var(--font-title);
    font-size: 2rem;
    color: var(--gold);
    margin-bottom: 1rem;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.8);
}

.protection-text {
    font-family: var(--font-elegant);
    color: rgba(244, 228, 188, 0.7);
    margin-bottom: 2rem;
    line-height: 1.6;
}

.protection-input-group {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

#site-password {
    background: rgba(0, 0, 0, 0.5);
    border: 2px solid rgba(201, 162, 39, 0.4);
    border-radius: 10px;
    padding: 1rem 1.5rem;
    color: var(--paper-color);
    font-family: var(--font-body);
    font-size: 1.1rem;
    text-align: center;
    outline: none;
    transition: all 0.3s ease;
}

#site-password:focus {
    border-color: var(--gold);
    box-shadow: 0 0 20px rgba(201, 162, 39, 0.3);
}

#site-unlock-btn {
    background: linear-gradient(145deg, var(--gold), #a88620);
    border: none;
    border-radius: 10px;
    padding: 1rem 2rem;
    color: var(--bg-dark);
    font-family: var(--font-title);
    font-size: 1.1rem;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 2px;
}

#site-unlock-btn:hover {
    background: linear-gradient(145deg, #d4b32a, var(--gold));
    transform: translateY(-3px);
    box-shadow: 0 10px 30px rgba(201, 162, 39, 0.4);
}

.protection-error {
    color: #e74c3c;
    font-weight: bold;
    margin-top: 1rem;
}

.protection-error.hidden {
    display: none;
}

.protection-card.shake {
    animation: shake-card 0.5s ease;
}

/* Texture Overlay */
.overlay-texture {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: url("data:image/svg+xml,%3Csvg width='100' height='100' viewBox='0 0 100 100' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)' opacity='0.08'/%3E%3C/svg%3E");
    pointer-events: none;
    z-index: 1000;
}

/* Floating particles */
.floating-particles {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
    background-image: 
        radial-gradient(2px 2px at 20% 30%, rgba(201, 162, 39, 0.3), transparent),
        radial-gradient(2px 2px at 40% 70%, rgba(201, 162, 39, 0.2), transparent),
        radial-gradient(1px 1px at 90% 40%, rgba(201, 162, 39, 0.3), transparent),
        radial-gradient(2px 2px at 60% 80%, rgba(201, 162, 39, 0.2), transparent),
        radial-gradient(1px 1px at 70% 20%, rgba(201, 162, 39, 0.4), transparent);
    animation: float-particles 20s ease-in-out infinite;
}

@keyframes float-particles {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-20px); }
}

#app {
    position: relative;
    z-index: 10;
}

/* Views Management */
.view {
    transition: opacity 1s ease-in-out;
}

.view.hidden {
    display: none !important;
    opacity: 0;
    position: absolute;
    pointer-events: none;
}

.view.active {
    opacity: 1;
}

/* ========== MAIN CONTAINER ========== */
.main-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem 1rem;
}

/* ========== HEADER ========== */
.mystery-header {
    text-align: center;
    margin-bottom: 3rem;
    padding: 2rem;
    background: rgba(0, 0, 0, 0.4);
    border-radius: 12px;
    border: 1px solid rgba(201, 162, 39, 0.2);
    position: relative;
}

.wax-seal {
    font-size: 3rem;
    margin-bottom: 1rem;
    filter: drop-shadow(0 0 20px rgba(201, 162, 39, 0.5));
    animation: flicker 3s ease-in-out infinite;
}

@keyframes flicker {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.8; }
}

.title-retro {
    font-family: var(--font-title);
    font-size: 2.5rem;
    color: var(--paper-color);
    margin-bottom: 0.5rem;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.8);
    letter-spacing: 2px;
}

.title-retro .highlight {
    color: var(--gold);
    display: block;
    font-size: 2.8rem;
}

.subtitle {
    font-family: var(--font-elegant);
    font-style: italic;
    font-size: 1.1rem;
    color: rgba(244, 228, 188, 0.7);
    margin-bottom: 2rem;
}

/* Password Progress */
.password-progress {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.letter-box {
    width: 45px;
    height: 50px;
    background: rgba(0, 0, 0, 0.5);
    border: 2px solid rgba(201, 162, 39, 0.3);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-title);
    font-size: 1.5rem;
    font-weight: bold;
    color: rgba(244, 228, 188, 0.4);
    transition: all 0.4s ease;
}

.letter-box.revealed {
    background: linear-gradient(145deg, var(--gold), #a88620);
    border-color: var(--gold);
    color: var(--bg-dark);
    animation: letter-reveal 0.6s ease;
    box-shadow: 0 0 20px rgba(201, 162, 39, 0.5);
}

@keyframes letter-reveal {
    0% { transform: rotateY(90deg) scale(0.5); }
    50% { transform: rotateY(-10deg) scale(1.1); }
    100% { transform: rotateY(0) scale(1); }
}

/* ========== ENIGMAS GRID ========== */
.enigmas-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.2rem;
    margin-bottom: 3rem;
    padding: 0 0.5rem;
    align-items: stretch;
}

.enigmas-grid > .enigma-card {
    height: 100%;
}

/* ========== ENIGMA CARD ========== */
.enigma-card {
    background: linear-gradient(145deg, rgba(30, 20, 10, 0.9), rgba(20, 15, 8, 0.95));
    border: 2px solid rgba(139, 69, 19, 0.4);
    border-radius: 12px;
    overflow: hidden;
    transition: all 0.3s ease;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
}

.enigma-card:hover {
    border-color: var(--gold);
    transform: translateY(-5px);
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.6), 0 0 30px rgba(201, 162, 39, 0.1);
}

.enigma-card.solved {
    border-color: var(--success-green);
    background: linear-gradient(145deg, rgba(30, 50, 30, 0.9), rgba(20, 35, 20, 0.95));
}

.card-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem 1.2rem;
    background: rgba(0, 0, 0, 0.3);
    border-bottom: 1px solid rgba(139, 69, 19, 0.3);
}

.enigma-number {
    font-family: var(--font-title);
    font-size: 1.2rem;
    color: var(--gold);
    text-shadow: 0 0 10px rgba(201, 162, 39, 0.5);
}

.card-header h3 {
    flex: 1;
    font-family: var(--font-elegant);
    font-size: 1.1rem;
    font-weight: 400;
    color: var(--paper-color);
}

.card-status {
    font-size: 1.2rem;
    transition: all 0.3s ease;
}

.enigma-card.solved .card-status::after {
    content: '✓';
    color: var(--success-green);
}

.enigma-card.solved .card-status {
    font-size: 0;
}

.card-content {
    padding: 1.2rem 1rem;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    flex: 1;
}

.enigma-body {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.enigma-intro {
    font-family: var(--font-elegant);
    font-style: italic;
    color: rgba(244, 228, 188, 0.8);
    margin-bottom: 1.2rem;
    line-height: 1.5;
    font-size: 0.95rem;
}

.answer-input-group {
    margin-top: auto;
}

.enigma-card.solved .enigma-body {
    display: none;
}

/* Enigma Solved State */
.enigma-solved {
    text-align: center;
    padding: 1.5rem;
}

.enigma-solved.hidden {
    display: none;
}

.enigma-card.solved .enigma-solved {
    display: block;
}

.solved-letter {
    display: inline-block;
    font-family: var(--font-title);
    font-size: 3rem;
    font-weight: bold;
    color: var(--gold);
    text-shadow: 0 0 20px rgba(201, 162, 39, 0.8);
    animation: pulse-letter 2s ease-in-out infinite;
}

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

.enigma-solved p {
    font-family: var(--font-elegant);
    color: var(--success-green);
    margin-top: 0.5rem;
}

/* ========== COMMON ENIGMA ELEMENTS ========== */
.answer-input-group {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: auto;
    padding-top: 1rem;
    width: 100%;
}

.enigma-input {
    flex: 1;
    min-width: 0;
    background: rgba(0, 0, 0, 0.5);
    border: 2px solid rgba(201, 162, 39, 0.4);
    border-radius: 8px;
    padding: 0.8rem 1rem;
    color: var(--paper-color);
    font-family: var(--font-body);
    font-size: 1rem;
    transition: all 0.3s ease;
}

.enigma-input:focus {
    outline: none;
    border-color: var(--gold);
    box-shadow: 0 0 15px rgba(201, 162, 39, 0.3);
    background: rgba(0, 0, 0, 0.6);
}

.enigma-input::placeholder {
    color: rgba(244, 228, 188, 0.5);
}

.validate-enigma-btn {
    background: linear-gradient(145deg, var(--gold), #a88620);
    border: none;
    border-radius: 8px;
    padding: 0.8rem 1.5rem;
    color: var(--bg-dark);
    font-family: var(--font-title);
    font-size: 0.9rem;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    white-space: nowrap;
    flex-shrink: 0;
    text-transform: uppercase;
    letter-spacing: 1px;
    box-shadow: 0 4px 15px rgba(201, 162, 39, 0.3);
}

.validate-enigma-btn:hover {
    background: linear-gradient(145deg, #d4b32a, var(--gold));
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(201, 162, 39, 0.5);
}

/* Wrong answer animation */
.enigma-card.wrong-answer {
    animation: shake-card 0.5s ease;
}

@keyframes shake-card {
    0%, 100% { transform: translateX(0); }
    20%, 60% { transform: translateX(-10px); }
    40%, 80% { transform: translateX(10px); }
}

/* ========== ENIGMA 1: SOUND ========== */
.play-mystery-sound {
    width: 100%;
    padding: 1rem 1.2rem;
    background: linear-gradient(145deg, var(--burgundy), #5a2028);
    border: 2px solid rgba(201, 162, 39, 0.4);
    border-radius: 10px;
    color: var(--paper-color);
    font-family: var(--font-body);
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.6rem;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

.play-mystery-sound:hover {
    background: linear-gradient(145deg, #8a3a42, var(--burgundy));
    border-color: var(--gold);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4);
}

.play-mystery-sound .play-icon {
    font-size: 1.3rem;
}

.play-mystery-sound .playing-icon {
    display: none;
    animation: sound-wave 0.5s ease infinite;
}

.play-mystery-sound.playing .play-icon { display: none; }
.play-mystery-sound.playing .playing-icon { display: inline; }
.play-mystery-sound.playing {
    background: linear-gradient(145deg, #9a4a52, var(--burgundy));
    border-color: var(--gold);
}

/* Sound Controls */
.sound-controls {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.sound-controls .play-mystery-sound {
    flex: 1;
}

.stop-sound-btn {
    padding: 0.8rem 1rem;
    background: rgba(231, 76, 60, 0.3);
    border: 2px solid rgba(231, 76, 60, 0.5);
    border-radius: 10px;
    color: #e74c3c;
    font-family: var(--font-body);
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.3s ease;
}

.stop-sound-btn:hover {
    background: rgba(231, 76, 60, 0.5);
    border-color: #e74c3c;
}

.stop-sound-btn.hidden {
    display: none;
}

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

.sound-hint {
    text-align: center;
    margin-top: 1rem;
    font-size: 0.9rem;
    color: rgba(244, 228, 188, 0.6);
}

/* ========== ENIGMA 2: CODED MESSAGE ========== */
.coded-message {
    text-align: center;
    margin-bottom: 1rem;
}

.code-paper {
    font-family: var(--font-title);
    font-size: 1.6rem;
    letter-spacing: 6px;
    color: var(--burgundy);
    background: linear-gradient(145deg, var(--paper-color), var(--paper-dark));
    padding: 1rem 1.2rem;
    border-radius: 6px;
    display: inline-block;
    transform: rotate(-1deg);
    box-shadow: 3px 3px 15px rgba(0, 0, 0, 0.5);
    max-width: 100%;
    word-break: break-all;
}

.code-hint {
    margin-top: 1rem;
    font-size: 0.85rem;
    color: rgba(244, 228, 188, 0.7);
    line-height: 1.5;
}

.code-hint small {
    display: block;
    margin-top: 0.4rem;
    color: rgba(244, 228, 188, 0.5);
    font-size: 0.8rem;
}

/* ========== ENIGMA 3: BOOKSHELF ========== */
.bookshelf {
    display: flex;
    justify-content: center;
    gap: 0.3rem;
    background: linear-gradient(180deg, #3d2817 0%, #2a1a0f 100%);
    padding: 1rem 0.5rem 0.5rem;
    border-radius: 4px;
    margin-bottom: 1rem;
}

.book {
    width: 55px;
    height: 120px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 0.5rem 0.3rem;
    border-radius: 2px;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
}

.book:nth-child(1) { background: linear-gradient(90deg, #8b0000, #a52a2a); }
.book:nth-child(2) { background: linear-gradient(90deg, #1a365d, #2c5282); }
.book:nth-child(3) { background: linear-gradient(90deg, #2d3748, #4a5568); }
.book:nth-child(4) { background: linear-gradient(90deg, #553c2a, #7c5c42); }

.book:hover {
    transform: translateY(-10px);
}

.book-spine {
    font-size: 0.55rem;
    text-align: center;
    color: var(--gold);
    writing-mode: horizontal-tb;
    line-height: 1.2;
}

.book-year {
    font-size: 0.5rem;
    text-align: center;
    color: rgba(255, 255, 255, 0.6);
}

.book-riddle {
    text-align: center;
    font-family: var(--font-elegant);
    font-style: italic;
    margin-bottom: 1rem;
    color: rgba(244, 228, 188, 0.8);
}

.book-buttons {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.book-choice {
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(201, 162, 39, 0.3);
    border-radius: 4px;
    padding: 0.5rem 1rem;
    color: var(--paper-color);
    font-family: var(--font-body);
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.3s ease;
}

.book-choice:hover {
    background: rgba(201, 162, 39, 0.2);
    border-color: var(--gold);
}

/* ========== ENIGMA 4: PATH PUZZLE ========== */
.path-puzzle {
    text-align: center;
}

.path-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 4px;
    max-width: 250px;
    margin: 0 auto 1rem;
    background: rgba(255, 255, 255, 0.1);
    padding: 8px;
    border-radius: 8px;
}

.path-cell {
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    background: rgba(200, 220, 240, 0.15);
    border-radius: 4px;
    cursor: default;
    transition: all 0.3s ease;
}

.path-cell[data-step] {
    cursor: pointer;
}

.path-cell[data-step]:hover {
    background: rgba(201, 162, 39, 0.3);
    transform: scale(1.1);
}

.path-cell.clicked {
    background: var(--success-green);
    pointer-events: none;
}

.path-cell.wrong {
    opacity: 0.5;
}

.path-cell.start, .path-cell.end {
    font-size: 1.5rem;
}

.path-instruction {
    font-size: 0.85rem;
    color: rgba(244, 228, 188, 0.6);
    margin-bottom: 0.8rem;
}

.path-progress {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
}

.step-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: rgba(244, 228, 188, 0.2);
    border: 1px solid rgba(244, 228, 188, 0.4);
    transition: all 0.3s ease;
}

.step-dot.active {
    background: var(--success-green);
    border-color: var(--success-green);
}

/* ========== ENIGMA 5: GRIMOIRE ========== */
.grimoire-page {
    background: linear-gradient(145deg, var(--paper-color), var(--paper-dark));
    color: var(--text-color);
    padding: 1.5rem;
    border-radius: 4px;
    margin-bottom: 1rem;
    box-shadow: inset 0 0 30px rgba(139, 69, 19, 0.2);
    transform: rotate(-0.5deg);
}

.spell-text {
    font-family: var(--font-elegant);
    font-size: 1rem;
    line-height: 2;
    text-align: center;
}

.spell-blank {
    color: var(--burgundy);
    font-weight: bold;
    border-bottom: 2px dashed var(--burgundy);
    padding: 0 0.2rem;
}

.spell-inputs {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.spell-input {
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(201, 162, 39, 0.3);
    border-radius: 4px;
    padding: 0.5rem;
    color: var(--paper-color);
    font-family: var(--font-body);
    font-size: 0.9rem;
    text-align: center;
}

.spell-input:focus {
    outline: none;
    border-color: var(--gold);
}

.spell-input.correct {
    border-color: var(--success-green);
    background: rgba(46, 204, 113, 0.2);
}

.spell-validate {
    width: 100%;
}

/* ========== ENIGMA 6: CLOCK ========== */
.clock-puzzle {
    text-align: center;
}

.clock-face {
    width: 150px;
    height: 150px;
    border-radius: 50%;
    background: linear-gradient(145deg, var(--paper-color), var(--paper-dark));
    margin: 0 auto 1rem;
    position: relative;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.4), inset 0 0 20px rgba(139, 69, 19, 0.2);
    border: 4px solid var(--accent-color);
}

.clock-center {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 10px;
    height: 10px;
    background: var(--text-color);
    border-radius: 50%;
    z-index: 3;
}

.hour-hand {
    position: absolute;
    bottom: 50%;
    left: 50%;
    width: 4px;
    height: 35px;
    background: var(--text-color);
    transform-origin: bottom center;
    transform: translateX(-50%) rotate(90deg);
    border-radius: 2px;
}

.minute-hand {
    position: absolute;
    bottom: 50%;
    left: 50%;
    width: 2px;
    height: 50px;
    background: var(--burgundy);
    transform-origin: bottom center;
    transform: translateX(-50%) rotate(0deg);
    border-radius: 2px;
}

.clock-number {
    position: absolute;
    font-family: var(--font-title);
    font-size: 0.9rem;
    color: var(--text-color);
    font-weight: bold;
}

.n12 { top: 8px; left: 50%; transform: translateX(-50%); }
.n3 { top: 50%; right: 10px; transform: translateY(-50%); }
.n6 { bottom: 8px; left: 50%; transform: translateX(-50%); }
.n9 { top: 50%; left: 10px; transform: translateY(-50%); }

.clock-clues {
    text-align: left;
    margin-bottom: 1rem;
}

.clock-clues p {
    font-size: 0.85rem;
    color: rgba(244, 228, 188, 0.8);
    margin-bottom: 0.5rem;
    padding-left: 0.5rem;
}

.time-suffix {
    color: rgba(244, 228, 188, 0.6);
    align-self: center;
}

/* ========== ENIGMA 7: PORTRAITS ========== */
.portraits-gallery {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}

.portrait {
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
}

.portrait:hover {
    transform: scale(1.1);
}

.portrait-frame {
    width: 55px;
    height: 70px;
    background: linear-gradient(145deg, #4a3728, #2d1f15);
    border: 3px solid var(--gold);
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    margin-bottom: 0.3rem;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.4);
}

.portrait-label {
    font-size: 0.7rem;
    color: rgba(244, 228, 188, 0.7);
}

.portrait.selected .portrait-frame {
    border-color: var(--success-green);
    box-shadow: 0 0 15px rgba(46, 204, 113, 0.5);
}

.intruder-hint {
    text-align: center;
    font-family: var(--font-elegant);
    font-style: italic;
    font-size: 0.9rem;
    color: rgba(244, 228, 188, 0.7);
}

/* ========== FAMILY ENIGMAS ========== */
.family-card {
    border-color: rgba(201, 162, 39, 0.5);
}

.family-card .card-header {
    background: linear-gradient(90deg, rgba(114, 47, 55, 0.4), rgba(0, 0, 0, 0.3));
}

.family-mystery {
    text-align: center;
    margin-bottom: 1rem;
    flex: 0;
}

.mystery-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
    filter: drop-shadow(0 0 10px rgba(201, 162, 39, 0.5));
}

.mystery-question {
    background: rgba(0, 0, 0, 0.3);
    padding: 1.2rem;
    border-radius: 8px;
    border-left: 3px solid var(--gold);
}

.question-text {
    font-family: var(--font-elegant);
    font-size: 0.95rem;
    color: rgba(244, 228, 188, 0.8);
    margin-bottom: 0.8rem;
    line-height: 1.5;
}

.question-main {
    font-family: var(--font-title);
    font-size: 1.1rem;
    color: var(--gold);
}

.hint-text {
    font-size: 0.8rem;
    color: rgba(244, 228, 188, 0.5);
    margin-top: 0.8rem;
    font-style: italic;
}


/* Word Puzzle (Simon) */
.word-puzzle {
    margin-bottom: 1rem;
    flex: 1;
}

/* Bouton centré pour Simon */
#validate-simon {
    display: block;
    margin: 1rem auto 0;
    width: auto;
    min-width: 200px;
}

.puzzle-hint {
    font-family: var(--font-body);
    color: rgba(244, 228, 188, 0.6);
    margin-bottom: 1rem;
    letter-spacing: 2px;
}

.puzzle-inputs {
    display: flex;
    justify-content: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.word-group {
    display: flex;
    gap: 3px;
}

.letter-input {
    width: 32px;
    height: 40px;
    background: rgba(0, 0, 0, 0.5);
    border: 2px solid rgba(201, 162, 39, 0.3);
    border-radius: 4px;
    color: var(--paper-color);
    font-family: var(--font-title);
    font-size: 1.2rem;
    text-align: center;
    text-transform: uppercase;
    transition: all 0.3s ease;
}

.letter-input:focus {
    outline: none;
    border-color: var(--gold);
    background: rgba(201, 162, 39, 0.1);
}

.letter-input.correct {
    border-color: var(--success-green);
    background: rgba(46, 204, 113, 0.2);
}

.letter-input.wrong {
    border-color: #e74c3c;
    animation: shake-letter 0.3s ease;
}

@keyframes shake-letter {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-3px); }
    75% { transform: translateX(3px); }
}

/* Number Selector (Elisa) */
.number-selector {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin: 1rem 0;
}

.number-btn {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.4);
    border: 2px solid rgba(201, 162, 39, 0.3);
    color: var(--paper-color);
    font-family: var(--font-title);
    font-size: 1.3rem;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
}

.number-btn:hover {
    background: rgba(201, 162, 39, 0.2);
    border-color: var(--gold);
    transform: scale(1.1);
}

.number-btn.selected {
    background: linear-gradient(145deg, var(--gold), #a88620);
    border-color: var(--gold);
    color: var(--bg-dark);
    box-shadow: 0 0 15px rgba(201, 162, 39, 0.5);
}

.number-btn.wrong {
    animation: shake-card 0.4s ease;
    border-color: #e74c3c;
}

/* Smell Challenge (Hervé) */
.smell-challenge {
    text-align: center;
    padding: 1.5rem;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 10px;
    margin: 1rem 0;
}

.blindfold-icon {
    font-size: 3rem;
    margin-bottom: 0.5rem;
    animation: float-gentle 3s ease-in-out infinite;
}

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

.smell-instruction {
    font-family: var(--font-elegant);
    font-style: italic;
    color: rgba(244, 228, 188, 0.7);
}

/* Music Player (Sabine) */
.music-player {
    text-align: center;
    margin: 1.5rem 0;
}

.play-music-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.8rem;
    padding: 1rem 2rem;
    background: linear-gradient(145deg, #1db954, #169c46);
    border: none;
    border-radius: 50px;
    color: white;
    font-family: var(--font-body);
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 5px 20px rgba(29, 185, 84, 0.3);
}

.play-music-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 8px 30px rgba(29, 185, 84, 0.5);
}

.play-music-btn .play-icon {
    font-size: 1.3rem;
}

.play-music-btn .playing-icon {
    display: none;
    animation: bounce-music 0.5s ease infinite;
}

.play-music-btn.playing .play-icon { display: none; }
.play-music-btn.playing .playing-icon { display: inline; }

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

.song-title {
    margin-top: 1rem;
    font-family: var(--font-elegant);
    font-size: 1.1rem;
    color: var(--gold);
}

.song-title.hidden {
    display: none;
}


/* ========== FINAL PASSWORD SECTION ========== */
.final-password-section {
    background: rgba(0, 0, 0, 0.5);
    border-radius: 12px;
    border: 2px solid rgba(201, 162, 39, 0.3);
    padding: 2rem;
    text-align: center;
}

.final-title {
    font-family: var(--font-title);
    font-size: 1.8rem;
    color: var(--gold);
    margin-bottom: 0.5rem;
}

.final-hint {
    font-family: var(--font-elegant);
    font-style: italic;
    color: rgba(244, 228, 188, 0.7);
    margin-bottom: 1.5rem;
}

.input-group {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

#password-input {
    background: rgba(0, 0, 0, 0.5);
    border: 2px solid rgba(201, 162, 39, 0.4);
    border-radius: 8px;
    color: var(--paper-color);
    font-family: var(--font-body);
    font-size: 1.3rem;
    padding: 0.8rem 1.5rem;
    width: 250px;
    text-align: center;
    outline: none;
    transition: all 0.3s ease;
}

#password-input:focus {
    border-color: var(--gold);
    box-shadow: 0 0 20px rgba(201, 162, 39, 0.3);
}

#unlock-btn {
    background: linear-gradient(145deg, var(--gold), #a88620);
    border: none;
    font-family: var(--font-title);
    font-weight: bold;
    padding: 0.8rem 2rem;
    cursor: pointer;
    font-size: 1rem;
    color: var(--bg-dark);
    border-radius: 8px;
    transition: all 0.3s ease;
}

#unlock-btn:hover {
    background: linear-gradient(145deg, #d4b32a, var(--gold));
    transform: translateY(-3px);
    box-shadow: 0 5px 20px rgba(201, 162, 39, 0.4);
}

#error-message {
    color: #e74c3c;
    font-weight: bold;
}

#error-message.hidden {
    display: none;
}

.shake {
    animation: shake-card 0.5s ease;
}

/* ========== REVEAL VIEW ========== */
.grimoire-container {
    background-color: var(--paper-color);
    color: var(--text-color);
    padding: 4rem;
    max-width: 800px;
    width: 90%;
    margin: 2rem auto;
    min-height: 500px;
    box-shadow: 0 0 50px rgba(0,0,0,0.8), inset 0 0 100px rgba(139, 69, 19, 0.2);
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.grimoire-container::before {
    content: '';
    position: absolute;
    left: 20px;
    top: 0;
    bottom: 0;
    width: 2px;
    background: rgba(0,0,0,0.1);
}

.handwritten-title {
    font-family: var(--font-hand);
    font-size: 3.5rem;
    color: var(--accent-color);
    margin-bottom: 2rem;
    transform: rotate(-2deg);
}

.story-text {
    font-family: var(--font-elegant);
    font-size: 1.2rem;
    line-height: 1.8;
    text-align: center;
    max-width: 600px;
}

.story-text p {
    margin-bottom: 1.5rem;
}

.highlight-big {
    font-family: var(--font-title);
    font-size: 2.2rem;
    font-weight: bold;
    color: var(--forest-green);
    display: block;
    margin: 2rem 0;
    border-top: 2px double var(--accent-color);
    border-bottom: 2px double var(--accent-color);
    padding: 1rem;
}

.signature {
    text-align: center;
    font-family: var(--font-hand);
    font-size: 1.5rem;
    margin-top: 2rem;
    color: var(--accent-color);
}

.heart {
    font-size: 2rem;
    animation: heartbeat 1.5s ease infinite;
}

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

/* ========== RESPONSIVE ========== */
@media (max-width: 768px) {
    .main-container {
        padding: 1rem 0.5rem;
    }

    .mystery-header {
        padding: 1.5rem 1rem;
        margin-bottom: 2rem;
    }
    
    .title-retro {
        font-size: 1.6rem;
    }
    
    .title-retro .highlight {
        font-size: 1.8rem;
    }

    .subtitle {
        font-size: 0.95rem;
        margin-bottom: 1.5rem;
    }
    
    .enigmas-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
        padding: 0;
    }
    
    .letter-box {
        width: 32px;
        height: 38px;
        font-size: 1.1rem;
    }

    .password-progress {
        gap: 0.3rem;
    }

    .card-content {
        padding: 1rem 0.8rem;
    }

    .enigma-intro {
        font-size: 0.9rem;
        margin-bottom: 1rem;
    }

    /* Boutons sur mobile */
    .answer-input-group {
        flex-direction: column;
    }

    .enigma-input {
        width: 100%;
        font-size: 1rem;
    }

    .validate-enigma-btn {
        width: 100%;
        padding: 0.9rem 1rem;
    }

    .play-mystery-sound {
        padding: 0.9rem 1rem;
        font-size: 0.9rem;
    }

    .code-paper {
        font-size: 1.3rem;
        letter-spacing: 4px;
        padding: 0.8rem 1rem;
    }

    /* Puzzle lettres */
    .puzzle-inputs {
        gap: 0.5rem;
    }

    .letter-input {
        width: 26px;
        height: 34px;
        font-size: 1rem;
    }

    .word-group {
        gap: 2px;
    }

    /* Sélecteur nombres */
    .number-btn {
        width: 42px;
        height: 42px;
        font-size: 1.1rem;
    }

    /* Section finale */
    .final-password-section {
        padding: 1.5rem 1rem;
    }

    .final-title {
        font-size: 1.4rem;
    }

    #password-input {
        width: 100%;
        max-width: 250px;
        font-size: 1.1rem;
    }

    #unlock-btn {
        padding: 0.8rem 1.5rem;
    }
    
    .grimoire-container {
        padding: 1.5rem;
        min-height: auto;
    }
    
    .handwritten-title {
        font-size: 2rem;
    }

    .highlight-big {
        font-size: 1.6rem;
    }

    .story-text {
        font-size: 1rem;
    }

    /* Énigmes familiales */
    .mystery-icon {
        font-size: 2.5rem;
    }

    .mystery-question {
        padding: 1rem;
    }

    .question-main {
        font-size: 1rem;
    }

    /* Livres bibliothèque */
    .bookshelf {
        gap: 0.2rem;
        padding: 0.8rem 0.3rem 0.3rem;
    }

    .book {
        width: 48px;
        height: 100px;
    }

    .book-spine {
        font-size: 0.5rem;
    }

    .book-buttons {
        gap: 0.3rem;
    }

    .book-choice {
        padding: 0.4rem 0.7rem;
        font-size: 0.75rem;
    }

    /* Player musique */
    .play-music-btn {
        padding: 0.8rem 1.5rem;
        font-size: 0.9rem;
    }
}

@media (max-width: 400px) {
    .letter-box {
        width: 28px;
        height: 34px;
        font-size: 1rem;
    }

    .code-paper {
        font-size: 1.1rem;
        letter-spacing: 3px;
    }

    .letter-input {
        width: 22px;
        height: 30px;
        font-size: 0.9rem;
    }
}
