@import url('https://fonts.googleapis.com/css2?family=Press+Start+2P&display=swap');

:root {
    --retro-bg: #0d0d1a;
    --retro-dark: #1a1a2e;
    --retro-panel: #16213e;
    --retro-accent: #e94560;
    --retro-accent-glow: #ff6b6b;
    --retro-cyan: #0f3460;
    --retro-gold: #f9d423;
    --retro-green: #00d9ff;
    --pixel-font: 'Press Start 2P', cursive;
}

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

body {
    background: var(--retro-bg);
    color: #fff;
    font-family: var(--pixel-font);
    font-size: 12px;
    overflow: hidden;
    height: 100vh;
    width: 100vw;
}

/* --- CRT EFFECT OVERLAY --- */
#app::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: repeating-linear-gradient(
        0deg,
        rgba(0, 0, 0, 0.15),
        rgba(0, 0, 0, 0.15) 1px,
        transparent 1px,
        transparent 2px
    );
    pointer-events: none;
    z-index: 1000;
}

/* --- LOGIN SCREEN --- */
#login-screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100vh;
    gap: 30px;
    animation: flicker 4s infinite;
}

@keyframes flicker {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.98; }
    52% { opacity: 0.85; }
    54% { opacity: 1; }
}

.game-title {
    font-size: 32px;
    color: var(--retro-accent);
    text-shadow: 
        0 0 10px var(--retro-accent-glow),
        4px 4px 0px var(--retro-cyan);
    letter-spacing: 2px;
    margin-bottom: 20px;
}

.login-box {
    background: var(--retro-dark);
    border: 3px solid var(--retro-cyan);
    padding: 40px;
    box-shadow: 
        0 0 20px rgba(0, 217, 255, 0.3),
        inset 0 0 20px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    gap: 20px;
    min-width: 320px;
}

.login-box label {
    color: var(--retro-green);
    font-size: 10px;
    text-transform: uppercase;
}

.login-box input {
    background: var(--retro-bg);
    border: 2px solid var(--retro-cyan);
    color: var(--retro-gold);
    font-family: var(--pixel-font);
    font-size: 14px;
    padding: 12px;
    outline: none;
    transition: all 0.2s;
}

.login-box input:focus {
    border-color: var(--retro-accent);
    box-shadow: 0 0 15px rgba(233, 69, 96, 0.4);
}

.btn-retro {
    background: var(--retro-accent);
    border: none;
    color: white;
    font-family: var(--pixel-font);
    font-size: 12px;
    padding: 15px;
    cursor: pointer;
    text-transform: uppercase;
    letter-spacing: 2px;
    transition: all 0.1s;
    box-shadow: 0 4px 0 #b91c3a;
    position: relative;
    top: 0;
}

.btn-retro:hover {
    background: var(--retro-accent-glow);
    transform: translateY(-2px);
    box-shadow: 0 6px 0 #b91c3a;
}

.btn-retro:active {
    transform: translateY(4px);
    box-shadow: 0 0 0 #b91c3a;
    top: 4px;
}

/* --- LOBBY SCREEN --- */
#lobby-screen {
    height: 100vh;
    display: flex;
    flex-direction: column;
    padding: 20px;
    background: radial-gradient(ellipse at center, var(--retro-dark) 0%, var(--retro-bg) 100%);
}

.lobby-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    background: var(--retro-panel);
    border: 2px solid var(--retro-cyan);
    margin-bottom: 20px;
    box-shadow: 0 0 15px rgba(0, 217, 255, 0.2);
}

.user-badge {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--retro-gold);
}

.pulse-dot {
    width: 10px;
    height: 10px;
    background: #00ff88;
    border-radius: 0; /* Square for retro feel */
    box-shadow: 0 0 10px #00ff88;
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.6; transform: scale(0.8); }
}

.lobby-main {
    display: flex;
    gap: 20px;
    flex: 1;
    overflow: hidden;
}

/* --- ACTIVE USERS PANEL --- */
.users-panel {
    width: 300px;
    background: var(--retro-panel);
    border: 2px solid var(--retro-cyan);
    display: flex;
    flex-direction: column;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.5);
}

.panel-title {
    padding: 15px;
    background: var(--retro-cyan);
    color: white;
    font-size: 10px;
    text-align: center;
    border-bottom: 2px solid var(--retro-accent);
}

