/* ─── Reset & Base ─────────────────────────────────────────── */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --color-bg: #050510;
    --color-hp: #00ff88;
    --color-hp-low: #ff2244;
    --color-hp-mid: #ffaa00;
    --color-block: #2288ff;
    --color-punch-ready: #00ff88;
    --color-punch-cooldown: #ff4466;
    --color-stun: #ffcc00;
    --color-glass: rgba(8, 8, 18, 0.7);
    --color-glass-border: rgba(255, 255, 255, 0.06);
    --color-glass-shine: rgba(255, 255, 255, 0.03);
    --font: 'Outfit', sans-serif;
    --glow-hp: 0 0 12px rgba(0, 255, 136, 0.4), 0 0 30px rgba(0, 255, 136, 0.1);
    --glow-hp-low: 0 0 12px rgba(255, 34, 68, 0.5), 0 0 30px rgba(255, 34, 68, 0.15);
    --glow-hp-mid: 0 0 12px rgba(255, 170, 0, 0.4), 0 0 30px rgba(255, 170, 0, 0.1);
}

html,
body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: var(--color-bg);
    font-family: var(--font);
    color: #fff;
    cursor: crosshair;
}

/* ─── Canvas ───────────────────────────────────────────────── */
#gameCanvas {
    display: block;
    width: 100%;
    height: 100%;
    position: fixed;
    top: 0;
    left: 0;
    z-index: 0;
}

/* ─── Hidden utility ───────────────────────────────────────── */
.hidden {
    display: none !important;
}

/* ─── LOBBY SCREEN ─────────────────────────────────────────── */
#lobby-screen {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(ellipse at center, #0a0a1a 0%, #050510 100%);
}

.lobby-container {
    text-align: center;
    max-width: 440px;
    width: 90%;
    padding: 3rem 2.5rem;
    background: rgba(10, 10, 25, 0.85);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 24px;
    backdrop-filter: blur(24px);
    box-shadow:
        0 0 60px rgba(100, 80, 200, 0.08),
        0 0 120px rgba(255, 50, 80, 0.04),
        inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.lobby-title {
    font-size: 2.8rem;
    font-weight: 800;
    letter-spacing: 3px;
    background: linear-gradient(135deg, #ff4466, #ffaa33, #ff4466);
    background-size: 200% 200%;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    animation: titleShift 4s ease infinite;
    margin-bottom: 0.3rem;
}

.lobby-subtitle {
    font-size: 0.95rem;
    color: rgba(255, 255, 255, 0.35);
    letter-spacing: 2px;
    text-transform: uppercase;
    margin-bottom: 2.5rem;
}

.lobby-actions {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

/* ─── Lobby Buttons ────────────────────────────────────────── */
.lobby-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.3rem;
    padding: 1.1rem 2rem;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 16px;
    font-family: var(--font);
    cursor: pointer;
    transition: all 0.25s ease;
    position: relative;
    overflow: hidden;
}

.lobby-btn::before {
    content: '';
    position: absolute;
    inset: 0;
    opacity: 0;
    transition: opacity 0.25s;
}

.lobby-btn:hover::before {
    opacity: 1;
}

.lobby-btn-create {
    background: linear-gradient(135deg, rgba(255, 50, 80, 0.15), rgba(255, 120, 50, 0.1));
    color: #fff;
}

.lobby-btn-create::before {
    background: linear-gradient(135deg, rgba(255, 50, 80, 0.25), rgba(255, 120, 50, 0.18));
}

.lobby-btn-create:hover {
    border-color: rgba(255, 80, 100, 0.3);
    box-shadow: 0 0 30px rgba(255, 50, 80, 0.15);
    transform: translateY(-2px);
}

.lobby-btn-join {
    background: linear-gradient(135deg, rgba(34, 100, 255, 0.15), rgba(80, 160, 255, 0.1));
    color: #fff;
    padding: 0.85rem 1.5rem;
    flex-shrink: 0;
}

.lobby-btn-join::before {
    background: linear-gradient(135deg, rgba(34, 100, 255, 0.25), rgba(80, 160, 255, 0.18));
}

.lobby-btn-join:hover {
    border-color: rgba(34, 100, 255, 0.3);
    box-shadow: 0 0 30px rgba(34, 100, 255, 0.15);
    transform: translateY(-2px);
}

.btn-icon {
    font-size: 1.5rem;
}

.btn-text {
    font-size: 1.05rem;
    font-weight: 700;
    letter-spacing: 1px;
}

.btn-hint {
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.35);
    letter-spacing: 0.5px;
}

/* ─── Divider ────────────────────────────────────────────── */
.lobby-divider {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin: 0.6rem 0;
    color: rgba(255, 255, 255, 0.2);
    font-size: 0.8rem;
    letter-spacing: 2px;
}

.lobby-divider::before,
.lobby-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: linear-gradient(to right, transparent, rgba(255, 255, 255, 0.08), transparent);
}

