/* --- Base --- */

@font-face {
    font-family: 'BoldPixels';
    src: url(/fonts/Boldpixels.ttf), url(/fonts/Boldpixels.otf);
}

html,
body {
    height: 100%;
    margin: 0;
    background-color: #595959;
    /* base dark gray */
    background-size: 4px 4px;
    /* larger = more visible pixel texture */
    image-rendering: pixelated;
    /* keeps pattern crisp */
    color: #f5f5f5;
    font-family: 'BoldPixels', system-ui, sans-serif;
    /* ✅ consistent name */
}


/* Hide via [hidden] everywhere */

[hidden] {
    display: none !important;
}


/* --- Top nav --- */

.topnav {
    display: flex;
    gap: 8px;
    padding: 10px 12px;
    border-bottom: 1px solid #121a2f;
    background: #0e172a;
    position: sticky;
    top: 0;
    z-index: 10;
    min-height: 52px;
    /* used in screen calc */
}

.topnav .tab[aria-current="page"] {
    border-color: #22c55e;
    box-shadow: 0 0 0 2px rgba(34, 197, 94, 0.15) inset;
}


/* --- Screens / layout --- */

.screen {
    min-height: calc(100vh - 52px);
    /* full viewport minus the topnav */
    display: grid;
    place-items: center;
    padding: 16px 16px 64px;
    /* bottom padding so bottomnav doesn't cover content */
}


/* Runs page: disable centering grid from .screen */

#runs.screen {
    display: block;
    /* grid off */
    padding: 16px 16px 80px;
    /* place-items removed; irrelevant when not grid */
}


/* --- Stats panel & map --- */

#stats {
    width: 100%;
    max-width: 540px;
    display: flex;
    flex-direction: column;
    align-items: center;
    font-family: 'BoldPixels', sans-serif;
}

#map {
    width: 100%;
    max-width: 540px;
    height: 40vh;
    margin-top: 12px;
    border-radius: 12px;
    border: 1px solid #121a2f;
    overflow: hidden;
}


/* --- Bottom nav --- */

.bottomnav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    justify-content: space-around;
    align-items: center;
    padding: 10px 12px;
    border-top: 1px solid #121a2f;
    /* ✅ give it a color */
    z-index: 10;
    min-height: 52px;
    font-family: 'BoldPixels', sans-serif;
}


/* --- Retro (GBA-ish) button style --- */

:root {
    --btn-radius: 2px;
    /* sharper corners */
    --btn-pad-y: 21px;
    --btn-pad-x: 34px;
    --btn-font-w: 800;
    --btn-shadow: 0 3px 0 rgba(0, 0, 0, 0.45);
    --btn-shadow-press: 0 1px 0 rgba(0, 0, 0, 0.45);
    /* pixel grid overlay variables */
    --px-grid-size: 3px;
    --px-grid-bright: rgba(255, 255, 255, 0.08);
    --px-grid-opacity: 0.55;
}

@keyframes pulse {
    0%,
    100% {
        box-shadow: 0 0 16px rgba(255, 0, 13, 0.6), 0 0 36px rgba(255, 0, 13, 0.3), 0 3px 0 rgba(0, 0, 0, 0.45);
        filter: brightness(1);
    }
    50% {
        box-shadow: 0 0 32px rgba(255, 0, 13, 0.9), 0 0 60px rgba(255, 0, 13, 0.6), 0 3px 0 rgba(0, 0, 0, 0.45);
        filter: brightness(1.25);
    }
}


/* ===== Primary (Start) ===== */