.users-list {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* Custom scrollbar */
.users-list::-webkit-scrollbar {
    width: 8px;
}
.users-list::-webkit-scrollbar-track {
    background: var(--retro-dark);
}
.users-list::-webkit-scrollbar-thumb {
    background: var(--retro-accent);
}

.user-card {
    background: var(--retro-dark);
    border: 2px solid transparent;
    padding: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: all 0.2s;
    position: relative;
    overflow: hidden;
}

.user-card::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    width: 3px;
    height: 100%;
    background: var(--retro-green);
    opacity: 0;
    transition: opacity 0.2s;
}

.user-card:hover {
    border-color: var(--retro-accent);
    background: #1e2a4a;
    transform: translateX(5px);
}

.user-card:hover::before {
    opacity: 1;
}

.user-card .avatar {
    width: 32px;
    height: 32px;
    background: var(--retro-accent);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    border: 2px solid white;
}

.user-card .info {
    flex: 1;
}

.user-card .name {
    color: white;
    font-size: 10px;
    margin-bottom: 4px;
}

.user-card .status {
    color: var(--retro-green);
    font-size: 8px;
}

.user-card .challenge-btn {
    background: var(--retro-accent);
    border: none;
    color: white;
    font-family: var(--pixel-font);
    font-size: 8px;
    padding: 6px 10px;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.2s;
}

.user-card:hover .challenge-btn {
    opacity: 1;
}

.user-card.challenged {
    border-color: var(--retro-gold);
    animation: challenge-pulse 0.5s infinite alternate;
}

@keyframes challenge-pulse {
    from { box-shadow: 0 0 5px var(--retro-gold); }
    to { box-shadow: 0 0 15px var(--retro-gold); }
}

/* --- CHALLENGE MODAL --- */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    backdrop-filter: blur(4px);
}

.modal-box {
    background: var(--retro-dark);
    border: 3px solid var(--retro-gold);
    padding: 30px;
    text-align: center;
    box-shadow: 0 0 30px rgba(249, 212, 35, 0.3);
    max-width: 400px;
    animation: modal-pop 0.3s ease-out;
}

@keyframes modal-pop {
    0% { transform: scale(0.5); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}

.modal-box h3 {
    color: var(--retro-gold);
    margin-bottom: 20px;
    font-size: 14px;
}

.modal-actions {
    display: flex;
    gap: 15px;
    justify-content: center;
    margin-top: 20px;
}

.btn-accept {
    background: #00c853;
    box-shadow: 0 4px 0 #009624;
}

.btn-decline {
    background: var(--retro-accent);
    box-shadow: 0 4px 0 #b91c3a;
}

/* --- GAME SCREEN --- */
#game-screen {
    height: 100vh;
    width: 100vw;
    display: flex;
    flex-direction: column;
    background: var(--retro-bg);
}

.game-hud {
    display: flex;
    justify-content: space-between;
    padding: 10px 20px;
    background: var(--retro-panel);
    border-bottom: 3px solid var(--retro-cyan);
}

.player-hud {
    display: flex;
    align-items: center;
    gap: 15px;
}

.player-hud .hud-name {
    color: var(--retro-gold);
    font-size: 10px;
}

.player-hud .hud-health {
    width: 150px;
    height: 20px;
    background: var(--retro-dark);
    border: 2px solid white;
    position: relative;
}

