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

:root {
    --black: #000;
    --white: #fff;
    --font-mono: 'Courier New', Courier, monospace;
    --font-display: 'VT323', 'Courier New', monospace;
    /* Opacity tiers for white-on-black */
    --white-dim:    rgba(255, 255, 255, 0.15);
    --white-faint:  rgba(255, 255, 255, 0.1);
    --white-subtle: rgba(255, 255, 255, 0.2);
    --white-muted:  rgba(255, 255, 255, 0.4);
    --white-soft:   rgba(255, 255, 255, 0.6);
}

html,
body {
    height: 100%;
}

body {
    font-family: 'Courier New', Courier, monospace;
    background-color: var(--black);
    color: var(--white);
    line-height: 1.4;
}

/* VIEWS */
.view {
    display: none;
    min-height: 100vh;
    flex-direction: column;
    padding: 1rem;
}

.view.active {
    display: flex;
}

/* Workout view needs fixed height for scroll behavior */
#view-workout.view.active {
    height: 100vh;
    height: 100dvh;
    max-height: 100vh;
    max-height: 100dvh;
    overflow: hidden;
}

/* HEADER */
header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 1rem;
    border-bottom: 2px solid var(--white);
    margin-bottom: 1.5rem;
}

header h1 {
    font-size: 1.5rem;
    font-family: var(--font-display);
    font-weight: normal;
    letter-spacing: 0.1em;
}

