:root {
    --bg-primary:    #050010;
    --bg-secondary:  #000000;
    --bg-card:       #0d0420;
    --text-primary:  #FFFFFF;
    --text-secondary:#8A82A8;
    --pink:          #FF006E;
    --cyan:          #00F5D4;
    --yellow:        #FFD60A;
    --magenta:       #C200FB;
    --lime:          #B9FF66;
    --steel:         #6F7B8A;
    --skin:          #F2C9A0;
    --font-pixel:    'Press Start 2P', 'Courier New', monospace;
    --font-crt:      'VT323', 'Courier New', monospace;
}

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

html, body {
    background: var(--bg-primary);
    color: var(--text-primary);
    font-family: var(--font-crt);
    font-size: 22px;
    height: 100%;
    overflow: hidden;
    image-rendering: pixelated;
}

button {
    font-family: inherit;
    cursor: pointer;
    background: none;
    border: none;
    color: inherit;
}

.scanlines {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 9999;
    background: repeating-linear-gradient(
        to bottom,
        transparent 0,
        transparent 2px,
        rgba(0, 0, 0, 0.30) 3px,
        rgba(0, 0, 0, 0.30) 4px
    );
    mix-blend-mode: multiply;
}

.game-container {
    width: 100%;
    height: 100vh;
    display: flex;
    flex-direction: column;
    position: relative;
}

/* ====== HEADER ====== */
.game-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 14px;
    padding: 1.25rem 2rem;
    background: var(--bg-secondary);
    border-bottom: 3px solid var(--pink);
    box-shadow: 0 4px 0 0 var(--magenta);
    z-index: 10;
}

.score-display, .combo-display {
    display: flex;
    flex-direction: column;
    align-items: center;
    font-family: var(--font-pixel);
}

.label {
    font-size: 9px;
    letter-spacing: 2px;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.score-value, .combo-value {
    font-family: var(--font-pixel);
    font-size: 16px;
    color: var(--yellow);
    text-shadow: 2px 2px 0 var(--bg-secondary);
    letter-spacing: 1px;
}
.combo-value { color: var(--cyan); }

.lives-display { display: flex; gap: 0.5rem; font-size: 1.6rem; }
.heart { transition: opacity 0.2s, filter 0.2s; }
.heart:not(.active) { opacity: 0.2; filter: grayscale(100%); }

.stage-display {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--bg-card);
    border: 3px solid var(--cyan);
    box-shadow: 3px 3px 0 var(--bg-secondary);
    padding: 6px 10px;
    transition: border-color 0.3s, box-shadow 0.3s;
}
.stage-display.swole { border-color: var(--yellow); box-shadow: 3px 3px 0 var(--pink); }
.stage-display.beast { border-color: var(--pink); box-shadow: 3px 3px 0 var(--magenta); animation: stageWobble 1.6s ease-in-out infinite; }

@keyframes stageWobble {
    0%, 100% { transform: rotate(0deg); }
    50%      { transform: rotate(-2deg); }
}

.stage-face { font-size: 32px; line-height: 1; filter: drop-shadow(2px 2px 0 var(--bg-secondary)); }
.stage-meta { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; font-family: var(--font-pixel); }
.stage-name { font-size: 11px; letter-spacing: 2px; color: var(--yellow); text-shadow: 2px 2px 0 var(--bg-secondary); }
.stage-progress { font-size: 8px; letter-spacing: 1px; color: var(--text-secondary); }

.quit-btn {
    font-family: var(--font-pixel);
    font-size: 9px;
    letter-spacing: 1.5px;
    background: var(--bg-card);
    border: 3px solid var(--pink);
    color: var(--pink);
    padding: 10px 14px;
    cursor: pointer;
    box-shadow: 3px 3px 0 var(--bg-secondary);
    transition: transform 0.05s, box-shadow 0.05s, background 0.05s, color 0.05s;
}
.quit-btn:hover { background: var(--pink); color: var(--bg-secondary); }
.quit-btn:active { transform: translate(3px, 3px); box-shadow: none; }

/* ====== GAME AREA ====== */
.game-area {
    flex: 1;
    position: relative;
    background:
        linear-gradient(to bottom, rgba(255, 0, 110, 0.06) 0%, transparent 30%),
        repeating-linear-gradient(
            to bottom,
            transparent 0,
            transparent 28px,
            rgba(255, 255, 255, 0.02) 28px,
            rgba(255, 255, 255, 0.02) 29px
        ),
        var(--bg-primary);
    overflow: hidden;
}

.gym-scene {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    bottom: 2vh;
    width: min(420px, 92vw);
    height: 84vh;
    pointer-events: none;
}

