/* Self-hosted Press Start 2P — CSP font-src 'self' blocks Google Fonts,
   so mobile (no system install) fell back to monospace and lost the pixel
   look. TTF lives in /public/fonts/ (already used by HorseJumperOgService
   via sharp+pango). font-display: block keeps the layout from flashing
   the proportional fallback during the ~50ms TTF fetch — pixel game UI
   tolerates a brief invisible-text window better than a CLS jolt. */
@font-face {
    font-family: 'Press Start 2P';
    src: url('/fonts/PressStart2P-Regular.ttf') format('truetype');
    font-weight: 400;
    font-style: normal;
    font-display: block;
}

* { box-sizing: border-box; padding: 0; margin: 0; }

:root {
    --sky-1: #7cc5ff;
    --sky-2: #cfe9ff;
    --grass: #5fb04a;
    --grass-dark: #2e6b27;
    --sand-light: #f0dca8;
    --sand-mid: #d4b76e;
    --sand-dark: #a8864a;
    --sand-shadow: #7d5d2e;
    --pole-light: #fff5d6;
    --pole-dark: #3a2410;
    --pole-stripe: #d23028;
    --post-light: #f5efd9;
    --post-shadow: #b8a373;
    --filler: #6b3a17;
    --filler-shadow: #3f1f08;
    --flag: #e0282a;
    --ink: #1a1a2e;
    /* Stable Guard Technologies brand palette */
    --sgt-navy: #192F5B;
    --sgt-navy-dark: #0F1F3D;
    --sgt-navy-light: #1a3a6e;
    --pixel-gold: #f4c84a;
    --pixel-blue: #7cc5ff;
}