/* MAIN */
main {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

/* FOOTER */
footer {
    padding-top: 1rem;
    border-top: 2px solid var(--white);
    margin-top: auto;
}

/* BUTTONS */
button {
    font-family: inherit;
    font-size: 1rem;
    cursor: pointer;
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

:focus-visible {
    outline: 3px solid var(--white);
    outline-offset: 2px;
}

/* Override for white-background elements where white outline would be invisible */
.btn-primary:focus-visible,
.btn-difficulty.active:focus-visible {
    outline: 3px solid var(--black);
    outline-offset: 2px;
}

.btn-primary {
    width: 100%;
    padding: 1rem;
    background-color: var(--white);
    color: var(--black);
    border: 2px solid var(--white);
    font-weight: bold;
    transition: opacity 0.15s ease;
}

.btn-primary:active {
    background-color: var(--black);
    color: var(--white);
    transform: translateY(2px);
}

.btn-primary:hover {
    opacity: 0.85;
}

.btn-secondary {
    width: 100%;
    padding: 0.75rem;
    background-color: var(--black);
    color: var(--white);
    border: 2px solid var(--white);
    transition: opacity 0.15s ease, background-color 0.1s ease, color 0.1s ease;
}

.btn-secondary:active {
    background-color: var(--white);
    color: var(--black);
}

.btn-secondary:hover {
    opacity: 0.85;
}

.btn-back {
    background: none;
    border: none;
    color: var(--white);
    font-size: 1rem;
    padding: 0.5rem 0;
    min-height: 44px;
    transition: opacity 0.15s ease;
}

.btn-back:hover {
    opacity: 0.6;
}

.btn-back:active {
    opacity: 0.4;
}

/* STREAK DISPLAY */
.streak-display {
    text-align: center;
    padding: 2rem 0;
}

.streak-label {
    display: block;
    font-size: 0.875rem;
    letter-spacing: 0.2em;
    margin-bottom: 0.5rem;
}

.streak-count {
    display: block;
    font-size: 4rem;
    font-weight: bold;
    line-height: 1;
}

.streak-display.large .streak-count {
    font-size: 6rem;
}

/* DIFFICULTY SELECT */
.difficulty-select {
    text-align: center;
}

.difficulty-select label {
    display: block;
    font-size: 0.875rem;
    letter-spacing: 0.2em;
    margin-bottom: 0.75rem;
}

.difficulty-buttons {
    display: flex;
    gap: 0;
}

.btn-difficulty {
    flex: 1;
    padding: 0.75rem 0.5rem;
    min-height: 44px;
    background-color: var(--black);
    color: var(--white);
    border: 2px solid var(--white);
    font-size: 0.75rem;
    transition: background-color 0.1s ease, color 0.1s ease;
}

.btn-difficulty+.btn-difficulty {
    border-left: none;
}

.btn-difficulty.active {
    background-color: var(--white);
    color: var(--black);
}

.btn-difficulty:hover:not(.active) {
    background-color: var(--white-faint);
}

/* WORKOUT STATUS */
.workout-status {
    text-align: center;
    font-size: 0.875rem;
}

.workout-status.completed {
    color: var(--white);
}

/* PROGRESS */
.progress-container {
    flex: 1;
    height: 1rem;
    border: 2px solid var(--white);
    margin: 0 1rem;
    position: relative;
    max-width: 200px;
}

.progress-bar {
    height: 100%;
    background-color: var(--white);
    width: 0%;
    transition: width 0.3s ease;
}

.progress {
    font-size: 1rem;
    letter-spacing: 0.1em;
}

/* EXERCISE DISPLAY */
.exercise-name {
    text-align: center;
    font-size: 1.75rem;
    font-family: var(--font-display);
    font-weight: normal;
    letter-spacing: 0;
    text-transform: uppercase;
    line-height: 0.92;
    max-width: 100%;
    min-width: 0;
    overflow-wrap: anywhere;
    text-wrap: balance;
}

.exercise-images {
    flex-shrink: 0;
    text-align: center;
}

.exercise-images img {
    display: block;
    margin: 0 auto;
    max-width: 100%;
    max-height: 200px;
    border: 2px solid var(--white);
    background-color: var(--black);
    filter: grayscale(100%) contrast(1.2) brightness(0.9);
}


/* REPS AND TIMER ROW */
.reps-timer-row {
    flex-shrink: 0;
    display: flex;
    gap: 0.5rem;
    align-items: stretch;
}

/* EXERCISE REPS */
.exercise-reps {
    flex: 1;
    text-align: center;
    padding: 0.75rem 0.5rem;
    border: 2px solid var(--white);
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.exercise-reps .reps-count {
    display: block;
    font-size: 2.5rem;
    font-weight: bold;
    line-height: 1;
}

.exercise-reps .reps-label {
    display: block;
    font-size: 0.75rem;
    letter-spacing: 0.15em;
    margin-top: 0.25rem;
}

/* INLINE TIMER CONTAINER */
.timer-container-inline {
    flex: 1;
}

.timer-container-inline:empty {
    display: none;
}

.timer-container-inline .timer {
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 0.5rem;
}

.timer-container-inline .timer-digits {
    font-size: 2rem;
}

.timer-container-inline .timer-type {
    font-size: 0.75rem;
}

.timer-container-inline .timer-progress {
    margin-top: 0.25rem;
}

.timer-container-inline .timer-control {
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
    margin-top: 0.25rem;
}



/* EXERCISE INSTRUCTIONS */
.exercise-instructions {
    flex: 1;
    overflow-y: auto;
    min-height: 0;
    /* Critical for flexbox scroll to work */
    padding-bottom: 0.5rem;
}

.exercise-instructions h3 {
    font-size: 0.875rem;
    letter-spacing: 0.2em;
    margin-bottom: 0.75rem;
    font-weight: normal;
}

.exercise-instructions ol {
    padding-left: 2rem;
    font-size: 0.875rem;
}

.exercise-instructions li {
    margin-bottom: 0.5rem;
}

/* WORKOUT FOOTER */
.workout-footer {
    flex-shrink: 0;
    background-color: var(--black);
    padding: 1rem;
    border-top: 2px solid var(--white);
    margin-top: auto;
    display: flex;
    justify-content: space-between;
}

/* WORKOUT MAIN */
.workout-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-height: 0;
    /* Critical for nested flex scroll */
    gap: 1rem;
}

/* COMPLETE VIEW */
.complete-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    gap: 2rem;
}

.complete-main h1 {
    font-size: 1.5rem;
    letter-spacing: 0.2em;
}

.complete-main .btn-primary {
    width: auto;
    padding: 1rem 3rem;
}

/* HISTORY */
.history-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.history-item {
    border: 2px solid var(--white);
    padding: 1rem;
}

.history-item-date {
    font-size: 0.875rem;
    letter-spacing: 0.1em;
    margin-bottom: 0.5rem;
    display: block;
}

.history-item-exercises {
    font-size: 0.75rem;
    color: var(--white);
    opacity: 0.6;
}

.history-empty {
    text-align: center;
    padding: 2rem;
    font-size: 0.875rem;
    letter-spacing: 0.1em;
    line-height: 1.8;
    display: none;
}

.history-empty.visible {
    display: block;
}

/* RESPONSIVE - Tablet and up */
@media (min-width: 600px) {
    .view {
        max-width: 500px;
        margin: 0 auto;
        padding: 2rem;
    }

    header h1 {
        font-size: 2rem;
    }

    .streak-count {
        font-size: 5rem;
    }

    .streak-display.large .streak-count {
        font-size: 8rem;
    }

    .btn-difficulty {
        font-size: 0.875rem;
        padding: 1rem;
    }

    .exercise-images img {
        max-height: 300px;
    }

    .exercise-name {
        font-size: 2.25rem;
    }

    .exercise-reps .reps-count {
        font-size: 4rem;
    }
}

/* ============================================
   V2 STYLES - Gamification, Timer, Analytics
   ============================================ */

/* VERSION BADGE */
.version-badge {
    font-size: 0.625rem;
    padding: 0.25rem 0.5rem;
    border: 1px solid var(--white);
    opacity: 0.4;
}

/* PLAYER CARD */
.player-card {
    border: 1px solid rgba(255, 255, 255, 0.5);
    padding: 1rem;
    margin-bottom: 0.5rem;
}

.player-level {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
}

.level-badge {
    font-size: 1.25rem;
    font-weight: bold;
    letter-spacing: 0.1em;
}

.player-title {
    font-size: 0.875rem;
    letter-spacing: 0.2em;
    opacity: 0.6;
}

/* XP BAR */
.xp-bar {
    height: 1.5rem;
    border: 2px solid var(--white);
    position: relative;
    margin-bottom: 1rem;
}

.xp-bar-fill {
    height: 100%;
    background-color: var(--white);
    transition: width 0.5s ease;
}

.xp-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 0.75rem;
    letter-spacing: 0.1em;
    color: var(--white);
    mix-blend-mode: difference;
}

