/* ── Reset ─────────────────────────────────────────── */
*, *::before, *::after { margin:0; padding:0; box-sizing:border-box; }

body {
    font-family: 'Arial', sans-serif;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
}

.game-container {
    width: 100%;
    max-width: 820px;
    position: relative;
}

/* ── Utility ───────────────────────────────────────── */
.hidden { display: none !important; }

/* ── Shared screen wrapper ─────────────────────────── */
.screen {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 14px;
    background: rgba(10,10,30,0.96);
    border: 3px solid #8b5cf6;
    border-radius: 16px;
    z-index: 20;
    padding: 40px 30px;
}

/* ── Menu ──────────────────────────────────────────── */
.menu-dino-wrap {
    width: 96px;
    height: 120px;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    margin-bottom: 8px;
}
.menu-dino-wrap svg { animation: menuBob 1.2s ease-in-out infinite; }
@keyframes menuBob {
    0%,100% { transform: translateY(0); }
    50%      { transform: translateY(-10px); }
}

.game-title {
    font-size: 2.8rem;
    font-weight: 900;
    letter-spacing: 4px;
    color: #fff;
    text-shadow: 0 0 20px #8b5cf6, 0 0 40px #6d28d9;
}

.shop-title, .gameover-title {
    font-size: 1.8rem;
    color: #a78bfa;
    font-weight: bold;
    margin-bottom: 8px;
}

