/* ============================================
   HARSHA'S RUN — PIXEL EDITION
   Full pixel art UI. No smooth UI. No gradients.
   Nearest-neighbor rendering only.
   ============================================ */

/* Press Start 2P pixel font */
@import url('https://fonts.googleapis.com/css2?family=Press+Start+2P&display=swap');

:root {
    /* Pixel palette */
    --px-bg: #0d1b3e;
    --px-bg2: #162448;
    --px-surface: #1e2f52;
    --px-border: #4a90d9;
    --px-border2: #2a4070;
    --px-shadow: #0a1228;
    --px-primary: #FF4B6B;
    --px-primary2: #cc2d4a;
    --px-accent: #FFE66D;
    --px-teal: #4ECDC4;
    --px-text: #e8f0fe;
    --px-muted: #7a9cc0;
    --px-white: #ffffff;
    --px-gold: #ffd700;
    --px-green: #3ddc84;

    --font-pixel: 'Press Start 2P', 'Courier New', monospace;
    --font-ui: 'Press Start 2P', monospace;

    /* Safe Area Insets (Notch support) */
    --sat: env(safe-area-inset-top);
    --sab: env(safe-area-inset-bottom);
    --sal: env(safe-area-inset-left);
    --sar: env(safe-area-inset-right);
}

/* ============================================
   RESET
   ============================================ */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
    touch-action: manipulation;
}

body {
    font-family: var(--font-pixel);
    background: var(--px-bg);
    background-attachment: fixed;
    min-height: 100vh;
    overflow: hidden;
    color: var(--px-text);
    line-height: 1.6;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
}

/* Pixel font for everything */
button,
input,
select,
textarea {
    font-family: var(--font-pixel);
}

/* ============================================
   UTILITIES
   ============================================ */
.hidden {
    display: none !important;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ============================================
   LOADING SCREEN
   ============================================ */
#loading-screen {
    position: fixed;
    inset: 0;
    background: var(--px-bg);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 24px;
}

#loading-screen .px-title {
    font-family: var(--font-pixel);
    font-size: 14px;
    color: var(--px-accent);
    letter-spacing: 2px;
    text-shadow: 2px 2px 0 var(--px-shadow);
}

.px-loader {
    width: 120px;
    height: 10px;
    border: 2px solid var(--px-border);
    background: var(--px-bg2);
    position: relative;
    overflow: hidden;
}

.px-loader::after {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    background: var(--px-teal);
    animation: px-load 1.5s steps(12, end) infinite;
}

@keyframes px-load {
    from {
        width: 0;
    }

    to {
        width: 100%;
    }
}

/* ============================================
   GAME CONTAINER
   ============================================ */
.game-container {
    position: relative;
    width: 100vw;

    /* iOS-safe viewport sizing */
    height: 100svh;
    height: 100dvh;
    height: -webkit-fill-available;

    display: flex;
    align-items: center;
    justify-content: center;

    overflow: hidden;
    background: var(--px-bg);

    padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

.game-canvas {
    display: block;
    position: relative;
    flex-shrink: 0;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
    background: transparent;
    touch-action: none;
    -webkit-tap-highlight-color: transparent;
}

/* ============================================
   PIXEL PANEL MIXIN (via class)
   ============================================ */
.px-panel {
    background: var(--px-surface);
    border: 2px solid var(--px-border);
    box-shadow:
        2px 2px 0 var(--px-border2),
        4px 4px 0 var(--px-shadow);
    border-radius: 0;
}

/* ============================================
   TOAST NOTIFICATIONS
   ============================================ */
.toast {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(-80px);
    background: var(--px-surface);
    color: var(--px-accent);
    padding: 8px 16px;
    border: 2px solid var(--px-accent);
    box-shadow: 2px 2px 0 var(--px-shadow);
    font-family: var(--font-pixel);
    font-size: 9px;
    z-index: 1000;
    opacity: 0;
    transition: transform 200ms steps(4), opacity 200ms steps(4);
    pointer-events: none;
    white-space: nowrap;
    border-radius: 0;
}

.toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

/* ============================================
   CHALLENGE BANNER
   ============================================ */
.challenge-banner {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background: var(--px-primary);
    color: var(--px-white);
    padding: 8px 16px;
    text-align: center;
    font-family: var(--font-pixel);
    font-size: 9px;
    z-index: 100;
    border-bottom: 2px solid var(--px-primary2);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

/* ============================================
   SETTINGS PANEL
   ============================================ */
.settings-panel {
    position: fixed;
    top: 0;
    right: 0;
    width: 240px;
    height: 100vh;
    background: var(--px-bg2);
    z-index: 200;
    border-left: 2px solid var(--px-border);
    box-shadow: -4px 0 0 var(--px-shadow);
}

.settings-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 2px solid var(--px-border);
    background: var(--px-surface);
}

.settings-header h3 {
    font-family: var(--font-pixel);
    font-size: 10px;
    color: var(--px-accent);
}

.settings-content {
    padding: 16px;
}

.setting-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 0;
    font-size: 8px;
    color: var(--px-text);
    border-bottom: 1px solid var(--px-border2);
    cursor: pointer;
}

