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

:root {
    --gold: #d4af37;
    --gold-light: #f4d03f;
    --gold-dark: #b8941e;
    --black: #0a0a0a;
    --gray-dark: #1a1a1a;
    --gray: #2a2a2a;
    --gray-light: #4a4a4a;
    --white: #e8e8e8;

    /* NEW atmospheric colors to match Elden Ring backgrounds */
    --mist-blue: rgba(100, 140, 200, 0.15);
    --mist-blue-border: rgba(120, 160, 220, 0.35);
    --dark-glass: rgba(8, 10, 18, 0.75);
    --dark-glass-heavy: rgba(5, 7, 14, 0.88);
    --rune-glow: rgba(140, 180, 255, 0.5);
    --rune-glow-strong: rgba(160, 200, 255, 0.8);
    --wall-color: rgba(15, 18, 28, 0.88);
    --wall-border: rgba(80, 110, 160, 0.4);
    --silver: #c0c8d8;
    --silver-light: #dde4f0;
}

body {
    font-family: 'Cinzel', serif;
    overflow: hidden;
    background: var(--black);
    color: var(--white);
    height: 100vh;
    width: 100vw;
    overscroll-behavior-y: contain;
}

/* SCREENS */
.screen {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    display: none;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    opacity: 0;
    transition: opacity 0.8s ease;
}

.screen.active {
    display: flex;
    opacity: 1;
}

/* HOME SCREEN */
#homeScreen {
    background-image: url('assets/bg-home.jpg');
    justify-content: center;
    align-items: center;
    flex-direction: column;
}

/* MAP SCREEN */
#mapScreen {
    justify-content: center;
    align-items: center;
    flex-direction: column;
    position: relative;
    overflow: hidden;
    background: transparent;
}

#mapScreen::before {
    content: '';
    position: absolute;
    top: -20px; left: -20px; right: -20px; bottom: -20px;
    background-image: url('assets/bg-home.jpg');
    background-size: cover;
    background-position: center;
    filter: blur(15px) brightness(0.4);
    z-index: 0;
}

/* GAME SCREEN */
#gameScreen {
    background-color: var(--black);
    background-size: cover;
    background-position: center;
    flex-direction: column;
    transition: background-image 0.6s ease;
}

/* OVERLAYS */
.golden-overlay {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    background: radial-gradient(ellipse at center,
        transparent 0%,
        rgba(5, 8, 18, 0.5) 60%,
        rgba(3, 5, 12, 0.85) 100%);
    pointer-events: none;
    z-index: 1;
}

/* HOME CONTENT */
.home-content {
    z-index: 10;
    position: relative;
    text-align: center;
    animation: fadeInUp 1.5s ease;
}

/* MAP CONTENT */
.map-content {
    z-index: 10;
    position: relative;
    text-align: center;
    width: 90%;
    max-width: 1200px;
    max-height: 85vh;
    overflow-y: auto;
    padding: 1rem;
    border-radius: 10px;
}

