/* ════════════════════════════════════════════════════════════════
   PONG MULTIPLAYER — Black & White Design System
   ════════════════════════════════════════════════════════════════ */

:root {
    --black: #000000;
    --white: #ffffff;
    --gray-100: #f5f5f5;
    --gray-200: #e0e0e0;
    --gray-300: #bdbdbd;
    --gray-400: #9e9e9e;
    --gray-500: #757575;
    --gray-600: #616161;
    --gray-700: #424242;
    --gray-800: #1a1a1a;
    --gray-900: #0d0d0d;
    
    --font-mono: 'Space Mono', monospace;
    --font-sans: 'Inter', -apple-system, sans-serif;
    
    --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-normal: 300ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 500ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* ─── Reset & Base ──────────────────────────────────────────────── */

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

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
}

body {
    font-family: var(--font-sans);
    background: var(--black);
    color: var(--white);
    display: flex;
    align-items: center;
    justify-content: center;
    -webkit-font-smoothing: antialiased;
}

/* ─── Screen Management ─────────────────────────────────────────── */

.screen {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity var(--transition-slow), visibility var(--transition-slow);
}

.screen.active {
    opacity: 1;
    visibility: visible;
}

/* ─── Menu Screen ────────────────────────────────────────────────── */

.menu-container {
    text-align: center;
    max-width: 480px;
    width: 90%;
    animation: fadeInUp 0.8s ease-out;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Logo Animation */

.logo-section {
    margin-bottom: 48px;
}

.logo-art {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 24px;
    margin-bottom: 20px;
    height: 60px;
}

.logo-paddle {
    width: 8px;
    height: 48px;
    background: var(--white);
    border-radius: 4px;
}

.logo-paddle.left-paddle {
    animation: paddleBounceLeft 2s ease-in-out infinite;
}

.logo-paddle.right-paddle {
    animation: paddleBounceRight 2s ease-in-out infinite;
}

.logo-ball {
    width: 14px;
    height: 14px;
    background: var(--white);
    border-radius: 50%;
    animation: ballBounce 2s ease-in-out infinite;
}

@keyframes paddleBounceLeft {
    0%, 100% { transform: translateY(-8px); }
    50% { transform: translateY(8px); }
}

@keyframes paddleBounceRight {
    0%, 100% { transform: translateY(8px); }
    50% { transform: translateY(-8px); }
}

@keyframes ballBounce {
    0%, 100% { transform: translateX(-20px); }
    50% { transform: translateX(20px); }
}

.game-title {
    font-family: var(--font-mono);
    font-size: 72px;
    font-weight: 700;
    letter-spacing: 24px;
    line-height: 1;
    margin-bottom: 8px;
    text-indent: 24px;
}

.game-subtitle {
    font-family: var(--font-mono);
    font-size: 14px;
    font-weight: 400;
    letter-spacing: 12px;
    color: var(--gray-400);
    text-indent: 12px;
}

.powered-by {
    margin-top: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-size: 11px;
    color: var(--gray-500);
    letter-spacing: 1px;
    text-transform: uppercase;
}

.aws-badge {
    display: inline-block;
    padding: 3px 10px;
    border: 1px solid var(--gray-600);
    border-radius: 4px;
    color: var(--gray-300);
    font-family: var(--font-mono);
    font-size: 10px;
    font-weight: 700;
}

/* Menu Actions */

.menu-actions {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 16px 32px;
    font-family: var(--font-mono);
    font-size: 14px;
    font-weight: 700;
    letter-spacing: 2px;
    border: none;
    border-radius: 0;
    cursor: pointer;
    transition: all var(--transition-fast);
    text-transform: uppercase;
    position: relative;
    overflow: hidden;
}

.btn::after {
    content: '';
    position: absolute;
    inset: 0;
    background: var(--white);
    opacity: 0;
    transition: opacity var(--transition-fast);
}

.btn:hover::after {
    opacity: 0.1;
}

.btn:active {
    transform: scale(0.98);
}

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

.btn-primary:hover {
    background: var(--gray-200);
}

.btn-primary::after {
    background: var(--black);
}

.btn-secondary {
    background: transparent;
    color: var(--white);
    border: 2px solid var(--white);
}

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

.btn-ghost {
    background: transparent;
    color: var(--gray-400);
    border: 1px solid var(--gray-700);
    font-size: 12px;
    padding: 12px 24px;
}

.btn-ghost:hover {
    color: var(--white);
    border-color: var(--gray-400);
}

.btn-icon {
    font-size: 18px;
    font-weight: 400;
}

.btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.btn:disabled:hover {
    transform: none;
}

/* Divider */

.divider {
    display: flex;
    align-items: center;
    gap: 16px;
    color: var(--gray-600);
    font-family: var(--font-mono);
    font-size: 12px;
    letter-spacing: 4px;
}

.divider::before,
.divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--gray-800);
}

/* Join Section */

.join-section {
    display: flex;
    gap: 0;
}

.room-input {
    flex: 1;
    padding: 16px 20px;
    background: var(--gray-900);
    border: 2px solid var(--gray-700);
    border-right: none;
    color: var(--white);
    font-family: var(--font-mono);
    font-size: 18px;
    font-weight: 700;
    letter-spacing: 8px;
    text-align: center;
    text-transform: uppercase;
    outline: none;
    transition: border-color var(--transition-fast);
}

.room-input::placeholder {
    font-size: 12px;
    letter-spacing: 2px;
    color: var(--gray-600);
    font-weight: 400;
}

.room-input:focus {
    border-color: var(--white);
}

