/* ============================================
   ATHLETIC RUNNER - Stadium Track Theme!
   An endless runner game where an athletic girl
   jumps over hurdles on a running track.
   ============================================ */

:root {
    /* Sky colors */
    --sky-top: #4a90d9;
    --sky-bottom: #87CEEB;

    /* Track colors */
    --track-red: #D44638;
    --track-dark: #B83A2F;
    --track-line: rgba(255, 255, 255, 0.6);

    /* Hurdle colors */
    --hurdle-bar: #FF6B00;
    --hurdle-post: #FFFFFF;
    --hurdle-stripe: #FF6B00;

    /* Player character colors */
    --player-skin: #C68642;
    --player-shirt: #E91E63;
    --player-jeans: #4a6fa5;
    --player-jeans-dark: #3b5a88;
    --player-hair: #1a1a2e;
    --player-shoes: #333333;
    --player-boy-shirt: #1E88E5;

    /* UI colors */
    --star-gold: #FFD700;
    --text-light: #ffffff;
    --text-mid: #6b7fa3;
    --text-dark: #2c3e50;
    --accent-red: #E91E63;
    --accent-blue: #1565C0;

    /* Crowd */
    --crowd-dark: #3a3a6a;
    --crowd-mid: #4a4a7a;

    /* Game sizing */
    --ground-height: 60px;
    --player-height: 48px;
    --player-width: 20px;
}

/* ====== RESET ====== */
* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; overflow: hidden; }

body {
    font-family: 'Nunito', sans-serif;
    color: var(--text-dark);
    /* Bright blue sky gradient */
    background: linear-gradient(180deg,
        var(--sky-top) 0%,
        var(--sky-bottom) 60%,
        #c8e6f0 100%
    );
    -webkit-user-select: none;
    user-select: none;
}

/* Material Symbols base style - filled icons */
.material-symbols-rounded {
    font-variation-settings: 'FILL' 1, 'wght' 400, 'GRAD' 0, 'opsz' 24;
    vertical-align: middle;
}

/* ============================================
   SCENIC BACKGROUND - Stadium Sky!
   Clouds float by, stadium crowd at the bottom.
   ============================================ */
.scene {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 0;
    overflow: hidden;
}

/* ====== FLOATING CLOUDS ====== */
.cloud {
    position: absolute;
    background: rgba(255, 255, 255, 0.9);
    border-radius: 50px;
    animation: cloudDrift var(--speed, 30s) linear infinite;
}

/* Puffy cloud shape using pseudo-elements */
.cloud::before,
.cloud::after {
    content: '';
    position: absolute;
    background: rgba(255, 255, 255, 0.9);
    border-radius: 50%;
}

.cloud::before {
    width: 60%;
    height: 130%;
    top: -40%;
    left: 20%;
}

.cloud::after {
    width: 40%;
    height: 100%;
    top: -20%;
    left: 50%;
}

@keyframes cloudDrift {
    from { transform: translateX(110vw); }
    to { transform: translateX(-200px); }
}

/* ====== STADIUM CROWD SILHOUETTE ====== */
.stadium-crowd {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 120px;
    pointer-events: none;
    z-index: 0;
    /* Crowd silhouette made with wavy gradients */
    background:
        /* Row of bumpy "heads" on top */
        radial-gradient(ellipse 12px 14px at 10px 20px, var(--crowd-dark) 70%, transparent 71%),
        radial-gradient(ellipse 10px 12px at 30px 22px, var(--crowd-mid) 70%, transparent 71%),
        radial-gradient(ellipse 14px 14px at 55px 18px, var(--crowd-dark) 70%, transparent 71%),
        radial-gradient(ellipse 11px 13px at 78px 21px, var(--crowd-mid) 70%, transparent 71%),
        radial-gradient(ellipse 13px 14px at 100px 19px, var(--crowd-dark) 70%, transparent 71%),
        /* Solid crowd mass */
        linear-gradient(0deg,
            var(--crowd-dark) 0%,
            var(--crowd-dark) 60%,
            var(--crowd-mid) 70%,
            transparent 85%
        );
    background-repeat: repeat-x;
    background-size: 110px 120px, 110px 120px, 110px 120px, 110px 120px, 110px 120px, 100% 100%;
    opacity: 0.3;
}