/* Pixel Toggle Switch */
.toggle {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
}

.toggle-track {
    display: block;
    width: 40px;
    height: 16px;
    background: var(--px-border2);
    border: 2px solid var(--px-muted);
    position: relative;
    border-radius: 0;
}

.toggle[aria-pressed="true"] .toggle-track {
    background: var(--px-teal);
    border-color: var(--px-border);
}

.toggle-thumb {
    display: block;
    width: 10px;
    height: 10px;
    background: var(--px-white);
    position: absolute;
    top: 1px;
    left: 1px;
    transition: transform 100ms steps(3);
    border-radius: 0;
}

.toggle[aria-pressed="true"] .toggle-thumb {
    transform: translateX(22px);
}

/* ============================================
   HUD (HEADS UP DISPLAY) — Pixel Panel Style
   ============================================ */
.hud {
    /* Fixed so HUD always sits on top of canvas regardless of flex/scroll layout */
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    /* Safe-area: push below notch / Dynamic Island */
    padding: max(8px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) 8px max(12px, env(safe-area-inset-left));
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    pointer-events: none;
    z-index: 9999;
}

.hud-item {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    background: var(--px-bg2);
    border: 2px solid var(--px-border);
    box-shadow: 2px 2px 0 var(--px-shadow);
    padding: 4px 8px;
}

.hud-right {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 10px;
}

.hud-right .hud-item {
    align-items: flex-end;
}

.hud-label {
    font-family: var(--font-pixel);
    font-size: 7px;
    color: var(--px-muted);
    letter-spacing: 0.1em;
}

.hud-value {
    font-family: var(--font-pixel);
    font-size: 16px;
    color: var(--px-accent);
    line-height: 1.2;
    text-shadow: 1px 1px 0 var(--px-shadow);
}

.powerup-indicator {
    position: absolute;
    bottom: 8px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--px-surface);
    border: 2px solid var(--px-teal);
    box-shadow: 2px 2px 0 var(--px-shadow);
    color: var(--px-teal);
    padding: 4px 10px;
    font-family: var(--font-pixel);
    font-size: 7px;
    display: flex;
    align-items: center;
    gap: 6px;
    animation: px-pulse 1s steps(2) infinite;
}

@keyframes px-pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.6;
    }
}

.token-counter {
    /* Flows below score inside .hud-right — no absolute positioning needed */
    background: var(--px-surface);
    border: 2px solid var(--px-gold);
    box-shadow: 2px 2px 0 var(--px-shadow);
    padding: 4px 8px;
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--px-gold);
    font-family: var(--font-pixel);
    font-size: 9px;
}

/* ============================================
   PIXEL SCREEN (shared by Start + Game Over)
   ============================================ */
.screen {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 20;
    padding: 16px;
    background: rgba(13, 27, 62, 0.85);
}