.join-section .btn-secondary {
    border-radius: 0;
    min-width: 80px;
    border-left: none;
    border: 2px solid var(--gray-700);
}

.room-input:focus + .btn-secondary {
    border-color: var(--white);
}

/* Footer Logos */

.footer-logos {
    margin-top: 40px;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 32px;
    opacity: 0.8;
}

.footer-logo {
    height: 52px;
    object-fit: contain;
    filter: brightness(0) invert(1); /* Ensure logos are white on the black background if they aren't already */
    transition: opacity var(--transition-fast);
}

.footer-logo:hover {
    opacity: 1;
}

/* Status Bar */

.status-bar {
    margin-top: 24px;
    padding: 12px 20px;
    font-family: var(--font-mono);
    font-size: 12px;
    letter-spacing: 1px;
    border: 1px solid var(--gray-700);
    background: var(--gray-900);
    transition: all var(--transition-normal);
}

.status-bar.error {
    border-color: var(--white);
    color: var(--white);
    background: var(--gray-800);
}

.status-bar.loading {
    color: var(--gray-400);
    animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.hidden {
    display: none !important;
}

/* ─── Lobby Screen ───────────────────────────────────────────────── */

.lobby-container {
    text-align: center;
    animation: fadeInUp 0.6s ease-out;
}

.lobby-title {
    font-family: var(--font-mono);
    font-size: 18px;
    font-weight: 700;
    letter-spacing: 6px;
    color: var(--gray-400);
    margin-bottom: 32px;
}

.room-code-display {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 40px;
}

.room-code-label {
    font-family: var(--font-mono);
    font-size: 10px;
    font-weight: 400;
    letter-spacing: 4px;
    color: var(--gray-500);
}

.room-code-value {
    font-family: var(--font-mono);
    font-size: 56px;
    font-weight: 700;
    letter-spacing: 16px;
    text-indent: 16px;
    line-height: 1;
    padding: 16px 24px;
    border: 2px solid var(--gray-700);
    background: var(--gray-900);
    user-select: all;
    cursor: pointer;
    transition: border-color var(--transition-fast);
}

.room-code-value:hover {
    border-color: var(--white);
}

.btn-copy {
    background: none;
    border: 1px solid var(--gray-700);
    color: var(--gray-400);
    padding: 8px 12px;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.btn-copy:hover {
    color: var(--white);
    border-color: var(--white);
}

.lobby-status {
    margin-bottom: 32px;
    color: var(--gray-400);
    font-size: 14px;
}

.waiting-dots {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-bottom: 16px;
}

.waiting-dots span {
    width: 8px;
    height: 8px;
    background: var(--gray-500);
    border-radius: 50%;
    animation: dotPulse 1.4s ease-in-out infinite;
}

.waiting-dots span:nth-child(2) { animation-delay: 0.2s; }
.waiting-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes dotPulse {
    0%, 80%, 100% { opacity: 0.3; transform: scale(0.8); }
    40% { opacity: 1; transform: scale(1); }
}

/* ─── Game Screen ────────────────────────────────────────────────── */

.game-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 16px;
    z-index: 10;
    flex-direction: column;
    gap: 8px;
}

.score-display {
    display: flex;
    align-items: center;
    gap: 16px;
    font-family: var(--font-mono);
}

.score-player {
    display: flex;
    align-items: center;
    gap: 12px;
}

.player-label {
    font-size: 12px;
    font-weight: 400;
    color: var(--gray-500);
    letter-spacing: 2px;
}

.score-value {
    font-size: 40px;
    font-weight: 700;
    line-height: 1;
    min-width: 48px;
    text-align: center;
}

.score-separator {
    font-size: 28px;
    color: var(--gray-600);
    font-weight: 700;
}

.game-info {
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--gray-500);
    letter-spacing: 2px;
}

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

#game-canvas {
    border: 2px solid var(--gray-800);
    background: var(--black);
    max-width: 100vw;
    max-height: 80vh;
    image-rendering: pixelated;
}

/* Countdown Overlay */

.countdown-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.7);
    z-index: 20;
}

.countdown-number {
    font-family: var(--font-mono);
    font-size: 120px;
    font-weight: 700;
    animation: countPulse 1s ease-out;
}

@keyframes countPulse {
    from {
        opacity: 0;
        transform: scale(2);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* Game Over Overlay */

.game-over-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 32px;
    background: rgba(0, 0, 0, 0.85);
    z-index: 20;
    animation: fadeIn 0.5s ease-out;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.winner-text {
    font-family: var(--font-mono);
    font-size: 36px;
    font-weight: 700;
    letter-spacing: 8px;
}

/* Game Controls Hint */

.game-controls-hint {
    position: fixed;
    bottom: 16px;
    left: 0;
    right: 0;
    text-align: center;
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--gray-600);
    letter-spacing: 2px;
    display: flex;
    justify-content: center;
    gap: 16px;
}

.controls-separator {
    color: var(--gray-800);
}

/* ─── Responsive ─────────────────────────────────────────────────── */

@media (max-width: 640px) {
    .game-title {
        font-size: 48px;
        letter-spacing: 16px;
        text-indent: 16px;
    }

    .game-subtitle {
        font-size: 11px;
        letter-spacing: 8px;
        text-indent: 8px;
    }

    .room-code-value {
        font-size: 36px;
        letter-spacing: 10px;
        text-indent: 10px;
    }

    .room-input {
        font-size: 14px;
        letter-spacing: 4px;
    }

    .score-value {
        font-size: 28px;
    }

    .btn {
        padding: 14px 24px;
        font-size: 12px;
    }
}