/* ============================================
   GAME CONTAINER
   ============================================ */
#game-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    height: 100vh;
    height: 100dvh;
    padding: 8px;
    position: relative;
    z-index: 2;
}

/* ====== HUD (Head-Up Display) ====== */
#hud {
    width: 100%;
    max-width: 800px;
    padding: 8px 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    position: relative;
    z-index: 5;
}

/* Back button */
.back-btn {
    position: absolute;
    left: 8px;
    top: 8px;
    color: var(--text-dark);
    text-decoration: none;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(6px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    transition: background 0.2s;
}

.back-btn:hover {
    background: rgba(255, 255, 255, 0.9);
}

/* Mute button */
.mute-btn {
    position: absolute;
    right: 8px;
    top: 8px;
    color: var(--text-dark);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    border: none;
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(6px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    cursor: pointer;
    transition: background 0.2s;
}

.mute-btn:hover {
    background: rgba(255, 255, 255, 0.9);
}

/* Game title in the HUD */
.hud-title {
    display: flex;
    align-items: center;
    gap: 8px;
}

.hud-title h1 {
    font-family: 'Fredoka One', cursive;
    font-size: 1.4em;
    color: var(--text-dark);
    text-shadow: 0 1px 3px rgba(255, 255, 255, 0.5);
}

.hud-icon {
    font-size: 30px !important;
    color: var(--accent-red);
    filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.15));
}

/* Stats bar - frosted glass style */
.hud-stats {
    display: flex;
    gap: 16px;
    align-items: center;
    flex-wrap: wrap;
    justify-content: center;
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(8px);
    padding: 6px 20px;
    border-radius: 24px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.5);
}

.hud-item {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 0.95em;
    font-weight: 700;
    color: var(--text-dark);
}

.hud-item .material-symbols-rounded {
    font-size: 20px;
    color: var(--accent-red);
}

/* ============================================
   GAME AREA - The running track!
   ============================================ */
#game-area {
    flex: 1;
    display: flex;
    align-items: flex-end;
    position: relative;
    width: 100%;
    max-width: 800px;
    overflow: hidden;
    z-index: 3;
    border-radius: 12px;
    cursor: pointer;
}

/* ====== RUNNING TRACK (Ground) ====== */
#ground {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: var(--ground-height);
    background: var(--track-red);
    /* White lane markings that scroll */
    background-image:
        repeating-linear-gradient(
            90deg,
            transparent 0px,
            transparent 58px,
            var(--track-line) 58px,
            var(--track-line) 60px
        );
    background-size: 60px 100%;
    border-top: 3px solid #ffffff;
}

/* Bright white top line of the track */
#ground-line {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: #ffffff;
    box-shadow:
        0 0 8px rgba(255, 255, 255, 0.5),
        0 0 16px rgba(255, 255, 255, 0.2);
}

/* ============================================
   PLAYER CHARACTER - The Athletic Girl!
   Built entirely from CSS divs. No images!
   ============================================ */
#player {
    position: absolute;
    bottom: var(--ground-height);
    left: 80px;
    width: var(--player-width);
    height: var(--player-height);
    z-index: 10;
}

/* The runner's head */
.runner-head {
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 14px;
    height: 14px;
    background: var(--player-skin);
    border-radius: 50%;
    z-index: 3;
}

/* Hair - base style (shared by both girl and boy) */
.runner-hair {
    position: absolute;
    top: -3px;
    left: -3px;
    right: -3px;
    height: 11px;
    background: var(--player-hair);
    border-radius: 9px 9px 2px 2px;
    z-index: 1;
}

/* Girl: Long straight hair flowing down behind her */
#player.girl .runner-hair::after {
    content: '';
    position: absolute;
    top: 6px;
    left: -2px;
    width: 8px;
    height: 22px;
    background: var(--player-hair);
    border-radius: 2px 0 6px 6px;
    transform-origin: top center;
    animation: hairSway 0.4s ease-in-out infinite alternate;
}

/* No scrunchie needed for straight hair */
#player.girl .runner-hair::before {
    display: none;
}

@keyframes hairSway {
    from { transform: rotate(-4deg); }
    to { transform: rotate(4deg); }
}