/* PLAYER STATS ROW */
.player-stats-row {
    display: flex;
    justify-content: space-around;
    text-align: center;
}

.mini-stat {
    flex: 1;
}

.mini-stat .stat-value {
    display: block;
    font-size: 1.5rem;
    font-weight: bold;
    line-height: 1;
}

.mini-stat .stat-label {
    display: block;
    font-size: 0.75rem;
    letter-spacing: 0.15em;
    opacity: 0.6;
    margin-top: 0.25rem;
}

/* NAV FOOTER */
.nav-footer {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.btn-nav {
    flex: 1;
    min-width: 80px;
    padding: 0.75rem 0.5rem;
    min-height: 44px;
    background-color: var(--black);
    color: var(--white-soft);
    border: 1px solid rgba(255, 255, 255, 0.35);
    font-size: 0.625rem;
    letter-spacing: 0.08em;
    transition: background-color 0.1s ease, color 0.1s ease;
}

.btn-nav:active {
    background-color: var(--white);
    color: var(--black);
}

.btn-nav:hover {
    background-color: var(--white-faint);
    color: var(--white);
}


/* TIMER CONTAINER */
.timer-container {
    margin-bottom: 0.75rem;
}

.timer {
    text-align: center;
    padding: 0.75rem;
    border: 2px solid var(--white);
    position: relative;
}

.timer.paused {
    opacity: 0.4;
}

.timer.complete {
    background-color: var(--white);
    color: var(--black);
}

.timer-type {
    font-size: 0.75rem;
    letter-spacing: 0.2em;
    margin-bottom: 0.25rem;
    opacity: 0.6;
}

.timer-digits {
    font-size: 2.5rem;
    font-weight: bold;
    line-height: 1;
    letter-spacing: 0.1em;
    font-variant-numeric: tabular-nums;
}

.timer-progress {
    height: 4px;
    background-color: var(--white-subtle);
    margin-top: 0.5rem;
}

.timer-progress-bar {
    height: 100%;
    background-color: var(--white);
    transition: width 0.3s linear;
}

.timer-control {
    margin-top: 0.5rem;
    padding: 0.5rem 1rem;
    font-size: 0.75rem;
    background: transparent;
    border: 1px solid var(--white);
    color: var(--white);
    transition: background-color 0.1s ease;
}

.timer-control:hover {
    background: var(--white-faint);
}

.timer-complete-text {
    font-size: 1rem;
    margin-top: 0.5rem;
    animation: blink 0.5s infinite;
}

@keyframes blink {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.3;
    }
}