.btn--primary {
    display: inline-block;
    padding: var(--btn-pad-y) var(--btn-pad-x);
    border-radius: var(--btn-radius);
    border: 2px solid #2e2e2e;
    font-family: 'BoldPixels';
    font-weight: 800;
    font-size: 32px;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    image-rendering: pixelated;
    position: relative;
    z-index: 1;
    color: white;
    background-color: #ff000d;
    background-image: linear-gradient(#ff4d58, #d4000a);
    box-shadow: 0 3px 0 #7d0a0a, 0 4px 0 #3d0303;
    transition: transform 0.1s ease;
    animation: pulse 2.5s ease-in-out infinite;
}

.btn--primary:hover {
    transform: translateY(-1px);
    filter: brightness(1.1);
}

.btn--primary:active {
    transform: translateY(2px);
    filter: brightness(0.9);
    box-shadow: 0 1px 0 #3d0303, inset 0 1px 0 rgba(0, 0, 0, 0.2);
}


/* ===== Success (Stop) ===== */

.btn--success {
    display: inline-block;
    padding: var(--btn-pad-y) var(--btn-pad-x);
    border-radius: var(--btn-radius);
    border: 2px solid #1d5e3a;
    font-family: 'BoldPixels';
    font-weight: 800;
    font-size: 32px;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    image-rendering: pixelated;
    position: relative;
    z-index: 1;
    color: white;
    background-color: #00ff73;
    background-image: linear-gradient(#5fff9b, #00cc5a);
    box-shadow: 0 3px 0 #008b47, 0 4px 0 #004b28;
    transition: transform 0.1s ease;
}

.btn--success:hover {
    filter: brightness(1.1);
    transform: translateY(-1px);
}

.btn--success:active {
    filter: brightness(0.9);
    transform: translateY(2px);
    box-shadow: 0 1px 0 #004b28, inset 0 1px 0 rgba(0, 0, 0, 0.2);
}


/* ===== Nav Buttons ===== */

.btn--nav {
    display: inline-block;
    padding: var(--btn-pad-y) var(--btn-pad-x);
    border-radius: var(--btn-radius);
    border: 2px solid #6b4300;
    font-family: 'BoldPixels';
    font-weight: 800;
    font-size: 32px;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    image-rendering: pixelated;
    position: relative;
    z-index: 1;
    background-color: #ffb100;
    background-image: linear-gradient(#ffd666, #ff9800);
    color: #1a1200;
    text-shadow: 0 1px 0 rgba(255, 255, 255, 0.25);
    box-shadow: 0 3px 0 #b36b00, 0 4px 0 #663b00;
    transition: transform 0.1s ease;
}

.btn--nav:hover {
    filter: brightness(1.1);
    transform: translateY(-1px);
}

.btn--nav:active {
    filter: brightness(0.98);
    transform: translateY(2px);
    box-shadow: 0 1px 0 #663b00, inset 0 1px 0 rgba(0, 0, 0, 0.2);
}


/* ===== Pixel Highlight Grid Overlay ===== */

.btn--primary::after,
.btn--success::after,
.btn--nav::after {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: inherit;
    pointer-events: none;
    mix-blend-mode: screen;
    opacity: var(--px-grid-opacity);
    image-rendering: pixelated;
    background: repeating-linear-gradient(0deg, var(--px-grid-bright) 0 calc(var(--px-grid-size) - 1px), transparent calc(var(--px-grid-size) - 1px) var(--px-grid-size)), repeating-linear-gradient(90deg, var(--px-grid-bright) 0 calc(var(--px-grid-size) - 1px), transparent calc(var(--px-grid-size) - 1px) var(--px-grid-size));
}

.btn--primary:hover::after,
.btn--success:hover::after,
.btn--nav:hover::after {
    opacity: calc(var(--px-grid-opacity) + 0.1);
}

.btn--primary:active::after,
.btn--success:active::after,
.btn--nav:active::after {
    opacity: calc(var(--px-grid-opacity) - 0.2);
}


/* optional: tint grid per button type */

.btn--primary {
    --px-grid-bright: rgba(255, 200, 200, 0.12);
}

.btn--success {
    --px-grid-bright: rgba(210, 255, 220, 0.12);
}

.btn--nav {
    --px-grid-bright: rgba(255, 240, 200, 0.10);
}


/* ====== Run Stats HUD ====== */

#stats .grid {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 14px;
    max-width: 540px;
}

#stats .card {
    position: relative;
    background: #1b1f29;
    /* dark bezel */
    border: 1px solid #2b3140;
    /* crisp frame */
    border-radius: 14px;
    padding: 12px 14px;
    box-shadow: 0 10px 24px rgba(0, 0, 0, 0.35), 0 1px 0 rgba(255, 255, 255, 0.06) inset, 0 -1px 0 rgba(0, 0, 0, 0.55) inset;
    overflow: hidden;
}

#stats .card::before {
    content: "";
    position: absolute;
    inset: 8px;
    border-radius: 10px;
    background: radial-gradient(120% 140% at 30% 15%, rgba(255, 210, 140, 0.55) 0%, rgba(255, 160, 40, 0.45) 35%, rgba(255, 140, 0, 0.35) 60%, rgba(255, 120, 0, 0.25) 80%, rgba(255, 120, 0, 0.18) 100%), linear-gradient(180deg, #ffb356, #ff9a2b);
    box-shadow: 0 0 22px rgba(255, 140, 0, 0.45) inset, 0 0 54px rgba(255, 140, 0, 0.28) inset, 0 0 26px rgba(255, 120, 0, 0.22);
    pointer-events: none;
}

#stats .card::after {
    content: "";
    position: absolute;
    inset: 8px;
    border-radius: 10px;
    background: repeating-linear-gradient(180deg, rgba(0, 0, 0, 0.08) 0 1px, rgba(0, 0, 0, 0.00) 1px 3px);
    mix-blend-mode: multiply;
    opacity: 0.32;
    animation: hudScan 6s linear infinite;
    pointer-events: none;
}