/* ─── Join Section ───────────────────────────────────────── */
.join-section {
    display: flex;
    flex-direction: column;
    gap: 0.7rem;
}

.join-label {
    font-size: 0.85rem;
    color: rgba(255, 255, 255, 0.4);
    text-transform: uppercase;
    letter-spacing: 1.5px;
}

.join-input-row {
    display: flex;
    gap: 0.6rem;
    align-items: stretch;
}

.code-input {
    flex: 1;
    padding: 0.85rem 1rem;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    color: #fff;
    font-family: 'Courier New', monospace;
    font-size: 1.4rem;
    font-weight: 700;
    letter-spacing: 8px;
    text-align: center;
    text-transform: uppercase;
    outline: none;
    transition: all 0.25s;
}

.code-input::placeholder {
    color: rgba(255, 255, 255, 0.15);
    letter-spacing: 6px;
    font-size: 1rem;
}

.code-input:focus {
    border-color: rgba(34, 100, 255, 0.4);
    box-shadow: 0 0 20px rgba(34, 100, 255, 0.1);
    background: rgba(255, 255, 255, 0.06);
}

/* ─── Error Toast ────────────────────────────────────────── */
.lobby-error {
    margin-top: 1.2rem;
    padding: 0.75rem 1rem;
    background: rgba(255, 34, 68, 0.12);
    border: 1px solid rgba(255, 34, 68, 0.25);
    border-radius: 10px;
    color: #ff6677;
    font-size: 0.85rem;
    animation: fadeIn 0.3s ease;
}

/* ─── Waiting State ──────────────────────────────────────── */
.lobby-waiting {
    margin-top: 2rem;
    animation: fadeIn 0.4s ease;
}

.waiting-spinner {
    width: 32px;
    height: 32px;
    margin: 0 auto 1rem;
    border: 3px solid rgba(255, 255, 255, 0.1);
    border-top-color: #ff4466;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.waiting-text {
    font-size: 0.95rem;
    color: rgba(255, 255, 255, 0.5);
    margin-bottom: 1.2rem;
}

.room-code-display {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.8rem;
    margin-bottom: 0.5rem;
}

.code-label {
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.35);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.code-value {
    font-family: 'Courier New', monospace;
    font-size: 2rem;
    font-weight: 800;
    letter-spacing: 6px;
    background: linear-gradient(135deg, #ff4466, #ffaa33);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    user-select: all;
}

.code-hint {
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.25);
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(6px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ─── HUD Overlay ──────────────────────────────────────────── */
#hud {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 10;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 20px 24px;
    pointer-events: none;
}

/* ─── HP Containers ────────────────────────────────────────── */
.hp-container {
    width: 300px;
    backdrop-filter: blur(20px) saturate(130%);
    background: var(--color-glass);
    border: 1px solid var(--color-glass-border);
    border-radius: 14px;
    padding: 14px 18px 12px;
    position: relative;
    overflow: hidden;
}

/* Shimmer across the glass panel */
.hp-container::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg,
            transparent,
            var(--color-glass-shine),
            transparent);
    animation: shimmer 6s ease-in-out infinite;
}

.hp-left::before {
    animation-delay: 0s;
}

.hp-right::before {
    animation-delay: 3s;
}

@keyframes shimmer {

    0%,
    100% {
        left: -100%;
    }

    50% {
        left: 100%;
    }
}

.hp-label {
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 3px;
    text-transform: uppercase;
    margin-bottom: 8px;
    opacity: 0.5;
    display: flex;
    align-items: center;
    gap: 6px;
}

.hp-label .player-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    display: inline-block;
}

.hp-left .player-dot {
    background: #ff3344;
    box-shadow: 0 0 6px #ff3344;
}

.hp-right .player-dot {
    background: #3366ff;
    box-shadow: 0 0 6px #3366ff;
}

/* ─── HP Bars ──────────────────────────────────────────────── */
.hp-bar-bg {
    width: 100%;
    height: 16px;
    background: rgba(255, 255, 255, 0.04);
    border-radius: 8px;
    overflow: hidden;
    position: relative;
    border: 1px solid rgba(255, 255, 255, 0.04);
}