/* COMPLETE VIEW ENHANCED */
.complete-icon {
    min-width: 180px;
}

.complete-stats-row {
    display: flex;
    gap: 1rem;
    justify-content: center;
}

.complete-stat {
    text-align: center;
    padding: 1rem;
    border: 2px solid var(--white);
    min-width: 80px;
}

.complete-stat .stat-value {
    display: block;
    font-size: 1.5rem;
    font-weight: bold;
}

.complete-stat .stat-label {
    display: block;
    font-size: 0.75rem;
    letter-spacing: 0.1em;
    opacity: 0.6;
    margin-top: 0.25rem;
}

.streak-celebration {
    font-size: 1rem;
    padding: 0.75rem 1.5rem;
    border: 2px solid var(--white);
    animation: streakPulse 1s infinite;
    transform-origin: center center;
}

@keyframes streakPulse {

    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.05);
    }
}

/* LEVEL UP VIEW */
.levelup-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    gap: 1.5rem;
}

.levelup-animation {
    padding: 2rem 1rem;
}

.celebration-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 3.5rem;
    padding: 0.5rem 1.5rem;
    border: 2px solid var(--white);
    background: var(--white);
    color: var(--black);
    font-family: var(--font-display);
    font-size: 2.5rem;
    line-height: 1;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    box-shadow: 6px 6px 0 var(--black), 8px 8px 0 var(--white);
    animation: badgePulse 1s infinite steps(2, end);
}

.levelup-badge {
    min-width: 150px;
    font-size: 3.5rem;
}

@keyframes badgePulse {

    0%,
    100% {
        transform: translate(0, 0);
        opacity: 1;
    }

    50% {
        transform: translate(2px, -2px);
        opacity: 0.92;
    }
}

.levelup-title {
    font-size: 2rem;
    letter-spacing: 0.3em;
    margin: 1rem 0;
}

.levelup-level {
    font-size: 3rem;
    font-weight: bold;
}

.levelup-rank {
    font-size: 1.5rem;
    letter-spacing: 0.2em;
    margin-top: 0.5rem;
}

.levelup-desc {
    font-size: 0.875rem;
    opacity: 0.6;
    margin-top: 0.25rem;
}

.levelup-bonus {
    margin-top: 1rem;
    padding: 0.75rem 1.5rem;
    border: 2px solid var(--white);
    font-size: 0.875rem;
}

/* LEVEL UP VIEW */
#view-levelup {
    background-color: var(--black);
    color: var(--white);
}

#view-levelup::before {
    content: '';
    position: fixed;
    inset: 0;
    background: repeating-linear-gradient(
        to bottom,
        transparent 0px,
        transparent 2px,
        rgba(255, 255, 255, 0.05) 2px,
        rgba(255, 255, 255, 0.05) 4px
    );
    pointer-events: none;
    z-index: 0;
}