.screen-content {
    background: var(--px-surface);
    border: 3px solid var(--px-border);
    box-shadow:
        4px 4px 0 var(--px-border2),
        8px 8px 0 var(--px-shadow);
    padding: 28px 24px;
    width: 100%;
    max-width: 420px;
    text-align: center;
    position: relative;
    padding-bottom: max(28px, var(--sab));
}

/* Pixel window title bar */
.screen-content::before {
    content: '■ ■ ■';
    position: absolute;
    top: -20px;
    left: 0;
    right: 0;
    height: 20px;
    background: var(--px-border2);
    border: 3px solid var(--px-border);
    border-bottom: none;
    color: var(--px-muted);
    font-family: var(--font-pixel);
    font-size: 7px;
    display: flex;
    align-items: center;
    padding: 0 8px;
    letter-spacing: 3px;
}

/* START SCREEN */
.logo-container {
    margin-bottom: 12px;
}

.logo {
    width: 80px;
    height: auto;
    image-rendering: pixelated;
}

.title-section {
    margin-bottom: 16px;
}

.game-title {
    font-family: var(--font-pixel);
    font-size: 20px;
    color: var(--px-accent);
    letter-spacing: 2px;
    line-height: 1.3;
    text-shadow:
        2px 0 0 var(--px-primary),
        0 2px 0 var(--px-shadow),
        2px 2px 0 var(--px-shadow);
}

.game-subtitle {
    font-family: var(--font-pixel);
    font-size: 8px;
    color: var(--px-muted);
    margin-top: 8px;
    letter-spacing: 1px;
}

/* Daily Preview */
.daily-preview {
    background: var(--px-bg);
    border: 2px solid var(--px-border);
    box-shadow: 2px 2px 0 var(--px-shadow);
    padding: 8px 12px;
    margin-bottom: 12px;
    color: var(--px-teal);
}

.daily-badge {
    font-size: 7px;
    letter-spacing: 1px;
    opacity: 0.9;
}

.daily-date {
    font-size: 8px;
    margin-top: 4px;
    color: var(--px-text);
}

/* Leaderboard Preview */
.leaderboard-preview {
    background: var(--px-bg);
    border: 2px solid var(--px-border2);
    padding: 10px 12px;
    margin-bottom: 16px;
}

.preview-title {
    font-size: 8px;
    color: var(--px-muted);
    letter-spacing: 1px;
    margin-bottom: 8px;
}

.top-three {
    list-style: none;
}

.top-three li {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 5px 0;
    border-bottom: 1px solid var(--px-border2);
    font-size: 8px;
}

.top-three li:last-child {
    border-bottom: none;
}

.top-three .rank {
    width: 20px;
    font-size: 10px;
}

.top-three .rank.gold {
    color: var(--px-gold);
}

.top-three .rank.silver {
    color: #aac;
}

.top-three .rank.bronze {
    color: #c96;
}

.top-three .name {
    flex: 1;
    text-align: left;
    padding-left: 6px;
    color: var(--px-text);
}

.top-three .score {
    color: var(--px-primary);
}