/* TITLE */
.main-title {
    font-size: clamp(3rem, 10vw, 8rem);
    font-weight: 900;
    letter-spacing: 0.3rem;
    margin-bottom: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.title-word {
    display: block;
    background: linear-gradient(180deg,
        #ffffff 0%,
        var(--gold-light) 30%,
        var(--gold) 60%,
        var(--gold-dark) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-shadow: none;
    filter: drop-shadow(0 0 30px rgba(212, 175, 55, 0.7))
            drop-shadow(0 0 60px rgba(212, 175, 55, 0.3));
}

.subtitle {
    font-family: 'Playfair Display', serif;
    font-size: clamp(0.9rem, 2vw, 1.5rem);
    color: var(--silver-light);
    margin-bottom: 3rem;
    letter-spacing: 0.3rem;
    text-transform: uppercase;
    text-shadow: 0 0 20px rgba(180, 200, 255, 0.6);
}

.menu-buttons {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    align-items: center;
}

/* BUTTONS */
.elden-btn {
    position: relative;
    background: var(--dark-glass-heavy);
    border: 1px solid rgba(180, 160, 80, 0.5);
    color: var(--gold-light);
    font-family: 'Cinzel', serif;
    font-size: clamp(0.9rem, 2vw, 1.1rem);
    font-weight: 600;
    padding: 1.2rem 3rem;
    cursor: pointer;
    letter-spacing: 0.2rem;
    text-transform: uppercase;
    overflow: hidden;
    transition: all 0.4s ease;
    backdrop-filter: blur(10px);
    box-shadow:
        0 4px 25px rgba(0, 0, 0, 0.7),
        inset 0 1px 0 rgba(212, 175, 55, 0.15),
        inset 0 -1px 0 rgba(0, 0, 0, 0.5);
}

.elden-btn:hover, .elden-btn:active {
    border-color: rgba(244, 208, 63, 0.8);
    color: #ffffff;
    box-shadow:
        0 6px 35px rgba(212, 175, 55, 0.35),
        0 0 60px rgba(212, 175, 55, 0.15),
        inset 0 1px 0 rgba(212, 175, 55, 0.3);
    transform: translateY(-2px);
}

.btn-shine {
    position: absolute;
    top: -50%; left: -100%;
    width: 30%; height: 200%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.15), transparent);
    transform: skewX(-25deg);
    transition: left 0.6s ease;
}

.elden-btn:hover .btn-shine { left: 150%; }

.elden-btn.secondary {
    background: rgba(10, 14, 25, 0.8);
    border-color: var(--mist-blue-border);
    color: var(--silver-light);
}

.elden-btn.secondary:hover {
    border-color: rgba(160, 200, 255, 0.7);
    color: #ffffff;
    box-shadow: 0 6px 35px rgba(100, 150, 255, 0.2);
}

.elden-btn.primary {
    background: linear-gradient(135deg,
        rgba(180, 140, 20, 0.6) 0%,
        rgba(212, 175, 55, 0.4) 50%,
        rgba(180, 140, 20, 0.6) 100%);
    border-color: rgba(244, 208, 63, 0.7);
    color: #fff8dc;
}

.elden-btn.primary:hover {
    background: linear-gradient(135deg,
        rgba(212, 175, 55, 0.7) 0%,
        rgba(244, 208, 63, 0.5) 50%,
        rgba(212, 175, 55, 0.7) 100%);
    box-shadow: 0 8px 40px rgba(212, 175, 55, 0.5);
}

/* SOUND TOGGLE */
.sound-toggle {
    position: absolute;
    top: 1.5rem; right: 1.5rem;
    background: var(--dark-glass);
    border: 1px solid var(--mist-blue-border);
    width: 55px; height: 55px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: all 0.3s ease;
    z-index: 100;
    backdrop-filter: blur(10px);
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255,255,255,0.05);
}

.sound-toggle:hover {
    border-color: var(--rune-glow);
    box-shadow: 0 0 25px rgba(140, 180, 255, 0.4);
    transform: scale(1.1);
}

.sound-toggle.small {
    width: 45px; height: 45px;
    position: relative;
    top: 0; right: 0;
}

.sound-icon { font-size: 1.6rem; }
.sound-toggle.muted .sound-icon::after { content: '🔇'; position: absolute; }
.sound-toggle.muted .sound-icon { opacity: 0; }

/* MAP SCREEN SETTINGS */
.screen-title {
    font-size: clamp(1.8rem, 5vw, 3.5rem);
    color: var(--silver-light);
    margin-bottom: 2rem;
    letter-spacing: 0.2rem;
    text-shadow: 0 0 30px rgba(160, 200, 255, 0.5),
                 0 0 60px rgba(100, 140, 255, 0.2);
}

.level-map {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.level-node {
    background: var(--dark-glass-heavy);
    border: 1px solid var(--mist-blue-border);
    padding: 1.5rem;
    cursor: pointer;
    transition: all 0.4s ease;
    position: relative;
    overflow: hidden;
    text-align: center;
    backdrop-filter: blur(12px);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5),
                inset 0 1px 0 rgba(255,255,255,0.04);
}