@keyframes hudScan {
    0% {
        background-position: 0 0;
        opacity: 0.30;
    }
    50% {
        background-position: 0 8px;
        opacity: 0.36;
    }
    100% {
        background-position: 0 0;
        opacity: 0.30;
    }
}

#stats .card>* {
    position: relative;
    z-index: 1;
}


/* Final/kept versions of label/value (earlier duplicates removed) */

#stats .label {
    display: block;
    font-size: 12px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: rgba(40, 22, 0, 0.85);
    text-shadow: 0 1px 0 rgba(255, 210, 150, 0.35);
    margin-bottom: 6px;
}

#stats .value {
    display: block;
    font-family: 'BoldPixels', sans-serif;
    font-weight: 800;
    font-size: 34px;
    line-height: 1.1;
    color: #1b0e00;
    text-shadow: 0 1px 0 rgba(255, 190, 120, 0.5), 0 -1px 0 rgba(0, 0, 0, 0.15);
}

@media (max-width: 380px) {
    #stats .value {
        font-size: 30px;
    }
}


/* ====== Runs list ====== */

#runsList {
    display: block !important;
    /* parent is normal block */
    width: 100%;
    max-width: 540px;
    margin: 0 auto;
}

#runsList>* {
    display: block !important;
    width: 100% !important;
    box-sizing: border-box;
    float: none !important;
    /* defeat legacy float layouts */
    flex: initial !important;
    /* defeat flex child sizing */
    white-space: normal !important;
    /* defeat nowrap rows */
}


/* Actions row (single, consolidated block) */

.run-actions {
    display: flex;
    gap: 10px;
    margin-top: 10px;
}

.run-actions .tiny,
.run-card .run-actions .tiny,
.run-card .run-actions a.tiny,
.run-card .run-actions button.tiny {
    display: inline-block;
    padding: 8px 12px;
    font-size: 14px;
    line-height: 1;
    border: 1px solid #2b3140;
    border-radius: 10px;
    background: #1a1a1a;
    color: #f5f5f5;
    text-decoration: none;
    cursor: pointer;
}

.run-actions .tiny:hover,
.run-card .run-actions .tiny:hover {
    filter: brightness(1.1);
}

.run-actions .tiny.danger,
.run-card .run-actions .tiny.danger,
.run-card .run-actions button.tiny.danger {
    border-color: #7f1d1d;
    background: #3a1111;
    color: #ffdede;
}


/* Engraved top banner */


/* === Raised Top Banner (skeuomorphic lifted look) === */

.engraved-banner {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 64px;
    padding: 10px 16px;
    /* same gray palette */
    background: linear-gradient(180deg, #6e6e6e 0%, #595959 60%, #4e4e4e 100%), repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.02) 0 1px, transparent 1px 4px);
    /* raised outer highlights instead of inset */
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.4), /* bottom drop shadow = lift */
    0 -2px 2px rgba(255, 255, 255, 0.15), /* top rim highlight */
    0 6px 12px rgba(0, 0, 0, 0.25);
    /* ambient depth */
    border-top: 1px solid rgba(255, 255, 255, 0.15);
    border-bottom: 1px solid rgba(0, 0, 0, 0.65);
}


