:root {
    --bg-color: #050505;
    --text-primary: #ffffff;
    --accent-cyan: #00ffcc;
    --accent-pink: #ff00ff;
    --glass-bg: rgba(255, 255, 255, 0.04);
    --border-thin: 1px solid rgba(255, 255, 255, 0.15);
}

body {
    background-color: var(--bg-color);
    color: var(--text-primary);
    font-family: 'Inter', -apple-system, monospace;
    margin: 0;
    min-height: 100vh;
    overflow: hidden;
}

.wrap {
    width: 100vw;
    height: 100vh;
    max-width: none;
    padding: 0;
    position: relative;
}

header {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    z-index: 10;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 0.75rem 1rem 1.5rem;
    background: linear-gradient(to bottom, rgba(0,0,0,0.75), rgba(0,0,0,0));
    pointer-events: none;
}

header > .title-block, header .hud { pointer-events: auto; }
.title-block { max-width: 50%; }

h1 { margin: 0; color: var(--accent-cyan); font-size: 1.5rem; text-transform: uppercase; }
h2 { margin: 0; font-size: 0.9rem; opacity: 0.7; }
.meta {
    font-size: 0.85rem;
    opacity: 0.95;
    margin-top: 6px;
    color: var(--accent-cyan);
    font-family: monospace;
    letter-spacing: 0.02em;
}