html, body {
    height: 100%;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
    background: #f6f7fb;
    color: var(--ink);
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

body {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100dvh;
    padding: 16px;
    background:
        radial-gradient(ellipse at top, #eaf2ff 0%, #f6f7fb 60%, #e9eef7 100%);
}

body.embed {
    justify-content: flex-start;
    padding: 14px 16px 4px;
    min-height: 0;
}
body.embed .masthead { margin-bottom: 14px; }

.masthead {
    text-align: center;
    margin-bottom: 18px;
    width: min(720px, 100%);
}

.title-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 14px;
    padding: 14px 28px;
    width: 100%;
    background: #fff;
    box-shadow:
        0 0 0 2px var(--sgt-navy),
        0 0 0 4px #f4c84a,
        0 0 0 6px var(--sgt-navy),
        4px 4px 0 6px rgba(15,31,61,0.30);
    image-rendering: pixelated;
}

.trophy {
    display: inline-block;
    width: 28px;
    height: 32px;
    flex: 0 0 28px;
    transform: translateY(1px);
    image-rendering: pixelated;
    filter: drop-shadow(2px 2px 0 rgba(15,31,61,0.35));
}
.trophy svg {
    width: 100%;
    height: 100%;
    display: block;
}

.masthead h1 {
    margin: 0;
    font-family: "Press Start 2P", "Pixelify Sans", "Courier New", monospace;
    font-weight: 400;
    line-height: 1;
    letter-spacing: 1.2px;
    text-transform: uppercase;
    color: var(--sgt-navy);
    display: inline-flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
}
.masthead h1 .brand {
    font-size: 14px;
    letter-spacing: 1.2px;
    line-height: 1;
}
.masthead h1 .cup {
    font-size: 18px;
    line-height: 1;
    color: #8a6308;
    text-shadow:
        2px 2px 0 var(--sgt-navy),
        4px 4px 0 rgba(15,31,61,0.35);
    letter-spacing: 1.5px;
}

.hint {
    margin-top: 22px;
    font-family: "Press Start 2P", "Pixelify Sans", "Courier New", monospace;
    font-size: 10px;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: var(--sgt-navy);
    opacity: 0.85;
}
.hint-mobile { display: none; }

kbd {
    display: inline-block;
    background: #fff;
    color: var(--sgt-navy);
    border: 0;
    box-shadow:
        inset 0 0 0 2px var(--sgt-navy),
        2px 2px 0 var(--sgt-navy-dark);
    border-radius: 0;
    padding: 2px 6px;
    margin: 0 2px;
    font-family: "Press Start 2P", "Pixelify Sans", "Courier New", monospace;
    font-size: 9px;
    letter-spacing: 1px;
}

@media (hover: none) and (pointer: coarse) {
    .hint-desktop { display: none; }
    .hint-mobile  { display: inline; }
}

@media (max-width: 520px) {
    body { padding: 10px 8px; }
    .title-row {
        gap: 10px;
        padding: 8px 12px;
        box-shadow:
            0 0 0 2px var(--sgt-navy),
            0 0 0 3px #f4c84a,
            0 0 0 5px var(--sgt-navy),
            3px 3px 0 5px rgba(15,31,61,0.30);
    }
    .trophy { width: 22px; height: 25px; flex-basis: 22px; transform: translateY(1px); }
    .title-row { gap: 10px; padding: 10px 14px; }
    .masthead h1 { gap: 6px; letter-spacing: 0.6px; flex-wrap: wrap; justify-content: center; align-items: center; }
    .masthead h1 .brand { font-size: 9px; letter-spacing: 0.6px; }
    .masthead h1 .cup   { font-size: 12px; letter-spacing: 1.2px; }
    .hint { font-size: 8px; margin-top: 8px; letter-spacing: 0.8px; }
    kbd { font-size: 8px; padding: 2px 5px; }
}

.game {
    position: relative;
    width: min(720px, 100%);
    height: 380px;
    overflow: visible;
    cursor: pointer;
    --speed: 1; /* shared by terrain + obstacle so obstacle never outruns ground */
}

/* Clipping wrapper for gameplay sprites (sky/ground/horse/obstacles).
   Lets .overlay card escape .game bounds while obstacles still clip
   at the canvas edges. */
.game-stage {
    position: absolute;
    inset: 0;
    overflow: hidden;
    z-index: 0;
}

.sky {
    position: absolute;
    inset: 0;
    /* stepped (pixelated-feel) gradient: 4 distinct sky bands */
    background: linear-gradient(
        to bottom,
        var(--sky-1) 0%, var(--sky-1) 30%,
        #9bd2ff 30%, #9bd2ff 55%,
        #b8def9 55%, #b8def9 80%,
        var(--sky-2) 80%, var(--sky-2) 100%
    );
    image-rendering: pixelated;
}

/* blocky pixel clouds via box-shadow */
.sky::before, .sky::after {
    content: "";
    position: absolute;
    width: 8px;
    height: 8px;
    background: #fff;
    box-shadow:
        8px 0 0 #fff, 16px 0 0 #fff, 24px 0 0 #fff, 32px 0 0 #fff,
        0 -8px 0 #fff, 8px -8px 0 #fff, 16px -8px 0 #fff,
        16px 8px 0 #fff, 24px 8px 0 #fff;
    animation: cloud-drift 30s linear infinite;
}
.sky::before { top: 35px; left: 80%; }
.sky::after  {
    top: 70px; left: 110%;
    animation-duration: 45s;
    animation-delay: -15s;
    transform: scale(0.7);
}

@keyframes cloud-drift {
    from { transform: translateX(0) scale(1); }
    to   { transform: translateX(-900px) scale(1); }
}

.sky::after { animation-name: cloud-drift-2; }
@keyframes cloud-drift-2 {
    from { transform: translateX(0) scale(0.7); }
    to   { transform: translateX(-900px) scale(0.7); }
}

/* distant grazing animals — sheep + cow tile, slow scroll */
.bg-animals {
    position: absolute;
    left: 0; right: 0;
    bottom: 50px;
    height: 72px;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 480 36' shape-rendering='crispEdges'><g transform='translate(20,18)'><rect x='6' y='14' width='2' height='4' fill='%23222'/><rect x='10' y='14' width='2' height='4' fill='%23222'/><rect x='16' y='14' width='2' height='4' fill='%23222'/><rect x='20' y='14' width='2' height='4' fill='%23222'/><rect x='4' y='6' width='20' height='8' fill='%23f5f5f5'/><rect x='3' y='7' width='1' height='6' fill='%23f5f5f5'/><rect x='24' y='7' width='1' height='6' fill='%23f5f5f5'/><rect x='6' y='4' width='2' height='2' fill='%23f5f5f5'/><rect x='10' y='4' width='2' height='2' fill='%23f5f5f5'/><rect x='14' y='4' width='2' height='2' fill='%23f5f5f5'/><rect x='18' y='4' width='2' height='2' fill='%23f5f5f5'/><rect x='4' y='13' width='20' height='1' fill='%23c8c8c8'/><rect x='22' y='8' width='5' height='5' fill='%23222'/><rect x='25' y='9' width='1' height='1' fill='%23fff'/></g><g transform='translate(80,16)'><rect x='4' y='0' width='2' height='2' fill='%23244a1f'/><rect x='3' y='2' width='4' height='2' fill='%23244a1f'/><rect x='2' y='4' width='6' height='3' fill='%232e6b27'/><rect x='1' y='7' width='8' height='3' fill='%23244a1f'/><rect x='0' y='10' width='10' height='4' fill='%232e6b27'/><rect x='0' y='14' width='10' height='4' fill='%23244a1f'/><rect x='4' y='18' width='2' height='2' fill='%235c3317'/></g><g transform='translate(106,8)'><rect x='14' y='0' width='4' height='2' fill='%238b2e1c'/><rect x='10' y='2' width='12' height='2' fill='%238b2e1c'/><rect x='6' y='4' width='20' height='2' fill='%23a83829'/><rect x='2' y='6' width='28' height='2' fill='%23a83829'/><rect x='2' y='8' width='28' height='20' fill='%23c43c2e'/><rect x='2' y='13' width='28' height='1' fill='%23f5f5f5'/><rect x='14' y='8' width='4' height='20' fill='%23f5f5f5'/><rect x='14' y='20' width='4' height='8' fill='%235c2418'/><rect x='5' y='10' width='4' height='3' fill='%23fff5d6'/><rect x='23' y='10' width='4' height='3' fill='%23fff5d6'/><rect x='5' y='16' width='4' height='3' fill='%23fff5d6'/><rect x='23' y='16' width='4' height='3' fill='%23fff5d6'/></g><g transform='translate(150,28)'><rect x='1' y='1' width='12' height='7' fill='%23d4a84a'/><rect x='0' y='3' width='1' height='4' fill='%23d4a84a'/><rect x='13' y='3' width='1' height='4' fill='%23d4a84a'/><rect x='2' y='0' width='10' height='1' fill='%23e6ba5a'/><rect x='1' y='3' width='12' height='1' fill='%23a8862e'/><rect x='1' y='6' width='12' height='1' fill='%23a8862e'/></g><g transform='translate(190,14)'><rect x='6' y='17' width='2' height='5' fill='%23222'/><rect x='11' y='17' width='2' height='5' fill='%23222'/><rect x='19' y='17' width='2' height='5' fill='%23222'/><rect x='24' y='17' width='2' height='5' fill='%23222'/><rect x='4' y='8' width='24' height='9' fill='%23f8f8f8'/><rect x='6' y='9' width='5' height='4' fill='%23222'/><rect x='14' y='10' width='6' height='5' fill='%23222'/><rect x='22' y='9' width='4' height='3' fill='%23222'/><rect x='13' y='17' width='4' height='2' fill='%23ff9aa2'/><rect x='26' y='10' width='6' height='6' fill='%23f8f8f8'/><rect x='30' y='13' width='2' height='3' fill='%23ff9aa2'/><rect x='27' y='8' width='1' height='2' fill='%23fff5d6'/><rect x='30' y='8' width='1' height='2' fill='%23fff5d6'/><rect x='28' y='12' width='1' height='1' fill='%23000'/><rect x='3' y='9' width='1' height='6' fill='%23222'/><rect x='2' y='14' width='2' height='2' fill='%23222'/></g><g transform='translate(260,22)'><rect x='0' y='0' width='2' height='14' fill='%23f5efd9'/><rect x='14' y='0' width='2' height='14' fill='%23f5efd9'/><rect x='0' y='0' width='2' height='2' fill='%23e0282a'/><rect x='14' y='0' width='2' height='2' fill='%23e0282a'/><rect x='2' y='3' width='3' height='2' fill='%23d23028'/><rect x='5' y='3' width='3' height='2' fill='%23fff5d6'/><rect x='8' y='3' width='3' height='2' fill='%23d23028'/><rect x='11' y='3' width='3' height='2' fill='%23fff5d6'/><rect x='2' y='8' width='3' height='2' fill='%23d23028'/><rect x='5' y='8' width='3' height='2' fill='%23fff5d6'/><rect x='8' y='8' width='3' height='2' fill='%23d23028'/><rect x='11' y='8' width='3' height='2' fill='%23fff5d6'/></g><g transform='translate(295,30)'><rect x='0' y='0' width='18' height='1' fill='%23a87858'/><rect x='1' y='1' width='16' height='1' fill='%237ec0e6'/><rect x='1' y='2' width='16' height='2' fill='%235da3d6'/><rect x='0' y='4' width='18' height='2' fill='%237d5d2e'/></g><g transform='translate(330,10)'><rect x='14' y='-2' width='3' height='4' fill='%23a83829'/><rect x='8' y='0' width='4' height='2' fill='%237a4a2a'/><rect x='6' y='2' width='8' height='2' fill='%237a4a2a'/><rect x='4' y='4' width='12' height='2' fill='%238c5a36'/><rect x='2' y='6' width='16' height='2' fill='%238c5a36'/><rect x='2' y='8' width='16' height='18' fill='%23f4ead2'/><rect x='8' y='17' width='4' height='9' fill='%235c2418'/><rect x='4' y='11' width='3' height='3' fill='%2378b8d4'/><rect x='13' y='11' width='3' height='3' fill='%2378b8d4'/><rect x='4' y='12' width='3' height='1' fill='%23ffffff'/><rect x='13' y='12' width='3' height='1' fill='%23ffffff'/></g><g transform='translate(380,18)'><rect x='6' y='14' width='2' height='4' fill='%23222'/><rect x='10' y='14' width='2' height='4' fill='%23222'/><rect x='16' y='14' width='2' height='4' fill='%23222'/><rect x='20' y='14' width='2' height='4' fill='%23222'/><rect x='4' y='6' width='20' height='8' fill='%23f5f5f5'/><rect x='3' y='7' width='1' height='6' fill='%23f5f5f5'/><rect x='24' y='7' width='1' height='6' fill='%23f5f5f5'/><rect x='6' y='4' width='2' height='2' fill='%23f5f5f5'/><rect x='10' y='4' width='2' height='2' fill='%23f5f5f5'/><rect x='14' y='4' width='2' height='2' fill='%23f5f5f5'/><rect x='18' y='4' width='2' height='2' fill='%23f5f5f5'/><rect x='4' y='13' width='20' height='1' fill='%23c8c8c8'/><rect x='22' y='8' width='5' height='5' fill='%23222'/><rect x='25' y='9' width='1' height='1' fill='%23fff'/></g><g transform='translate(430,28)'><rect x='1' y='1' width='12' height='7' fill='%23d4a84a'/><rect x='0' y='3' width='1' height='4' fill='%23d4a84a'/><rect x='13' y='3' width='1' height='4' fill='%23d4a84a'/><rect x='2' y='0' width='10' height='1' fill='%23e6ba5a'/><rect x='1' y='3' width='12' height='1' fill='%23a8862e'/><rect x='1' y='6' width='12' height='1' fill='%23a8862e'/></g></svg>");
    background-repeat: repeat-x;
    background-size: 960px 72px;
    image-rendering: pixelated;
    animation: scroll-bg 18s linear infinite;
    pointer-events: none;
    z-index: 1;
}
@keyframes scroll-bg {
    from { background-position: 0 0; }
    to   { background-position: -960px 0; }
}

/* tiny pixel birds in sky */
.birds {
    position: absolute;
    top: 28px;
    left: 0; right: 0;
    height: 24px;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 240 12' shape-rendering='crispEdges'><g fill='%23222'><g transform='translate(30,4)'><rect x='0' y='2' width='1' height='1'/><rect x='1' y='1' width='1' height='1'/><rect x='2' y='0' width='1' height='1'/><rect x='3' y='1' width='1' height='1'/><rect x='4' y='2' width='1' height='1'/><rect x='5' y='2' width='1' height='1'/><rect x='6' y='1' width='1' height='1'/><rect x='7' y='0' width='1' height='1'/><rect x='8' y='1' width='1' height='1'/><rect x='9' y='2' width='1' height='1'/></g><g transform='translate(110,2)'><rect x='0' y='2' width='1' height='1'/><rect x='1' y='1' width='1' height='1'/><rect x='2' y='0' width='1' height='1'/><rect x='3' y='1' width='1' height='1'/><rect x='4' y='2' width='1' height='1'/><rect x='5' y='2' width='1' height='1'/><rect x='6' y='1' width='1' height='1'/><rect x='7' y='0' width='1' height='1'/><rect x='8' y='1' width='1' height='1'/><rect x='9' y='2' width='1' height='1'/></g><g transform='translate(180,5)'><rect x='0' y='2' width='1' height='1'/><rect x='1' y='1' width='1' height='1'/><rect x='2' y='0' width='1' height='1'/><rect x='3' y='1' width='1' height='1'/><rect x='4' y='2' width='1' height='1'/><rect x='5' y='2' width='1' height='1'/><rect x='6' y='1' width='1' height='1'/><rect x='7' y='0' width='1' height='1'/><rect x='8' y='1' width='1' height='1'/><rect x='9' y='2' width='1' height='1'/></g></g></svg>");
    background-repeat: repeat-x;
    background-size: 480px 24px;
    image-rendering: pixelated;
    animation: scroll-birds 9s linear infinite;
    pointer-events: none;
    opacity: 0.75;
    z-index: 0;
}
@keyframes scroll-birds {
    from { background-position: 0 0; }
    to   { background-position: -480px 0; }
}

.ground {
    position: absolute;
    left: 0; right: 0; bottom: 0;
    height: 50px;
    background: var(--sand-mid);
    image-rendering: pixelated;
    z-index: 2;
}

/* alternating sand + grass terrain in one scrolling pixel-SVG tile */
.ground::before {
    content: "";
    position: absolute;
    top: -14px;
    left: 0; right: 0;
    height: 64px;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='640' height='16' shape-rendering='crispEdges'><defs><g id='s'><rect x='0' y='3' width='80' height='1' fill='%237d5d2e'/><rect x='0' y='4' width='80' height='3' fill='%23f0dca8'/><rect x='0' y='7' width='80' height='4' fill='%23d4b76e'/><rect x='0' y='11' width='80' height='5' fill='%23a8864a'/><g fill='%23a8864a'><rect x='3' y='5' width='1' height='1'/><rect x='9' y='4' width='1' height='1'/><rect x='14' y='6' width='2' height='1'/><rect x='20' y='5' width='1' height='1'/><rect x='26' y='4' width='2' height='1'/><rect x='31' y='5' width='1' height='1'/><rect x='36' y='6' width='1' height='1'/><rect x='41' y='4' width='2' height='1'/><rect x='47' y='5' width='1' height='1'/><rect x='53' y='4' width='1' height='1'/><rect x='58' y='6' width='2' height='1'/><rect x='64' y='5' width='1' height='1'/><rect x='70' y='4' width='1' height='1'/><rect x='75' y='6' width='2' height='1'/><rect x='5' y='8' width='2' height='1'/><rect x='12' y='9' width='1' height='1'/><rect x='18' y='8' width='2' height='1'/><rect x='24' y='10' width='1' height='1'/><rect x='30' y='8' width='1' height='1'/><rect x='36' y='9' width='2' height='1'/><rect x='43' y='8' width='1' height='1'/><rect x='49' y='10' width='2' height='1'/><rect x='55' y='8' width='1' height='1'/><rect x='61' y='9' width='2' height='1'/><rect x='67' y='8' width='1' height='1'/><rect x='73' y='10' width='2' height='1'/></g><g fill='%237d5d2e'><rect x='2' y='12' width='1' height='1'/><rect x='8' y='14' width='1' height='1'/><rect x='14' y='12' width='2' height='1'/><rect x='20' y='13' width='1' height='1'/><rect x='26' y='15' width='1' height='1'/><rect x='32' y='12' width='2' height='1'/><rect x='38' y='14' width='1' height='1'/><rect x='44' y='13' width='2' height='1'/><rect x='50' y='12' width='1' height='1'/><rect x='56' y='14' width='1' height='1'/><rect x='62' y='15' width='2' height='1'/><rect x='68' y='13' width='1' height='1'/><rect x='74' y='12' width='1' height='1'/><rect x='78' y='14' width='1' height='1'/></g><g fill='%23fff5d6'><rect x='7' y='5' width='1' height='1'/><rect x='22' y='4' width='1' height='1'/><rect x='38' y='4' width='1' height='1'/><rect x='51' y='5' width='1' height='1'/><rect x='67' y='4' width='1' height='1'/><rect x='76' y='5' width='1' height='1'/></g></g><g id='g'><rect x='0' y='3' width='80' height='1' fill='%23244a1f'/><rect x='0' y='4' width='80' height='3' fill='%235fb04a'/><rect x='0' y='7' width='80' height='4' fill='%234f9a3e'/><rect x='0' y='11' width='80' height='5' fill='%232e6b27'/><g fill='%237ac558'><rect x='1' y='3' width='1' height='1'/><rect x='3' y='2' width='1' height='2'/><rect x='5' y='1' width='2' height='3'/><rect x='8' y='0' width='1' height='4'/><rect x='10' y='2' width='2' height='2'/><rect x='13' y='1' width='1' height='3'/><rect x='15' y='0' width='2' height='4'/><rect x='18' y='3' width='1' height='1'/><rect x='20' y='2' width='1' height='2'/><rect x='22' y='0' width='2' height='4'/><rect x='25' y='1' width='1' height='3'/><rect x='27' y='2' width='2' height='2'/><rect x='30' y='0' width='1' height='4'/><rect x='32' y='1' width='2' height='3'/><rect x='35' y='3' width='1' height='1'/><rect x='37' y='2' width='2' height='2'/><rect x='40' y='0' width='2' height='4'/><rect x='43' y='1' width='1' height='3'/><rect x='45' y='2' width='2' height='2'/><rect x='48' y='0' width='1' height='4'/><rect x='50' y='3' width='1' height='1'/><rect x='52' y='1' width='2' height='3'/><rect x='55' y='2' width='2' height='2'/><rect x='58' y='0' width='1' height='4'/><rect x='60' y='1' width='2' height='3'/><rect x='63' y='2' width='2' height='2'/><rect x='66' y='0' width='2' height='4'/><rect x='69' y='1' width='1' height='3'/><rect x='71' y='3' width='1' height='1'/><rect x='73' y='2' width='2' height='2'/><rect x='76' y='0' width='1' height='4'/><rect x='78' y='1' width='2' height='3'/></g><g fill='%23498f3a'><rect x='6' y='1' width='1' height='3'/><rect x='15' y='0' width='1' height='4'/><rect x='22' y='0' width='1' height='4'/><rect x='32' y='1' width='1' height='3'/><rect x='40' y='0' width='1' height='4'/><rect x='52' y='1' width='1' height='3'/><rect x='66' y='0' width='1' height='4'/><rect x='78' y='1' width='1' height='3'/></g></g><g id='s2g'><rect x='0' y='3' width='42' height='1' fill='%237d5d2e'/><rect x='42' y='3' width='38' height='1' fill='%23244a1f'/><rect x='0' y='4' width='38' height='3' fill='%23f0dca8'/><rect x='38' y='4' width='42' height='3' fill='%235fb04a'/><rect x='0' y='7' width='44' height='4' fill='%23d4b76e'/><rect x='44' y='7' width='36' height='4' fill='%234f9a3e'/><rect x='0' y='11' width='36' height='5' fill='%23a8864a'/><rect x='36' y='11' width='44' height='5' fill='%232e6b27'/><g fill='%23a8864a'><rect x='3' y='5' width='1' height='1'/><rect x='9' y='4' width='1' height='1'/><rect x='14' y='6' width='2' height='1'/><rect x='20' y='5' width='1' height='1'/><rect x='26' y='4' width='2' height='1'/><rect x='5' y='8' width='2' height='1'/><rect x='12' y='9' width='1' height='1'/><rect x='18' y='8' width='2' height='1'/><rect x='24' y='10' width='1' height='1'/><rect x='30' y='8' width='1' height='1'/></g><g fill='%237d5d2e'><rect x='2' y='12' width='1' height='1'/><rect x='8' y='14' width='1' height='1'/><rect x='14' y='12' width='2' height='1'/><rect x='20' y='13' width='1' height='1'/><rect x='26' y='15' width='1' height='1'/><rect x='32' y='12' width='2' height='1'/></g><g fill='%23fff5d6'><rect x='7' y='5' width='1' height='1'/><rect x='22' y='4' width='1' height='1'/></g><g fill='%237ac558'><rect x='34' y='2' width='1' height='2'/><rect x='37' y='1' width='1' height='3'/><rect x='40' y='0' width='1' height='4'/><rect x='43' y='1' width='2' height='3'/><rect x='46' y='2' width='2' height='2'/><rect x='49' y='1' width='1' height='3'/><rect x='52' y='1' width='2' height='3'/><rect x='55' y='2' width='2' height='2'/><rect x='58' y='0' width='1' height='4'/><rect x='60' y='1' width='2' height='3'/><rect x='63' y='2' width='2' height='2'/><rect x='66' y='0' width='2' height='4'/><rect x='69' y='1' width='1' height='3'/><rect x='71' y='3' width='1' height='1'/><rect x='73' y='2' width='2' height='2'/><rect x='76' y='0' width='1' height='4'/><rect x='78' y='1' width='2' height='3'/></g><g fill='%23498f3a'><rect x='40' y='0' width='1' height='4'/><rect x='43' y='1' width='1' height='3'/><rect x='52' y='1' width='1' height='3'/><rect x='66' y='0' width='1' height='4'/><rect x='78' y='1' width='1' height='3'/></g></g><g id='g2s'><rect x='0' y='3' width='38' height='1' fill='%23244a1f'/><rect x='38' y='3' width='42' height='1' fill='%237d5d2e'/><rect x='0' y='4' width='42' height='3' fill='%235fb04a'/><rect x='42' y='4' width='38' height='3' fill='%23f0dca8'/><rect x='0' y='7' width='36' height='4' fill='%234f9a3e'/><rect x='36' y='7' width='44' height='4' fill='%23d4b76e'/><rect x='0' y='11' width='44' height='5' fill='%232e6b27'/><rect x='44' y='11' width='36' height='5' fill='%23a8864a'/><g fill='%237ac558'><rect x='1' y='3' width='1' height='1'/><rect x='3' y='2' width='1' height='2'/><rect x='5' y='1' width='2' height='3'/><rect x='8' y='0' width='1' height='4'/><rect x='10' y='2' width='2' height='2'/><rect x='13' y='1' width='1' height='3'/><rect x='15' y='0' width='2' height='4'/><rect x='18' y='3' width='1' height='1'/><rect x='20' y='2' width='1' height='2'/><rect x='22' y='0' width='2' height='4'/><rect x='25' y='1' width='1' height='3'/><rect x='27' y='2' width='2' height='2'/><rect x='30' y='0' width='1' height='4'/><rect x='32' y='1' width='2' height='3'/><rect x='35' y='2' width='1' height='2'/><rect x='37' y='0' width='1' height='4'/><rect x='40' y='2' width='1' height='2'/><rect x='43' y='1' width='1' height='3'/><rect x='45' y='2' width='1' height='2'/></g><g fill='%23498f3a'><rect x='6' y='1' width='1' height='3'/><rect x='15' y='0' width='1' height='4'/><rect x='22' y='0' width='1' height='4'/><rect x='32' y='1' width='1' height='3'/><rect x='37' y='0' width='1' height='4'/></g><g fill='%23a8864a'><rect x='49' y='5' width='1' height='1'/><rect x='53' y='4' width='1' height='1'/><rect x='58' y='6' width='2' height='1'/><rect x='64' y='5' width='1' height='1'/><rect x='70' y='4' width='1' height='1'/><rect x='75' y='6' width='2' height='1'/><rect x='55' y='8' width='1' height='1'/><rect x='61' y='9' width='2' height='1'/><rect x='67' y='8' width='1' height='1'/><rect x='73' y='10' width='2' height='1'/></g><g fill='%237d5d2e'><rect x='50' y='12' width='1' height='1'/><rect x='56' y='14' width='1' height='1'/><rect x='62' y='15' width='2' height='1'/><rect x='68' y='13' width='1' height='1'/><rect x='74' y='12' width='1' height='1'/></g><g fill='%23fff5d6'><rect x='51' y='5' width='1' height='1'/><rect x='67' y='4' width='1' height='1'/><rect x='76' y='5' width='1' height='1'/></g></g></defs><use href='%23s' x='0'/><use href='%23s' x='80'/><use href='%23s' x='160'/><use href='%23s2g' x='240'/><use href='%23g' x='320'/><use href='%23g' x='400'/><use href='%23g' x='480'/><use href='%23g2s' x='560'/></svg>");
    background-repeat: repeat-x;
    background-size: 2560px 64px;
    image-rendering: pixelated;
    animation: scroll calc(5.35s / var(--speed, 1)) linear infinite;
    pointer-events: none;
    z-index: 1;
}

@keyframes scroll {
    from { background-position: 0 0; }
    to   { background-position: -2560px 0; }
}

.char {
    position: absolute;
    left: 60px;
    bottom: 50px;
    width: 150px;
    height: 83px;
    background-image: url("img/Horse_Run_white.png");
    background-repeat: no-repeat;
    background-size: 900px 83px; /* 6 frames * 150px scaled */
    background-position: 0 0;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
    transform: scaleX(-1);
    animation: gallop 0.55s steps(6) infinite;
    z-index: 4;
}

@keyframes gallop {
    from { background-position: 0 0; }
    to   { background-position: -900px 0; }
}

.char.jump {
    animation: gallop 0.55s steps(6) infinite, jump 0.6s cubic-bezier(.3,.8,.4,1);
}

/* peak 160 + extended hangtime (35–68%) clears goose (h=72) without horse
   leaving the arena visually. paired w/ hitbox shrink (cRect.bottom-16). */
@keyframes jump {
    0%   { bottom: 50px; }
    35%  { bottom: 160px; }
    68%  { bottom: 160px; }
    100% { bottom: 50px; }
}

.char.idle {
    background-image: url("img/Horse_Idle_white.png");
    background-size: 1950px 83px; /* 13 frames * 150px scaled */
    animation: idle 1.2s steps(13) infinite;
}

@keyframes idle {
    from { background-position: 0 0; }
    to   { background-position: -1950px 0; }
}

/* show-jumping fence: two posts + two striped poles + filler box */
.obstacle {
    position: absolute;
    bottom: 50px;
    left: 100%;
    width: 36px;
    height: 70px;
    image-rendering: pixelated;
    z-index: 3;
    /* 1-px ink outline so brush/goose/etc never camouflage on matching terrain
       (e.g. brush-green on grass-green at score ~520) */
    filter:
        drop-shadow(1px 0 0 var(--ink))
        drop-shadow(-1px 0 0 var(--ink))
        drop-shadow(0 1px 0 var(--ink))
        drop-shadow(0 -1px 0 var(--ink));
}

.obstacle.pig       { width: 56px; height: 40px; }
.obstacle.goose     { width: 48px; height: 72px; }
.obstacle.wall      { width: 32px; height: 52px; }
.obstacle.brush     { width: 44px; height: 32px; }
.obstacle.water     { width: 60px; height: 22px; }
.obstacle.liverpool { width: 52px; height: 56px; }

/* obstacle dur computed in JS (syncObstacleSpeed) so px/s exactly matches terrain (478) at any viewport */
.obstacle.run { animation: obstacle calc(var(--obstacle-dur, 1.67s) / var(--speed, 1)) linear infinite; }

/* trail: parallel obstacle delayed ~0.7s so an "oxer" forces 2 quick jumps */
.obstacle.trail { display: none; }
.obstacle.trail.show { display: block; }
.obstacle.trail.run {
    animation: obstacle calc(var(--obstacle-dur, 1.67s) / var(--speed, 1)) linear infinite;
    animation-delay: calc(var(--obstacle-dur, 1.67s) * 0.42 / var(--speed, 1));
}

@keyframes obstacle {
    from { left: 100%; }
    to   { left: -80px; }
}

/* show only sprite for active type — fence + oxer keep DOM post/pole/filler */
.obstacle:not(.fence):not(.oxer) > .post,
.obstacle:not(.fence):not(.oxer) > .pole,
.obstacle:not(.fence):not(.oxer) > .filler { display: none; }
.obstacle .sprite { display: none; position: absolute; inset: 0; background-repeat: no-repeat; background-size: contain; background-position: bottom center; image-rendering: pixelated; }
.obstacle.pig .pig-sprite { display: block; }
.obstacle.goose .goose-sprite { display: block; }
.obstacle.wall .wall-sprite { display: block; }
.obstacle.brush .brush-sprite { display: block; }
.obstacle.water .water-sprite { display: block; }
.obstacle.liverpool .liverpool-sprite { display: block; }

/* oxer + trail: blue striped poles instead of red */
.obstacle.oxer .pole,
.obstacle.trail .pole {
    background: repeating-linear-gradient(90deg,
        #3a78c2 0 8px,
        var(--pole-light) 8px 16px);
}

.pig-sprite {
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 28 20' shape-rendering='crispEdges'><rect x='6' y='15' width='2' height='5' fill='%23d77a8a'/><rect x='11' y='15' width='2' height='5' fill='%23d77a8a'/><rect x='17' y='15' width='2' height='5' fill='%23d77a8a'/><rect x='22' y='15' width='2' height='5' fill='%23d77a8a'/><rect x='4' y='6' width='20' height='9' fill='%23f5b3c0'/><rect x='3' y='8' width='1' height='5' fill='%23f5b3c0'/><rect x='4' y='14' width='20' height='1' fill='%23d77a8a'/><rect x='22' y='7' width='6' height='7' fill='%23f5b3c0'/><rect x='26' y='10' width='2' height='3' fill='%23d77a8a'/><rect x='26' y='10' width='1' height='1' fill='%23222'/><rect x='27' y='12' width='1' height='1' fill='%23222'/><rect x='22' y='5' width='2' height='2' fill='%23d77a8a'/><rect x='24' y='9' width='1' height='1' fill='%23222'/><rect x='2' y='6' width='1' height='1' fill='%23f5b3c0'/><rect x='1' y='7' width='1' height='2' fill='%23f5b3c0'/><rect x='2' y='9' width='1' height='1' fill='%23f5b3c0'/></svg>");
}
.goose-sprite {
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 36' shape-rendering='crispEdges'><rect x='8' y='30' width='2' height='6' fill='%23ff8c1a'/><rect x='14' y='30' width='2' height='6' fill='%23ff8c1a'/><rect x='6' y='35' width='4' height='1' fill='%23ff8c1a'/><rect x='14' y='35' width='4' height='1' fill='%23ff8c1a'/><rect x='4' y='18' width='16' height='12' fill='%23fafafa'/><rect x='3' y='20' width='1' height='8' fill='%23fafafa'/><rect x='20' y='20' width='1' height='8' fill='%23fafafa'/><rect x='2' y='22' width='2' height='3' fill='%23fafafa'/><rect x='14' y='8' width='4' height='12' fill='%23fafafa'/><rect x='12' y='4' width='8' height='6' fill='%23fafafa'/><rect x='20' y='6' width='3' height='3' fill='%23ff8c1a'/><rect x='17' y='6' width='1' height='1' fill='%23000'/><rect x='6' y='22' width='10' height='1' fill='%23d8d8d8'/><rect x='8' y='25' width='8' height='1' fill='%23d8d8d8'/></svg>");
}

.wall-sprite {
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 26' shape-rendering='crispEdges'><rect x='0' y='0' width='2' height='26' fill='%237a4a2a'/><rect x='14' y='0' width='2' height='26' fill='%237a4a2a'/><rect x='1' y='0' width='1' height='26' fill='%23a87650'/><rect x='14' y='0' width='1' height='26' fill='%23a87650'/><rect x='0' y='0' width='16' height='1' fill='%23e0282a'/><rect x='2' y='2' width='12' height='4' fill='%23c44d3d'/><rect x='7' y='2' width='1' height='4' fill='%237a2a20'/><rect x='2' y='6' width='12' height='1' fill='%237a2a20'/><rect x='2' y='7' width='12' height='4' fill='%23c44d3d'/><rect x='4' y='7' width='1' height='4' fill='%237a2a20'/><rect x='10' y='7' width='1' height='4' fill='%237a2a20'/><rect x='2' y='11' width='12' height='1' fill='%237a2a20'/><rect x='2' y='12' width='12' height='4' fill='%23c44d3d'/><rect x='7' y='12' width='1' height='4' fill='%237a2a20'/><rect x='2' y='16' width='12' height='1' fill='%237a2a20'/><rect x='2' y='17' width='12' height='4' fill='%23c44d3d'/><rect x='4' y='17' width='1' height='4' fill='%237a2a20'/><rect x='10' y='17' width='1' height='4' fill='%237a2a20'/><rect x='2' y='21' width='12' height='1' fill='%237a2a20'/><rect x='2' y='22' width='12' height='4' fill='%23c44d3d'/><rect x='2' y='2' width='12' height='1' fill='%23db6d5d' opacity='0.7'/></svg>");
}

.brush-sprite {
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 22 16' shape-rendering='crispEdges'><rect x='0' y='13' width='22' height='3' fill='%235a3a1a'/><rect x='0' y='12' width='22' height='1' fill='%233a2410'/><rect x='0' y='15' width='22' height='1' fill='%233a2410'/><g fill='%233d8a3a'><rect x='1' y='4' width='3' height='9'/><rect x='4' y='2' width='4' height='11'/><rect x='8' y='3' width='3' height='10'/><rect x='11' y='1' width='4' height='12'/><rect x='15' y='3' width='3' height='10'/><rect x='18' y='4' width='3' height='9'/></g><g fill='%235fb04a'><rect x='2' y='5' width='2' height='2'/><rect x='5' y='3' width='2' height='2'/><rect x='9' y='4' width='1' height='2'/><rect x='12' y='2' width='2' height='2'/><rect x='16' y='4' width='1' height='2'/><rect x='19' y='5' width='2' height='2'/></g><g fill='%23244a1f'><rect x='3' y='10' width='2' height='2'/><rect x='7' y='11' width='2' height='2'/><rect x='13' y='10' width='2' height='2'/><rect x='17' y='11' width='2' height='2'/></g><g fill='%237ac558'><rect x='6' y='2' width='1' height='1'/><rect x='13' y='1' width='1' height='1'/><rect x='17' y='3' width='1' height='1'/></g></svg>");
}

.water-sprite {
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 30 11' shape-rendering='crispEdges'><rect x='0' y='0' width='30' height='2' fill='%23f5efd9'/><rect x='0' y='9' width='30' height='2' fill='%23f5efd9'/><rect x='0' y='2' width='30' height='7' fill='%233a8fc2'/><rect x='2' y='4' width='4' height='1' fill='%237cc5ff'/><rect x='10' y='3' width='6' height='1' fill='%237cc5ff'/><rect x='20' y='5' width='5' height='1' fill='%237cc5ff'/><rect x='5' y='6' width='3' height='1' fill='%23cfe9ff'/><rect x='14' y='7' width='4' height='1' fill='%23cfe9ff'/><rect x='22' y='4' width='3' height='1' fill='%23cfe9ff'/><rect x='8' y='5' width='1' height='1' fill='%232e6090'/><rect x='18' y='4' width='1' height='1' fill='%232e6090'/><rect x='25' y='6' width='1' height='1' fill='%232e6090'/><rect x='0' y='0' width='1' height='11' fill='%23b8a373'/><rect x='29' y='0' width='1' height='11' fill='%23b8a373'/><rect x='1' y='0' width='2' height='2' fill='%23e0282a'/><rect x='27' y='0' width='2' height='2' fill='%23e0282a'/></svg>");
}

.liverpool-sprite {
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 26 28' shape-rendering='crispEdges'><rect x='0' y='0' width='3' height='24' fill='%23fff5d6'/><rect x='2' y='0' width='1' height='24' fill='%23b8a373'/><rect x='23' y='0' width='3' height='24' fill='%23fff5d6'/><rect x='25' y='0' width='1' height='24' fill='%23b8a373'/><rect x='0' y='0' width='3' height='2' fill='%23e0282a'/><rect x='23' y='0' width='3' height='2' fill='%23e0282a'/><rect x='3' y='0' width='2' height='2' fill='%23e0282a'/><rect x='21' y='0' width='2' height='2' fill='%23e0282a'/><rect x='3' y='5' width='3' height='3' fill='%23fff5d6'/><rect x='6' y='5' width='3' height='3' fill='%233a78c2'/><rect x='9' y='5' width='3' height='3' fill='%23fff5d6'/><rect x='12' y='5' width='3' height='3' fill='%233a78c2'/><rect x='15' y='5' width='3' height='3' fill='%23fff5d6'/><rect x='18' y='5' width='3' height='3' fill='%233a78c2'/><rect x='21' y='5' width='2' height='3' fill='%23fff5d6'/><rect x='3' y='4' width='20' height='1' fill='%23000' opacity='0.25'/><rect x='3' y='8' width='20' height='1' fill='%23000' opacity='0.4'/><rect x='3' y='14' width='20' height='2' fill='%23c44d3d'/><rect x='3' y='13' width='20' height='1' fill='%23000' opacity='0.25'/><rect x='3' y='16' width='20' height='1' fill='%23000' opacity='0.4'/><rect x='0' y='23' width='26' height='1' fill='%23f5efd9'/><rect x='0' y='24' width='26' height='4' fill='%233a8fc2'/><rect x='3' y='25' width='4' height='1' fill='%237cc5ff'/><rect x='12' y='25' width='5' height='1' fill='%237cc5ff'/><rect x='20' y='25' width='3' height='1' fill='%237cc5ff'/><rect x='6' y='26' width='3' height='1' fill='%23cfe9ff'/><rect x='15' y='26' width='4' height='1' fill='%23cfe9ff'/><rect x='0' y='27' width='26' height='1' fill='%232e6090'/></svg>");
}

.post {
    position: absolute;
    width: 6px;
    height: 70px;
    background:
        linear-gradient(to right,
            var(--post-shadow) 0 2px,
            var(--post-light) 2px 6px,
            var(--post-shadow) 6px 8px);
    border-top: 4px solid var(--flag);
}
.post-l { left: 0; }
.post-r { right: 0; }

/* triangular flag pixel on top of each post */
.post::before {
    content: "";
    position: absolute;
    top: -4px;
    left: 6px;
    width: 4px;
    height: 4px;
    background: var(--flag);
}
.post-r::before { left: -4px; }

.pole {
    position: absolute;
    left: 2px;
    right: 2px;
    height: 8px;
    background:
        repeating-linear-gradient(90deg,
            var(--pole-stripe) 0 8px,
            var(--pole-light) 8px 16px);
    border-top: 2px solid rgba(0,0,0,0.25);
    border-bottom: 2px solid rgba(0,0,0,0.4);
}
.pole-top { top: 16px; }
.pole-mid { top: 36px; }

/* solid wooden filler at the base */
.filler {
    position: absolute;
    bottom: 0;
    left: 4px;
    right: 4px;
    height: 16px;
    background:
        linear-gradient(to bottom,
            var(--filler) 0 6px,
            var(--filler-shadow) 6px 8px,
            var(--filler) 8px 14px,
            var(--filler-shadow) 14px 16px);
    border-left: 2px solid var(--filler-shadow);
    border-right: 2px solid var(--filler-shadow);
}

.hud {
    position: absolute;
    top: 14px;
    left: 14px;
    right: 14px;
    display: flex;
    justify-content: space-between;
    gap: 12px;
    font-family: "Press Start 2P", "Pixelify Sans", "Courier New", monospace;
    font-size: 10px;
    color: var(--sgt-navy);
    text-transform: uppercase;
    letter-spacing: 1px;
    line-height: 1;
    z-index: 4;
    pointer-events: none;
    image-rendering: pixelated;
}

.hud > div {
    display: flex;
    align-items: center;
    gap: 8px;
    background: #fff;
    padding: 7px 9px;
    box-shadow:
        0 0 0 2px var(--sgt-navy),
        0 0 0 3px var(--pixel-gold),
        0 0 0 5px var(--sgt-navy),
        3px 3px 0 5px rgba(15,31,61,0.35);
}

.hud span {
    display: inline-block;
    padding: 3px 6px;
    background: var(--sgt-navy);
    color: var(--pixel-gold);
    box-shadow: inset 0 0 0 1px var(--pixel-gold-dark);
    font-size: 11px;
    min-width: 4ch;
    text-align: right;
    font-variant-numeric: tabular-nums;
    font-feature-settings: "tnum" 1;
}

/* ===== retro pixel-art overlay card ===== */
:root {
    --pixel-gold: #7cc5ff;
    --pixel-gold-dark: #3b8fd6;
}

.overlay {
    position: absolute;
    inset: 0;
    background: transparent;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    z-index: 5;
    transition: opacity 0.2s;
    image-rendering: pixelated;
    overflow: visible;
}

/* Dim layer — clipped to .game bounds so card can escape without
   the diagonal hatch leaking outside the canvas. */
.overlay::before {
    content: "";
    position: absolute;
    inset: 0;
    background:
        repeating-linear-gradient(45deg,
            rgba(0,0,0,0.55) 0 4px,
            rgba(0,0,0,0.45) 4px 8px);
    pointer-events: none;
    z-index: 0;
}

.overlay.hidden { opacity: 0; pointer-events: none; }

.card {
    position: relative;
    background: #fff;
    color: var(--sgt-navy);
    padding: 38px 28px 24px;
    text-align: center;
    max-width: 320px;
    font-family: "VT323", "Courier New", monospace;
    /* stepped pixel frame: navy → gold → navy hairline */
    box-shadow:
        0 0 0 4px var(--sgt-navy),
        0 0 0 6px var(--pixel-gold),
        0 0 0 10px var(--sgt-navy),
        8px 8px 0 10px rgba(15,31,61,0.45);
    image-rendering: pixelated;
    z-index: 1;
    /* Lift card so its top edge escapes the game canvas, popping out
       of the frame for a true modal feel. .game-stage clips gameplay,
       .game has overflow:visible so the card can extend above. */
    transform: translateY(-44px);
}

/* Embed mode (welcome iframe): masthead sits directly above .game
   inside a 510px iframe — lifting the card would clip it on the
   masthead. Keep card centered in canvas. */
body.embed .card { transform: none; }

/* navy + gold checker ribbon across top of card */
.card::before {
    content: "";
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 14px;
    background:
        linear-gradient(var(--sgt-navy), var(--sgt-navy)),
        repeating-linear-gradient(90deg,
            var(--pixel-gold) 0 8px,
            var(--sgt-navy-dark) 8px 16px);
    background-size: 100% 6px, 100% 8px;
    background-position: 0 0, 0 6px;
    background-repeat: no-repeat, repeat-x;
    border-bottom: 2px solid var(--sgt-navy-dark);
}

.card h2 {
    margin: 8px 0 14px;
    font-family: "Press Start 2P", "Pixelify Sans", "Courier New", monospace;
    font-size: 22px;
    font-weight: 400;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: var(--sgt-navy);
    text-shadow:
        2px 2px 0 var(--pixel-gold),
        4px 4px 0 var(--sgt-navy-dark);
    line-height: 1.2;
}

.card p {
    margin: 0 0 22px;
    font-family: "Press Start 2P", "Pixelify Sans", "Courier New", monospace;
    font-size: 11px;
    color: var(--sgt-navy);
    letter-spacing: 1px;
    text-transform: uppercase;
    line-height: 2;
}

.score-num {
    display: inline-block;
    margin-left: 6px;
    padding: 4px 10px;
    font-family: "Press Start 2P", "Pixelify Sans", "Courier New", monospace;
    font-size: 20px;
    color: var(--pixel-gold);
    background: var(--sgt-navy);
    box-shadow:
        inset 0 0 0 2px var(--pixel-gold-dark),
        2px 2px 0 0 var(--sgt-navy-dark);
    vertical-align: middle;
    letter-spacing: 0;
    /* Reserve room for up to 4 digits + lock glyph widths so any
       digit combination renders identical (Pixelify Sans fallback is
       proportional). */
    min-width: 4ch;
    text-align: center;
    font-variant-numeric: tabular-nums;
    font-feature-settings: "tnum" 1;
    box-sizing: content-box;
}

button {
    background: var(--sgt-navy);
    color: #fff;
    border: 0;
    padding: 12px 22px;
    font-family: "Press Start 2P", "Pixelify Sans", "Courier New", monospace;
    font-size: 12px;
    font-weight: 400;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    cursor: pointer;
    /* permanent gold inner border + hard offset shadow */
    box-shadow:
        inset 0 0 0 2px var(--pixel-gold),
        0 0 0 3px var(--sgt-navy-dark),
        4px 4px 0 3px var(--sgt-navy-dark);
    transition: transform 0.08s, box-shadow 0.08s, background 0.12s;
    image-rendering: pixelated;
}
button:hover {
    background: var(--sgt-navy-light);
    transform: translate(-1px, -1px);
    box-shadow:
        inset 0 0 0 2px var(--pixel-gold),
        0 0 0 3px var(--sgt-navy-dark),
        5px 5px 0 3px var(--sgt-navy-dark);
}
button:active {
    transform: translate(3px, 3px);
    box-shadow:
        inset 0 0 0 2px var(--pixel-gold),
        0 0 0 3px var(--sgt-navy-dark),
        1px 1px 0 3px var(--sgt-navy-dark);
}
button:focus-visible {
    outline: 3px solid var(--pixel-gold);
    outline-offset: 4px;
}

/* Share row: hidden until game over */
.share-row { display: none; }
.overlay.crashed .share-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-top: 18px;
    flex-wrap: wrap;
}
.share-btn {
    background: var(--pixel-gold);
    color: var(--sgt-navy);
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    font-family: "Press Start 2P", "Pixelify Sans", "Courier New", monospace;
    font-size: 10px;
    letter-spacing: 1.2px;
    text-transform: uppercase;
    box-shadow:
        inset 0 0 0 2px var(--sgt-navy),
        0 0 0 3px var(--sgt-navy-dark),
        4px 4px 0 3px var(--sgt-navy-dark);
    image-rendering: pixelated;
}
.share-btn:hover {
    background: #ffd96a;
    transform: translate(-1px, -1px);
    box-shadow:
        inset 0 0 0 2px var(--sgt-navy),
        0 0 0 3px var(--sgt-navy-dark),
        5px 5px 0 3px var(--sgt-navy-dark);
}
.share-btn:active {
    transform: translate(3px, 3px);
    box-shadow:
        inset 0 0 0 2px var(--sgt-navy),
        0 0 0 3px var(--sgt-navy-dark),
        1px 1px 0 3px var(--sgt-navy-dark);
}
.share-icon {
    width: 16px; height: 16px;
    flex: 0 0 16px;
    image-rendering: pixelated;
}
.share-toast {
    display: none;
    font-family: "Press Start 2P", "Pixelify Sans", "Courier New", monospace;
    font-size: 9px;
    color: var(--sgt-navy);
    background: #fff;
    padding: 4px 8px;
    box-shadow: inset 0 0 0 2px var(--sgt-navy), 2px 2px 0 var(--sgt-navy-dark);
}
.share-row.copied .share-toast { display: inline-block; }

