/* ===================================
   CSS Custom Properties (Design Tokens)
   =================================== */
:root {
    /* Color Palette - Darker Pine Green Theme */
    --color-primary: #2d5016;        /* Dark Pine Green */
    --color-primary-dark: #1a3d0a;   /* Darker Forest Green */
    --color-primary-light: #4a7c28;  /* Medium Pine */
    --color-secondary: #6b9e3e;      /* Darker Sea Green accent */
    --color-success: #10b981;        /* Green for correct */
    --color-error: #dc2626;          /* Red for wrong */
    --color-warning: #f59e0b;        /* Orange for attention */
    
    /* Neutrals */
    --color-bg-dark: #0a0f0a;        /* Very dark green-black */
    --color-bg-medium: #1a2e1a;      /* Dark forest */
    --color-bg-light: #2d4a2d;       /* Medium forest */
    --color-text-primary: #f0fdf4;   /* Light green-white */
    --color-text-secondary: #d1fae5; /* Light mint */
    
    /* Gradients - Darker */
    --gradient-primary: linear-gradient(135deg, #1a3d0a 0%, #2d5016 30%, #0f3d0f 70%, #047857 100%);
    --gradient-success: linear-gradient(135deg, #10b981 0%, #34d399 100%);
    --gradient-error: linear-gradient(135deg, #dc2626 0%, #ef4444 100%);
    
    /* Shadows */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.3), 0 2px 4px -1px rgba(0, 0, 0, 0.2);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.3), 0 4px 6px -2px rgba(0, 0, 0, 0.2);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.3), 0 10px 10px -5px rgba(0, 0, 0, 0.2);
    --shadow-glow: 0 0 20px rgba(107, 158, 62, 0.6);
    
    /* Typography */
    --font-primary: 'Montserrat', system-ui, -apple-system, sans-serif;
    --font-display: 'Koulen', Impact, sans-serif;
    
    /* Spacing */
    --space-xs: 0.25rem;
    --space-sm: 0.5rem;
    --space-md: 1rem;
    --space-lg: 1.5rem;
    --space-xl: 2rem;
    --space-2xl: 3rem;
    
    /* Border Radius */
    --radius-sm: 0.375rem;
    --radius-md: 0.5rem;
    --radius-lg: 0.75rem;
    --radius-xl: 1rem;
    --radius-full: 9999px;
    
    /* Transitions */
    --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-base: 300ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 500ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* ===================================
   Reset & Base Styles
   =================================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-primary);
    background-color: var(--color-bg-dark);
    color: var(--color-text-primary);
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    line-height: 1.6;
}

a {
    color: inherit;
    text-decoration: none;
    transition: all var(--transition-base);
}

button {
    cursor: pointer;
    border: none;
    font-family: inherit;
    touch-action: manipulation;
    transition: all var(--transition-base);
}

button:active {
    transform: scale(0.98);
}

/* ===================================
   Hero Section & Background
   =================================== */
.hero {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    min-height: 100svh;
    position: relative;
    overflow: hidden;
    background: var(--gradient-primary);
    background-size: 200% 200%;
    animation: gradientShift 15s ease infinite;
    padding: var(--space-md);
}

@keyframes gradientShift {
    0%, 100% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
}

/* Animated background pattern - Organic blobs - DARKER */
.hero::before {
    content: '';
    position: absolute;
    top: -10%;
    left: -10%;
    right: -10%;
    bottom: -10%;
    background-image: 
        radial-gradient(circle at 20% 30%, rgba(107, 158, 62, 0.25) 0%, rgba(107, 158, 62, 0.1) 30%, transparent 60%),
        radial-gradient(circle at 80% 70%, rgba(45, 80, 22, 0.3) 0%, rgba(45, 80, 22, 0.15) 30%, transparent 65%),
        radial-gradient(circle at 50% 50%, rgba(107, 158, 62, 0.18) 0%, rgba(107, 158, 62, 0.08) 35%, transparent 70%),
        radial-gradient(circle at 10% 80%, rgba(74, 124, 40, 0.22) 0%, transparent 50%),
        radial-gradient(circle at 90% 20%, rgba(107, 158, 62, 0.22) 0%, transparent 55%);
    background-size: 100% 100%;
    animation: parallaxFloat 20s ease-in-out infinite;
    pointer-events: none;
    z-index: 0;
}

@keyframes parallaxFloat {
    0%, 100% {
        transform: translate(0, 0) scale(1);
        opacity: 1;
    }
    25% {
        transform: translate(-30px, 40px) scale(1.08);
        opacity: 0.9;
    }
    50% {
        transform: translate(0, -20px) scale(1);
        opacity: 1;
    }
    75% {
        transform: translate(30px, 30px) scale(0.95);
        opacity: 0.85;
    }
}