.level-node::before {
    content: '';
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    background: radial-gradient(circle at center,
        rgba(100, 150, 255, 0.06) 0%, transparent 70%);
    opacity: 0;
    transition: opacity 0.4s ease;
}

.level-node:hover::before { opacity: 1; }

.level-node.unlocked {
    border-color: rgba(180, 155, 60, 0.5);
    box-shadow: 0 0 25px rgba(212, 175, 55, 0.15),
                inset 0 1px 0 rgba(212, 175, 55, 0.08);
}

.level-node.unlocked:hover {
    border-color: rgba(220, 190, 80, 0.8);
    transform: translateY(-4px);
    box-shadow: 0 10px 40px rgba(212, 175, 55, 0.25),
                0 0 60px rgba(100, 150, 255, 0.1);
}

.level-node.locked {
    opacity: 0.35;
    filter: grayscale(80%);
    pointer-events: none;
}

.level-node.completed {
    border-color: rgba(200, 180, 80, 0.6);
    background: linear-gradient(135deg,
        rgba(212, 175, 55, 0.1) 0%,
        rgba(8, 10, 18, 0.9) 100%);
}

.level-node h3 {
    font-size: 1.1rem;
    color: var(--gold-light);
    margin-bottom: 0.5rem;
    text-shadow: 0 0 10px rgba(212, 175, 55, 0.4);
}

.level-node p {
    font-family: 'Playfair Display', serif;
    color: var(--silver);
    font-size: 0.85rem;
    line-height: 1.4;
}

.level-status {
    margin-top: 1rem;
    font-size: 0.75rem;
    color: rgba(180, 200, 255, 0.7);
    text-transform: uppercase;
    letter-spacing: 0.1rem;
}

.back-btn { margin-top: 1.5rem; }

/* =============================================
   GAME HUD - Beautiful dark glass design
   ============================================= */
.game-hud {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.8rem 1.5rem;

    /* Rich dark glass with atmospheric glow */
    background: linear-gradient(180deg,
        rgba(5, 7, 15, 0.96) 0%,
        rgba(8, 11, 22, 0.90) 100%);

    /* Glowing bottom border that fades into the background */
    border-bottom: 1px solid rgba(100, 140, 200, 0.3);
    box-shadow:
        0 4px 30px rgba(0, 0, 0, 0.6),
        0 1px 0 rgba(120, 160, 220, 0.15),
        inset 0 -1px 0 rgba(80, 120, 200, 0.1);

    z-index: 50;
    position: relative;
    backdrop-filter: blur(20px);
}

/* Decorative top line on HUD */
.game-hud::before {
    content: '';
    position: absolute;
    top: 0; left: 5%; width: 90%; height: 1px;
    background: linear-gradient(90deg,
        transparent,
        rgba(120, 160, 220, 0.4),
        rgba(212, 175, 55, 0.3),
        rgba(120, 160, 220, 0.4),
        transparent);
}