/* Notches on the HP bar */
.hp-bar-bg::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: repeating-linear-gradient(90deg,
            transparent,
            transparent 9.8%,
            rgba(0, 0, 0, 0.3) 9.8%,
            rgba(0, 0, 0, 0.3) 10.2%);
    z-index: 2;
    pointer-events: none;
}

.hp-bar-fill {
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, #00cc66, #00ff88, #66ffaa);
    border-radius: 8px;
    transition: width 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    position: relative;
    box-shadow: var(--glow-hp);
}

/* Animated shine on HP bar */
.hp-bar-fill::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 50%;
    background: linear-gradient(180deg,
            rgba(255, 255, 255, 0.25) 0%,
            rgba(255, 255, 255, 0) 100%);
    border-radius: 8px 8px 0 0;
}

.hp-bar-fill.mid {
    background: linear-gradient(90deg, #cc8800, #ffaa00, #ffcc44);
    box-shadow: var(--glow-hp-mid);
}

.hp-bar-fill.low {
    background: linear-gradient(90deg, #cc0022, #ff2244, #ff6666);
    box-shadow: var(--glow-hp-low);
    animation: hpPulse 0.8s ease-in-out infinite;
}

@keyframes hpPulse {

    0%,
    100% {
        box-shadow: var(--glow-hp-low);
    }

    50% {
        box-shadow: 0 0 20px rgba(255, 34, 68, 0.7), 0 0 40px rgba(255, 34, 68, 0.25);
    }
}

/* HP percentage text */
.hp-text {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 9px;
    font-weight: 800;
    letter-spacing: 0.5px;
    z-index: 3;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
}

/* ─── Status Badge ─────────────────────────────────────────── */
.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    margin-top: 8px;
    padding: 3px 12px;
    font-size: 9px;
    font-weight: 800;
    letter-spacing: 2px;
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.06);
    text-transform: uppercase;
    transition: all 0.2s ease;
}

.status-badge::before {
    content: '';
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    transition: all 0.2s ease;
}

.status-badge.punching {
    background: rgba(255, 34, 68, 0.2);
    border-color: rgba(255, 34, 68, 0.35);
    color: #ff6677;
    box-shadow: 0 0 15px rgba(255, 34, 68, 0.15);
}

.status-badge.punching::before {
    background: #ff3344;
    box-shadow: 0 0 6px #ff3344;
}

.status-badge.blocking {
    background: rgba(34, 136, 255, 0.2);
    border-color: rgba(34, 136, 255, 0.35);
    color: #66aaff;
    box-shadow: 0 0 15px rgba(34, 136, 255, 0.15);
}

.status-badge.blocking::before {
    background: #2288ff;
    box-shadow: 0 0 6px #2288ff;
}

.status-badge.stunned {
    background: rgba(255, 204, 0, 0.2);
    border-color: rgba(255, 204, 0, 0.35);
    color: #ffdd44;
    box-shadow: 0 0 15px rgba(255, 204, 0, 0.15);
    animation: stunPulse 0.3s ease-in-out infinite;
}

.status-badge.stunned::before {
    background: #ffcc00;
    box-shadow: 0 0 6px #ffcc00;
}

@keyframes stunPulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }
}

/* ─── Center Info ──────────────────────────────────────────── */
.center-info {
    text-align: center;
    flex-shrink: 0;
    padding-top: 4px;
}

.game-title {
    font-size: 13px;
    font-weight: 800;
    letter-spacing: 5px;
    text-transform: uppercase;
    background: linear-gradient(135deg, #ff6644 0%, #ffcc00 50%, #ff6644 100%);
    background-size: 200% auto;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: titleGlow 4s linear infinite;
}

@keyframes titleGlow {
    0% {
        background-position: 0% center;
    }

    100% {
        background-position: 200% center;
    }
}

.game-status {
    font-size: 12px;
    font-weight: 600;
    margin-top: 6px;
    opacity: 0.8;
    color: var(--color-stun);
    text-shadow: 0 0 10px rgba(255, 204, 0, 0.3);
}

/* VS separator */
.vs-badge {
    display: inline-block;
    margin-top: 12px;
    font-size: 18px;
    font-weight: 800;
    letter-spacing: 4px;
    opacity: 0.15;
    color: #fff;
}

/* ─── Bottom HUD group ─────────────────────────────────────── */
#bottom-hud {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    pointer-events: none;
}

/* ─── Actions row ──────────────────────────────────────────── */
.actions-row {
    display: flex;
    gap: 16px;
    align-items: center;
}