/* Floor plate (bottom of scene) */
.floor {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 8%;
    background:
        repeating-linear-gradient(
            90deg,
            #1f1130 0 24px,
            #2a1640 24px 26px
        );
    border-top: 4px solid var(--pink);
    box-shadow: 0 -4px 0 var(--bg-secondary);
}

/* Squat racks framing the press track (above character) */
.rack {
    position: absolute;
    bottom: 46%;
    width: 14px;
    height: 36%;
    background: var(--steel);
    border: 3px solid var(--bg-secondary);
    box-shadow: 3px 3px 0 var(--bg-secondary);
}
.rack::after {
    content: '';
    position: absolute;
    top: -10px;
    left: -10px;
    right: -10px;
    height: 14px;
    background: var(--steel);
    border: 3px solid var(--bg-secondary);
}
.rack-left  { left: calc(50% - 70px); }
.rack-right { left: calc(50% + 56px); }

/* Bench — sits behind the character at butt level */
.bench {
    position: absolute;
    bottom: 25%;
    left: 50%;
    transform: translateX(-50%);
    width: 220px;
    height: 18px;
    background: var(--pink);
    border: 3px solid var(--bg-secondary);
    box-shadow: 4px 4px 0 var(--bg-secondary);
    z-index: 1;
}
/* Bench legs — tall verticals down to the floor */
.bench::before {
    content: '';
    position: absolute;
    top: 18px;
    left: 16%;
    width: 10px;
    height: 200px;
    background: var(--steel);
    border: 2px solid var(--bg-secondary);
}
.bench::after {
    content: '';
    position: absolute;
    top: 18px;
    right: 16%;
    width: 10px;
    height: 200px;
    background: var(--steel);
    border: 2px solid var(--bg-secondary);
}

/* Pixel-art lifter sprite — locked to SVG's aspect ratio so the visible
   character actually fills its container. */
.character {
    position: absolute;
    bottom: 5%;
    left: 50%;
    transform: translateX(-50%);
    width: 180px;
    aspect-ratio: 80 / 200;   /* matches the SVG viewBox */
    pointer-events: none;
    overflow: visible;        /* arms extend up beyond the character box */
    z-index: 3;
}
.lifter-svg {
    width: 100%;
    height: 100%;
    display: block;
    filter: drop-shadow(3px 3px 0 var(--bg-secondary));
}

/* Press track (above character's head, where the barbell rides).
   Tuned to sit close to the character's hands so arms have a sensible range. */
.press-track {
    position: absolute;
    bottom: 50%;
    left: 50%;
    transform: translateX(-50%);
    width: 140px;
    height: 30%;
    pointer-events: none;
}
.press-zone {
    position: absolute;
    top: 0;
    left: -22px;
    right: -22px;
    height: 35%;
    background: rgba(185, 255, 102, 0.18);
    border-top: 3px solid var(--lime);
    border-bottom: 3px solid var(--lime);
    box-shadow: 0 0 0 1px var(--bg-secondary) inset;
    transition: height 0.4s ease, background 0.18s ease;
    display: flex;
    justify-content: center;
    align-items: flex-end;
    padding-bottom: 6px;
}
.press-zone.peak {
    background: rgba(185, 255, 102, 0.46);
    border-color: var(--white);
}
.zone-label {
    font-family: var(--font-pixel);
    font-size: 10px;
    letter-spacing: 2px;
    color: var(--lime);
    text-shadow: 2px 2px 0 var(--bg-secondary);
    pointer-events: none;
}
.press-zone.peak .zone-label { color: var(--white); }

.track-bar {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 4px;
    background: rgba(255, 255, 255, 0.07);
}
.barbell {
    position: absolute;
    left: 50%;
    transform: translate(-50%, 0);
    top: 0;
    display: flex;
    align-items: center;
    gap: 4px;
    will-change: transform;
    z-index: 4;
}
.barbell .bar {
    display: inline-block;
    width: 110px;
    height: 8px;
    background: var(--steel);
    border: 2px solid var(--bg-secondary);
}
.barbell .weight {
    display: inline-block;
    background: var(--bg-secondary);
    border: 3px solid var(--pink);
    box-shadow: 2px 2px 0 var(--magenta);
    border-radius: 2px;
    transition: width 0.4s ease, height 0.4s ease, border-color 0.4s, box-shadow 0.4s;
}
/* Per-stage weight plates: bigger & flashier as you progress */
.gym-scene[data-stage="0"] .barbell .weight { width: 24px; height: 50px; }
.gym-scene[data-stage="1"] .barbell .weight { width: 28px; height: 56px; border-color: var(--cyan); box-shadow: 2px 2px 0 var(--magenta); }
.gym-scene[data-stage="2"] .barbell .weight { width: 32px; height: 64px; border-color: var(--yellow); box-shadow: 2px 2px 0 var(--pink); }
.gym-scene[data-stage="3"] .barbell .weight { width: 38px; height: 72px; border-color: var(--magenta); box-shadow: 3px 3px 0 var(--pink); }
.gym-scene[data-stage="4"] .barbell .weight { width: 44px; height: 80px; border-color: var(--lime); box-shadow: 3px 3px 0 var(--magenta); }