/* The runner's body (torso with jersey) */
.runner-body {
    position: absolute;
    top: 12px;
    left: 50%;
    transform: translateX(-50%);
    width: 12px;
    height: 16px;
    background: var(--player-shirt);
    border-radius: 3px 3px 0 0;
    z-index: 2;
}

/* Jersey number (using a tiny light stripe) */
.runner-body::after {
    content: '';
    position: absolute;
    top: 4px;
    left: 3px;
    width: 6px;
    height: 2px;
    background: rgba(255, 255, 255, 0.5);
    border-radius: 1px;
}

/* ====== ARMS ====== */
.runner-arm {
    position: absolute;
    top: 14px;
    width: 5px;
    height: 14px;
    background: var(--player-skin);
    border-radius: 3px;
    transform-origin: top center;
    z-index: 1;
}

.runner-arm.left {
    left: 0px;
    animation: armSwing 0.3s ease-in-out infinite alternate;
}

.runner-arm.right {
    right: 0px;
    animation: armSwing 0.3s ease-in-out infinite alternate-reverse;
}

@keyframes armSwing {
    from { transform: rotate(-30deg); }
    to { transform: rotate(30deg); }
}

/* ====== LEGS (Baggy Jeans!) ====== */
.runner-leg {
    position: absolute;
    top: 26px;
    width: 8px;
    height: 19px;
    background: var(--player-jeans);
    border-radius: 2px 2px 4px 4px;
    transform-origin: top center;
    z-index: 2;
    /* Baggy jeans are wider at the bottom! */
    clip-path: polygon(10% 0%, 90% 0%, 100% 100%, 0% 100%);
}

/* The bottom of the jeans flares out a bit (baggy look) */
.runner-leg::before {
    content: '';
    position: absolute;
    bottom: 0;
    left: -1px;
    right: -1px;
    height: 5px;
    background: var(--player-jeans-dark);
    border-radius: 0 0 3px 3px;
}

/* Shoe peeking out at the bottom */
.runner-leg::after {
    content: '';
    position: absolute;
    bottom: -5px;
    left: 0;
    width: 8px;
    height: 5px;
    background: var(--player-shoes);
    border-radius: 0 0 3px 3px;
}

.runner-leg.left {
    left: 1px;
    animation: legStride 0.3s ease-in-out infinite alternate;
}

.runner-leg.right {
    right: 1px;
    animation: legStride 0.3s ease-in-out infinite alternate-reverse;
}

@keyframes legStride {
    from { transform: rotate(-35deg); }
    to { transform: rotate(35deg); }
}

/* ====== JUMPING STATE ====== */
/* When jumping, tuck legs up and spread arms */
#player.jumping .runner-leg.left {
    animation: none;
    transform: rotate(-45deg);
}

#player.jumping .runner-leg.right {
    animation: none;
    transform: rotate(20deg);
}

#player.jumping .runner-arm.left {
    animation: none;
    transform: rotate(-50deg);
}

#player.jumping .runner-arm.right {
    animation: none;
    transform: rotate(40deg);
}

/* Hair flies back when jumping! */
#player.jumping .runner-hair::after {
    animation: none;
    transform: rotate(-15deg);
}

/* ====== IDLE STATE (before game starts) ====== */
#player.idle .runner-leg.left,
#player.idle .runner-leg.right,
#player.idle .runner-arm.left,
#player.idle .runner-arm.right {
    animation: none;
    transform: rotate(0deg);
}

#player.idle .runner-hair::after {
    animation: none;
    transform: rotate(0deg);
}

/* ====== DEAD STATE (hit a hurdle) ====== */
#player.dead {
    opacity: 0;
    transition: opacity 0.2s;
}

/* ============================================
   GIRL AVATAR - Skirt + Long Straight Hair
   The default look! A sporty skirt and
   long flowing straight hair.
   ============================================ */

/* Skirt - a cute flared athletic skirt */
.runner-skirt {
    display: none; /* Hidden by default, shown for girl */
    position: absolute;
    top: 25px;
    left: 50%;
    transform: translateX(-50%);
    width: 18px;
    height: 8px;
    background: var(--accent-red);
    border-radius: 0 0 8px 8px;
    clip-path: polygon(15% 0%, 85% 0%, 100% 100%, 0% 100%);
    z-index: 3;
}