/* === Raised Title (embossed text illusion) === */

.engraved-title {
    margin: 0;
    font-family: 'BoldPixels', system-ui, sans-serif;
    font-weight: 800;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    font-size: clamp(20px, 5vw, 36px);
    color: #595959;
    /* reversed shadow directions (light top, dark bottom) */
    text-shadow: 0 -1px 0 rgba(255, 255, 255, 0.7), /* top highlight */
    0 1px 0 rgba(0, 0, 0, 0.75), /* bottom depth */
    -1px 0 0 rgba(255, 255, 255, 0.25), /* left highlight */
    1px 0 0 rgba(0, 0, 0, 0.5);
    /* right depth */
    position: relative;
}


/* optional gloss sheen across the top edge */

.engraved-title::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 40%;
    background: linear-gradient( to bottom, rgba(255, 255, 255, 0.18), transparent 100%);
    pointer-events: none;
}

.engraved-title::after {
    content: "";
    position: absolute;
    inset: 0;
    mix-blend-mode: multiply;
    pointer-events: none;
    /* a super subtle inner gradient, darker at the top */
    background: linear-gradient(to bottom, rgba(0, 0, 0, 0.25) 0%, rgba(0, 0, 0, 0.10) 40%, transparent 100%);
    opacity: .35;
}


/* Optional right/left slot items inside the banner */

.engraved-slot {
    margin-left: auto;
    color: #cfd8ff;
    font-family: 'BoldPixels', system-ui, sans-serif;
    font-size: 14px;
    text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.7), 0 1px 0 rgba(255, 255, 255, 0.18);
}


/* If you keep .topnav, you can nest it inside the banner for tabs */

.engraved-banner .topnav {
    margin-top: 6px;
    border: 0;
    background: transparent;
    box-shadow: none;
    min-height: unset;
    gap: 10px;
    justify-content: center;
}


/* =====  animated scanlines on HUD cards (override) ===== */

:root {
    /* dial these to taste */
    --hud-scanline-size: 4px;
    /* distance between lines */
    --hud-scanline-line: rgba(0, 0, 0, 0.22);
    /* line darkness */
    --hud-scanline-opacity: .55;
    /* overall opacity */
    --hud-scan-speed: 3s;
    /* slower = larger number */
}


/* Make sure card is a positioning context */

#stats .card {
    position: relative;
    overflow: hidden;
}


/* Put the scanlines on ::after and ensure they win */

#stats .card::after {
    content: "";
    position: absolute;
    inset: 8px;
    /* match your inner bezel inset */
    border-radius: 10px;
    /* match inner radius */
    pointer-events: none;
    mix-blend-mode: multiply;
    image-rendering: pixelated;
    opacity: var(--hud-scanline-opacity);
    z-index: 0;
    /* stays under text; your card > * uses z-index:1 */
    will-change: background-position;
    /* crisp horizontal lines that scroll vertically */
    background: repeating-linear-gradient( 180deg, var(--hud-scanline-line) 0 1px, transparent 1px var(--hud-scanline-size));
    /* IMPORTANT: name is different to avoid being overridden by older keyframes */
    animation: hudScanScrollStrong var(--hud-scan-speed) linear infinite !important;
}


/* If your theme uses ::before for orange glow, keep it underneath as well */

#stats .card::before {
    z-index: 0;
}


/* Stronger motion so you can see it's working; tweak later if too bold */

@keyframes hudScanScrollStrong {
    0% {
        background-position: 0 0;
    }
    100% {
        background-position: 0 var(--hud-scanline-size);
    }
}


/* Respect reduced motion */

@media (prefers-reduced-motion: reduce) {
    #stats .card::after {
        animation: none !important;
    }
}


/* Disabled/locked nav look */

.bottomnav.is-locked a {
    pointer-events: none;
    filter: grayscale(1) brightness(.8);
    opacity: .55;
    cursor: not-allowed;
    text-shadow: none;
    box-shadow: none;
    transform: none !important;
    transition: filter .15s, opacity .15s;
}