/* ============================================
   PIXEL BUTTONS
   ============================================ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 16px;
    border: 2px solid var(--px-border);
    border-bottom-color: var(--px-border2);
    border-right-color: var(--px-border2);
    background: var(--px-bg2);
    font-family: var(--font-pixel);
    font-size: 9px;
    color: var(--px-text);
    cursor: pointer;
    text-decoration: none;
    width: 100%;
    transition: none;
    border-radius: 0;
    box-shadow: 2px 2px 0 var(--px-shadow);
    letter-spacing: 1px;
    text-transform: uppercase;
}

.btn-vote {
    background: #FFC720;
    color: #0d1b3e;
    border: 3px solid #FFD95A;
    border-bottom-color: #B88400;
    border-right-color: #B88400;
    box-shadow: 3px 3px 0 rgba(0, 0, 0, 0.6);
    font-family: 'Press Start 2P', monospace;
}

.btn-vote:hover {
    background: #FFD95A;
}

.btn-vote:active {
    transform: translateY(2px);
    box-shadow: none;
}

.btn:hover {
    transform: translateY(1px);
    box-shadow: 1px 1px 0 var(--px-shadow);
    border-bottom-color: var(--px-border);
}

.btn:active {
    transform: translateY(2px);
    box-shadow: none;
}

.btn-primary {
    background: var(--px-primary2);
    color: var(--px-white);
    border-color: var(--px-primary);
    border-bottom-color: #8b1a2e;
    border-right-color: #8b1a2e;
    font-size: 11px;
}

.btn-primary:hover {
    background: var(--px-primary);
}

.btn-secondary {
    background: var(--px-bg);
    color: var(--px-muted);
    font-size: 8px;
}

.btn-secondary:hover {
    color: var(--px-text);
    background: var(--px-bg2);
}

.btn-share {
    background: #0a4bab;
    color: var(--px-white);
    border-color: #2668cc;
    border-bottom-color: #062f6e;
    font-size: 9px;
}

.btn-copy {
    background: var(--px-teal);
    color: var(--px-bg);
    width: auto;
    padding: 6px 12px;
    font-size: 8px;
    border-color: #3dbdb4;
    border-bottom-color: #2a8a83;
}

.btn-large {
    padding: 14px 20px;
    font-size: 12px;
}

.btn-icon {
    font-size: 1.2em;
}

.secondary-actions {
    display: flex;
    gap: 8px;
    margin-top: 10px;
}

.secondary-actions .btn {
    flex: 1;
    font-size: 8px;
}

.tap-hint {
    margin-top: 16px;
    font-size: 7px;
    color: var(--px-muted);
    animation: px-pulse 1.5s steps(2) infinite;
}

/* Settings/Close Buttons */
.btn-settings {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 36px;
    height: 36px;
    background: var(--px-bg2);
    border: 2px solid var(--px-border);
    box-shadow: 2px 2px 0 var(--px-shadow);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--px-teal);
    z-index: 30;
    border-radius: 0;
    padding: 0;
}

.btn-settings:hover {
    background: var(--px-surface);
}

.btn-settings svg {
    width: 18px;
    height: 18px;
}

.btn-close {
    width: 30px;
    height: 30px;
    background: var(--px-bg);
    border: 2px solid var(--px-border);
    color: var(--px-primary);
    font-family: var(--font-pixel);
    font-size: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 0;
    box-shadow: 1px 1px 0 var(--px-shadow);
}

.btn-close:hover {
    background: var(--px-primary2);
    color: white;
}

/* ============================================
   MODAL (Leaderboard)
   ============================================ */
