* { margin: 0; padding: 0; box-sizing: border-box; }
body { overflow: hidden; font-family: Arial, sans-serif; background: #000; touch-action: none; }

/* Screens */
.screen {
    position: fixed; inset: 0; display: flex; flex-direction: column;
    align-items: center; justify-content: center; z-index: 30;
    background: rgba(10, 30, 60, 0.88); color: #fff;
}
.screen h1 { font-size: 42px; font-weight: 700; margin-bottom: 10px; text-shadow: 2px 2px 0 #000a; }
.screen p { font-size: 18px; margin-bottom: 24px; opacity: 0.85; }
.screen button {
    padding: 14px 36px; font-size: 20px; font-weight: 700;
    background: #e8a020; color: #1a0a00; border: none;
    border-radius: 12px; cursor: pointer; letter-spacing: 1px;
    touch-action: manipulation;
}
.screen button:hover { background: #f0b830; }
.screen .hint { font-size: 13px; opacity: 0.55; margin-top: 10px; margin-bottom: 0; }

/* Game container */
#gameWrap {
    position: relative; width: 100vw; height: 100vh; overflow: hidden;
    display: none; touch-action: none;
}

/* Sky */
#skyBg {
    position: absolute; inset: 0;
    background: linear-gradient(180deg, #1a6eb5 0%, #4a9fd4 40%, #87ceeb 70%, #b0e0f7 100%);
}
#sun {
    position: absolute; top: 32px; right: 70px;
    width: 56px; height: 56px; background: #ffe566; border-radius: 50%;
    box-shadow: 0 0 0 12px rgba(255, 229, 102, 0.2);
}
.cloud {
    position: absolute; background: #fff; border-radius: 50px;
    opacity: 0.88; animation: cloudMove linear infinite;
}
.cloud::before, .cloud::after {
    content: ''; position: absolute; background: #fff; border-radius: 50%;
}
.cloud::before { width: 60%; height: 140%; top: -40%; left: 15%; }
.cloud::after  { width: 50%; height: 120%; top: -30%; right: 10%; }
@keyframes cloudMove {
    from { transform: translateX(110vw); }
    to   { transform: translateX(-250px); }
}

/* Ground */
#ground      { position: absolute; bottom: 0; width: 100%; height: 50px; background: #5c3d1e; border-top: 4px solid #7a5230; }
#groundGrass { position: absolute; bottom: 46px; width: 100%; height: 14px; background: #4a8c2a; }

/* Bird */
#bird { position: absolute; width: 40px; height: 40px; z-index: 10; }
.bird-body  { position: absolute; inset: 0; background: #e8a020; border-radius: 50% 60% 50% 40%; border: 2px solid #b87018; }
.bird-eye   { position: absolute; top: 8px; right: 8px; width: 9px; height: 9px; background: #fff; border-radius: 50%; }
.bird-pupil { position: absolute; top: 10px; right: 9px; width: 5px; height: 5px; background: #111; border-radius: 50%; }
.bird-beak  { position: absolute; top: 14px; right: -8px; border-top: 6px solid transparent; border-bottom: 4px solid transparent; border-left: 11px solid #f06020; }
.bird-tail  { position: absolute; left: -11px; top: 50%; transform: translateY(-50%); border-top: 7px solid transparent; border-bottom: 7px solid transparent; border-right: 13px solid #c07010; }

.wing-top, .wing-bot {
    position: absolute; width: 24px; height: 14px;
    background: #d08010; border-radius: 60% 40% 60% 40%;
    left: 4px; transform-origin: right center;
}
.wing-top { top: 3px;  animation: flapUp   0.22s ease-in-out infinite alternate; }
.wing-bot { top: 20px; animation: flapDown 0.22s ease-in-out infinite alternate; }
@keyframes flapUp   { from { transform: rotate(-30deg); } to { transform: rotate(10deg);  } }
@keyframes flapDown { from { transform: rotate(10deg);  } to { transform: rotate(-30deg); } }

/* Pipes */
.obstacle { position: absolute; z-index: 5; }
.pipe-body {
    position: absolute; width: 54px; left: 0;
    background: linear-gradient(90deg, #3a9f3a 0%, #5cc85c 35%, #7ee87e 50%, #5cc85c 65%, #3a9f3a 100%);
    border: 2px solid #287028;
}
.pipe-cap {
    position: absolute; width: 66px; height: 20px; left: -8px;
    background: linear-gradient(90deg, #2e8e2e 0%, #4db44d 40%, #6fd46f 55%, #4db44d 70%, #2e8e2e 100%);
    border: 2px solid #1e6e1e; border-radius: 4px;
}

/* HUD */
#score {
    position: absolute; top: 18px; left: 50%; transform: translateX(-50%);
    font-size: 32px; font-weight: 700; color: #fff;
    text-shadow: 2px 2px 0 rgba(0,0,0,0.4); z-index: 20; letter-spacing: 2px;
}
#pauseBtn {
    position: absolute; top: 16px; right: 18px; z-index: 30;
    background: rgba(0,0,0,0.35); border: none; color: #fff;
    font-size: 20px; padding: 6px 16px; border-radius: 8px; cursor: pointer;
}
#pauseBtn:hover { background: rgba(0,0,0,0.55); }

/* Pause overlay */
#pauseOverlay {
    display: none; position: absolute; inset: 0; z-index: 25;
    background: rgba(0,0,0,0.45);
    align-items: center; justify-content: center;
}
#pauseOverlay.active { display: flex; }
#pauseOverlay span { color: #fff; font-size: 48px; font-weight: 700; text-shadow: 2px 2px 0 #000a; letter-spacing: 4px; }

/* Mobile vertical controls: big ▲ / ▼ on the right (primary movement) */
#verticalControls {
    position: fixed; right: 22px; bottom: 40px; z-index: 25;
    display: none;                /* hidden on desktop */
    flex-direction: column; gap: 24px;
    pointer-events: none;
    touch-action: none;
}
.vbtn {
    width: 96px; height: 96px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.15);
    border: 3px solid rgba(255, 255, 255, 0.45);
    color: #fff;
    font-size: 34px;
    font-weight: 700;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    touch-action: none;
    pointer-events: auto;
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
    transition: transform 0.08s ease, background 0.08s ease;
}
.vbtn:active, .vbtn.active {
    background: rgba(255, 255, 255, 0.55);
    transform: scale(0.9);
    box-shadow: 0 0 20px rgba(255, 255, 255, 0.4);
}

/* Show on touch devices, hide on desktop */
@media (hover: none), (pointer: coarse) {
    #verticalControls { display: flex; }
}
@media (hover: hover) and (pointer: fine) {
    #verticalControls { display: none !important; }
}

/* Responsive tweaks for small screens */
@media (max-width: 600px) {
    .screen h1 { font-size: 28px; }
    .screen p { font-size: 15px; }
    .screen button { padding: 12px 28px; font-size: 17px; }
    #score { font-size: 24px; top: 12px; }
    #pauseBtn { font-size: 18px; padding: 5px 12px; top: 10px; right: 10px; }
    #verticalControls { right: 16px; bottom: 26px; gap: 18px; }
    .vbtn { width: 84px; height: 84px; font-size: 30px; }
}