.hud { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.badge {
    background: var(--glass-bg);
    padding: 4px 10px;
    border-radius: 4px;
    border: var(--border-thin);
    font-family: monospace;
    font-size: 0.9rem;
    transition: color 0.2s, border-color 0.2s, background 0.2s;
}
.badge strong { color: var(--accent-pink); }

/* Difficulty colors */
.diff { font-weight: bold; padding: 0 4px; border-radius: 3px; }
.diff-easy   { color: #7cf99c; }
.diff-medium { color: #ffd166; }
.diff-hard   { color: #ff5577; }
.level-badge { letter-spacing: 0.05em; }

/* Timer warnings — escalate as time runs out */
.timer-badge.timer-warn1 { color: #ffd166; border-color: #ffd166; }
.timer-badge.timer-warn1 strong { color: #ffd166; }
.timer-badge.timer-warn2 {
    color: #ff8c42;
    border-color: #ff8c42;
    background: rgba(255, 140, 66, 0.12);
    animation: timer-pulse 0.6s ease-in-out infinite;
}
.timer-badge.timer-warn2 strong { color: #ff8c42; }
.timer-badge.timer-warn3 {
    color: #ff3344;
    border-color: #ff3344;
    background: rgba(255, 51, 68, 0.18);
    animation: timer-pulse 0.28s ease-in-out infinite;
}
.timer-badge.timer-warn3 strong { color: #ff3344; }
@keyframes timer-pulse {
    0%, 100% { transform: scale(1); }
    50%      { transform: scale(1.08); }
}

.btn {
    background: var(--accent-cyan);
    color: #000;
    border: none;
    padding: 6px 12px;
    font-weight: bold;
    cursor: pointer;
    border-radius: 4px;
    text-transform: uppercase;
}

.btn:hover { box-shadow: 0 0 15px var(--accent-cyan); }

.btn-icon {
    padding: 4px 10px;
    font-size: 1rem;
    line-height: 1;
    min-width: 32px;
}
.btn-icon[aria-pressed="true"] {
    background: transparent;
    color: var(--accent-cyan);
    border: 1px solid var(--accent-cyan);
    box-shadow: none;
    opacity: 0.7;
}

/* Eaten badge: cap warning states */
.eaten-badge.cap-near strong { color: #ffd166; }
.eaten-badge.cap-over {
    color: #ff5577;
    border-color: #ff5577;
    background: rgba(255, 85, 119, 0.12);
}
.eaten-badge.cap-over strong { color: #ff5577; }

/* Combo badge: tier colors + pop animation */
.combo-badge[hidden] { display: none; }
.combo-badge {
    border-color: currentColor;
    transition: color 0.15s, border-color 0.15s, transform 0.15s;
}
.combo-badge.combo-tier-1 { color: #cfcfcf; }
.combo-badge.combo-tier-2 { color: #7cf99c; }
.combo-badge.combo-tier-3 { color: #00ffcc; }
.combo-badge.combo-tier-4 { color: #ffd166; }
.combo-badge.combo-tier-5 { color: #ff5cf0; }
.combo-badge strong { color: inherit; }
.combo-badge.combo-pop {
    animation: combo-pop 0.32s ease-out;
}
@keyframes combo-pop {
    0%   { transform: scale(1); }
    40%  { transform: scale(1.25); }
    100% { transform: scale(1); }
}

.stage {
    position: absolute;
    inset: 0;
    background: #000;
    border: none;
    box-shadow: none;
    line-height: 0;
    overflow: hidden;
}

canvas {
    width: 100%;
    height: 100%;
    display: block;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
}

.help { display: none; }

/* End-of-level overlay */
.end-screen {
    position: absolute;
    inset: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(2px);
    animation: fade-in 0.35s ease-out;
}
.end-screen[hidden] { display: none; }
.end-card {
    background: rgba(10, 10, 10, 0.92);
    border: 2px solid var(--accent-cyan);
    box-shadow: 0 0 30px rgba(0, 255, 204, 0.35);
    padding: 1.5rem 2rem;
    text-align: center;
    min-width: 280px;
    max-width: 90vw;
}
.end-card h2 {
    color: var(--accent-cyan);
    font-size: 1.6rem;
    margin: 0 0 0.5rem;
    opacity: 1;
    text-transform: uppercase;
}
.end-card p {
    margin: 0 0 1rem;
    font-size: 0.95rem;
    opacity: 0.85;
}
.end-stats {
    display: flex;
    justify-content: center;
    gap: 1.5rem;
    margin: 0.75rem 0 1.25rem;
    font-family: monospace;
    font-size: 0.95rem;
}
.end-stats strong { color: var(--accent-pink); margin-left: 4px; }
.end-card .btn { padding: 8px 18px; font-size: 0.95rem; }

@keyframes fade-in {
    from { opacity: 0; }
    to   { opacity: 1; }
}


/* ---------- Modals (skins, high scores) ---------- */
.modal {
    position: absolute;
    inset: 0;
    z-index: 30;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.65);
    backdrop-filter: blur(3px);
    animation: fade-in 0.2s ease-out;
}
.modal[hidden] { display: none; }
.modal-card {
    background: rgba(10, 10, 10, 0.94);
    border: 2px solid var(--accent-cyan);
    box-shadow: 0 0 30px rgba(0, 255, 204, 0.35);
    padding: 1.25rem 1.5rem;
    text-align: center;
    min-width: 320px;
    max-width: 90vw;
    max-height: 86vh;
    overflow-y: auto;
}
.modal-card h2 {
    color: var(--accent-cyan);
    font-size: 1.4rem;
    margin: 0 0 1rem;
    text-transform: uppercase;
}
.modal-close { margin-top: 1rem; }

/* Skin grid */
.skin-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 12px;
    margin-bottom: 0.5rem;
}
.skin-card {
    border: 1px solid rgba(255, 255, 255, 0.18);
    background: rgba(255, 255, 255, 0.03);
    padding: 10px;
    border-radius: 6px;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s, transform 0.15s;
    text-align: center;
}
.skin-card:hover:not(.locked) {
    border-color: var(--accent-cyan);
    background: rgba(0, 255, 204, 0.08);
    transform: translateY(-2px);
}
.skin-card.equipped {
    border-color: var(--accent-pink);
    background: rgba(255, 0, 255, 0.08);
}
.skin-card.locked {
    cursor: not-allowed;
    opacity: 0.55;
}
.skin-name {
    font-weight: bold;
    font-size: 0.95rem;
    margin-bottom: 6px;
    color: var(--accent-cyan);
}
.skin-thumb {
    width: 100%;
    aspect-ratio: 1 / 1;
    background-color: rgba(0, 0, 0, 0.4);
    /* george-moves.png is a 4×3 grid of 151px frames in a 609×457 sheet.
       Show the top-left walk-one frame (~25% × ~33% of the sheet). */
    background-size: 403% 303%;
    background-position: 0% 0%;
    background-repeat: no-repeat;
    image-rendering: pixelated;
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 4px;
    margin-bottom: 6px;
}
.skin-card.locked .skin-thumb {
    background: repeating-linear-gradient(
        45deg,
        rgba(255, 255, 255, 0.04),
        rgba(255, 255, 255, 0.04) 6px,
        rgba(255, 255, 255, 0.10) 6px,
        rgba(255, 255, 255, 0.10) 12px
    );
}
.skin-desc {
    font-size: 0.78rem;
    opacity: 0.8;
    min-height: 2em;
    margin-bottom: 6px;
}
.skin-status {
    font-family: monospace;
    font-size: 0.72rem;
    letter-spacing: 0.05em;
    color: var(--accent-cyan);
}
.skin-card.equipped .skin-status { color: var(--accent-pink); }
.skin-card.locked .skin-status { color: #888; }

/* High scores */
.scores-overall {
    font-family: monospace;
    font-size: 0.95rem;
    margin-bottom: 1rem;
    color: var(--accent-cyan);
}
.scores-overall strong { color: var(--accent-pink); }
.scores-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
    text-align: left;
    font-family: monospace;
}
.scores-row {
    display: flex;
    justify-content: space-between;
    padding: 6px 10px;
    background: rgba(255, 255, 255, 0.04);
    border-radius: 3px;
    font-size: 0.85rem;
}
.scores-row span:last-child { color: var(--accent-pink); font-weight: bold; }

/* End-screen extras */
.end-new {
    margin: 0.25rem 0 0.75rem;
    font-family: monospace;
    font-size: 0.95rem;
    letter-spacing: 0.08em;
    color: var(--accent-pink);
    animation: end-new-pulse 0.7s ease-in-out infinite alternate;
}
.end-new[hidden] { display: none; }
@keyframes end-new-pulse {
    from { transform: scale(1);    opacity: 0.85; }
    to   { transform: scale(1.05); opacity: 1;    }
}
.end-unlock {
    margin: 0.25rem 0 0.75rem;
    padding: 6px 10px;
    background: rgba(0, 255, 204, 0.12);
    border: 1px solid var(--accent-cyan);
    border-radius: 4px;
    font-size: 0.85rem;
    color: var(--accent-cyan);
}
.end-unlock[hidden] { display: none; }

/* Coin badge */
.coin-badge { color: #ffd166; border-color: rgba(255, 209, 102, 0.4); }
.coin-badge strong { color: #ffd166; }
.coin-badge.coin-pop { animation: combo-pop 0.32s ease-out; }

/* Mascot badge on HUD */
.mascot-badge[hidden] { display: none; }
.mascot-badge {
    padding: 2px 6px;
    border-color: var(--accent-pink);
    background: rgba(255, 0, 255, 0.08);
    display: inline-flex;
    align-items: center;
}
.mascot-badge canvas {
    width: 28px;
    height: 28px;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
    display: block;
}

/* Mascot shop */
.mascot-balance {
    font-family: monospace;
    font-size: 0.95rem;
    margin-bottom: 1rem;
    color: #ffd166;
}
.mascot-balance strong { color: var(--accent-pink); }
.mascot-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 10px;
    margin-bottom: 0.5rem;
}
.mascot-card {
    border: 1px solid rgba(255, 255, 255, 0.18);
    background: rgba(255, 255, 255, 0.03);
    padding: 8px;
    border-radius: 6px;
    text-align: center;
    transition: border-color 0.15s, background 0.15s, transform 0.15s;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}
.mascot-card.owned { cursor: pointer; }
.mascot-card.owned:hover {
    border-color: var(--accent-cyan);
    background: rgba(0, 255, 204, 0.08);
    transform: translateY(-2px);
}
.mascot-card.equipped {
    border-color: var(--accent-pink);
    background: rgba(255, 0, 255, 0.08);
}
.mascot-card.locked.affordable { cursor: pointer; }
.mascot-card.locked.affordable:hover {
    border-color: #ffd166;
    background: rgba(255, 209, 102, 0.08);
}
.mascot-card.locked.unaffordable { opacity: 0.55; cursor: not-allowed; }
.mascot-thumb {
    width: 80px;
    height: 80px;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
    display: block;
    background-color: rgba(0, 0, 0, 0.35);
    border-radius: 4px;
    border: 1px solid rgba(255, 255, 255, 0.12);
}
.mascot-card.locked .mascot-thumb { filter: grayscale(0.8) brightness(0.55); }
.mascot-name {
    font-weight: bold;
    font-size: 0.85rem;
    color: var(--accent-cyan);
}
.mascot-status {
    font-family: monospace;
    font-size: 0.7rem;
    letter-spacing: 0.04em;
}
.mascot-card.equipped .mascot-status { color: var(--accent-pink); }
.mascot-card.owned .mascot-status { color: var(--accent-cyan); }
.mascot-card.locked.affordable .mascot-status { color: #ffd166; }
.mascot-card.locked.unaffordable .mascot-status { color: #888; }

/* Header buttons wrap on mobile */
@media (max-width: 540px) {
    .hud { gap: 6px; font-size: 0.8rem; }
    .badge { padding: 3px 7px; font-size: 0.78rem; }
    .mascot-badge canvas { width: 22px; height: 22px; }
    .modal-card { min-width: 260px; padding: 1rem; }
    .mascot-thumb { width: 64px; height: 64px; }
}