.modal {
    position: fixed;
    inset: 0;
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.modal-overlay {
    position: absolute;
    inset: 0;
    background: rgba(10, 18, 40, 0.82);
}

.modal-content {
    position: relative;
    background: var(--px-surface);
    border: 3px solid var(--px-border);
    box-shadow: 6px 6px 0 var(--px-shadow);
    width: 100%;
    max-width: 400px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    border-radius: 0;
    padding-bottom: max(20px, var(--sab));
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    border-bottom: 2px solid var(--px-border);
    background: var(--px-bg);
}

.modal-header h2 {
    font-size: 11px;
    color: var(--px-accent);
}

/* Tabs */
.tabs {
    display: flex;
    padding: 6px;
    gap: 4px;
    background: var(--px-bg);
    border-bottom: 2px solid var(--px-border2);
}

.tab {
    flex: 1;
    padding: 7px 6px;
    border: 2px solid var(--px-border2);
    background: var(--px-bg);
    font-family: var(--font-pixel);
    font-size: 7px;
    color: var(--px-muted);
    cursor: pointer;
    border-radius: 0;
    box-shadow: 1px 1px 0 var(--px-shadow);
}

.tab.active {
    background: var(--px-surface);
    color: var(--px-accent);
    border-color: var(--px-border);
}

.leaderboard-content {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
}

.leaderboard-list {
    list-style: none;
}

.leaderboard-list li {
    display: flex;
    align-items: center;
    padding: 8px 10px;
    border-bottom: 1px solid var(--px-border2);
    font-size: 8px;
}

.leaderboard-list li:last-child {
    border-bottom: none;
}

.leaderboard-list .rank {
    width: 28px;
    color: var(--px-muted);
}

.leaderboard-list .rank.top-1 {
    color: var(--px-gold);
}

.leaderboard-list .rank.top-2 {
    color: #aac;
}

.leaderboard-list .rank.top-3 {
    color: #c96;
}

.leaderboard-list .name {
    flex: 1;
    text-align: left;
    color: var(--px-text);
}

.leaderboard-list .score {
    color: var(--px-primary);
}

/* ============================================
   CAUSE CARD
   ============================================ */
.cause-card {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 40;
    animation: px-card-in 0.2s steps(3) forwards;
}

@keyframes px-card-in {
    from {
        opacity: 0;
        transform: translate(-50%, -60%);
    }

    to {
        opacity: 1;
        transform: translate(-50%, -50%);
    }
}

.cause-card-content {
    background: var(--px-surface);
    border: 3px solid;
    box-shadow: 6px 6px 0 var(--px-shadow);
    padding: 28px 24px;
    text-align: center;
    max-width: 300px;
}

.cause-icon {
    font-size: 40px;
    margin-bottom: 12px;
}

.cause-title {
    font-family: var(--font-pixel);
    font-size: 10px;
    color: var(--px-accent);
    margin-bottom: 8px;
    line-height: 1.5;
}

.cause-text {
    font-family: var(--font-pixel);
    font-size: 8px;
    color: var(--px-muted);
    line-height: 1.8;
}

.cause-special {
    margin-top: 12px;
    padding: 4px 10px;
    background: var(--px-gold);
    color: var(--px-bg);
    font-size: 7px;
    display: inline-block;
}

/* ============================================
   GAME OVER SCREEN
   ============================================ */
.game-over-screen .screen-content {
    max-width: 380px;
}

.result-section {
    margin-bottom: 16px;
}

.result-title {
    font-size: 14px;
    color: var(--px-primary);
    letter-spacing: 3px;
    margin-bottom: 10px;
    text-shadow:
        2px 0 0 #8b1a2e,
        0 2px 0 var(--px-shadow);
}

.score-display {
    display: flex;
    align-items: baseline;
    justify-content: center;
    gap: 8px;
    margin-bottom: 12px;
}

.final-score {
    font-family: var(--font-pixel);
    font-size: 36px;
    color: var(--px-accent);
    line-height: 1;
    text-shadow: 2px 2px 0 var(--px-shadow);
}

.score-label {
    font-family: var(--font-pixel);
    font-size: 8px;
    color: var(--px-muted);
}

.best-score {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    margin-bottom: 10px;
}

.new-best {
    background: var(--px-gold);
    color: var(--px-bg);
    padding: 4px 10px;
    font-family: var(--font-pixel);
    font-size: 9px;
    letter-spacing: 1px;
    animation: px-new-best 0.5s steps(2) infinite;
    box-shadow: 2px 2px 0 var(--px-shadow);
}

@keyframes px-new-best {

    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.04);
    }
}

/* Pixel confetti */
.pixel-confetti {
    position: absolute;
    width: 4px;
    height: 4px;
    animation: px-confetti-fall 1.5s steps(12) forwards;
    pointer-events: none;
}

@keyframes px-confetti-fall {
    from {
        transform: translateY(-10px);
        opacity: 1;
    }

    to {
        transform: translateY(180px) rotate(360deg);
        opacity: 0;
    }
}

.rank-display {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    color: var(--px-muted);
    font-size: 8px;
}

.rank-label {
    font-size: 7px;
}

.rank-value {
    font-size: 18px;
    color: var(--px-teal);
    text-shadow: 1px 1px 0 var(--px-shadow);
}

/* Name Input */
.name-input-section {
    margin-bottom: 14px;
}

