:root {
    --bg-dark: #090d16;
    --bg-panel: rgba(15, 23, 42, 0.88);
    --border-glow: rgba(56, 189, 248, 0.35);
    --cyan: #00f0ff;
    --magenta: #f43f5e;
    --purple: #a855f7;
    --amber: #f59e0b;
    --green: #10b981;
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Rajdhani', 'Segoe UI', system-ui, -apple-system, sans-serif;
    user-select: none;
}

body, html {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background-color: var(--bg-dark);
    color: var(--text-main);
}

/* CANVAS VIEWPORT */
#gameCanvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: block;
    z-index: 1;
}

/* FULLSCREEN SCREENS */
.screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(circle at center, rgba(15, 23, 42, 0.92) 0%, rgba(9, 13, 22, 0.98) 100%);
    backdrop-filter: blur(8px);
}

.hidden {
    display: none !important;
}

/* LOBBY CONTAINER */
.lobby-container {
    width: 92%;
    max-width: 1100px;
    background: var(--bg-panel);
    border: 1px solid var(--border-glow);
    border-radius: 16px;
    padding: 28px 36px;
    box-shadow: 0 0 40px rgba(0, 240, 255, 0.15);
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.lobby-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    padding-bottom: 16px;
}

.title-glow {
    font-size: 38px;
    font-weight: 800;
    letter-spacing: 2px;
    background: linear-gradient(90deg, #00f0ff, #a855f7, #f43f5e);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    text-shadow: 0 0 20px rgba(0, 240, 255, 0.4);
}

.room-badge {
    display: flex;
    align-items: center;
    gap: 12px;
    background: rgba(0, 0, 0, 0.5);
    padding: 8px 16px;
    border-radius: 10px;
    border: 1px solid rgba(56, 189, 248, 0.3);
}

.room-code {
    font-size: 22px;
    font-weight: 700;
    letter-spacing: 3px;
    color: var(--cyan);
}

.btn-icon {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 16px;
    transition: color 0.2s;
}

.btn-icon:hover {
    color: var(--cyan);
}

/* LOBBY CONTENT GRID */
.lobby-grid {
    display: grid;
    grid-template-columns: 1.8fr 1fr;
    gap: 24px;
}

.section-title {
    font-size: 18px;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--text-muted);
    margin-bottom: 12px;
}

/* CHARACTER SELECT GRID */
.char-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
}

