:root {
    --slytherin-green: #1a5c2e;
    --slytherin-dark: #0d2818;
    --slytherin-silver: #c0c0c0;
    --slytherin-accent: #3aff7f;
    --dark-stone: #0a0a0f;
    --stone-mid: #16161e;
    --danger: #e74c3c;
    --cloak-blue: #4a9eff;
    --gold: #d4a843;
}

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

body {
    background-color: #000;
    font-family: 'Fira Code', monospace;
    color: #ddd;
    overflow: hidden;
    height: 100vh;
    width: 100vw;
}

#game-container {
    width: 100vw;
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    background: radial-gradient(ellipse at center, #0a1a0f 0%, #000 70%);
}

canvas {
    background-color: #060610;
    border: 1px solid rgba(26, 92, 46, 0.4);
    box-shadow:
        0 0 60px rgba(26, 92, 46, 0.2),
        inset 0 0 80px rgba(0, 0, 0, 0.5);
    image-rendering: auto;
}

#ui-layer {
    position: absolute;
    top: 16px;
    left: 16px;
    pointer-events: none;
    z-index: 10;
}

#stats {
    background: rgba(10, 10, 15, 0.85);
    border: 1px solid rgba(26, 92, 46, 0.3);
    border-radius: 6px;
    padding: 12px 16px;
    backdrop-filter: blur(8px);
}

.stat {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
    font-size: 12px;
    font-weight: 500;
    letter-spacing: 1px;
}

.stat:last-child { margin-bottom: 0; }

.stat-label {
    color: var(--slytherin-accent);
    font-size: 10px;
    font-weight: 300;
    min-width: 55px;
    letter-spacing: 2px;
}

.stat-dim { color: #555; }

.key-hint {
    color: #555;
    font-size: 10px;
}

#stealth-meter, #cloak-meter {
    height: 6px;
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 3px;
    overflow: hidden;
    display: inline-block;
    vertical-align: middle;
}

#stealth-meter { width: 120px; }
#cloak-meter { width: 80px; }

#stealth-fill {
    height: 100%;
    width: 100%;
    background: linear-gradient(90deg, var(--danger), var(--slytherin-accent));
    transition: width 0.15s ease;
    border-radius: 3px;
}

#cloak-fill {
    height: 100%;
    width: 100%;
    background: linear-gradient(90deg, #1a5caa, var(--cloak-blue));
    transition: width 0.15s ease;
    border-radius: 3px;
}

