/* style.css — Modern, fun, advanced Flappy Bird style */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    user-select: none;
    touch-action: manipulation;
}

html, body {
    width: 100%;
    height: 100vh;
    background: linear-gradient(145deg, #0b1a2f 0%, #1a3a4f 100%);
    display: flex;
    justify-content: center;
    align-items: center;
    font-family: 'Segoe UI', 'Poppins', system-ui, sans-serif;
    overflow: hidden;
    padding: 0;
    margin: 0;
}

.game-container {
    position: relative;
    width: 100%;
    height: 100vh;
    max-width: 100%;
    max-height: 100vh;
    border-radius: 0;
    box-shadow: none;
    overflow: hidden;
    background: #6f958f;
    animation: containerPulse 0.3s ease-out;
}

@keyframes containerPulse {
    0% { transform: scale(0.98); }
    100% { transform: scale(1); }
}

canvas {
    display: block;
    width: 100%;
    height: 100%;
    background: linear-gradient(180deg, #87CEEB 0%, #98d8d0 40%, #f0e6b2 100%);
    image-rendering: crisp-edges;
    image-rendering: pixelated;
}

/* ---------- SCREENS (overlay) ---------- */
.screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: rgba(10, 25, 35, 0.9);
    backdrop-filter: blur(8px);
    opacity: 0;
    visibility: hidden;
    transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    z-index: 20;
    padding: 24px;
    text-align: center;
    color: white;
    text-shadow: 2px 2px 0 #1e2f3d;
}

.screen.active {
    opacity: 1;
    visibility: visible;
    animation: slideIn 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes slideIn {
    0% { 
        opacity: 0;
        transform: scale(0.95) translateY(20px);
    }
    100% { 
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.start-content, .gameover-content {
    background: rgba(255, 248, 225, 0.466);
    padding: 28px 20px;
    border-radius: 60px 20px 60px 20px;
    box-shadow: inset 0 2px 8px white, 0 16px 30px #00000055;
    border: 3px solid #302c2c;
    width: 100%;
    max-width: 85%;
    color: #1e2f3d;
    text-shadow: none;
    animation: contentBounce 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes contentBounce {
    0% {
        transform: scale(0.8) translateY(-30px);
        opacity: 0;
    }
    60% {
        transform: scale(1.05);
    }
    100% {
        transform: scale(1) translateY(0);
        opacity: 1;
    }
}

.game-title {
    font-size: clamp(1.8rem, 5vw, 2.8rem);
    font-weight: 900;
    letter-spacing: 2px;
    margin-bottom: 10px;
    animation: titleGlow 2s ease-in-out infinite;
}

@keyframes titleGlow {
    0%, 100% {
        text-shadow: 0 0 20px rgba(255, 107, 107, 0.5);
    }
    50% {
        text-shadow: 0 0 40px rgba(255, 107, 107, 0.8);
    }
}

.flappy { 
    color: #6b86ff; 
    -webkit-text-stroke: 2px #1a1919;
    animation: flappyFloat 2s ease-in-out infinite;
    display: inline-block;
    font-family:'Comic Sans MS', 'Comic Sans', cursive;
}

.evolution { 
    color: #4ecdc4; 
    -webkit-text-stroke: 2px #1e6f6b;
    animation: evolutionFloat 2s ease-in-out infinite;
    display: inline-block;
     font-family:'Comic Sans MS', 'Comic Sans', cursive;
}

@keyframes flappyFloat {
    0%, 100% { transform: translateY(0px); }
    50% { transform: translateY(-8px); }
}

@keyframes evolutionFloat {
    0%, 100% { transform: translateY(0px); }
    50% { transform: translateY(-8px); }
}

.bird-preview {
    font-size: clamp(3rem, 8vw, 6rem);
    filter: drop-shadow(4px 10px 4px #00000033);
    animation: birdFlutter 0.8s infinite ease-in-out;
    margin: 10px 0;
    display: flex;
    align-items: center;
    justify-content: center;
    height: clamp(4rem, 10vw, 7rem);
}

.bird-emoji {
    display: block;
    line-height: 1;
}

.bird-image {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    animation: birdFlutter 0.8s infinite ease-in-out;
    border-radius: 50%; /* Make the image circular */
    border: 3px solid #ffe694; /* Add a nice border */
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2); /* Add some shadow */
}

@keyframes birdFlutter {
    0%, 100% { 
        transform: translateY(0px) rotate(-5deg);
    }
    25% {
        transform: translateY(-15px) rotate(5deg);
    }
    50% {
        transform: translateY(0px) rotate(-5deg);
    }
    75% {
        transform: translateY(-8px) rotate(5deg);
    }
}

.tagline {
    font-weight: bold;
    background: #ffecb3;
    padding: 8px 16px;
    border-radius: 30px;
    display: inline-block;
    margin-bottom: 20px;
    color: #1e3c4b;
    font-size: clamp(0.85rem, 2.5vw, 1rem);
    animation: taglineShine 2s ease-in-out infinite;
}

@keyframes taglineShine {
    0%, 100% { background: #ffecb3; }
    50% { background: #fff9e6; }
}

.difficulty-selector {
    margin: 12px 0 18px;
}

.difficulty-selector p {
    font-size: clamp(0.9rem, 2vw, 1rem);
    margin-bottom: 10px;
}

.diff-buttons {
    display: flex;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
}

.diff-btn {
    background: #2e4c5e;
    border: none;
    padding: 8px 14px;
    border-radius: 40px;
    font-weight: bold;
    color: #e9f2e9;
    border: 2px solid #7c7cb8;
    cursor: pointer;
    box-shadow: 0 4px 0 #102027;
    transition: all 0.15s cubic-bezier(0.34, 1.56, 0.64, 1);
    font-size: clamp(0.8rem, 2vw, 1rem);
    transform-origin: center;
}

.diff-btn:hover:not(.active-diff) {
    transform: translateY(-2px);
    box-shadow: 0 6px 0 #102027;
}

.diff-btn.active-diff {
    background: #7983f5;
    color: #1e2f3d;
    border-color: #839ff3;
    transform: scale(1.08);
    box-shadow: 0 2px 0 #102027, 0 0 20px rgba(121, 127, 245, 0.6);
    animation: pulseBadge 0.6s ease-out;
}

@keyframes pulseBadge {
    0% {
        transform: scale(0.9);
        box-shadow: 0 0 0 0 rgba(121, 169, 245, 0.8);
    }
    100% {
        transform: scale(1.08);
        box-shadow: 0 2px 0 #102027, 0 0 20px rgba(245, 205, 121, 0);
    }
}

.diff-btn:active {
    transform: translateY(2px) scale(0.98);
}

.play-btn, .menu-btn {
    background: #477bff;
    border: none;
    font-weight: 800;
    font-size: clamp(1rem, 4vw, 1.6rem);
    padding: 14px 20px;
    border-radius: 60px;
    color: #1d2c3a;
    border: 3px solid #8cdcff;
    box-shadow: 0 7px 0 #2b52b4, 0 4px 12px black;
    cursor: pointer;
    margin: 10px 0;
    width: 100%;
    transition: all 0.1s cubic-bezier(0.34, 1.56, 0.64, 1);
    text-transform: uppercase;
    position: relative;
}

.play-btn:hover, .menu-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 0 #0e2db5, 0 6px 16px black;
    animation: buttonGlow 0.4s ease-out;
}

@keyframes buttonGlow {
    0% {
        box-shadow: 0 7px 0 #2b79b4, 0 4px 12px black;
    }
    100% {
        box-shadow: 0 7px 0 #2b4bb4, 0 4px 20px rgba(71, 89, 255, 0.6);
    }
}

.menu-btn {
    background: #b0bec5;
    font-size: clamp(0.9rem, 3.5vw, 1.3rem);
    box-shadow: 0 5px 0 #546e7a;
    border-color: #cfd8dc;
}

.menu-btn:hover {
    box-shadow: 0 5px 0 #546e7a, 0 4px 16px rgba(176, 190, 197, 0.5);
}

.play-btn:active, .menu-btn:active {
    transform: translateY(5px);
    box-shadow: 0 2px 0 #b45f2b, 0 2px 8px black;
}

.final-score-box, .best-box {
    background: #283845;
    padding: 12px;
    border-radius: 30px;
    margin: 10px 0;
    color: #f6e9b2;
    animation: scoreBoxPop 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes scoreBoxPop {
    0% {
        transform: scale(0);
        opacity: 0;
    }
    60% {
        transform: scale(1.1);
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

.final-score-box span, .best-box span {
    font-size: clamp(2rem, 8vw, 3.5rem);
    font-weight: 900;
    display: block;
    color: #fee69c;
    animation: scoreNumber 0.6s ease-out;
}

@keyframes scoreNumber {
    0% {
        transform: translateY(-30px);
        opacity: 0;
    }
    100% {
        transform: translateY(0);
        opacity: 1;
    }
}

/* ---------- HUD (in-game) ---------- */
.game-hud {
    position: absolute;
    top: 18px;
    left: 20px;
    right: 20px;
    display: flex;
    justify-content: flex-start; /* Changed from space-between to flex-start */
    z-index: 15;
    pointer-events: none;
    animation: hudSlideDown 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes hudSlideDown {
    0% {
        opacity: 0;
        transform: translateY(-30px);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

.game-hud.hidden {
    display: none;
}

.score-badge, .level-badge {
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(8px);
    padding: clamp(8px, 2vw, 12px) clamp(16px, 4vw, 28px);
    border-radius: 60px;
    font-size: clamp(1.4rem, 3.5vw, 2rem);
    font-weight: bold;
    color: #fff9e6;
    border: 2px solid #ffe694;
    box-shadow: 0 4px 0 #1e2a2e, 0 0 15px rgba(255, 230, 148, 0.3);
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.3s ease;
}

.score-badge:hover, .level-badge:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 0 #1e2a2e, 0 0 25px rgba(255, 230, 148, 0.6);
}

.level-badge {
    font-size: clamp(1rem, 2.5vw, 1.6rem);
}

.tap-message {
    position: absolute;
    bottom: 30px;
    left: 0;
    right: 0;
    text-align: center;
    color: white;
    text-shadow: 3px 3px 0 #1b2b36;
    font-weight: 900;
    font-size: clamp(1rem, 2.5vw, 1.4rem);
    z-index: 12;
    background: rgba(0, 0, 0, 0.5);
    padding: 8px 12px;
    border-radius: 30px;
    margin: 0 auto;
    margin-left: 40px;
    margin-right: 40px;
    backdrop-filter: blur(6px);
    pointer-events: none;
    animation: tapPulse 1s ease-in-out infinite;
}

@keyframes tapPulse {
    0%, 100% {
        opacity: 0.8;
        transform: translateY(0);
    }
    50% {
        opacity: 1;
        transform: translateY(-5px);
    }
}

.tap-message.hidden { 
    display: none; 
}

.hint {
    font-size: clamp(0.75rem, 2vw, 0.95rem);
    margin-top: 10px;
    color: #5a5a5a;
}

.over-title {
    font-size: clamp(1.8rem, 6vw, 2.8rem);
    font-weight: 900;
    color: #1e2f3d;
    margin-bottom: 20px;
    animation: titleShake 0.6s ease-out;
}

@keyframes titleShake {
    0%, 100% { transform: translateX(0); }
    10% { transform: translateX(-15px); }
    20% { transform: translateX(15px); }
    30% { transform: translateX(-15px); }
    40% { transform: translateX(15px); }
    50% { transform: translateX(-10px); }
}

/* ---------- RESPONSIVE DESIGN ---------- */

/* Small screens - ultra compact */
@media (max-height: 500px) {
    .start-content, .gameover-content {
        padding: 12px 10px;
        max-width: 80%;
    }
    
    .game-title {
        font-size: clamp(1.3rem, 3vw, 1.8rem);
        margin-bottom: 4px;
    }
    
    .bird-preview {
        font-size: clamp(2rem, 5vw, 3rem);
        margin: 2px 0;
    }
    
    .difficulty-selector {
        margin: 6px 0 10px;
    }
    
    .diff-buttons {
        gap: 6px;
    }
    
    .diff-btn {
        padding: 5px 10px;
        font-size: 0.8rem;
    }
    
    .play-btn, .menu-btn {
        padding: 10px 16px;
        font-size: 1rem;
    }
}

/* Mobile portrait - standard size */
@media (max-height: 700px) and (max-width: 500px) {
    .start-content, .gameover-content {
        padding: 16px 12px;
        max-width: 85%;
    }
    
    .game-title {
        margin-bottom: 6px;
    }
    
    .bird-preview {
        margin: 4px 0;
    }
    
    .tagline {
        margin-bottom: 12px;
    }
    
    .game-hud {
        top: 12px;
        left: 12px;
        right: 12px;
    }
}

/* Extra small devices */
@media (max-width: 320px) {
    .start-content, .gameover-content {
        max-width: 90%;
        padding: 12px 10px;
    }
    
    .game-title {
        font-size: 1.4rem;
    }
    
    .bird-preview {
        font-size: 2.2rem;
    }
    
    .diff-buttons {
        flex-direction: column;
        gap: 6px;
    }
    
    .diff-btn {
        width: 100%;
        padding: 6px 10px;
    }
}

/* Wide screens - landscape */
@media (min-width: 1600px) {
    .start-content, .gameover-content {
        max-width: 600px;
    }
    
    .game-title {
        font-size: 3.2rem;
    }
    
    .bird-preview {
        font-size: 7rem;
    }
}

/* Aspect ratio adjustments */
@media (min-aspect-ratio: 16/9) {
    .start-content, .gameover-content {
        max-width: 70%;
        padding: 20px 28px;
    }
}

@media (max-aspect-ratio: 9/16) {
    .start-content, .gameover-content {
        max-width: 80%;
    }
}