/* Floating musical notes - FULL SCREEN - DARKER */
.hero::after {
    content: '♪ ♫ ♩ ♬ ♪ ♫ ♩ ♬ ♪ ♫ ♩ ♬ ♪ ♫ ♩ ♬ ♪ ♫ ♩ ♬ ♪ ♫ ♩ ♬';
    position: absolute;
    top: -100px;
    left: -50px;
    width: calc(100% + 100px);
    height: calc(100% + 200px);
    font-size: clamp(3rem, 8vw, 6rem);
    color: rgba(107, 158, 62, 0.3);
    pointer-events: none;
    word-spacing: clamp(80px, 15vw, 150px);
    line-height: clamp(120px, 25vh, 200px);
    animation: floatingNotes 35s linear infinite;
    z-index: 0;
    letter-spacing: 30px;
}

@keyframes floatingNotes {
    0% {
        transform: translateY(0) rotate(0deg);
        opacity: 0;
    }
    5% {
        opacity: 0.3;
    }
    95% {
        opacity: 0.3;
    }
    100% {
        transform: translateY(-100%) rotate(180deg);
        opacity: 0;
    }
}

/* Ensure container content is above background */
.container {
    position: relative;
    z-index: 1;
}

.video-bg {
    display: none;
}

/* ===================================
   Container & Layout
   =================================== */
.container {
    width: 100%;
    max-width: 900px;
    padding: var(--space-lg);
    position: relative;
    z-index: 1;
}

/* ===================================
   Typography
   =================================== */
.title {
    font-family: var(--font-display);
    font-size: clamp(2.5rem, 10vw, 5rem);
    color: var(--color-text-primary);
    margin-bottom: var(--space-lg);
    text-align: center;
    letter-spacing: 0.05em;
    text-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    animation: fadeInDown 0.8s ease;
}

.subtitle {
    font-size: clamp(1rem, 4vw, 1.25rem);
    color: var(--color-text-secondary);
    margin-bottom: var(--space-xl);
    text-align: center;
    font-weight: 500;
    animation: fadeIn 1s ease 0.3s backwards;
}

.back-link {
    display: inline-flex;
    align-items: center;
    gap: var(--space-sm);
    font-family: var(--font-display);
    font-size: clamp(1.1rem, 4vw, 1.5rem);
    color: var(--color-text-primary);
    margin: 0 auto var(--space-xl);
    padding: var(--space-sm) var(--space-lg);
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    border-radius: var(--radius-full);
    border: 1px solid rgba(255, 255, 255, 0.2);
    transition: all var(--transition-base);
    display: block;
    width: fit-content;
    margin-left: auto;
    margin-right: auto;
}

.back-link:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

/* ===================================
   Buttons - Primary (Play/Start)
   =================================== */
.play-button {
    display: block;
    width: 100%;
    max-width: 300px;
    margin: var(--space-xl) auto;
    padding: var(--space-md) var(--space-lg);
    font-size: clamp(1.1rem, 3.5vw, 1.5rem);
    font-weight: 700;
    letter-spacing: 0.1em;
    color: var(--color-text-primary);
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(20px);
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-xl), var(--shadow-glow);
    position: relative;
    overflow: hidden;
    animation: fadeIn 1s ease 0.5s backwards, pulse 2s ease infinite;
}

.play-button::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.3) 0%, transparent 70%);
    transform: translate(-50%, -50%) scale(0);
    transition: transform var(--transition-slow);
}

.play-button:hover::before {
    transform: translate(-50%, -50%) scale(1.5);
}

.play-button:hover {
    background: rgba(255, 255, 255, 0.25);
    border-color: rgba(255, 255, 255, 0.5);
    box-shadow: var(--shadow-xl), 0 0 30px rgba(107, 158, 62, 0.9);
    transform: translateY(-4px);
}

@keyframes pulse {
    0%, 100% { box-shadow: var(--shadow-xl), 0 0 20px rgba(107, 158, 62, 0.5); }
    50% { box-shadow: var(--shadow-xl), 0 0 40px rgba(107, 158, 62, 0.7); }
}

/* ===================================
   Menu Buttons
   =================================== */
.menu {
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
    width: 100%;
    max-width: 500px;
    margin: 0 auto;
}

.menu-button {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
    padding: var(--space-lg) var(--space-xl);
    font-size: clamp(1rem, 3vw, 1.25rem);
    font-weight: 600;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    color: var(--color-text-primary);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: var(--radius-lg);
    transition: all var(--transition-base);
    animation: fadeInUp 0.6s ease backwards;
}

.menu-button:nth-child(1) { animation-delay: 0.1s; }
.menu-button:nth-child(2) { animation-delay: 0.2s; }
.menu-button:nth-child(3) { animation-delay: 0.3s; }

.menu-button:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.4);
    transform: translateX(8px);
    box-shadow: var(--shadow-lg);
}