/* Level name with silver-gold shimmer */
.level-name {
    font-size: clamp(0.85rem, 2.5vw, 1.3rem);
    background: linear-gradient(90deg,
        var(--silver-light) 0%,
        var(--gold-light) 50%,
        var(--silver-light) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: 0.08rem;
    text-shadow: none;
    filter: drop-shadow(0 0 8px rgba(200, 180, 100, 0.5));
}

.hud-right {
    display: flex;
    gap: 0.8rem;
    align-items: center;
}

/* HUD Buttons - dark glass style */
.hud-btn {
    background: rgba(8, 12, 22, 0.85);
    border: 1px solid var(--mist-blue-border);
    color: var(--silver-light);
    font-family: 'Cinzel', serif;
    font-size: 0.75rem;
    padding: 0.5rem 1rem;
    cursor: pointer;
    text-transform: uppercase;
    letter-spacing: 0.1rem;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
    box-shadow: 0 2px 10px rgba(0,0,0,0.4),
                inset 0 1px 0 rgba(255,255,255,0.04);
}

.hud-btn:hover, .hud-btn:active {
    border-color: rgba(180, 200, 255, 0.6);
    color: #ffffff;
    background: rgba(20, 30, 55, 0.85);
    box-shadow: 0 4px 20px rgba(80, 130, 255, 0.2),
                inset 0 1px 0 rgba(255,255,255,0.08);
    transform: translateY(-1px);
}

/* GAME CANVAS AREA */
.game-container {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 1rem;
    position: relative;
    z-index: 10;
    touch-action: none;
}

/* Canvas border with ethereal atmospheric glow */
#mazeCanvas {
    max-width: 100%;
    max-height: 100%;

    /* Layered border glow matching the misty backgrounds */
    border: 1px solid rgba(100, 140, 200, 0.4);
    box-shadow:
        0 0 0 1px rgba(50, 80, 140, 0.3),
        0 0 30px rgba(60, 100, 180, 0.2),
        0 0 60px rgba(30, 60, 120, 0.15),
        0 10px 40px rgba(0, 0, 0, 0.7),
        inset 0 0 40px rgba(0, 0, 0, 0.3);

    background: rgba(5, 8, 15, 0.25);
}

/* =============================================
   MOBILE D-PAD - Beautiful rune stone buttons
   ============================================= */
.mobile-controls {
    display: none;
    position: absolute;
    bottom: 12px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 100;
    width: 100%;
    padding: 0 16px;
}

.dpad {
    display: flex;
    flex-direction: row;
    justify-content: center;
    align-items: center;
    gap: 8px;
    width: 100%;
}

/* Ancient rune stone button design */
.dpad-btn {
    position: static;
    width: 58px;
    height: 52px;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    user-select: none;
    font-size: 1rem;

    /* Dark stone base */
    background: linear-gradient(160deg,
        rgba(18, 22, 38, 0.95) 0%,
        rgba(10, 13, 25, 0.98) 100%);

    /* Layered atmospheric border */
    border: 1px solid rgba(80, 120, 200, 0.4);
    outline: 1px solid rgba(40, 70, 140, 0.2);
    outline-offset: 2px;

    /* Rune glow effect */
    box-shadow:
        0 4px 15px rgba(0, 0, 0, 0.7),
        0 0 20px rgba(60, 100, 200, 0.1),
        inset 0 1px 0 rgba(120, 160, 255, 0.08),
        inset 0 -1px 0 rgba(0, 0, 0, 0.4);

    /* Soft rounded stone shape */
    border-radius: 6px;

    /* Direction arrow styling */
    color: rgba(180, 200, 240, 0.8);
    text-shadow: 0 0 8px rgba(140, 180, 255, 0.6);

    backdrop-filter: blur(8px);
    transition: all 0.15s ease;
}

/* Active state - rune lighting up */
.dpad-btn:active {
    background: linear-gradient(160deg,
        rgba(30, 45, 80, 0.95) 0%,
        rgba(20, 30, 60, 0.98) 100%);
    border-color: rgba(140, 180, 255, 0.7);
    outline-color: rgba(100, 150, 255, 0.3);
    color: #ffffff;
    text-shadow:
        0 0 10px rgba(180, 210, 255, 0.9),
        0 0 25px rgba(120, 170, 255, 0.6);
    box-shadow:
        0 2px 8px rgba(0, 0, 0, 0.7),
        0 0 30px rgba(80, 130, 255, 0.35),
        0 0 60px rgba(60, 100, 220, 0.15),
        inset 0 1px 0 rgba(160, 200, 255, 0.15);
    transform: translateY(1px);
}

/* Order buttons left to right */
.dpad-btn.left { order: 1; }
.dpad-btn.up { order: 2; }
.dpad-btn.down { order: 3; }
.dpad-btn.right { order: 4; }

/* MODALS */
.modal {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    display: none; justify-content: center; align-items: center;
    z-index: 1000; opacity: 0; transition: opacity 0.5s ease;
}

.modal.active { display: flex; opacity: 1; }

.modal-overlay {
    position: absolute; width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.88);
    backdrop-filter: blur(15px);
}