/* CTA: hidden by default, shown only on game-over */
.cta { display: none; }
.overlay.crashed .cta {
    display: block;
    margin-top: 22px;
    padding-top: 18px;
    border-top: 2px dashed var(--sgt-navy);
}
.cta-btn {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    background: var(--pixel-gold);
    color: var(--sgt-navy);
    text-decoration: none;
    padding: 10px 16px;
    font-family: "Press Start 2P", "Pixelify Sans", "Courier New", monospace;
    font-size: 10px;
    letter-spacing: 1.2px;
    text-transform: uppercase;
    box-shadow:
        inset 0 0 0 2px var(--sgt-navy),
        0 0 0 3px var(--sgt-navy-dark),
        4px 4px 0 3px var(--sgt-navy-dark);
    image-rendering: pixelated;
    transition: transform 0.08s, box-shadow 0.08s;
}
/* pixel-art arrow drawn as inline SVG (matches font weight) */
.cta-btn::after {
    content: "";
    width: 18px;
    height: 14px;
    background: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 9 7' shape-rendering='crispEdges' fill='%23192F5B'><rect x='0' y='3' width='9' height='1'/><rect x='5' y='0' width='1' height='7'/><rect x='6' y='1' width='1' height='5'/><rect x='7' y='2' width='1' height='3'/></svg>") no-repeat center / contain;
    image-rendering: pixelated;
    animation: arrow-nudge 1.2s ease-in-out infinite;
}
@keyframes arrow-nudge {
    0%, 100% { transform: translateX(0); }
    50%      { transform: translateX(3px); }
}
.cta-btn:hover {
    transform: translate(-1px, -1px);
    box-shadow:
        inset 0 0 0 2px var(--sgt-navy),
        0 0 0 3px var(--sgt-navy-dark),
        5px 5px 0 3px var(--sgt-navy-dark);
}
.cta-btn:active {
    transform: translate(3px, 3px);
    box-shadow:
        inset 0 0 0 2px var(--sgt-navy),
        0 0 0 3px var(--sgt-navy-dark),
        1px 1px 0 3px var(--sgt-navy-dark);
}
.shake { animation: shake 0.3s; }
@keyframes shake {
    0%,100% { transform: translateX(0); }
    25% { transform: translateX(-6px); }
    75% { transform: translateX(6px); }
}