#view-levelup > * {
    position: relative;
    z-index: 1;
}

#view-levelup .btn-primary {
    background-color: var(--white);
    color: var(--black);
    border-color: var(--white);
}

#view-levelup .btn-primary:active {
    background-color: var(--black);
    color: var(--white);
}

#view-levelup .btn-primary:focus-visible {
    outline-color: var(--white);
}

.levelup-level {
    font-size: 5rem;
    letter-spacing: 0.1em;
    line-height: 1;
}

.levelup-rank {
    font-size: 2rem;
    letter-spacing: 0.3em;
}

#view-levelup .levelup-bonus {
    background: var(--white);
    color: var(--black);
    border-color: var(--white);
}

/* REST VIEW */
.rest-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    gap: 1.5rem;
}

.rest-title {
    font-size: 2rem;
    letter-spacing: 0.3em;
}

.rest-next {
    font-size: 0.875rem;
    opacity: 0.6;
}

/* STATS VIEW */
.stats-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
}

.stat-card {
    border: 2px solid var(--white);
    padding: 1rem;
    text-align: center;
}

.stat-card .stat-value {
    display: block;
    font-size: 2rem;
    font-weight: bold;
    line-height: 1;
}

.stat-card .stat-label {
    display: block;
    font-size: 0.75rem;
    letter-spacing: 0.1em;
    opacity: 0.6;
    margin-top: 0.5rem;
}

/* CALENDAR */
.calendar-section {
    margin-top: 1rem;
}

.calendar-section h2 {
    font-size: 0.75rem;
    letter-spacing: 0.2em;
    font-weight: normal;
    margin-bottom: 1rem;
}

.calendar-grid {
    border: 2px solid var(--white);
    padding: 0.75rem;
}

.calendar-header {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 2px;
    margin-bottom: 0.5rem;
}

.calendar-day-name {
    text-align: center;
    font-size: 0.75rem;
    opacity: 0.6;
}

.calendar-week {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 2px;
}

.calendar-day {
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    border: 1px solid var(--white-subtle);
}

.calendar-day.empty {
    border-color: transparent;
}

.calendar-day.completed {
    background-color: var(--white);
    color: var(--black);
    font-weight: bold;
}

/* SETTINGS VIEW */
.settings-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.settings-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.setting-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem;
    border: 2px solid var(--white);
}

.setting-item label,
.setting-item .setting-label {
    font-size: 0.875rem;
}

.setting-item input[type="checkbox"] {
    width: 1.5rem;
    height: 1.5rem;
    appearance: none;
    -webkit-appearance: none;
    background-color: var(--black);
    border: 2px solid var(--white);
    cursor: pointer;
    position: relative;
    flex-shrink: 0;
}

.setting-item input[type="checkbox"]:checked::before {
    content: '✓';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: var(--white);
    font-size: 1rem;
    line-height: 1;
    font-family: var(--font-mono);
}

.setting-item select {
    font-family: inherit;
    font-size: 0.875rem;
    padding: 0.5rem;
    background-color: var(--black);
    color: var(--white);
    border: 2px solid var(--white);
}

.setting-item-stack {
    flex-direction: column;
    align-items: stretch;
    gap: 0.5rem;
}

.setting-item-stack .setting-label {
    align-self: flex-start;
}

.focus-buttons {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    grid-auto-rows: 40px;
}

.btn-focus {
    padding: 0.5rem 0.25rem;
    background-color: var(--black);
    color: var(--white);
    border: 2px solid var(--white);
    font-size: 0.7rem;
    transition: background-color 0.1s ease, color 0.1s ease;
}

/* Collapse shared borders so row 1 (buttons 1-4) and row 2 (buttons 5-7) look like one grid */
.btn-focus:nth-child(2),
.btn-focus:nth-child(3),
.btn-focus:nth-child(4),
.btn-focus:nth-child(6),
.btn-focus:nth-child(7) {
    border-left: none;
}