/* Overlays */
.overlay, #parseltongue-overlay {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.92);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
    animation: fadeIn 0.4s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal {
    background: linear-gradient(165deg, var(--stone-mid) 0%, var(--dark-stone) 100%);
    border: 1px solid rgba(26, 92, 46, 0.5);
    padding: 48px;
    text-align: center;
    max-width: 480px;
    width: 90%;
    border-radius: 4px;
    box-shadow:
        0 0 80px rgba(26, 92, 46, 0.15),
        0 20px 60px rgba(0, 0, 0, 0.8);
    animation: modalIn 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modalIn {
    from { transform: translateY(30px) scale(0.95); opacity: 0; }
    to { transform: translateY(0) scale(1); opacity: 1; }
}

h1 {
    font-family: 'Cinzel', serif;
    color: var(--slytherin-silver);
    letter-spacing: 6px;
    font-weight: 900;
    font-size: 28px;
    margin-bottom: 4px;
}

h2 {
    font-family: 'Cinzel', serif;
    color: var(--slytherin-accent);
    font-weight: 700;
    font-size: 20px;
    letter-spacing: 3px;
}

.subtitle {
    color: #666;
    font-size: 11px;
    letter-spacing: 4px;
    text-transform: uppercase;
    margin-bottom: 28px;
}

.instructions {
    text-align: left;
    margin: 20px 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.instruction-row {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 12px;
    color: #999;
}

.key-badge {
    display: inline-block;
    background: rgba(26, 92, 46, 0.2);
    border: 1px solid rgba(26, 92, 46, 0.4);
    border-radius: 3px;
    padding: 2px 8px;
    font-size: 10px;
    color: var(--slytherin-accent);
    min-width: 44px;
    text-align: center;
    letter-spacing: 1px;
}

.scale-icon {
    display: inline-block;
    width: 12px;
    height: 12px;
    background: var(--slytherin-accent);
    border-radius: 50%;
    box-shadow: 0 0 8px var(--slytherin-accent);
    margin: 0 16px;
}

.eye-icon {
    display: inline-block;
    width: 12px;
    height: 8px;
    border: 2px solid var(--danger);
    border-radius: 50%;
    margin: 0 16px;
}

.modal-serpent {
    font-size: 48px;
    margin-bottom: 16px;
    filter: drop-shadow(0 0 20px rgba(58, 255, 127, 0.3));
}

button {
    font-family: 'Cinzel', serif;
    background: linear-gradient(135deg, var(--slytherin-dark), var(--slytherin-green));
    color: var(--slytherin-silver);
    border: 1px solid rgba(192, 192, 192, 0.2);
    padding: 14px 36px;
    font-weight: 700;
    font-size: 13px;
    letter-spacing: 3px;
    cursor: pointer;
    margin-top: 24px;
    transition: all 0.3s ease;
    border-radius: 3px;
}

button:hover {
    background: linear-gradient(135deg, var(--slytherin-green), #2a7a40);
    transform: translateY(-2px);
    box-shadow: 0 8px 30px rgba(26, 92, 46, 0.3);
    border-color: rgba(58, 255, 127, 0.3);
}

button:active {
    transform: translateY(0);
}

.start-hint {
    color: #444;
    font-size: 10px;
    margin-top: 16px;
    letter-spacing: 1px;
}

#sequence-buttons {
    display: flex;
    justify-content: center;
    gap: 16px;
    margin-top: 24px;
}

.rune {
    font-size: 32px;
    padding: 12px;
    width: 72px;
    height: 72px;
    background: rgba(255,255,255,0.03);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-top: 0;
    letter-spacing: 0;
    transition: all 0.2s ease;
}

.rune:hover {
    background: rgba(58, 255, 127, 0.1);
    border-color: var(--slytherin-accent);
    transform: scale(1.1);
}

.rune:active {
    transform: scale(0.95);
}

.rune span { pointer-events: none; }

#sequence-display {
    min-height: 50px;
    font-size: 28px;
    margin-top: 20px;
    color: var(--slytherin-silver);
    letter-spacing: 8px;
}

#seq-progress {
    margin-top: 16px;
    font-size: 12px;
    color: #555;
    min-height: 20px;
}

#final-stats {
    margin: 16px 0;
    font-size: 12px;
    color: #666;
}

/* Level transition */
#level-transition .modal {
    padding: 32px;
}

.transition-progress {
    width: 200px;
    height: 4px;
    background: rgba(255,255,255,0.05);
    border-radius: 2px;
    margin: 20px auto 0;
    overflow: hidden;
}

.transition-bar {
    height: 100%;
    width: 0%;
    background: var(--slytherin-accent);
    border-radius: 2px;
    animation: transitionFill 1.8s ease forwards;
}

@keyframes transitionFill {
    to { width: 100%; }
}

#app-footer {
    position: fixed;
    bottom: 8px;
    right: 12px;
    z-index: 200;
}

#app-footer a {
    color: #333;
    font-family: 'Fira Code', monospace;
    font-size: 10px;
    text-decoration: none;
    letter-spacing: 1px;
    transition: color 0.3s;
}

#app-footer a:hover {
    color: var(--slytherin-accent);
}

/* Mobile */
@media (max-width: 600px) {
    .modal { padding: 28px 20px; }
    h1 { font-size: 22px; letter-spacing: 4px; }
    .instructions { gap: 6px; }
    .instruction-row { font-size: 11px; }
}