.name-input {
    width: 100%;
    padding: 10px;
    border: 2px solid var(--px-border);
    background: var(--px-bg);
    color: var(--px-accent);
    font-family: var(--font-pixel);
    font-size: 10px;
    text-align: center;
    border-radius: 0;
    outline: none;
    box-shadow: inset 2px 2px 0 var(--px-shadow);
}

.name-input:focus {
    border-color: var(--px-teal);
}

.honeypot {
    position: absolute;
    left: -9999px;
    opacity: 0;
}

.action-buttons {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.action-buttons .btn {
    width: 100%;
}

/* Challenge section */
.challenge-section {
    margin-top: 14px;
    padding-top: 14px;
    border-top: 2px dashed var(--px-border2);
}

.challenge-text {
    font-size: 7px;
    color: var(--px-muted);
    margin-bottom: 8px;
}

.challenge-link {
    display: flex;
    gap: 6px;
}

.challenge-link input {
    flex: 1;
    padding: 6px 8px;
    border: 2px solid var(--px-border2);
    background: var(--px-bg);
    color: var(--px-muted);
    font-family: var(--font-pixel);
    font-size: 7px;
    border-radius: 0;
}

/* ============================================
   PAUSE OVERLAY
   ============================================ */
.pause-overlay {
    position: absolute;
    inset: 0;
    background: rgba(10, 18, 40, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 30;
}

.pause-content {
    background: var(--px-surface);
    border: 3px solid var(--px-border);
    box-shadow: 6px 6px 0 var(--px-shadow);
    padding: 32px 40px;
    text-align: center;
}

.pause-content h2 {
    font-size: 18px;
    color: var(--px-accent);
    margin-bottom: 20px;
    text-shadow: 2px 2px 0 var(--px-shadow);
}

/* ============================================
   ACCESSIBILITY MODES
   ============================================ */
body.reduced-motion *,
body.reduced-motion *::before,
body.reduced-motion *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
}

body.high-contrast {
    --px-bg: #000;
    --px-bg2: #000;
    --px-surface: #000;
    --px-text: #fff;
    --px-muted: #ccc;
    --px-border: #fff;
    --px-accent: #ff0;
    --px-primary: #f00;
    --px-teal: #0ff;
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 480px) {
    .game-title {
        font-size: 14px;
    }

    .screen-content {
        padding: 20px 14px;
    }

    .btn-large {
        font-size: 10px;
        padding: 12px 14px;
    }

    .hud-value {
        font-size: 13px;
    }
}

@media (min-width: 768px) {
    .game-title {
        font-size: 24px;
    }
}

/* ============================================
   MISC
   ============================================ */
.loading {
    color: var(--px-muted);
    font-style: normal;
    font-size: 8px;
}

button:focus-visible,
input:focus-visible {
    outline: 2px solid var(--px-teal);
    outline-offset: 2px;
}

.game-container,
.hud,
.screen {
    user-select: none;
    -webkit-user-select: none;
}

.leaderboard-content::-webkit-scrollbar {
    width: 6px;
}

.leaderboard-content::-webkit-scrollbar-track {
    background: var(--px-bg);
}

.leaderboard-content::-webkit-scrollbar-thumb {
    background: var(--px-border2);
    border-radius: 0;
}

/* ============================================
   P2 — STAND HERO (Start Screen)
   ============================================ */
.stand-hero-container {
    display: flex;
    justify-content: center;
    margin-bottom: 10px;
}

.stand-hero {
    height: 128px;
    width: auto;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
}

@media (max-width: 480px) {
    .stand-hero {
        height: 96px;
    }
}

/* ============================================
   P3 — SAFE AREAS (Notch / Dynamic Island)
   ============================================ */
/* Safe-area padding is consolidated in the main .game-container rule above */

/* .hud safe-area padding is consolidated in the main .hud rule above */

.screen-content {
    /* Ensure bottom buttons are never hidden behind home indicator */
    padding-bottom: max(28px, env(safe-area-inset-bottom));
}

/* ============================================
   P3 — CANVAS: disable browser touch gestures
   ============================================ */
.game-canvas {
    touch-action: none;
    -webkit-tap-highlight-color: transparent;
}

/* Jump button removed — tap anywhere on canvas to jump */
/* ============================================
   P3 — CANVAS INPUT SAFETY
   ============================================ */
#game-canvas {
    /* Prevent iOS rubber-band / scroll during gameplay */
    touch-action: none;
    overscroll-behavior: none;
    -webkit-tap-highlight-color: transparent;
}