.btn-focus:nth-child(n+5) {
    border-top: none;
}

.btn-focus.active {
    background-color: var(--white);
    color: var(--black);
}

.btn-focus:hover:not(.active) {
    background-color: var(--white-faint);
}

.settings-actions {
    margin-top: 1rem;
}

.btn-test-sound {
    background: transparent;
    border: 2px solid var(--white);
    color: var(--white);
    font-family: inherit;
    font-size: 0.75rem;
    letter-spacing: 0.1em;
    padding: 0.5rem 0.75rem;
    min-height: 44px;
    cursor: pointer;
    transition: background-color 0.1s ease;
}

.btn-test-sound:hover {
    background: var(--white-faint);
}

.btn-danger {
    width: 100%;
    padding: 0.75rem;
    background-color: transparent;
    color: var(--white);
    border: 2px dashed var(--white);
    transition: background-color 0.1s ease, color 0.1s ease;
}

.btn-danger:hover {
    background-color: var(--white);
    color: var(--black);
}

.about-section {
    margin-top: auto;
    text-align: center;
    padding: 1rem;
    opacity: 0.6;
}

.about-section h3 {
    font-size: 0.75rem;
    letter-spacing: 0.2em;
    margin-bottom: 0.5rem;
}

.about-section p {
    font-size: 0.75rem;
    margin-bottom: 0.25rem;
}

.about-section a {
    color: var(--white);
    text-decoration: underline;
}

.support-buttons {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
    margin: 1rem 0;
}

/* Retro button face overlaid on top of the invisible Stripe iframe */
.donate-wrapper {
    position: relative;
    width: 100%;
    max-width: 240px;
    height: 48px;
    overflow: hidden;
    margin: 0 auto;
    cursor: pointer;
}

.donate-btn-face {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--white);
    color: var(--black);
    font-family: var(--font-mono);
    font-size: 0.875rem;
    font-weight: bold;
    letter-spacing: 0.05em;
    pointer-events: none;
    z-index: 1;
}

/* Stripe iframe is invisible but sits on top and receives clicks */
.donate-wrapper stripe-buy-button {
    position: absolute;
    top: 0;
    left: 0;
    width: 400px;
    height: 200px;
    opacity: 0.001;
    z-index: 2;
}

.btn-feedback {
    display: block;
    text-align: center;
    padding: 0.6rem 1.5rem;
    border: 2px solid var(--white);
    color: var(--white);
    background: transparent;
    font-family: var(--font-mono);
    font-size: 0.875rem;
    font-weight: bold;
    letter-spacing: 0.05em;
    text-decoration: none;
    width: 100%;
    max-width: 240px;
    box-sizing: border-box;
}

.btn-feedback:hover {
    opacity: 0.85;
}

.btn-feedback:active {
    background: var(--white);
    color: var(--black);
}

.support-prompt {
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid var(--white-subtle);
    text-align: center;
}

.support-prompt-text {
    font-size: 0.875rem;
    margin-bottom: 0.75rem;
    opacity: 0.6;
}

/* PREP OVERLAY */
.prep-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.9);
    z-index: 100;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

.prep-overlay.active {
    display: flex;
}

.prep-title {
    font-size: 2rem;
    font-weight: bold;
    letter-spacing: 0.2em;
    margin-bottom: 2rem;
    text-align: center;
}

.prep-count {
    font-size: 8rem;
    font-weight: bold;
    color: var(--white);
    animation: prepPulse 1s infinite;
}

@keyframes prepPulse {
    0% {
        transform: scale(1);
        opacity: 1;
    }

    50% {
        transform: scale(1.1);
        opacity: 0.8;
    }

    100% {
        transform: scale(1);
        opacity: 1;
    }
}

/* SIDE INDICATOR */
.side-indicator {
    display: inline-block;
    font-size: 0.75rem;
    background-color: var(--white);
    color: var(--black);
    padding: 0.25rem 0.5rem;
    margin-right: 0.5rem;
    vertical-align: middle;
    font-weight: bold;
}