/* Girl avatar: show skirt, ponytail, and shorter legs */
#player.girl .runner-skirt {
    display: block;
}

/* Girl has skin-colored legs (visible below skirt) */
#player.girl .runner-leg {
    background: var(--player-skin);
    clip-path: none;
    width: 5px;
    border-radius: 3px;
}

/* Girl's leg doesn't need jeans hem */
#player.girl .runner-leg::before {
    display: none;
}

/* Girl's shoes */
#player.girl .runner-leg::after {
    width: 6px;
    background: var(--player-shoes);
}

/* ============================================
   BOY AVATAR - Short Hair + Half Pants
   Short sporty hair, no ponytail,
   and knee-length half pants.
   ============================================ */

/* Boy: blue t-shirt instead of pink */
#player.boy .runner-body {
    background: var(--player-boy-shirt);
}

/* Boy: hide the ponytail and scrunchie */
#player.boy .runner-hair::after {
    display: none;
}

#player.boy .runner-hair::before {
    display: none;
}

/* Boy: shorter, buzzed hair style */
#player.boy .runner-hair {
    height: 8px;
    border-radius: 7px 7px 0 0;
    top: -2px;
    left: -2px;
    right: -2px;
}

/* Boy: hide the skirt */
#player.boy .runner-skirt {
    display: none;
}

/* Boy: half pants (knee-length shorts) */
#player.boy .runner-leg {
    background: var(--player-jeans);
    clip-path: none;
    width: 7px;
    height: 12px;
    border-radius: 2px;
}

/* Boy: skin showing below the half pants (lower leg) */
#player.boy .runner-leg::before {
    display: block;
    bottom: -8px;
    left: 1px;
    right: 1px;
    width: 5px;
    height: 8px;
    background: var(--player-skin);
    border-radius: 2px;
}

/* Boy: shoes at the very bottom */
#player.boy .runner-leg::after {
    bottom: -12px;
    width: 7px;
    height: 5px;
}

/* ============================================
   BACKGROUND COMPETITORS
   Other runners behind the player to show
   she's winning the race! They're smaller
   and faded to look further away.
   ============================================ */
#competitors {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 100%;
    z-index: 1;
    pointer-events: none;
}

/* All competitors share a base style */
.competitor {
    position: absolute;
    bottom: var(--ground-height);
    z-index: 1;
}

/* Competitor runners reuse the same body part classes
   but are scaled down and faded */

/* --- Competitor 1: closest behind, slightly smaller --- */
.comp-1 {
    left: 30px;
    transform: scale(0.75);
    transform-origin: bottom center;
    opacity: 0.5;
}

/* Green jersey */
.comp-1 .runner-body {
    background: #43A047;
}

.comp-1 .runner-leg {
    background: #333;
}

/* --- Competitor 2: further behind, smaller --- */
.comp-2 {
    left: 8px;
    transform: scale(0.6);
    transform-origin: bottom center;
    opacity: 0.35;
}

/* Orange jersey */
.comp-2 .runner-body {
    background: #FB8C00;
}

.comp-2 .runner-leg {
    background: #333;
}

/* --- Competitor 3: way behind, smallest --- */
.comp-3 {
    left: -12px;
    transform: scale(0.5);
    transform-origin: bottom center;
    opacity: 0.25;
}

/* Purple jersey */
.comp-3 .runner-body {
    background: #8E24AA;
}

.comp-3 .runner-leg {
    background: #333;
}

/* Competitors have shorter hair (no long flowing hair) */
.competitor .runner-hair::after {
    display: none;
}

/* Competitors don't have skirts */
.competitor .runner-skirt {
    display: none;
}

/* Hide competitors when game is not playing (overlays visible) */
#player.idle ~ #competitors {
    opacity: 0;
}

#player.dead ~ #competitors {
    opacity: 0;
    transition: opacity 0.3s;
}

/* ============================================
   HURDLE OBSTACLES
   Each hurdle has two posts and a crossbar.
   ============================================ */
.hurdle {
    position: absolute;
    bottom: var(--ground-height);
    z-index: 5;
}