.menu-button i {
    font-size: 1.25em;
}

/* ===================================
   Piano Keys
   =================================== */
.piano-wrapper {
    width: 100%;
    max-width: 800px;
    margin: var(--space-xl) auto;
    animation: fadeInUp 0.8s ease 0.6s backwards;
}

.sharp-keys,
.natural-keys {
    display: flex;
    gap: var(--space-xs); /* Same gap for both */
}

.sharp-keys {
    justify-content: center;
    margin-bottom: var(--space-sm);
    margin-left: calc((100% / 7) / 2); /* Shift right by half of one key width (1/7 of total width / 2) */
    position: relative;
    z-index: 1;
    width: calc(100% - (100% / 7) / 2); /* Adjust width to maintain centering */
}

.natural-keys {
    justify-content: center;
    margin-bottom: var(--space-sm);
    position: relative;
    z-index: 1;
}

/* Remove all individual positioning - just one continuous row */
.sharp-keys .key {
    /* All keys same size, no special positioning */
}

/* Piano Key Styling */
.key {
    flex: 1;
    min-width: 0;
    padding: var(--space-lg) var(--space-sm);
    font-size: clamp(0.9rem, 3vw, 1.25rem);
    font-weight: 700;
    border-radius: var(--radius-md);
    transition: all var(--transition-fast);
    position: relative;
    overflow: hidden;
    box-shadow: var(--shadow-md);
}

/* Glass morphism effect for keys */
.key::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.1) 0%, transparent 100%);
    pointer-events: none;
}

.key-natural {
    background: rgba(255, 255, 255, 0.95);
    color: var(--color-bg-dark);
    border: 2px solid rgba(255, 255, 255, 0.3);
}

.key-sharp {
    background: rgba(30, 41, 59, 0.9);
    color: var(--color-text-primary);
    border: 2px solid rgba(45, 80, 22, 0.7);
}

.key:hover,
.key:active {
    transform: translateY(-4px) scale(1.05);
    box-shadow: var(--shadow-xl), 0 0 20px rgba(107, 158, 62, 0.8);
}

.key-natural:hover {
    background: rgba(107, 158, 62, 0.95);
    color: var(--color-bg-dark);
    border-color: var(--color-secondary);
}

.key-sharp:hover {
    background: var(--color-primary-light);
    border-color: var(--color-secondary);
}

.key-spacer {
    flex: 1;
    visibility: hidden;
}

/* ===================================
   Game Feedback & Stats
   =================================== */
.feedback {
    padding: var(--space-sm);
    margin: var(--space-md) auto;
    max-width: 300px;
    font-size: clamp(0.9rem, 3vw, 1.1rem);
    font-weight: 700;
    text-align: center;
    color: var(--color-text-primary);
    border-radius: var(--radius-lg);
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    border: 2px solid rgba(255, 255, 255, 0.2);
    transition: all var(--transition-base);
    animation: fadeIn 0.8s ease 0.8s backwards;
}

.feedback.correct {
    background: var(--gradient-success);
    border-color: var(--color-success);
    box-shadow: 0 0 30px rgba(16, 185, 129, 0.5);
    animation: successPulse 0.5s ease;
}

.feedback.wrong {
    background: var(--gradient-error);
    border-color: var(--color-error);
    box-shadow: 0 0 30px rgba(239, 68, 68, 0.5);
    animation: shake 0.5s ease;
}

@keyframes successPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-10px); }
    75% { transform: translateX(10px); }
}

/* Stats row container */
.stats-row {
    display: flex;
    gap: var(--space-md);
    justify-content: center;
    align-items: stretch;
    max-width: 600px;
    margin: var(--space-lg) auto;
}

.score,
.timer {
    flex: 1;
    padding: var(--space-md);
    font-size: clamp(1rem, 3.5vw, 1.25rem);
    font-weight: 600;
    text-align: center;
    color: var(--color-text-primary);
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    animation: fadeIn 0.8s ease backwards;
}

.score { animation-delay: 0.9s; }
.timer { animation-delay: 1s; }

/* ===================================
   Name Entry (Game Over)
   =================================== */
.name-entry {
    max-width: 500px;
    margin: var(--space-xl) auto;
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
}

.name-input {
    width: 100%;
    padding: var(--space-lg);
    font-size: clamp(1rem, 3vw, 1.25rem);
    font-family: var(--font-primary);
    font-weight: 600;
    text-align: center;
    color: var(--color-text-primary);
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: var(--radius-lg);
    transition: all var(--transition-base);
}

.name-input::placeholder {
    color: rgba(255, 255, 255, 0.5);
}

.name-input:focus {
    outline: none;
    background: rgba(255, 255, 255, 0.15);
    border-color: var(--color-secondary);
    box-shadow: 0 0 20px rgba(107, 158, 62, 0.5);
}