/* REST PREVIEW */
.next-exercise-preview {
    margin-bottom: 2rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

.preview-label {
    font-size: 0.875rem;
    letter-spacing: 0.1em;
    opacity: 0.6;
}

.exercise-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.35rem;
    margin-bottom: 0.25rem;
}

.exercise-name-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    flex-wrap: nowrap;
    flex-direction: column;
    width: 100%;
}

.exercise-side {
    flex-shrink: 0;
    background: var(--white);
    color: var(--black);
    padding: 0.2rem 0.5rem;
    font-weight: bold;
    font-size: 0.875rem;
    letter-spacing: 0.15em;
    border: 2px solid var(--white);
    animation: pulse 2s infinite;
    align-self: center;
}

@keyframes pulse {
    0% {
        opacity: 1;
    }

    50% {
        opacity: 0.7;
    }

    100% {
        opacity: 1;
    }
}


.exercise-preview-img {
    max-width: 150px;
    height: auto;
    border: 2px solid var(--white);
    display: none;
    margin: 0.5rem 0;
    filter: grayscale(100%) contrast(1.2) brightness(0.9);
}

.rest-next {
    font-size: 1.25rem;
    font-weight: bold;
    color: var(--white);
}

.rest-instructions-preview {
    font-size: 0.875rem;
    max-width: 80%;
    margin-top: 0.5rem;
    text-align: left;
    max-height: 100px;
    overflow-y: auto;
    border-top: 1px solid var(--white-subtle);
    padding-top: 0.5rem;
}

.rest-instructions-preview ul {
    list-style: none;
    padding: 0;
}

.rest-instructions-preview li {
    margin-bottom: 0.25rem;
    opacity: 0.6;
}

/* ============================================
   LEADERBOARD
   ============================================ */

.leaderboard-main {
    padding: 1rem;
    overflow-y: auto;
    flex: 1;
}

.leaderboard-username-section {
    margin-bottom: 1rem;
}

.leaderboard-username-display {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem;
    border: 2px solid var(--white);
}

.leaderboard-username-display span {
    font-weight: bold;
    letter-spacing: 0.1em;
}

.leaderboard-username-form label {
    display: block;
    font-size: 0.75rem;
    letter-spacing: 0.15em;
    margin-bottom: 0.5rem;
    opacity: 0.6;
}

.username-input-row {
    display: flex;
    gap: 0.5rem;
}

.username-input-row input {
    flex: 1;
    background: var(--black);
    border: 2px solid var(--white);
    color: var(--white);
    padding: 0.75rem;
    font-family: 'Courier New', monospace;
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.username-input-row input::placeholder {
    color: var(--white-muted);
}

.btn-small {
    padding: 0.5rem 1rem;
    font-size: 0.75rem;
    white-space: nowrap;
}

.leaderboard-list {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.leaderboard-item {
    display: flex;
    align-items: center;
    padding: 0.75rem;
    border-bottom: 1px solid var(--white-subtle);
    gap: 0.75rem;
}

.leaderboard-item.leaderboard-podium {
    border: 2px solid var(--white);
    border-bottom: 2px solid var(--white);
    margin-bottom: 0.25rem;
}

.leaderboard-item.current-user {
    background: var(--white);
    color: var(--black);
}

.leaderboard-rank {
    font-size: 1.25rem;
    font-weight: bold;
    min-width: 2rem;
    text-align: center;
}

.leaderboard-podium .leaderboard-rank {
    font-size: 1.5rem;
}

.leaderboard-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.leaderboard-name {
    font-weight: bold;
    letter-spacing: 0.05em;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.leaderboard-meta {
    font-size: 0.75rem;
    opacity: 0.6;
    letter-spacing: 0.1em;
}

.current-user .leaderboard-meta {
    opacity: 0.4;
}

.leaderboard-xp {
    font-size: 0.75rem;
    font-weight: bold;
    letter-spacing: 0.05em;
    white-space: nowrap;
}

.leaderboard-empty,
.leaderboard-loading {
    text-align: center;
    padding: 3rem 1rem;
    opacity: 0.6;
    letter-spacing: 0.1em;
    font-size: 0.875rem;
    line-height: 1.6;
}

#btn-sync-score {
    width: 100%;
    margin-bottom: 1rem;
}

/* WORKOUT PREVIEW VIEW */
#view-preview {
    height: 100vh;
    height: 100dvh;
    max-height: 100vh;
    max-height: 100dvh;
    overflow: hidden;
}

.preview-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    overflow-y: auto;
    min-height: 0;
}