/* Hurdle crossbar (the part you jump over) */
.hurdle-bar {
    position: absolute;
    top: 0;
    left: -2px;
    right: -2px;
    height: 5px;
    background: var(--hurdle-bar);
    border-radius: 2px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

/* Hurdle posts (left and right legs) */
.hurdle-post {
    position: absolute;
    bottom: 0;
    width: 4px;
    height: 100%;
    background: var(--hurdle-post);
    border-radius: 1px;
}

.hurdle-post.post-left {
    left: 0;
}

.hurdle-post.post-right {
    right: 0;
}

/* Orange stripes on the posts */
.hurdle-post::before {
    content: '';
    position: absolute;
    top: 30%;
    left: 0;
    right: 0;
    height: 40%;
    background: repeating-linear-gradient(
        0deg,
        var(--hurdle-stripe) 0px,
        var(--hurdle-stripe) 3px,
        var(--hurdle-post) 3px,
        var(--hurdle-post) 6px
    );
}

/* Hurdle sizes */
.hurdle.short {
    width: 28px;
    height: 28px;
}

.hurdle.medium {
    width: 28px;
    height: 38px;
}

.hurdle.tall {
    width: 28px;
    height: 48px;
}

/* ============================================
   TRAIL PARTICLES (Dust behind the runner)
   ============================================ */
.trail-particle {
    position: absolute;
    border-radius: 50%;
    background: rgba(180, 140, 100, 0.5);
    animation: trailFade 0.5s ease-out forwards;
}

@keyframes trailFade {
    from { opacity: 0.6; transform: scale(1); }
    to { opacity: 0; transform: scale(0.2) translateX(-10px); }
}

/* ============================================
   OVERLAY SCREENS
   Frosted-glass style, bright theme.
   ============================================ */
.overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(135, 206, 235, 0.88);
    backdrop-filter: blur(10px);
    z-index: 50;
    animation: fadeIn 0.4s ease-out;
}

.overlay.hidden { display: none; }

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.overlay-box {
    background: linear-gradient(160deg, #ffffff, #f0f8ff);
    border: 2px solid rgba(255, 255, 255, 0.8);
    border-radius: 28px;
    padding: 36px 32px;
    text-align: center;
    max-width: 420px;
    width: 90%;
    box-shadow:
        0 20px 60px rgba(0, 0, 0, 0.15),
        0 0 40px rgba(74, 144, 217, 0.1);
    animation: slideUp 0.5s ease-out;
}

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

.overlay-icon {
    font-size: 72px !important;
    display: block;
    margin-bottom: 12px;
}

.start-icon {
    color: var(--accent-red);
    filter: drop-shadow(0 3px 8px rgba(233, 30, 99, 0.3));
    animation: iconBounce 2s ease-in-out infinite;
}

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

.overlay-box h2 {
    font-family: 'Fredoka One', cursive;
    font-size: 1.9em;
    margin-bottom: 8px;
    color: var(--text-dark);
}

.gameover-box h2 {
    color: var(--accent-red);
}

.overlay-box p {
    color: var(--text-mid);
    margin-bottom: 8px;
}

/* ====== AVATAR SELECTOR ====== */
.avatar-selector {
    margin: 12px 0 4px;
}

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

.avatar-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 10px 24px;
    border: 2px solid rgba(0, 0, 0, 0.1);
    border-radius: 16px;
    background: rgba(0, 0, 0, 0.04);
    color: var(--text-dark);
    font-family: 'Nunito', sans-serif;
    font-weight: 700;
    font-size: 0.95em;
    cursor: pointer;
    transition: all 0.2s;
}

.avatar-btn .material-symbols-rounded {
    font-size: 32px;
}

.avatar-btn:hover {
    background: rgba(233, 30, 99, 0.08);
    border-color: rgba(233, 30, 99, 0.2);
}