/* Arms — children of .character, so their position is anchored to the
   character's shoulder regardless of viewport size.
   bottom: 81% of character height = SVG y=38 (top of deltoid). */
.arm {
    position: absolute;
    bottom: 81%;
    width: 18px;
    background: var(--skin);
    border: 2px solid var(--bg-secondary);
    box-shadow: 2px 2px 0 var(--bg-secondary);
    z-index: 4;
    transition: height 0.06s linear, width 0.4s ease;
}
/* Match SVG deltoid columns at character width 180, viewBox 80:
   left deltoid SVG x=4–14 → display 9–31.5px from char left.
   right deltoid SVG x=66–76 → display 148.5–171px. */
.arm-l { left: 8px; }
.arm-r { left: 154px; }
.gym-scene[data-stage="2"] .arm { width: 20px; }
.gym-scene[data-stage="3"] .arm { width: 22px; }
.gym-scene[data-stage="4"] .arm { width: 24px; }

/* Fist at the top of each arm — slightly wider than the arm shaft, with a
   black outline matching the body. Acts as the "hand" gripping the barbell. */
.arm::after {
    content: '';
    position: absolute;
    top: -10px;
    left: -4px;
    right: -4px;
    height: 10px;
    background: var(--skin);
    border: 2px solid var(--bg-secondary);
    border-bottom: none;
    box-sizing: content-box;
}

/* Bicep shading near the shoulder so the arm reads as a shaped limb,
   not a flat skin-colored bar. */
.arm::before {
    content: '';
    position: absolute;
    bottom: 6px;
    left: 25%;
    width: 50%;
    height: 28px;
    background: #D9A77E;
    pointer-events: none;
}

/* Instruction + flash */
.instruction {
    position: absolute;
    top: 16px;
    left: 50%;
    transform: translateX(-50%);
    font-family: var(--font-pixel);
    font-size: 10px;
    letter-spacing: 2px;
    color: var(--cyan);
    text-shadow: 2px 2px 0 var(--bg-secondary);
    text-align: center;
    background: rgba(5, 0, 16, 0.6);
    padding: 6px 12px;
    border: 2px solid var(--cyan);
    pointer-events: none;
    z-index: 6;
}

.flash-message {
    position: absolute;
    top: 16%;
    left: 50%;
    transform: translateX(-50%) scale(0);
    font-family: var(--font-pixel);
    font-size: clamp(22px, 4vw, 38px);
    letter-spacing: 4px;
    color: var(--yellow);
    text-shadow: 4px 4px 0 var(--bg-secondary), 8px 8px 0 var(--pink);
    pointer-events: none;
    z-index: 7;
    transition: transform 0.18s ease-out, opacity 0.4s;
    opacity: 0;
}
.flash-message.show { transform: translateX(-50%) scale(1); opacity: 1; }
.flash-message.fade { opacity: 0; }

/* LEVEL UP banner */
.level-up {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0);
    background: var(--bg-card);
    border: 4px solid var(--yellow);
    box-shadow: 6px 6px 0 var(--bg-secondary), 12px 12px 0 var(--pink);
    padding: 28px 44px;
    text-align: center;
    pointer-events: none;
    z-index: 8;
    opacity: 0;
    transition: transform 0.3s cubic-bezier(.2,1.6,.5,1), opacity 0.25s;
}
.level-up.show { transform: translate(-50%, -50%) scale(1); opacity: 1; }
.level-up-tag {
    display: block;
    font-family: var(--font-pixel);
    font-size: 14px;
    letter-spacing: 4px;
    color: var(--cyan);
    margin-bottom: 12px;
    text-shadow: 3px 3px 0 var(--bg-secondary);
}
.level-up-name {
    display: block;
    font-family: var(--font-pixel);
    font-size: 26px;
    letter-spacing: 4px;
    color: var(--pink);
    text-shadow: 4px 4px 0 var(--bg-secondary), 8px 8px 0 var(--magenta);
}

