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

:root {
    --bg-dark: #0a0a14;
    --bg-purple: #16213e;
    --wall-color: #4a4a5a;
    --gold: #ffd700;
    --patronus: #87ceeb;
    --gryffindor: #740001;
    --parchment: #f4e4bc;
    --text-cream: #e8d8c8;
}

body {
    background: linear-gradient(135deg, var(--bg-dark) 0%, var(--bg-purple) 50%, #1a1a2e 100%);
    min-height: 100vh;
    font-family: 'Crimson Pro', serif;
    color: var(--text-cream);
    overflow-x: hidden;
}

#game-container {
    max-width: 650px;
    margin: 0 auto;
    padding: 10px;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

#game-header {
    text-align: center;
    padding: 15px 0;
}

#game-header h1 {
    font-family: 'Cinzel', serif;
    font-size: clamp(1.2rem, 5vw, 1.8rem);
    font-weight: 900;
    background: linear-gradient(180deg, var(--gold) 0%, #b8860b 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-shadow: 0 0 30px rgba(255, 215, 0, 0.3);
    letter-spacing: 2px;
    margin-bottom: 10px;
}

#stats {
    display: flex;
    justify-content: center;
    gap: 30px;
    flex-wrap: wrap;
}

.stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    background: rgba(255, 215, 0, 0.1);
    padding: 8px 20px;
    border-radius: 8px;
    border: 1px solid rgba(255, 215, 0, 0.3);
}

.stat-label {
    font-size: 0.7rem;
    letter-spacing: 2px;
    opacity: 0.7;
    font-family: 'Cinzel', serif;
}

.stat span:last-child {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--gold);
    font-family: 'Cinzel', serif;
}

#game-area {
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    flex: 1;
}

#canvas {
    border: 3px solid var(--wall-color);
    border-radius: 4px;
    box-shadow: 
        0 0 20px rgba(135, 206, 235, 0.2),
        inset 0 0 50px rgba(0, 0, 0, 0.5);
    background: var(--bg-dark);
}

.overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    background: rgba(10, 10, 20, 0.95);
    z-index: 10;
}

.overlay.hidden {
    display: none;
}

.parchment {
    background: linear-gradient(145deg, #d4c4a8 0%, #c4b498 50%, #b4a488 100%);
    padding: 40px;
    border-radius: 8px;
    text-align: center;
    max-width: 90%;
    box-shadow: 
        0 10px 40px rgba(0, 0, 0, 0.5),
        inset 0 0 20px rgba(139, 90, 43, 0.2);
    border: 2px solid #8b5a2b;
    color: #2c1810;
}

.parchment h2 {
    font-family: 'Cinzel', serif;
    font-size: clamp(1.5rem, 6vw, 2rem);
    font-weight: 900;
    color: var(--gryffindor);
    margin-bottom: 20px;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.2);
}

.instructions {
    font-size: 1rem;
    margin: 8px 0;
    color: #3c2820;
}

#high-score-display {
    margin: 20px 0;
    font-family: 'Cinzel', serif;
    font-size: 1.1rem;
    color: var(--gryffindor);
}

.magic-btn {
    font-family: 'Cinzel', serif;
    font-size: 1rem;
    padding: 15px 30px;
    background: linear-gradient(180deg, var(--gryffindor) 0%, #4a0001 100%);
    color: var(--gold);
    border: 2px solid var(--gold);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-top: 15px;
}

.magic-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 0 20px rgba(255, 215, 0, 0.5);
}

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

.game-over-text {
    color: var(--gryffindor) !important;
    animation: pulse 1s infinite;
}

.mischief-text {
    background: linear-gradient(180deg, var(--gold) 0%, #b8860b 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: sparkle 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

@keyframes sparkle {
    0%, 100% { filter: brightness(1); }
    50% { filter: brightness(1.3); }
}

.dumbledore-quote {
    font-style: italic;
    font-size: 0.95rem;
    margin: 15px 0;
    color: #5c4030;
    line-height: 1.5;
}

#mobile-controls {
    display: none;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    padding: 15px 0;
}

.ctrl-row {
    display: flex;
    gap: 5px;
}

.ctrl-btn {
    width: 55px;
    height: 55px;
    font-size: 1.5rem;
    background: rgba(255, 215, 0, 0.15);
    border: 2px solid rgba(255, 215, 0, 0.4);
    border-radius: 12px;
    color: var(--gold);
    cursor: pointer;
    transition: all 0.15s ease;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}

.ctrl-btn:active {
    background: rgba(255, 215, 0, 0.3);
    transform: scale(0.95);
}

footer {
    text-align: center;
    padding: 15px;
    opacity: 0.6;
    font-size: 0.85rem;
}

footer a {
    color: var(--text-cream);
    text-decoration: none;
    transition: opacity 0.3s;
}

footer a:hover {
    opacity: 1;
}

@media (max-width: 600px) {
    #mobile-controls {
        display: flex;
    }
    
    .stat {
        padding: 6px 15px;
    }
    
    .stat-label {
        font-size: 0.6rem;
    }
    
    .stat span:last-child {
        font-size: 1.1rem;
    }
    
    .parchment {
        padding: 25px;
    }
    
    .parchment h2 {
        font-size: 1.3rem;
    }
    
    .magic-btn {
        padding: 12px 24px;
        font-size: 0.9rem;
    }
}

@media (max-height: 700px) {
    #game-header {
        padding: 8px 0;
    }
    
    #game-header h1 {
        margin-bottom: 5px;
    }
    
    .ctrl-btn {
        width: 45px;
        height: 45px;
        font-size: 1.2rem;
    }
}