/* obstacle bumped by horse: tumbles forward (in horse travel dir) + fades */
.obstacle.knocked {
    animation: knock 0.55s cubic-bezier(.3,.6,.4,1) forwards;
    transform-origin: 50% 100%;
}
@keyframes knock {
    0%   { transform: translate(0, 0) rotate(0deg);              opacity: 1; }
    40%  { transform: translate(36px, -34px) rotate(28deg);      opacity: 1; }
    100% { transform: translate(90px, 30px) rotate(70deg);       opacity: 0; }
}

/* Countdown: 3,2,1,GO over still-galloping horse before obstacles spawn */
.countdown {
    position: absolute;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    z-index: 6;
    font-family: "Press Start 2P", "Pixelify Sans", monospace;
    font-size: 96px;
    line-height: 1;
    color: var(--pixel-gold, #ffd966);
    text-shadow:
        0 4px 0 var(--sgt-navy-dark, #0e1d3d),
        0 0 14px rgba(0, 0, 0, 0.55);
    -webkit-text-stroke: 3px var(--sgt-navy, #192f5b);
    paint-order: stroke fill;
}
.countdown.show {
    display: flex;
    animation: countdown-pop 0.85s ease-out forwards;
}
.countdown.go {
    font-size: 72px;
    color: var(--pixel-blue, #4fc3f7);
}
@keyframes countdown-pop {
    0%   { transform: scale(0.4); opacity: 0; }
    25%  { transform: scale(1.15); opacity: 1; }
    55%  { transform: scale(1);    opacity: 1; }
    100% { transform: scale(1.4);  opacity: 0; }
}

@media (max-width: 520px) {
    .countdown { font-size: 64px; }
    .countdown.go { font-size: 48px; }
}

/* ===== Mobile / portrait sizing ===== */
@media (max-width: 520px) {
    .game { height: 320px; }
    .hud {
        top: 10px; left: 10px; right: 10px;
        font-size: 9px;
        gap: 8px;
    }
    .hud > div { padding: 5px 7px; }
    .hud span { font-size: 10px; padding: 2px 5px; }

    .card {
        padding: 32px 20px 20px;
        max-width: 280px;
        transform: translateY(-28px);
    }
    .card h2 {
        font-size: 16px;
        margin: 6px 0 10px;
        text-shadow:
            2px 2px 0 var(--pixel-gold),
            3px 3px 0 var(--sgt-navy-dark);
    }
    .card p {
        font-size: 9px;
        margin: 0 0 16px;
        line-height: 1.8;
    }
    .score-num { font-size: 16px; padding: 3px 8px; }
    button { font-size: 10px; padding: 10px 18px; letter-spacing: 1px; }
    .share-btn { font-size: 8px; padding: 8px 12px; letter-spacing: 1px; gap: 6px; }
    .share-icon { width: 13px; height: 13px; flex-basis: 13px; }
    .share-toast { font-size: 8px; padding: 3px 6px; }
    .overlay.crashed .share-row { margin-top: 14px; gap: 8px; }
    .cta-btn { font-size: 8px; padding: 8px 12px; letter-spacing: 1px; gap: 8px; }
    .cta-btn::after { width: 14px; height: 11px; }
    .overlay.crashed .cta { margin-top: 16px; padding-top: 14px; }

    /* horse smaller so jump arc fits 320px frame */
    .char {
        left: 40px;
        width: 110px; height: 61px;
        background-size: 660px 61px;
    }
    @keyframes gallop { from { background-position: 0 0; } to { background-position: -660px 0; } }
    .char.idle {
        background-size: 1430px 61px;
    }
    @keyframes idle { from { background-position: 0 0; } to { background-position: -1430px 0; } }
}

/* very short viewports (landscape phones): trim more */
@media (max-height: 520px) and (orientation: landscape) {
    body { padding: 6px; min-height: 100dvh; }
    .masthead { margin-bottom: 8px; }
    .title-row { padding: 6px 12px; }
    .masthead h1 .brand { font-size: 9px; }
    .masthead h1 .cup { font-size: 14px; }
    .hint { display: none; }
    .game { height: calc(100dvh - 90px); max-height: 360px; }
}