.modal-content {
    position: relative;
    background: linear-gradient(160deg,
        rgba(10, 14, 25, 0.97) 0%,
        rgba(6, 8, 18, 0.99) 100%);
    border: 1px solid rgba(100, 140, 200, 0.3);
    box-shadow:
        0 0 0 1px rgba(60, 90, 160, 0.2),
        0 25px 60px rgba(0, 0, 0, 0.8),
        0 0 80px rgba(60, 100, 200, 0.1),
        inset 0 1px 0 rgba(255,255,255,0.04);
    padding: 2.5rem;
    max-width: 520px; width: 90%; max-height: 90vh;
    overflow-y: auto; text-align: center;
    animation: modalSlideIn 0.5s ease;
}

.modal-title {
    font-size: clamp(1.8rem, 5vw, 2.8rem);
    background: linear-gradient(180deg,
        var(--silver-light) 0%,
        var(--gold-light) 50%,
        var(--gold) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 1.5rem;
    letter-spacing: 0.2rem;
}

.modal-body { margin-bottom: 2rem; }

.instruction {
    margin-bottom: 1.5rem;
    border-bottom: 1px solid rgba(80, 110, 180, 0.2);
    padding-bottom: 1.2rem;
    text-align: left;
}

.instruction:last-child { border-bottom: none; }

.instruction h3 {
    color: var(--gold-light);
    font-size: 1rem;
    margin-bottom: 0.6rem;
    letter-spacing: 0.05rem;
}

.instruction p {
    font-family: 'Playfair Display', serif;
    color: var(--silver);
    font-size: 0.9rem;
    line-height: 1.7;
    margin-bottom: 0.4rem;
}

.instruction strong { color: var(--gold-light); }
.modal-content .elden-btn { width: 100%; }

/* VICTORY MODAL */
.modal-content.victory {
    border-color: rgba(180, 155, 60, 0.4);
    animation: victoryPulse 2.5s ease infinite;
}

.victory-title {
    font-size: clamp(2rem, 6vw, 3.5rem);
    background: linear-gradient(180deg,
        #ffffff 0%,
        var(--gold-light) 40%,
        var(--gold) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 1rem;
    filter: drop-shadow(0 0 20px rgba(212, 175, 55, 0.6));
    animation: victoryGlow 2s ease infinite;
}

.victory-text {
    font-family: 'Playfair Display', serif;
    font-size: 1.1rem;
    color: var(--silver);
    margin-bottom: 2rem;
    font-style: italic;
}

.victory-buttons { display: flex; flex-direction: column; gap: 1rem; }

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

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

@keyframes victoryPulse {
    0%, 100% { box-shadow: 0 0 40px rgba(212, 175, 55, 0.2), 0 25px 60px rgba(0,0,0,0.8); }
    50% { box-shadow: 0 0 80px rgba(212, 175, 55, 0.4), 0 25px 60px rgba(0,0,0,0.8); }
}

@keyframes victoryGlow {
    0%, 100% { filter: drop-shadow(0 0 15px rgba(212, 175, 55, 0.6)); }
    50% { filter: drop-shadow(0 0 35px rgba(244, 208, 63, 0.9)); }
}

/* RESPONSIVE */
@media (max-width: 768px) {
    .mobile-controls { display: block; }

    .game-hud {
        flex-direction: column;
        gap: 0.6rem;
        padding: 0.7rem 1rem;
    }

    .hud-right { width: 100%; justify-content: center; }

    .level-map { grid-template-columns: 1fr; }
    .map-content { padding: 0.5rem; width: 95%; max-height: 80vh; }
    .level-node { padding: 1rem; }

    .sound-toggle { top: 0.8rem; right: 0.8rem; width: 48px; height: 48px; }
    .sound-icon { font-size: 1.4rem; }

    .modal-content { padding: 1.5rem; }
}

::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: rgba(5,8,18,0.8); }
::-webkit-scrollbar-thumb { background: rgba(100, 140, 200, 0.4); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(140, 180, 255, 0.6); }