/* ============================================
   TOKEN ICON — pixel-crisp sprite in all contexts
   ============================================ */
.pixel-token-icon {
    width: 20px;
    height: 20px;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
    vertical-align: middle;
    display: inline-block;
}

/* Slightly smaller in HUD (tight space next to score) */
.token-icon .pixel-token-icon {
    width: 18px;
    height: 18px;
}

/* Slightly larger in headings */
.htp-heading .pixel-token-icon {
    width: 16px;
    height: 16px;
    vertical-align: baseline;
}

/* ============================================
   P3 — LANDSCAPE ROTATE HINT
   Shown when viewport height is too small to play
   ============================================ */
.rotate-hint {
    display: none;
    position: fixed;
    inset: 0;
    background: var(--px-bg);
    z-index: 9999;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 16px;
    text-align: center;
    font-family: var(--font-pixel);
    font-size: 9px;
    color: var(--px-accent);
    line-height: 2;
}

.rotate-hint-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

@media (orientation: landscape) and (max-height: 450px) {
    .rotate-hint {
        display: flex;
    }
}

/* ============================================
   P3 — SECONDARY ACTIONS: wrap for 3 buttons
   ============================================ */
.secondary-actions {
    flex-wrap: wrap;
}

.secondary-actions .btn {
    flex: 1 1 auto;
    min-width: 80px;
}

/* ============================================
   LOGO — bigger on start screen
   ============================================ */
.logo-container {
    margin-bottom: 6px;
}

.logo {
    width: 160px;
    /* bigger so text is more readable */
    height: auto;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
}

@media (max-width: 480px) {
    .logo {
        width: 120px;
    }
}

/* ============================================
   CAMPAIGN LINE (start screen)
   ============================================ */
.campaign-line {
    font-family: var(--font-pixel);
    font-size: 7px;
    color: var(--px-gold);
    letter-spacing: 1px;
    margin-bottom: 8px;
    text-shadow: 1px 1px 0 var(--px-shadow);
    animation: px-pulse 2s steps(2) infinite;
}

/* ============================================
   COINS TIEBREAKER — Game Over screen
   ============================================ */
.coins-display {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    margin: 8px 0 2px;
    padding: 6px 12px;
    background: var(--px-bg);
    border: 2px solid var(--px-gold);
    box-shadow: 2px 2px 0 var(--px-shadow);
}

.coins-icon {
    font-size: 14px;
}

.coins-value {
    font-family: var(--font-pixel);
    font-size: 16px;
    color: var(--px-gold);
    text-shadow: 1px 1px 0 var(--px-shadow);
}

.coins-label {
    font-family: var(--font-pixel);
    font-size: 6px;
    color: var(--px-muted);
    letter-spacing: 1px;
}

.tiebreaker-hint {
    font-family: var(--font-pixel);
    font-size: 6px;
    color: var(--px-teal);
    margin: 4px 0 8px;
    line-height: 1.8;
}

/* ============================================
   HOW TO PLAY MODAL
   ============================================ */
.htp-content {
    max-width: 420px;
}

.htp-section {
    margin-bottom: 14px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--px-border2);
}

.htp-section:last-child {
    border-bottom: none;
}

.htp-heading {
    font-family: var(--font-pixel);
    font-size: 8px;
    color: var(--px-accent);
    letter-spacing: 1px;
    margin-bottom: 10px;
    text-shadow: 1px 1px 0 var(--px-shadow);
}

.htp-row {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 8px;
    font-size: 8px;
    line-height: 1.6;
}