.avatar-btn.active {
    background: linear-gradient(135deg, var(--accent-red), #c2185b);
    border-color: rgba(233, 30, 99, 0.4);
    color: white;
    box-shadow: 0 4px 15px rgba(233, 30, 99, 0.3);
}

/* ====== DIFFICULTY SELECTOR ====== */
.difficulty-selector {
    margin: 16px 0 8px;
}

.difficulty-label {
    font-family: 'Fredoka One', cursive;
    font-size: 1em;
    color: var(--text-dark) !important;
    margin-bottom: 10px !important;
}

.difficulty-buttons {
    display: flex;
    gap: 8px;
    justify-content: center;
    flex-wrap: wrap;
}

.diff-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 10px 18px;
    border: 2px solid rgba(0, 0, 0, 0.1);
    border-radius: 16px;
    background: rgba(0, 0, 0, 0.04);
    color: var(--text-dark);
    font-family: 'Nunito', sans-serif;
    font-weight: 700;
    font-size: 0.95em;
    cursor: pointer;
    transition: all 0.2s;
}

.diff-btn .material-symbols-rounded {
    font-size: 28px;
}

.diff-btn:hover {
    background: rgba(233, 30, 99, 0.08);
    border-color: rgba(233, 30, 99, 0.2);
}

.diff-btn.active {
    background: linear-gradient(135deg, var(--accent-red), #c2185b);
    border-color: rgba(233, 30, 99, 0.4);
    color: white;
    box-shadow: 0 4px 15px rgba(233, 30, 99, 0.3);
}

/* Controls help section on start screen */
.controls-help {
    margin: 16px 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.help-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-size: 0.9em;
    color: var(--text-mid);
}

.help-row .material-symbols-rounded {
    font-size: 20px;
    color: var(--accent-blue);
}

/* High score display on start screen */
.high-score-box {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 18px;
    background: rgba(255, 215, 0, 0.15);
    border-radius: 20px;
    font-weight: 700;
    color: #b8860b;
    margin-bottom: 8px;
}

.high-score-box .material-symbols-rounded {
    font-size: 22px;
    color: var(--star-gold);
}

.high-score-box.hidden { display: none; }

/* ====== STARS DISPLAY (Game Over Screen) ====== */
.stars-display {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-bottom: 12px;
}

.star-icon {
    font-size: 50px !important;
    color: rgba(0, 0, 0, 0.1);
    transition: color 0.3s, transform 0.5s;
}

.star-icon.earned {
    color: var(--star-gold);
    filter: drop-shadow(0 2px 8px rgba(255, 193, 7, 0.5));
    animation: starPop 0.5s ease-out backwards;
}

@keyframes starPop {
    0% { transform: scale(0) rotate(-45deg); }
    70% { transform: scale(1.3) rotate(10deg); }
    100% { transform: scale(1) rotate(0); }
}

/* Score summary on game over screen */
.score-summary {
    display: flex;
    justify-content: center;
    gap: 24px;
    margin: 12px 0;
}

.score-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-weight: 700;
    color: var(--text-dark);
}

.score-item .material-symbols-rounded {
    font-size: 22px;
    color: var(--accent-red);
}

/* New best score badge */
.new-best {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 20px;
    background: linear-gradient(135deg, var(--star-gold), #ff8f00);
    border-radius: 20px;
    font-family: 'Fredoka One', cursive;
    font-size: 1em;
    color: white;
    margin-bottom: 8px;
    animation: newBestPulse 1s ease-in-out infinite;
}

.new-best.hidden { display: none; }

.new-best .material-symbols-rounded {
    font-size: 22px;
}

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

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

/* ====== BUTTONS ====== */
.game-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 14px 32px;
    border: none;
    border-radius: 18px;
    font-family: 'Fredoka One', cursive;
    font-size: 1.15em;
    cursor: pointer;
    transition: transform 0.15s, box-shadow 0.15s;
    text-decoration: none;
    margin-top: 8px;
}

.game-btn:hover { transform: translateY(-2px); }
.game-btn:active { transform: translateY(0); }

.primary-btn {
    background: linear-gradient(135deg, var(--accent-red), #c2185b);
    color: white;
    box-shadow: 0 4px 18px rgba(233, 30, 99, 0.35);
}

.primary-btn:hover {
    box-shadow: 0 6px 24px rgba(233, 30, 99, 0.5);
}

.secondary-btn {
    background: rgba(0, 0, 0, 0.06);
    color: var(--text-mid);
}

.secondary-btn:hover {
    background: rgba(0, 0, 0, 0.1);
}

/* ====== PARTICLES (Celebration & Death Effects) ====== */
#particles {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 100;
    overflow: hidden;
}