.gameover-score { font-size: 1.3rem; color: #fff; }
.gameover-coins { font-size: 1.1rem; color: #fbbf24; }

.coins-badge {
    background: rgba(139,92,246,0.3);
    border: 1px solid #8b5cf6;
    color: #fbbf24;
    font-size: 1rem;
    font-weight: bold;
    padding: 6px 18px;
    border-radius: 20px;
}

.btn {
    background: rgba(139,92,246,0.2);
    color: white;
    border: 2px solid #8b5cf6;
    padding: 12px 40px;
    font-size: 1.05rem;
    font-weight: bold;
    border-radius: 10px;
    cursor: pointer;
    letter-spacing: 1px;
    transition: all 0.2s;
    width: 200px;
}
.btn:hover { background: #8b5cf6; transform: scale(1.04); }
.btn-primary { background: #8b5cf6; }
.btn-primary:hover { background: #7c3aed; }

.gameover-buttons, .menu-buttons { display:flex; flex-direction:column; gap:10px; align-items:center; }

.hint-text { color: #a78bfa; font-size: 0.85rem; margin-top: 4px; }

/* ── Shop Grid ─────────────────────────────────────── */
.shop-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    width: 100%;
    max-width: 500px;
    margin-bottom: 6px;
}
.shop-card {
    background: rgba(255,255,255,0.06);
    border: 2px solid #4c1d95;
    border-radius: 12px;
    padding: 12px 8px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
}
.shop-card:hover { border-color: #8b5cf6; background: rgba(139,92,246,0.15); }
.shop-card.owned  { border-color: #22c55e; }
.shop-card.active { border-color: #fbbf24; background: rgba(251,191,36,0.15); }
.shop-card .emoji { font-size: 2rem; display: block; margin-bottom: 4px; }
.shop-card .skin-name  { color: #fff; font-size: 0.85rem; font-weight: bold; }
.shop-card .skin-price { color: #fbbf24; font-size: 0.75rem; margin-top: 2px; }
.shop-card .skin-status { color: #22c55e; font-size: 0.75rem; margin-top: 2px; font-weight: bold; }

/* ── HUD ───────────────────────────────────────────── */
.hud {
    display: flex;
    justify-content: space-between;
    color: white;
    font-size: 1.1rem;
    margin-bottom: 10px;
    padding: 0 10px;
}
.hud b { color: #a78bfa; }

/* ── Power-up ──────────────────────────────────────── */
.powerup-indicator {
    position: absolute;
    top: 50px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(139,92,246,0.92);
    color: white;
    padding: 8px 20px;
    border-radius: 20px;
    font-weight: bold;
    font-size: 0.9rem;
    display: none;
    z-index: 15;
    box-shadow: 0 0 20px rgba(139,92,246,0.8);
}
.powerup-indicator.active { display: block; }

/* ── Game Area ─────────────────────────────────────── */
.game-area {
    width: 100%;
    height: 420px;
    background: linear-gradient(to bottom, #1e90ff 0%, #87ceeb 55%, #b8e4f5 100%);
    position: relative;
    overflow: hidden;
    border: 3px solid #8b5cf6;
    border-radius: 12px;
    display: block;
}

.game-area.night {
    filter: brightness(0.25) hue-rotate(200deg);
}
/* Overlays inside .game-area must not be dimmed by the night filter */
.game-area.night .game-overlay {
    filter: brightness(4) hue-rotate(-200deg);
}

/* Sun */
.sun {
    position: absolute;
    top: 30px;
    right: 80px;
    width: 50px;
    height: 50px;
    background: radial-gradient(circle, #fff7a1 0%, #fbbf24 60%, transparent 100%);
    border-radius: 50%;
    box-shadow: 0 0 30px #fbbf24aa;
    animation: sunPulse 4s ease-in-out infinite;
}
@keyframes sunPulse {
    0%,100% { box-shadow: 0 0 30px #fbbf24aa; }
    50%      { box-shadow: 0 0 50px #fbbf24cc; }
}

/* Clouds */
.cloud {
    position: absolute;
    border-radius: 50px;
    background: rgba(255,255,255,0.85);
    animation: cloudMove linear infinite;
}
.cloud::before, .cloud::after {
    content:'';
    position:absolute;
    background: rgba(255,255,255,0.85);
    border-radius: 50%;
}
.c1 { width:100px; height:28px; top:50px; left:20%;   animation-duration: 18s; }
.c1::before { width:50px; height:50px; top:-28px; left:15px; }
.c1::after  { width:35px; height:35px; top:-18px; left:50px; }

.c2 { width:80px;  height:22px; top:80px; left:60%;   animation-duration: 24s; }
.c2::before { width:40px; height:40px; top:-22px; left:12px; }
.c2::after  { width:30px; height:30px; top:-14px; left:42px; }

.c3 { width:60px;  height:18px; top:35px; left:45%;   animation-duration: 30s; }
.c3::before { width:30px; height:30px; top:-17px; left:10px; }
.c3::after  { width:22px; height:22px; top:-10px; left:32px; }

@keyframes cloudMove {
    0%   { transform: translateX(0); }
    100% { transform: translateX(-900px); }
}

/* Ground – grass strip */
.ground-strip {
    position: absolute;
    bottom: 72px;
    left: 0;
    width: 100%;
    height: 14px;
    background: linear-gradient(to bottom, #4ade80 0%, #22c55e 100%);
    z-index: 2;
}

/* Ground – dirt scrolling */
.ground {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 200%;
    height: 72px;
    background: repeating-linear-gradient(
        90deg,
        #92400e 0px, #92400e 42px,
        #78350f 42px, #78350f 84px
    );
    animation: groundScroll 1.4s linear infinite;
    z-index: 1;
}
@keyframes groundScroll {
    0%   { transform: translateX(0); }
    100% { transform: translateX(-84px); }
}

/* ── Dino ──────────────────────────────────────────── */
.dino {
    position: absolute;
    bottom: 86px;
    left: 56px;
    width: 64px;
    height: 80px;
    z-index: 5;
    transform-origin: bottom center;
    transition: filter 0.3s;
}

/* Walking legs */
.dino .leg-back {
    transform-box: fill-box;
    transform-origin: center top;
    animation: legBack 0.35s ease-in-out infinite;
}
.dino .leg-front {
    transform-box: fill-box;
    transform-origin: center top;
    animation: legFront 0.35s ease-in-out infinite;
}
@keyframes legBack  { 0%,100%{transform:rotate(22deg)}  50%{transform:rotate(-22deg)} }
@keyframes legFront { 0%,100%{transform:rotate(-22deg)} 50%{transform:rotate(22deg)}  }

/* Pause walk when jumping or crouching */
.dino.jumping .leg-back,
.dino.jumping .leg-front,
.dino.crouching .leg-back,
.dino.crouching .leg-front { animation-play-state: paused; }

/* Crouch */
.dino.crouching {
    transform: scaleY(0.5);
    transform-origin: bottom center;
}

/* Jump – physics handled by JS (bottom property), only leg pause needed here */

/* Invincible */
.dino.invincible svg { animation: dinoGlow 0.5s ease-in-out infinite alternate; }
@keyframes dinoGlow {
    from { filter: drop-shadow(0 0 6px #8b5cf6); }
    to   { filter: drop-shadow(0 0 18px #a78bfa) brightness(1.3); }
}

/* Rainbow skin */
.dino.rainbow-skin svg { animation: rainbowHue 2s linear infinite; }
@keyframes rainbowHue { 0%{filter:hue-rotate(0deg)} 100%{filter:hue-rotate(360deg)} }

/* ── Cactus ────────────────────────────────────────── */
.cactus {
    position: absolute;
    bottom: 86px;
    right: -60px;
    z-index: 4;
}

/* ── Bird ──────────────────────────────────────────── */
.bird {
    position: absolute;
    right: -56px;
    z-index: 4;
    animation: birdFloat 0.6s ease-in-out infinite;
}
@keyframes birdFloat {
    0%,100% { transform: translateY(0) rotate(-3deg); }
    50%      { transform: translateY(-6px) rotate(3deg); }
}

/* Wing flap */
.bird .wing-top {
    transform-box: fill-box;
    transform-origin: right center;
    animation: wingUp 0.28s ease-in-out infinite;
}
.bird .wing-bottom {
    transform-box: fill-box;
    transform-origin: right center;
    animation: wingDown 0.28s ease-in-out infinite;
}
@keyframes wingUp   { 0%,100%{transform:rotate(-10deg) scaleY(1)} 50%{transform:rotate(30deg) scaleY(0.5)} }
@keyframes wingDown { 0%,100%{transform:rotate(10deg)  scaleY(1)} 50%{transform:rotate(-30deg) scaleY(0.5)} }

/* ── Pause button (in HUD) ─────────────────────────── */
.pause-btn {
    background: transparent;
    border: 1px solid #8b5cf6;
    color: #a78bfa;
    font-size: 1rem;
    border-radius: 6px;
    padding: 2px 10px;
    cursor: pointer;
    transition: all 0.15s;
}
.pause-btn:hover { background: #8b5cf6; color: white; }

/* ── In-game overlays (pause / countdown / revive / ad) ── */
.game-overlay {
    position: absolute;
    inset: 0;
    background: rgba(5, 5, 20, 0.88);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 14px;
    z-index: 30;
    border-radius: 10px;
    padding: 30px 20px;
}
.game-overlay h2 { color: #a78bfa; font-size: 1.8rem; }

/* Countdown */
.countdown-overlay { background: rgba(5,5,20,0.70); }
.countdown-num {
    font-size: 7rem;
    font-weight: 900;
    color: white;
    text-shadow: 0 0 40px #8b5cf6, 0 0 80px #6d28d9;
    animation: countPulse 0.9s ease-out;
}
@keyframes countPulse {
    0%   { transform: scale(1.5); opacity: 0; }
    40%  { opacity: 1; }
    100% { transform: scale(1); }
}

/* Revive */
.revive-title {
    font-size: 1.5rem;
    font-weight: bold;
    color: #f87171;
    letter-spacing: 2px;
}
.revive-ring-wrap {
    position: relative;
    width: 80px;
    height: 80px;
}
.revive-ring-svg {
    width: 80px;
    height: 80px;
    transform: rotate(-90deg);
}
.ring-bg   { fill: none; stroke: #333; stroke-width: 5; }
.ring-fill {
    fill: none;
    stroke: #8b5cf6;
    stroke-width: 5;
    stroke-dasharray: 163.36;
    stroke-dashoffset: 0;
    transition: stroke-dashoffset 0.95s linear;
    stroke-linecap: round;
}
.revive-num {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.8rem;
    font-weight: 900;
    color: white;
}
.revive-btns { display: flex; gap: 14px; }
.revive-btn {
    border: 2px solid #8b5cf6;
    border-radius: 12px;
    padding: 12px 18px;
    font-size: 0.9rem;
    font-weight: bold;
    cursor: pointer;
    text-align: center;
    line-height: 1.4;
    transition: all 0.2s;
}
.revive-btn small { font-size: 0.75rem; display: block; opacity: 0.8; }
.coin-btn { background: rgba(251,191,36,0.15); color: #fbbf24; border-color: #fbbf24; }
.coin-btn:hover { background: #fbbf24; color: #000; }
.no-btn   { background: rgba(255,255,255,0.05); color: #9ca3af; border-color: #4b5563; }
.no-btn:hover { background: rgba(255,255,255,0.1); color: #e5e7eb; }


/* ── Controls ──────────────────────────────────────── */
.controls {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 14px;
    justify-content: center;
    flex-wrap: wrap;
}
.ctrl-btn {
    background: #8b5cf6;
    color: white;
    border: none;
    padding: 13px 32px;
    font-size: 1rem;
    font-weight: bold;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s;
    user-select: none;
    -webkit-user-select: none;
}
.ctrl-btn:hover  { background: #7c3aed; transform: scale(1.05); }
.ctrl-btn:active { transform: scale(0.97); }

/* ── Responsive ────────────────────────────────────── */
@media (max-width: 700px) {
    .game-area { height: 310px; }
    .game-title { font-size: 2rem; }
    .dino { left: 36px; }
}