/* Touch press button */
.touch-controls {
    display: none;
    position: absolute;
    bottom: 14px;
    left: 14px;
    right: 14px;
    justify-content: center;
    align-items: center;
    z-index: 8;
    pointer-events: none;
}
.touch-btn {
    font-family: var(--font-pixel);
    font-size: 14px;
    letter-spacing: 2px;
    background: var(--yellow);
    color: var(--bg-secondary);
    border: 3px solid var(--bg-secondary);
    box-shadow: 4px 4px 0 var(--bg-secondary), 8px 8px 0 var(--pink);
    width: 140px;
    height: 70px;
    pointer-events: auto;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}
@media (hover: none) and (pointer: coarse) {
    .touch-controls { display: flex; }
}

/* Start / Game over */
.start-screen, .game-over-screen {
    position: absolute;
    inset: 0;
    background: var(--bg-primary);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 100;
    padding: 24px;
    text-align: center;
}
.game-over-screen { background: rgba(5, 0, 16, 0.95); }

.start-screen h1 {
    font-family: var(--font-pixel);
    font-size: clamp(20px, 4vw, 36px);
    color: var(--pink);
    text-shadow: 4px 4px 0 var(--bg-secondary), 8px 8px 0 var(--cyan);
    letter-spacing: 2px;
    margin-bottom: 1.5rem;
}
.game-description {
    font-family: var(--font-crt);
    font-size: 26px;
    color: var(--text-primary);
    margin-bottom: 2rem;
    line-height: 1.5;
}
.instructions {
    background: var(--bg-card);
    border: 3px solid var(--cyan);
    box-shadow: 4px 4px 0 var(--bg-secondary), 8px 8px 0 var(--pink);
    padding: 2rem;
    margin-bottom: 2rem;
    max-width: 480px;
    text-align: left;
}
.instructions h3 {
    font-family: var(--font-pixel);
    font-size: 12px;
    color: var(--yellow);
    letter-spacing: 2px;
    margin-bottom: 1rem;
}
.instructions ul { list-style: none; }
.instructions li {
    font-family: var(--font-crt);
    font-size: 22px;
    margin-bottom: 0.6rem;
    color: var(--text-primary);
}
.start-btn, .play-again-btn, .back-btn {
    font-family: var(--font-pixel);
    font-size: 13px;
    letter-spacing: 2px;
    padding: 18px 32px;
    background: var(--yellow);
    color: var(--bg-secondary);
    border: 3px solid var(--bg-secondary);
    box-shadow: 4px 4px 0 var(--bg-secondary), 8px 8px 0 var(--pink);
    cursor: pointer;
    transition: transform 0.05s, box-shadow 0.05s, background 0.05s;
    text-transform: uppercase;
}
.start-btn:hover, .play-again-btn:hover {
    background: var(--cyan);
    box-shadow: 4px 4px 0 var(--bg-secondary), 8px 8px 0 var(--magenta);
}
.start-btn:active, .play-again-btn:active, .back-btn:active {
    transform: translate(6px, 6px);
    box-shadow: none;
}
.back-btn {
    background: var(--bg-card);
    color: var(--cyan);
    border-color: var(--cyan);
    margin-top: 1rem;
    box-shadow: 4px 4px 0 var(--bg-secondary);
}
.back-btn:hover {
    background: var(--magenta);
    color: var(--text-primary);
    border-color: var(--magenta);
    box-shadow: 4px 4px 0 var(--bg-secondary), 8px 8px 0 var(--pink);
}

.game-over-screen h2 {
    font-family: var(--font-pixel);
    font-size: clamp(20px, 3.5vw, 32px);
    color: var(--pink);
    text-shadow: 4px 4px 0 var(--bg-secondary), 8px 8px 0 var(--magenta);
    letter-spacing: 2px;
    margin-bottom: 1.5rem;
}
.final-score, .final-line {
    font-family: var(--font-pixel);
    font-size: 14px;
    color: var(--yellow);
    letter-spacing: 2px;
    margin-bottom: 0.6rem;
}
.final-line { color: var(--cyan); }
.game-over-message {
    font-family: var(--font-crt);
    font-size: 22px;
    color: var(--text-secondary);
    margin: 1.4rem auto 2rem;
    max-width: 520px;
}

@media (max-width: 600px) {
    .game-header { padding: 0.75rem 1rem; gap: 8px; flex-wrap: wrap; }
    .score-value, .combo-value { font-size: 12px; }
    .label { font-size: 7px; }
    .stage-name { font-size: 9px; }
    .stage-progress { font-size: 7px; }
    .stage-face { font-size: 24px; }
    .instruction { font-size: 8px; }
    .gym-scene { width: 95vw; }
    .barbell .bar { width: 160px; }
    .bench { width: 200px; }
    .character { width: 200px; }
    .rack-left  { left: calc(50% - 80px); }
    .rack-right { left: calc(50% + 66px); }
    .arm-l { left: calc(50% - 86px); }
    .arm-r { left: calc(50% + 70px); }
}
