:root {
    --bg-color: #0f172a;
    --card-bg: rgba(30, 41, 59, 0.7);
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --accent-primary: #f472b6;
    /* Pinkish for this game */
    --accent-secondary: #c084fc;
    --success: #4ade80;
    --error: #f87171;
    --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 fix */
    display: flex;
    justify-content: center;
    align-items: center;
    background-image:
        radial-gradient(circle at 20% 20%, rgba(244, 114, 182, 0.1) 0%, transparent 40%),
        radial-gradient(circle at 80% 80%, rgba(192, 132, 252, 0.1) 0%, transparent 40%);
}

.app-container {
    width: 95%;
    max-width: 700px;
    padding: 2rem;
    text-align: center;
    background: var(--card-bg);
    backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: 24px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

header h1 {
    font-size: 2rem;
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 0.5rem;
}

#game-description {
    color: var(--text-secondary);
    margin-bottom: 2rem;
    font-size: 0.9rem;
}

/* Menu */
.key-buttons {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.8rem;
    margin-bottom: 1.5rem;
}

.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-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.key-btn:hover {
    background: var(--accent-primary);
    color: #0f172a;
}

/* Game Area */
.hidden {
    display: none !important;
}

.game-status {
    background: rgba(0, 0, 0, 0.2);
    padding: 1.5rem;
    border-radius: 16px;
    margin-bottom: 1.5rem;
}

/* Melody Slots */
.melody-slots {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    /* Fallback for small screens */
}

.slot {
    width: 40px;
    height: 50px;
    border-bottom: 3px solid var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--text-primary);
    transition: all 0.2s;
}

.slot.active {
    border-color: var(--accent-primary);
    background: rgba(244, 114, 182, 0.1);
}

.slot.filled {
    border-color: var(--text-primary);
}

/* Action Buttons */
.action-buttons {
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin-top: 1rem;
    flex-wrap: wrap;
}

.icon-btn,
.primary-btn,
.secondary-btn {
    padding: 0.8rem 1.5rem;
    border-radius: 50px;
    cursor: pointer;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.2s;
    border: none;
    font-size: 0.9rem;
    font-family: var(--font-main);
}

.icon-btn {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
    border: 1px solid var(--glass-border);
}

.icon-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

.primary-btn {
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    color: white;
}

.primary-btn:hover {
    box-shadow: 0 0 15px rgba(244, 114, 182, 0.5);
    transform: translateY(-2px);
}

.primary-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background: #4b5563;
    transform: none !important;
    box-shadow: none !important;
}

.secondary-btn {
    background: transparent;
    border: 1px solid var(--glass-border);
    color: var(--text-secondary);
}

.secondary-btn:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.05);
}

/* Input Area (Piano-like but Diatonic) */
.piano-container {
    display: flex;
    justify-content: space-between;
    height: 120px;
    background: #e2e8f0;
    padding: 4px;
    border-radius: 8px;
    /* gap: 4px; Removed to prevent layout breaking with percentage widths */
}

/* Since keys are white-key class in JS */
.white-key {
    background: white;
    flex: 1;
    border-radius: 0 0 4px 4px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    position: relative;
    /* Content is handled in JS innerHTML with flex */
}

.white-key:active {
    background: #e2e8f0 !important;
    transform: translateY(2px);
}

/* Nav Button */
.nav-back-button {
    text-decoration: none;
    color: var(--text-secondary);
    border: 1px solid var(--glass-border);
    padding: 0.5rem 1rem;
    border-radius: 20px;
    font-size: 0.9rem;
    display: inline-block;
    transition: all 0.2s;
}

.nav-back-button:hover {
    color: var(--accent-primary);
    border-color: var(--accent-primary);
}

.top-controls {
    display: flex;
    justify-content: center;
    margin-bottom: 1rem;
    position: relative;
    width: 100%;
}

.top-controls #back-to-menu-btn {
    position: absolute;
    left: 0;
}

/* Ensure clean header in score board */
.streak-label {
    position: absolute;
    right: 0;
    font-weight: bold;
    color: var(--accent-secondary);
    top: 0.5rem;
}

#score-board {
    position: relative;
}

/* Pulse animation for submit button */
@keyframes pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(244, 114, 182, 0.7);
    }

    70% {
        box-shadow: 0 0 0 10px rgba(244, 114, 182, 0);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(244, 114, 182, 0);
    }
}

.pulse {
    animation: pulse 2s infinite;
}

.feedback-text {
    min-height: 1.5rem;
    font-weight: bold;
    margin-top: 1rem;
}

.shake {
    animation: shake 0.5s 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);
    }
}

@media (max-width: 480px) {
    .piano-container {
        height: 100px;
    }

    .slot {
        width: 30px;
        height: 40px;
        font-size: 1.2rem;
    }

    .top-controls {
        height: 40px;
    }

    .streak-label {
        font-size: 0.8rem;
    }
}