.health-fill {
    height: 100%;
    background: linear-gradient(90deg, #ff4444, #ff8844);
    transition: width 0.3s;
    width: 100%;
}

.hud-percent {
    color: #00ff88;
    font-size: 12px;
    min-width: 50px;
}

.game-status {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 18px;
    color: var(--retro-gold);
    text-shadow: 0 0 20px var(--retro-gold);
    animation: pulse 1s infinite;
    z-index: 10;
}

.game-status.fade-out {
    animation: fade-out 1s forwards;
}

@keyframes fade-out {
    0% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
    100% { opacity: 0; transform: translate(-50%, -50%) scale(2); }
}

/* --- CHARACTER SELECT SCREEN --- */
#char-select-screen {
    height: 100vh;
    display: flex;
    flex-direction: column;
    padding: 20px;
    background: linear-gradient(180deg, #1a1a2e 0%, #0d0d1a 100%);
}

.char-select-header {
    text-align: center;
    margin-bottom: 20px;
}

.char-select-header h2 {
    color: var(--retro-gold);
    font-size: 24px;
    text-shadow: 0 0 10px var(--retro-gold);
    margin: 10px 0;
}

.room-info {
    color: #666;
    font-size: 10px;
}

.char-select-main {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    flex: 1;
    gap: 20px;
}

.char-panel {
    width: 200px;
    background: var(--retro-panel);
    border: 3px solid var(--retro-cyan);
    padding: 15px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

.player-panel {
    border-color: var(--retro-accent);
}

.opponent-panel {
    border-color: var(--retro-cyan);
}

.panel-label {
    color: var(--retro-gold);
    font-size: 12px;
    text-align: center;
}

.char-preview {
    width: 150px;
    height: 150px;
    background: #0a0a15;
    border: 2px solid #333;
    display: flex;
    align-items: center;
    justify-content: center;
}

.char-preview canvas {
    image-rendering: pixelated;
}

.char-name {
    color: #fff;
    font-size: 14px;
}

.ready-status {
    color: #666;
    font-size: 10px;
    padding: 5px 10px;
    border: 1px solid #333;
}

.ready-status.is-ready {
    color: #00ff88;
    border-color: #00ff88;
    animation: pulse 1s infinite;
}

.char-grid-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.char-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 15px;
    padding: 20px;
    background: var(--retro-dark);
    border: 2px solid var(--retro-cyan);
}

.char-slot {
    width: 100px;
    height: 100px;
    background: var(--retro-panel);
    border: 3px solid #444;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
}

.char-slot:hover:not(.locked) {
    border-color: var(--retro-accent);
    transform: scale(1.05);
}

.char-slot.selected {
    border-color: var(--retro-gold);
    box-shadow: 0 0 15px var(--retro-gold);
}

.char-slot.locked {
    opacity: 0.5;
    cursor: not-allowed;
}

.char-icon {
    font-size: 24px;
    color: #fff;
    margin-bottom: 5px;
}

.char-slot-name {
    font-size: 8px;
    color: #aaa;
}

.char-info-panel {
    background: var(--retro-panel);
    border: 2px solid var(--retro-cyan);
    padding: 15px;
    margin-top: 10px;
}

.char-stats h3 {
    color: var(--retro-gold);
    font-size: 14px;
    margin-bottom: 8px;
}

.char-stats p {
    color: #aaa;
    font-size: 10px;
    margin-bottom: 15px;
}

.attack-info {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.attack-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.attack-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px;
    background: #0a0a15;
    border: 1px solid #333;
    cursor: pointer;
    transition: border-color 0.2s;
}

.attack-row:hover {
    border-color: var(--retro-accent);
}

.attack-preview {
    width: 60px;
    height: 60px;
    background: #1a1a2e;
    border: 2px solid #444;
    image-rendering: pixelated;
    flex-shrink: 0;
}

.attack-row:hover .attack-preview {
    border-color: var(--retro-accent);
}

.attack-details {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.attack-details .key {
    background: var(--retro-accent);
    color: #fff;
    padding: 3px 8px;
    font-size: 10px;
    width: fit-content;
}

.attack-details .attack-name {
    color: #fff;
    font-size: 10px;
}

.attack-details .attack-type {
    color: #888;
    font-size: 8px;
}

.char-icon-locked {
    font-size: 32px;
    color: #666;
}

.char-select-footer {
    text-align: center;
    padding: 20px;
}

.btn-ready {
    padding: 15px 40px;
    font-size: 14px;
}

.btn-ready.ready-active {
    background: #00c853;
    box-shadow: 0 4px 0 #009624;
}

.ready-hint {
    color: #666;
    font-size: 8px;
    margin-top: 10px;
}

.countdown {
    font-size: 48px;
    color: var(--retro-gold);
    text-shadow: 0 0 20px var(--retro-gold);
    animation: pulse 0.5s infinite;
}

.game-canvas-container {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

#game-canvas {
    border: 4px solid var(--retro-cyan);
    box-shadow: 0 0 30px rgba(0, 217, 255, 0.2);
    background: #1a1a2e;
}

/* --- NOTIFICATIONS --- */
.notification {
    position: fixed;
    top: 20px;
    right: 20px;
    background: var(--retro-panel);
    border: 2px solid var(--retro-accent);
    padding: 15px 20px;
    color: white;
    font-size: 10px;
    z-index: 200;
    animation: slide-in 0.3s ease-out;
    box-shadow: 0 0 20px rgba(233, 69, 96, 0.4);
}

@keyframes slide-in {
    from { transform: translateX(400px); }
    to { transform: translateX(0); }
}

/* --- UTILITIES --- */
.hidden { display: none !important; }