.htp-key {
    display: inline-block;
    background: var(--px-bg);
    border: 2px solid var(--px-border);
    color: var(--px-teal);
    font-family: var(--font-pixel);
    font-size: 7px;
    padding: 2px 6px;
    white-space: nowrap;
    box-shadow: 1px 1px 0 var(--px-shadow);
    flex-shrink: 0;
}

.htp-icon {
    font-size: 16px;
    flex-shrink: 0;
    width: 22px;
    text-align: center;
}

.htp-desc {
    color: var(--px-text);
    font-family: var(--font-pixel);
    font-size: 7px;
    line-height: 2;
}

.htp-desc strong {
    color: var(--px-accent);
}

@media (max-width: 480px) {
    .htp-heading {
        font-size: 7px;
    }

    .htp-desc {
        font-size: 6px;
    }

    .htp-key {
        font-size: 6px;
    }
}

/* ============================================
   §2 — PRIZE CLAIM CODE PANEL
   ============================================ */
.claim-code-section {
    margin-top: 10px;
    background: var(--px-bg2);
    border: 2px solid var(--px-gold);
    box-shadow: 2px 2px 0 var(--px-shadow);
    padding: 8px 12px;
    text-align: center;
}

.claim-code-label {
    font-family: var(--font-pixel);
    font-size: 7px;
    color: var(--px-muted);
    letter-spacing: 0.1em;
    margin: 0 0 4px;
}

.claim-code-value {
    font-family: var(--font-pixel);
    font-size: 14px;
    color: var(--px-gold);
    letter-spacing: 3px;
    text-shadow: 1px 1px 0 var(--px-shadow);
    margin: 4px 0;
}

.claim-code-hint {
    font-family: var(--font-pixel);
    font-size: 6px;
    color: var(--px-muted);
    line-height: 1.6;
    margin: 4px 0 0;
}

/* ============================================
   §7 — MICRO-ANIMATIONS (pixel style only)
   ============================================ */

/* Gold glow pulse on coin panel when coins > 0 */
.token-counter:not(.hidden) {
    animation: px-coin-glow 2s steps(2) infinite;
}

@keyframes px-coin-glow {

    0%,
    100% {
        box-shadow: 2px 2px 0 var(--px-shadow);
    }

    50% {
        box-shadow: 2px 2px 0 var(--px-shadow), 0 0 0 1px var(--px-gold);
    }
}

/* Scale-pop on the final score number on NEW BEST */
#final-score.new-best-score {
    animation: px-score-pop 0.6s steps(3) forwards;
    display: inline-block;
}

@keyframes px-score-pop {
    0% {
        transform: scale(1);
    }

    40% {
        transform: scale(1.08);
    }

    100% {
        transform: scale(1);
    }
}

/* ============================================
   HUD MUTE BUTTON
   ============================================ */
.hud-mute-btn {
    width: 32px;
    height: 32px;
    background: var(--px-bg);
    border: 2px solid var(--px-border);
    color: var(--px-teal);
    font-size: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 0;
    box-shadow: 2px 2px 0 var(--px-shadow);
    pointer-events: auto;
    margin-right: 8px;
    /* space it from the edge or other elements if necessary */
}

/* ============================================
   DEVELOPER CREDIT
   ============================================ */
.developer-credit {
    position: absolute;
    bottom: 12px;
    width: 100%;
    text-align: center;
    font-family: var(--font-pixel);
    font-size: 6px;
    color: var(--px-muted);
    opacity: 0.5;
    transition: opacity 0.2s ease;
    z-index: 10;
    pointer-events: auto;
}

.developer-credit:hover {
    opacity: 1;
}

.developer-credit a {
    color: var(--px-teal);
    text-decoration: none;
    border-bottom: 1px dotted var(--px-teal);
}

.developer-credit a:hover {
    color: var(--px-gold);
    border-bottom-color: var(--px-gold);
}

.hud-mute-btn:active {
    transform: translateY(2px) translateX(2px);
    box-shadow: none;
}