:root {
    --bg-color: #06100c;
    --card-bg: rgba(16, 28, 24, 0.7);
    --text-primary: #f1f5f9;
    --text-secondary: #7e9a8e;
    --accent-primary: #10b981;
    --accent-secondary: #34d399;
    --success: #059669;
    --error: #ef4444;
    --glass-border: rgba(255, 255, 255, 0.08);
    --font-main: 'Outfit', 'Inter', sans-serif;
    --shadow-premium: 0 20px 25px -5px rgba(0, 0, 0, 0.3), 0 10px 10px -5px rgba(0, 0, 0, 0.2);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

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 0% 0%, rgba(16, 185, 129, 0.08) 0%, transparent 50%),
        radial-gradient(circle at 100% 100%, rgba(52, 211, 153, 0.08) 0%, transparent 50%);
    overflow: hidden;
    transition: background-color 0.5s ease, background-image 0.5s ease;
}

/* Fluid Entrance Animation */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.app-container {
    width: 90%;
    max-width: 520px;
    padding: 2.5rem 2rem;
    text-align: center;
    background: var(--card-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-radius: 32px;
    border: 1px solid var(--glass-border);
    box-shadow: var(--shadow-premium);
    animation: fadeInUp 0.8s cubic-bezier(0.16, 1, 0.3, 1) both;
}

header h1 {
    font-weight: 700;
    font-size: 2.75rem;
    letter-spacing: -0.02em;
    background: linear-gradient(to right, #10b981, #34d399);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 0.75rem;
}

header p {
    color: var(--text-secondary);
    margin-bottom: 2.5rem;
    line-height: 1.6;
    font-size: 0.95rem;
    font-weight: 400;
}

/* Key Selection Buttons */
.key-buttons {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.75rem;
    margin-top: 1rem;
}

.key-btn {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--glass-border);
    color: var(--text-primary);
    padding: 1rem 0.5rem;
    border-radius: 16px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    font-family: var(--font-main);
}

.nav-back-button {
    margin-top: 2rem;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.9rem;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    padding: 0.75rem 1.5rem;
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.03);
    display: inline-block;
}

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

.key-btn:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: var(--accent-primary);
    transform: translateY(-4px);
    box-shadow: 0 10px 15px -3px rgba(56, 189, 248, 0.2);
}

/* Game Area Feedback */
.feedback-container {
    margin-bottom: 2.5rem;
    text-align: center;
}

#feedback-message {
    font-size: 1.25rem;
    font-weight: 600;
    letter-spacing: 0.05em;
    margin-bottom: 1rem;
    min-height: 1.5rem;
    transition: color 0.3s ease;
}

.control-buttons {
    display: flex;
    justify-content: center;
    gap: 0.8rem;
    margin-bottom: 1.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: var(--accent-primary);
    color: #0f172a;
    transform: translateY(-2px);
}

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

/* Piano Refinement */
.piano-container {
    position: relative;
    width: 100%;
    height: 240px;
    display: flex;
    justify-content: center;
    background: #000;
    padding: 12px 6px 6px 6px;
    border-radius: 20px;
    box-shadow: inset 0 0 15px rgba(0, 0, 0, 0.8), 0 10px 30px rgba(0, 0, 0, 0.5);
    overflow: hidden;
}

.white-key {
    background: linear-gradient(to bottom, #fff 0%, #f1f5f9 100%);
    flex: 1;
    height: 100%;
    margin: 0 2px;
    border-radius: 0 0 8px 8px;
    position: relative;
    cursor: pointer;
    z-index: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    padding-bottom: 15px;
    color: #94a3b8;
    font-weight: 700;
    font-size: 0.8rem;
    transition: all 0.1s ease;
    box-shadow: 0 6px 0 #cbd5e1, 0 8px 10px rgba(0, 0, 0, 0.2);
}

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

.white-key .key-label {
    font-size: 1.4rem;
    color: var(--accent-secondary);
    margin-top: 4px;
    display: block;
}

.black-key {
    background: linear-gradient(to bottom, #334155 0%, #0f172a 100%);
    width: 9%;
    height: 62%;
    position: absolute;
    top: 0;
    z-index: 2;
    border-radius: 0 0 6px 6px;
    cursor: pointer;
    transition: all 0.1s ease;
    box-shadow: 0 4px 0 #000, 0 6px 12px rgba(0, 0, 0, 0.4);
    display: flex;
    align-items: flex-end;
    justify-content: center;
    padding-bottom: 10px;
    margin-left: -4.5%;
    /* Offset to center over join */
}

.black-key:active,
.black-key.active {
    background: #1e293b;
    transform: translateY(2px);
    box-shadow: 0 2px 0 #000;
}

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

/* Status Bar */
#score-board {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
    background: rgba(255, 255, 255, 0.03);
    padding: 0.75rem 1.25rem;
    border-radius: 100px;
    border: 1px solid var(--glass-border);
}

.streak-label {
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--accent-primary);
    letter-spacing: 0.05em;
}

.secondary-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: color 0.2s;
}

.secondary-btn:hover {
    color: var(--text-primary);
}

/* Animations */
.shake {
    animation: shake 0.4s cubic-bezier(.36, .07, .19, .97) both;
}

@keyframes shake {

    10%,
    90% {
        transform: translate3d(-1px, 0, 0);
    }

    20%,
    80% {
        transform: translate3d(2px, 0, 0);
    }

    30%,
    50%,
    70% {
        transform: translate3d(-4px, 0, 0);
    }

    40%,
    60% {
        transform: translate3d(4px, 0, 0);
    }
}

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

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

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

.hidden {
    display: none !important;
}

/* Responsive adjustments */
@media (max-width: 480px) {
    .app-container {
        padding: 2rem 1.25rem;
        border-radius: 24px;
    }

    header h1 {
        font-size: 2.2rem;
    }

    .piano-container {
        height: 200px;
    }
}