.char-card {
    background: rgba(30, 41, 59, 0.6);
    border: 2px solid rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    padding: 14px;
    cursor: pointer;
    transition: all 0.25s ease;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.char-card:hover {
    background: rgba(51, 65, 85, 0.8);
    border-color: rgba(0, 240, 255, 0.5);
    transform: translateY(-2px);
}

.char-card.selected {
    background: rgba(14, 116, 144, 0.35);
    border-color: var(--cyan);
    box-shadow: 0 0 20px rgba(0, 240, 255, 0.3);
}

.char-top {
    display: flex;
    align-items: center;
    gap: 10px;
}

.char-avatar {
    font-size: 28px;
}

.char-name {
    font-size: 16px;
    font-weight: 700;
}

.char-title {
    font-size: 12px;
    color: var(--text-muted);
}

.char-stats {
    font-size: 12px;
    color: #cbd5e1;
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin-top: 4px;
}

/* PLAYER SLOTS */
.players-panel {
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.player-slot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    background: rgba(30, 41, 59, 0.7);
    border-radius: 8px;
    border-left: 4px solid var(--text-muted);
}

.player-slot.ready {
    border-left-color: var(--green);
}

.player-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.player-tag {
    font-weight: 700;
}

.status-badge {
    font-size: 12px;
    padding: 4px 8px;
    border-radius: 6px;
    font-weight: 600;
}

.status-badge.ready {
    background: rgba(16, 185, 129, 0.2);
    color: var(--green);
}

.status-badge.waiting {
    background: rgba(245, 158, 11, 0.2);
    color: var(--amber);
}

/* BUTTONS */
.lobby-actions {
    display: flex;
    justify-content: flex-end;
    gap: 16px;
    margin-top: 10px;
}

.btn-primary {
    background: linear-gradient(135deg, #00f0ff, #0284c7);
    color: #04131f;
    font-weight: 800;
    font-size: 18px;
    border: none;
    border-radius: 10px;
    padding: 12px 32px;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 0 20px rgba(0, 240, 255, 0.4);
    letter-spacing: 1px;
}

.btn-primary:hover {
    transform: scale(1.03);
    box-shadow: 0 0 30px rgba(0, 240, 255, 0.7);
}

.btn-secondary {
    background: rgba(30, 41, 59, 0.8);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: var(--text-main);
    font-weight: 700;
    font-size: 16px;
    border-radius: 10px;
    padding: 12px 24px;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-secondary:hover {
    background: rgba(51, 65, 85, 1);
}

/* HUD IN-GAME OVERLAY */
#hud {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 5;
    pointer-events: none;
}

.hud-top {
    position: absolute;
    top: 16px;
    left: 50%;
    transform: translateX(-50%);
    width: 70%;
    max-width: 800px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.xp-bar-container {
    width: 100%;
    height: 22px;
    background: rgba(15, 23, 42, 0.85);
    border: 1px solid var(--border-glow);
    border-radius: 12px;
    overflow: hidden;
    position: relative;
    box-shadow: 0 0 15px rgba(0, 240, 255, 0.2);
}

.xp-bar-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #00f0ff, #a855f7);
    transition: width 0.15s ease-out;
}

.xp-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 12px;
    font-weight: 700;
    text-shadow: 0 0 6px rgba(0, 0, 0, 0.9);
}

.hud-top-meta {
    display: flex;
    justify-content: space-between;
    width: 100%;
    font-size: 16px;
    font-weight: 700;
    text-shadow: 0 0 8px rgba(0, 0, 0, 0.8);
}

/* BOSS HEALTH BAR */
.boss-hud {
    width: 100%;
    background: rgba(15, 23, 42, 0.9);
    border: 2px solid var(--magenta);
    border-radius: 10px;
    padding: 6px 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    box-shadow: 0 0 25px rgba(244, 63, 94, 0.4);
    animation: pulseGlow 1.5s infinite alternate;
}

@keyframes pulseGlow {
    from { box-shadow: 0 0 15px rgba(244, 63, 94, 0.3); }
    to { box-shadow: 0 0 30px rgba(244, 63, 94, 0.7); }
}

.boss-name {
    font-size: 14px;
    font-weight: 800;
    color: var(--magenta);
    letter-spacing: 1px;
    text-align: center;
}

.boss-bar-fill {
    height: 14px;
    width: 100%;
    background: linear-gradient(90deg, #f43f5e, #e11d48);
    border-radius: 6px;
    transition: width 0.2s ease;
}

/* RADAR MINIMAP */
.minimap-container {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 160px;
    height: 160px;
    background: rgba(15, 23, 42, 0.75);
    border: 2px solid rgba(0, 240, 255, 0.4);
    border-radius: 50%;
    box-shadow: 0 0 20px rgba(0, 240, 255, 0.25);
    overflow: hidden;
    pointer-events: auto;
}

#minimapCanvas {
    width: 100%;
    height: 100%;
    display: block;
}

/* BOTTOM-LEFT PLAYER STATS */
.hud-bottom-left {
    position: absolute;
    bottom: 24px;
    left: 24px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: auto;
}

.hp-bar-wrap {
    width: 240px;
    height: 18px;
    background: rgba(15, 23, 42, 0.8);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 8px;
    overflow: hidden;
    position: relative;
}

.hp-bar-fill {
    height: 100%;
    width: 100%;
    background: linear-gradient(90deg, #10b981, #22c55e);
    transition: width 0.1s ease;
}

.shield-bar-fill {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    background: rgba(6, 182, 212, 0.6);
}

.gear-slots {
    display: flex;
    gap: 8px;
}

.gear-slot {
    width: 38px;
    height: 38px;
    background: rgba(15, 23, 42, 0.85);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    position: relative;
}

.gear-lvl {
    position: absolute;
    bottom: 2px;
    right: 4px;
    font-size: 10px;
    font-weight: 800;
    color: var(--cyan);
}

.gear-slot.evolved {
    border-color: var(--amber);
    box-shadow: 0 0 10px rgba(245, 158, 11, 0.6);
}

/* SPECTATOR BANNER */
.spectator-banner {
    position: absolute;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(15, 23, 42, 0.9);
    border: 2px solid var(--magenta);
    padding: 10px 24px;
    border-radius: 12px;
    font-size: 18px;
    font-weight: 800;
    display: flex;
    align-items: center;
    gap: 16px;
    pointer-events: auto;
    box-shadow: 0 0 20px rgba(244, 63, 94, 0.5);
}

/* LEVEL UP MODAL (SYNC_LEVEL_PAUSE) */
.upgrade-modal {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(15, 23, 42, 0.95);
    border: 2px solid var(--cyan);
    border-radius: 20px;
    padding: 32px 40px;
    box-shadow: 0 0 60px rgba(0, 240, 255, 0.4);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 24px;
    z-index: 20;
    pointer-events: auto;
    width: 90%;
    max-width: 950px;
}

.upgrade-title {
    font-size: 32px;
    font-weight: 800;
    letter-spacing: 2px;
    color: var(--cyan);
}

.upgrade-cards {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
    width: 100%;
}

.upgrade-card {
    background: rgba(30, 41, 59, 0.7);
    border: 2px solid rgba(255, 255, 255, 0.15);
    border-radius: 14px;
    padding: 20px;
    cursor: pointer;
    transition: all 0.25s ease;
    display: flex;
    flex-direction: column;
    gap: 10px;
    position: relative;
    overflow: hidden;
}

.upgrade-card:hover {
    transform: translateY(-6px);
    border-color: var(--cyan);
    background: rgba(51, 65, 85, 0.9);
    box-shadow: 0 0 25px rgba(0, 240, 255, 0.4);
}

.upgrade-card.evolution-card {
    border-color: var(--amber);
    background: radial-gradient(circle at top, rgba(245, 158, 11, 0.25) 0%, rgba(30, 41, 59, 0.8) 100%);
    box-shadow: 0 0 35px rgba(245, 158, 11, 0.4);
    animation: evoPulse 2s infinite alternate;
}

@keyframes evoPulse {
    from { box-shadow: 0 0 20px rgba(245, 158, 11, 0.3); }
    to { box-shadow: 0 0 45px rgba(245, 158, 11, 0.8); }
}

.badge-evo {
    background: var(--amber);
    color: #000;
    font-size: 10px;
    font-weight: 800;
    padding: 3px 8px;
    border-radius: 6px;
    width: fit-content;
    text-transform: uppercase;
}

.card-header {
    display: flex;
    align-items: center;
    gap: 12px;
}

.card-icon {
    font-size: 32px;
}

.card-name {
    font-size: 18px;
    font-weight: 800;
}

.card-desc {
    font-size: 14px;
    color: #cbd5e1;
    line-height: 1.4;
}

.waiting-teammates {
    font-size: 14px;
    color: var(--amber);
    font-weight: 600;
}

/* GAME OVER MODAL */
.gameover-box {
    background: var(--bg-panel);
    border: 2px solid var(--magenta);
    border-radius: 20px;
    padding: 36px 48px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    box-shadow: 0 0 50px rgba(244, 63, 94, 0.4);
}

.gameover-title {
    font-size: 42px;
    font-weight: 900;
    color: var(--magenta);
    letter-spacing: 3px;
}

.stats-table {
    width: 100%;
    border-collapse: collapse;
    margin: 10px 0;
}

.stats-table th, .stats-table td {
    padding: 8px 16px;
    text-align: left;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.stats-table th {
    color: var(--text-muted);
    text-transform: uppercase;
    font-size: 12px;
}

/* OPEN LOBBIES LIST */
.lobby-list-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    background: rgba(30, 41, 59, 0.7);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    transition: all 0.2s ease;
    margin-bottom: 8px;
}

.lobby-list-item:hover {
    background: rgba(51, 65, 85, 0.9);
    border-color: var(--cyan);
    transform: translateX(3px);
}