.particle {
    position: absolute;
    border-radius: 50%;
    animation: particleBurst var(--duration) ease-out forwards;
}

.particle.sparkle {
    border-radius: 2px;
    transform: rotate(45deg);
}

@keyframes particleBurst {
    0% {
        transform: translate(0, 0) scale(1) rotate(0deg);
        opacity: 1;
    }
    100% {
        transform: translate(var(--tx), var(--ty)) scale(0) rotate(var(--rot, 180deg));
        opacity: 0;
    }
}

/* ============================================
   RESPONSIVE DESIGN
   Works on phones, tablets, and big screens!
   ============================================ */

/* Mobile phones */
@media (max-width: 480px) {
    :root {
        --ground-height: 45px;
        --player-height: 38px;
        --player-width: 16px;
    }
    #hud { padding: 4px 8px; }
    .hud-title h1 { font-size: 1em; }
    .hud-stats { gap: 10px; font-size: 0.85em; padding: 4px 12px; }
    .overlay-box { padding: 24px 20px; }
    .overlay-box h2 { font-size: 1.4em; }
    #player { left: 50px; }
    .runner-head { width: 11px; height: 11px; }
    .runner-body { top: 10px; width: 10px; height: 13px; }
    .runner-arm { top: 11px; width: 4px; height: 11px; }
    .runner-leg { top: 21px; width: 7px; height: 14px; }
    .runner-leg::after { height: 4px; width: 7px; bottom: -4px; }
    .runner-hair { height: 8px; }
    #player.girl .runner-hair::after { width: 6px; height: 18px; }
    .hurdle.short { height: 22px; width: 24px; }
    .hurdle.medium { height: 30px; width: 24px; }
    .hurdle.tall { height: 38px; width: 24px; }
}

/* Tablets */
@media (min-width: 481px) and (max-width: 768px) {
    :root {
        --ground-height: 50px;
        --player-height: 42px;
        --player-width: 18px;
    }
    #player { left: 65px; }
}

/* Large tablets */
@media (min-width: 769px) and (max-width: 1024px) {
    :root {
        --ground-height: 55px;
        --player-height: 45px;
    }
}

/* Desktop */
@media (min-width: 1025px) {
    :root {
        --ground-height: 60px;
        --player-height: 48px;
    }
}

/* Landscape mode on mobile */
@media (max-height: 500px) and (orientation: landscape) {
    :root {
        --ground-height: 40px;
        --player-height: 36px;
        --player-width: 15px;
    }
    #hud { padding: 2px 8px; }
    .hud-title h1 { font-size: 0.9em; }
    .hud-stats { padding: 3px 10px; }
    #player { left: 50px; }
    .runner-head { width: 10px; height: 10px; }
    .runner-body { top: 9px; width: 9px; height: 12px; }
    .runner-arm { top: 10px; width: 4px; height: 10px; }
    .runner-leg { top: 19px; width: 6px; height: 13px; }
    .runner-leg::after { height: 5px; width: 5px; bottom: -4px; }
    .hurdle.short { height: 20px; width: 22px; }
    .hurdle.medium { height: 28px; width: 22px; }
    .hurdle.tall { height: 36px; width: 22px; }
}

/* Hero credit badge - stylish pink banner */
.created-by {
    text-align: center;
    font-family: 'Fredoka One', cursive;
    font-size: 1.2em;
    margin: 12px auto;
    padding: 10px 28px;
    color: #fff;
    background: linear-gradient(135deg, #E91E63, #FF4081, #F50057);
    border-radius: 30px;
    display: block;
    width: fit-content;
    letter-spacing: 1px;
    box-shadow: 0 4px 15px rgba(233, 30, 99, 0.4);
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
    z-index: 4;
    position: relative;
    animation: createdByGlow 2s ease-in-out infinite alternate;
}

@keyframes createdByGlow {
    from { box-shadow: 0 4px 15px rgba(233, 30, 99, 0.4); }
    to   { box-shadow: 0 4px 25px rgba(233, 30, 99, 0.7), 0 0 40px rgba(255, 64, 129, 0.3); }
}