/* ===================================
   Leaderboard Table
   =================================== */
.leaderboard-container {
    max-width: 600px;
    margin: var(--space-xl) auto;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(20px);
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: var(--radius-xl);
    padding: var(--space-xl);
    animation: fadeInUp 0.8s ease backwards;
}

.leaderboard-table {
    width: 100%;
    border-collapse: collapse;
}

.leaderboard-table thead {
    border-bottom: 2px solid var(--color-secondary);
}

.leaderboard-table th {
    padding: var(--space-md);
    text-align: left;
    font-family: var(--font-display);
    font-size: clamp(1.2rem, 4vw, 1.5rem);
    color: var(--color-secondary);
}

.leaderboard-table td {
    padding: var(--space-md);
    font-size: clamp(1rem, 3vw, 1.2rem);
    color: var(--color-text-primary);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.leaderboard-table tbody tr {
    transition: all var(--transition-base);
}

.leaderboard-table tbody tr:hover {
    background: rgba(107, 158, 62, 0.1);
}

.leaderboard-rank {
    font-weight: 700;
    color: var(--color-secondary);
    width: 60px;
}

.leaderboard-name {
    font-weight: 600;
}

.leaderboard-score {
    text-align: right;
    font-weight: 700;
    color: var(--color-secondary);
}

/* Top 3 special styling */
.leaderboard-table tbody tr:nth-child(1) .leaderboard-rank {
    color: #ffd700; /* Gold */
    font-size: 1.5em;
}

.leaderboard-table tbody tr:nth-child(2) .leaderboard-rank {
    color: #c0c0c0; /* Silver */
    font-size: 1.3em;
}

.leaderboard-table tbody tr:nth-child(3) .leaderboard-rank {
    color: #cd7f32; /* Bronze */
    font-size: 1.2em;
}

.no-scores {
    text-align: center;
    padding: var(--space-xl);
    color: var(--color-text-secondary);
    font-size: clamp(1rem, 3vw, 1.2rem);
}

/* ===================================
   Content Sections
   =================================== */
.content-box {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(20px);
    color: var(--color-text-primary);
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: var(--radius-xl);
    padding: var(--space-xl);
    margin: var(--space-xl) auto;
    max-width: 700px;
    max-height: 500px;
    overflow-y: auto;
    animation: fadeInUp 0.8s ease backwards;
    line-height: 1.8;
    box-shadow: var(--shadow-xl);
}

.content-box h2 {
    color: var(--color-text-primary);
    font-family: var(--font-display);
    font-size: clamp(1.5rem, 5vw, 2rem);
    margin-bottom: var(--space-lg);
    text-align: center;
}

.content-box p {
    margin-bottom: var(--space-md);
    color: var(--color-text-secondary);
}

/* Custom scrollbar */
.content-box::-webkit-scrollbar {
    width: 8px;
}

.content-box::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
    border-radius: var(--radius-full);
}

.content-box::-webkit-scrollbar-thumb {
    background: var(--color-secondary);
    border-radius: var(--radius-full);
}

.content-box::-webkit-scrollbar-thumb:hover {
    background: var(--color-primary-light);
}

/* ===================================
   Animations
   =================================== */
@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

/* ===================================
   Responsive Design
   =================================== */
@media (max-width: 768px) {
    .container {
        padding: var(--space-md);
    }
    
    .menu {
        gap: var(--space-sm);
    }
    
    .key {
        padding: var(--space-md) var(--space-xs);
    }
    
    .sharp-keys,
    .natural-keys {
        gap: 2px;
    }
}

@media (max-width: 480px) {
    .key {
        padding: var(--space-sm) var(--space-xs);
        font-size: 0.85rem;
    }
    
    .title {
        margin-bottom: var(--space-md);
    }
    
    .piano-wrapper {
        margin: var(--space-lg) auto;
    }
}

/* ===================================
   Touch Device Optimizations
   =================================== */
@media (hover: none) and (pointer: coarse) {
    .key,
    .menu-button,
    .play-button {
        min-height: 48px;
    }
    
    /* Remove hover effects on touch devices */
    .key:hover {
        transform: none;
    }
    
    .key:active {
        transform: scale(0.95);
    }
}

/* Prevent text selection on interactive elements */
.key,
.play-button,
.menu-button {
    user-select: none;
    -webkit-user-select: none;
    -webkit-tap-highlight-color: transparent;
}

/* ===================================
   Accessibility
   =================================== */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Focus styles for keyboard navigation */
button:focus-visible,
a:focus-visible {
    outline: 3px solid var(--color-secondary);
    outline-offset: 3px;
}

/* ===================================
   Print Styles
   =================================== */
@media print {
    .hero {
        background: white;
        color: black;
    }
    
    .video-bg {
        display: none;
    }
}