/* ─── Action Card (Punch / Block) ──────────────────────────── */
.action-card {
    backdrop-filter: blur(16px) saturate(130%);
    background: var(--color-glass);
    border: 1px solid var(--color-glass-border);
    border-radius: 12px;
    padding: 10px 18px;
    text-align: center;
    min-width: 120px;
    position: relative;
    overflow: hidden;
}

.action-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.08), transparent);
}

.action-icon {
    font-size: 18px;
    display: block;
    margin-bottom: 4px;
}

.action-label {
    font-size: 9px;
    font-weight: 800;
    letter-spacing: 2px;
    opacity: 0.4;
    text-transform: uppercase;
    margin-bottom: 6px;
}

/* ─── Punch cooldown ───────────────────────────────────────── */
.cooldown-indicator {
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 1.5px;
    padding: 4px 14px;
    border-radius: 20px;
    background: rgba(0, 255, 136, 0.1);
    border: 1px solid rgba(0, 255, 136, 0.2);
    color: var(--color-punch-ready);
    transition: all 0.2s ease;
    text-shadow: 0 0 8px rgba(0, 255, 136, 0.3);
}

.cooldown-indicator.on-cooldown {
    background: rgba(255, 68, 102, 0.1);
    border-color: rgba(255, 68, 102, 0.25);
    color: var(--color-punch-cooldown);
    text-shadow: 0 0 8px rgba(255, 68, 102, 0.3);
}

/* ─── Stamina bar ──────────────────────────────────────────── */
.stamina-bar-bg {
    width: 100%;
    height: 6px;
    background: rgba(255, 255, 255, 0.04);
    border-radius: 3px;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.03);
}

.stamina-bar-fill {
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, #1166dd, #2288ff, #55aaff);
    border-radius: 3px;
    transition: width 0.15s ease;
    box-shadow: 0 0 8px rgba(34, 136, 255, 0.3);
    position: relative;
}

.stamina-bar-fill::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 50%;
    background: linear-gradient(180deg,
            rgba(255, 255, 255, 0.3) 0%,
            rgba(255, 255, 255, 0) 100%);
    border-radius: 3px 3px 0 0;
}

/* ─── Controls Hint ────────────────────────────────────────── */
#controls-hint {
    display: flex;
    gap: 20px;
    opacity: 0.25;
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.5px;
}

kbd {
    display: inline-block;
    padding: 2px 7px;
    font-family: var(--font);
    font-size: 9px;
    font-weight: 800;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 4px;
    margin-right: 4px;
}

/* ─── Game Over ────────────────────────────────────────────── */
#game-over-screen {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(30px) saturate(120%);
    animation: fadeIn 0.6s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

#game-over-screen.hidden {
    display: none;
}

.game-over-content {
    text-align: center;
    animation: scaleIn 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes scaleIn {
    from {
        transform: scale(0.8);
        opacity: 0;
    }

    to {
        transform: scale(1);
        opacity: 1;
    }
}

.game-over-content h1 {
    font-size: 80px;
    font-weight: 800;
    letter-spacing: 8px;
    background: linear-gradient(135deg, #ff4422, #ffcc00, #ff6644);
    background-size: 200% auto;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: titleGlow 3s linear infinite;
    margin-bottom: 16px;
    text-shadow: none;
    filter: drop-shadow(0 0 20px rgba(255, 100, 68, 0.3));
}

.game-over-content p {
    font-size: 16px;
    opacity: 0.6;
    margin-bottom: 36px;
    letter-spacing: 1px;
}

#restart-btn {
    padding: 16px 56px;
    font-family: var(--font);
    font-size: 13px;
    font-weight: 800;
    letter-spacing: 4px;
    color: #fff;
    background: linear-gradient(135deg, #ff2244, #ff6644);
    border: none;
    border-radius: 50px;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.3s;
    pointer-events: all;
    position: relative;
    overflow: hidden;
}

#restart-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg,
            transparent,
            rgba(255, 255, 255, 0.15),
            transparent);
    transition: left 0.5s;
}

#restart-btn:hover {
    transform: scale(1.06) translateY(-1px);
    box-shadow:
        0 8px 30px rgba(255, 34, 68, 0.35),
        0 0 60px rgba(255, 68, 68, 0.15);
}

#restart-btn:hover::before {
    left: 100%;
}

/* ─── Animations ───────────────────────────────────────────── */
@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

/* ─── Vignette overlay ─────────────────────────────────────── */
#vignette {
    position: fixed;
    inset: 0;
    z-index: 1;
    pointer-events: none;
    background: radial-gradient(ellipse at center,
            transparent 50%,
            rgba(0, 0, 0, 0.5) 100%);
}