:root {
    --bg-color: #0f172a;
    --card-bg: rgba(30, 41, 59, 0.7);
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --accent-primary: #38bdf8;
    /* Sky Blue */
    --accent-secondary: #818cf8;
    /* Indigo */
    --success: #4ade80;
    /* Green */
    --error: #f87171;
    /* Red */
    --glass-border: rgba(255, 255, 255, 0.1);
    --font-main: 'Outfit', sans-serif;
}

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

body {
    background-color: var(--bg-color);
    color: var(--text-primary);
    font-family: var(--font-main);
    height: 100vh;
    height: 100dvh;
    /* iOS Safari address bar fix */
    display: flex;
    justify-content: center;
    align-items: center;
    background-image:
        radial-gradient(circle at 10% 20%, rgba(56, 189, 248, 0.1) 0%, transparent 40%),
        radial-gradient(circle at 90% 80%, rgba(129, 140, 248, 0.1) 0%, transparent 40%);
    position: relative;
    /* For overlay */
}

/* Dimming Overlay */
body::after {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(236, 72, 153, 0.4);
    /* Pinkish overlay */
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.5s ease;
    z-index: 100;
    /* Above everything */
}

body.dimmed::after {
    opacity: 1;
}

.app-container {
    width: 100%;
    max-width: 600px;
    padding: 2rem;
    text-align: center;
    background: var(--card-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-radius: 24px;
    border: 1px solid var(--glass-border);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

header h1 {
    font-weight: 600;
    font-size: 2.5rem;
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 0.5rem;
}

header p {
    color: var(--text-secondary);
    margin-bottom: 2rem;
    letter-spacing: 1px;
    text-transform: uppercase;
    font-size: 1.1rem;
    /* Increased from 0.8rem */
}

/* Controls */
.primary-btn {
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    border: none;
    padding: 1rem 3rem;
    border-radius: 50px;
    color: white;
    font-weight: 600;
    font-size: 1.1rem;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    font-family: var(--font-main);
}

.primary-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 25px -5px rgba(56, 189, 248, 0.5);
}

.primary-btn:active {
    transform: translateY(0);
}

.secondary-btn {
    background: transparent;
    border: 1px solid var(--glass-border);
    color: var(--text-secondary);
    padding: 0.5rem 1rem;
    border-radius: 50px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s;
    font-family: var(--font-main);
}

.secondary-btn:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.05);
}

/* Key Selection Menu */
#start-menu {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;
}

.nav-back-button {
    margin-top: 1.5rem;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.9rem;
    transition: all 0.2s;
    padding: 0.8rem 1.5rem;
    border: 1px solid var(--glass-border);
    border-radius: 50px;
    background: rgba(255, 255, 255, 0.05);
}

.nav-back-button:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--accent-primary);
    transform: translateY(-2px);
}

.menu-label {
    color: var(--text-primary);
    font-size: 1.2rem;
    font-weight: 600;
}

.key-buttons {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
    width: 100%;
}

.key-btn {
    background: rgba(30, 41, 59, 0.5);
    border: 1px solid var(--accent-primary);
    color: var(--text-primary);
    padding: 1rem;
    border-radius: 12px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    font-family: var(--font-main);
}

.key-btn:hover {
    background: var(--accent-primary);
    color: #0f172a;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(56, 189, 248, 0.3);
}

.key-btn:active {
    transform: translateY(0);
}

#score-board {
    display: flex;
    justify-content: center;
    gap: 2rem;
    margin-bottom: 2rem;
    font-size: 1.2rem;
}

.hidden {
    display: none !important;
}

/* Game Area */
.feedback-container {
    margin-bottom: 2rem;
    height: 60px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

#feedback-message {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
    min-height: 2rem;
}

.control-buttons {
    display: flex;
    gap: 0.8rem;
    margin-top: 0.5rem;
}

.play-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    color: var(--text-primary);
    padding: 0.6rem 1rem;
    border-radius: 12px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    font-family: var(--font-main);
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 100px;
}

.play-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--accent-primary);
    transform: translateY(-2px);
}

.play-btn:active {
    transform: translateY(0);
}

/* Piano */
.piano-container {
    position: relative;
    width: 100%;
    height: 200px;
    display: flex;
    justify-content: space-between;
    margin: 0 auto;
    background: #1e293b;
    padding: 10px;
    border-radius: 12px;
    box-shadow: inset 0 2px 10px rgba(0, 0, 0, 0.5);
}

.white-key {
    background: #f8fafc;
    width: 12.5%;
    /* 8 keys total from D4 to D5 */
    height: 100%;
    border-radius: 0 0 6px 6px;
    position: relative;
    cursor: pointer;
    z-index: 1;
    display: flex;
    flex-direction: column;
    /* Stack text and label */
    align-items: center;
    justify-content: flex-end;
    /* Align to bottom */
    padding-bottom: 10px;
    color: #475569;
    font-weight: 600;
    transition: background 0.1s, transform 0.1s;
    box-shadow: 0 4px 0 #cbd5e1;
    border-right: 1px solid #e2e8f0;
}

.white-key:last-child {
    border-right: none;
}

.key-label {
    margin-top: 4px;
    font-size: 1.5em;
    /* Increased size */
    color: var(--accent-secondary);
    font-weight: bold;
}

.white-key:active,
.white-key.active {
    background: #e2e8f0;
    transform: translateY(2px);
    box-shadow: 0 2px 0 #cbd5e1;
}

.black-key {
    background: #0f172a;
    width: 8%;
    /* Slightly wider relative to white keys */
    height: 60%;
    position: absolute;
    top: 0;
    z-index: 2;
    border-radius: 0 0 6px 6px;
    cursor: pointer;
    transition: background 0.1s, transform 0.1s;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
    display: flex;
    align-items: flex-end;
    justify-content: center;
    padding-bottom: 8px;
    color: white;
}

.key-label-black {
    font-size: 1.2rem;
    /* Increased size */
    color: var(--accent-primary);
    font-weight: bold;
}

.black-key:active,
.black-key.active {
    background: #334155;
    transform: translateY(2px);
}

/* Utility Animations */
@keyframes shake {

    0%,
    100% {
        transform: translateX(0);
    }

    25% {
        transform: translateX(-5px);
    }

    75% {
        transform: translateX(5px);
    }
}

.shake {
    animation: shake 0.3s ease-in-out;
}

.correct-flash {
    background-color: var(--success) !important;
    color: white !important;
    box-shadow: 0 0 20px var(--success) !important;
}

.incorrect-flash {
    background-color: var(--error) !important;
    color: white !important;
}

footer {
    margin-top: 2rem;
    font-size: 0.8rem;
    color: var(--text-secondary);
    opacity: 0.6;
}