.preview-subtitle {
    font-size: 0.75rem;
    letter-spacing: 0.12em;
    text-align: center;
    opacity: 0.4;
    flex-shrink: 0;
}

.preview-list {
    display: flex;
    flex-direction: column;
    flex: 1;
}

.preview-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--white-subtle);
    gap: 0.75rem;
}

.preview-item:first-child {
    border-top: 1px solid var(--white-subtle);
}

.preview-item-left {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    flex: 1;
    min-width: 0;
}

.preview-phase {
    font-size: 0.75rem;
    letter-spacing: 0.2em;
    opacity: 0.4;
}

.preview-item-name {
    font-size: 0.875rem;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.btn-replace {
    background: none;
    border: 1px solid rgba(255, 255, 255, 0.6);
    color: var(--white);
    font-size: 1.1rem;
    padding: 0.5rem 0.75rem;
    cursor: pointer;
    flex-shrink: 0;
    line-height: 1;
    font-family: inherit;
    min-width: 44px;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.1s ease;
}

.btn-replace:active {
    background-color: var(--white);
    color: var(--black);
}

.btn-replace:hover {
    background-color: var(--white-dim);
}

.btn-replace.spinning {
    opacity: 0.4;
    pointer-events: none;
}

/* SKIP NAV */
.skip-nav {
    position: absolute;
    top: -100%;
    left: 0;
    padding: 0.75rem 1.5rem;
    background: var(--white);
    color: var(--black);
    font-family: inherit;
    font-weight: bold;
    letter-spacing: 0.1em;
    z-index: 9999;
    text-decoration: none;
}
.skip-nav:focus {
    top: 0;
}

/* DISPLAY FONT — VT323 for large numbers and display headings.
   Placed last so it wins the cascade over element-specific font-weight/letter-spacing. */
.streak-count,
.timer-digits,
.reps-count,
.levelup-level,
.levelup-title,
.levelup-rank,
.celebration-badge,
.prep-count,
.stat-card .stat-value,
.mini-stat .stat-value,
.complete-stat .stat-value,
.complete-icon,
.complete-main h1,
.rest-title {
    font-family: var(--font-display);
    font-weight: normal;
    letter-spacing: 0;
}

/* REDUCED MOTION */
@media (prefers-reduced-motion: reduce) {
    .streak-celebration,
    .timer-complete-text,
    .celebration-badge,
    .prep-count,
    .exercise-side {
        animation: none;
    }
}

/* EXERCISE PHASE TAG */
.exercise-phase-tag {
    font-size: 0.75rem;
    letter-spacing: 0.2em;
    opacity: 0.6;
    text-transform: uppercase;
    text-align: center;
    min-height: 1rem;
}

@media (min-width: 600px) {
    .exercise-name-row {
        flex-direction: row;
        flex-wrap: wrap;
    }
}

/* DONATE WRAPPER KEYBOARD FOCUS */
.donate-wrapper:focus-within {
    outline: 3px solid var(--white);
    outline-offset: 2px;
}

/* SETTING HINT */
.setting-hint {
    display: block;
    font-size: 0.65rem;
    letter-spacing: 0.1em;
    opacity: 0.5;
    margin-top: 0.2rem;
    font-weight: normal;
    text-transform: none;
}
