/* ===================================
   CUSTOM FONT
   =================================== */
@font-face {
    font-family: 'MainFont';
    src: url('./Assets/Fonts/Mainfont.otf') format('opentype');
    font-weight: normal;
    font-style: normal;
}

/* ===================================
   CSS VARIABLES & RESET
   =================================== */
:root {
    /* High-Key Neumorphic Colors */
    --bg-primary: #F0F2F5;
    --shadow-dark: rgba(163, 177, 198, 0.6);
    --shadow-light: rgba(255, 255, 255, 0.9);
    --shadow-inset-dark: rgba(163, 177, 198, 0.4);
    --shadow-inset-light: rgba(255, 255, 255, 0.7);

    /* Accent Colors */
    --accent-mpp: #6B8CFF;
    --accent-user: #FF6B9D;
    --accent-glow: #FFD93D;
    --text-primary: #4A5568;
    --text-secondary: #718096;

    /* Glassmorphism */
    --glass-bg: rgba(240, 242, 245, 0.7);
    --glass-border: rgba(255, 255, 255, 0.5);

    /* Spacing */
    --spacing-xs: 0.5rem;
    --spacing-sm: 1rem;
    --spacing-md: 1.5rem;
    --spacing-lg: 2rem;
    --spacing-xl: 3rem;
}

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

body {
    font-family: 'MainFont', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    overflow: hidden;
    width: 100vw;
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ===================================
   MAIN CONTAINER
   =================================== */
.container {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: var(--spacing-lg);
    position: relative;
}

/* ===================================
   PING PONG TABLE
   =================================== */
.table-container {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-md);
    width: 100%;
    max-width: 1200px;
    margin-bottom: var(--spacing-xl);
}

.table {
    position: relative;
    width: 800px;
    height: 400px;
    background: var(--bg-primary);
    border-radius: 24px;

    /* Neumorphic Inset Effect */
    box-shadow:
        inset 8px 8px 16px var(--shadow-inset-dark),
        inset -8px -8px 16px var(--shadow-inset-light);

    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

/* Center Net */
.net {
    position: absolute;
    left: 50%;
    top: 0;
    bottom: 0;
    width: 2px;
    background: linear-gradient(to bottom,
            transparent 0%,
            rgba(163, 177, 198, 0.3) 10%,
            rgba(163, 177, 198, 0.3) 90%,
            transparent 100%);
    transform: translateX(-50%);
}

/* ===================================
   PADDLES
   =================================== */
.paddle {
    width: 16px;
    height: 120px;
    border-radius: 100px;
    background: var(--bg-primary);

    /* Neumorphic Extruded Effect */
    box-shadow:
        6px 6px 12px var(--shadow-dark),
        -6px -6px 12px var(--shadow-light);

    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.paddle-mpp {
    background: linear-gradient(135deg, var(--bg-primary) 0%, #E8EAF0 100%);
    position: relative;
}

.paddle-mpp::before {
    content: '';
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 8px;
    height: 40px;
    background: var(--accent-mpp);
    border-radius: 100px;
    opacity: 0.6;
}

.paddle-user {
    background: linear-gradient(135deg, var(--bg-primary) 0%, #E8EAF0 100%);
    position: relative;
}

.paddle-user::before {
    content: '';
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 8px;
    height: 40px;
    background: var(--accent-user);
    border-radius: 100px;
    opacity: 0.6;
}

.paddle.active {
    transform: scale(1.05);
    box-shadow:
        8px 8px 16px var(--shadow-dark),
        -8px -8px 16px var(--shadow-light);
}

.paddle.dimmed {
    opacity: 0.5;
    transition: opacity 0.3s ease;
}

.paddle.thinking {
    animation: breathe 2s ease-in-out infinite;
}

@keyframes breathe {

    0%,
    100% {
        box-shadow:
            inset 4px 4px 8px var(--shadow-inset-dark),
            inset -4px -4px 8px var(--shadow-inset-light),
            0 0 20px rgba(59, 130, 246, 0.3);
    }

    50% {
        box-shadow:
            inset 4px 4px 8px var(--shadow-inset-dark),
            inset -4px -4px 8px var(--shadow-inset-light),
            0 0 40px rgba(59, 130, 246, 0.6);
    }
}

/* ===================================
   BALL
   =================================== */
.ball {
    position: absolute;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: radial-gradient(circle at 30% 30%, #FFF4A3, var(--accent-glow));

    /* Glowing Effect */
    box-shadow:
        0 0 20px rgba(255, 217, 61, 0.8),
        0 0 40px rgba(255, 217, 61, 0.4),
        inset -2px -2px 4px rgba(0, 0, 0, 0.1);

    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    opacity: 0;
    transition: opacity 0.3s ease;
    z-index: 10;
}

.ball.visible {
    opacity: 1;
}

/* Ball Animation */
@keyframes ballTravelToAI {
    0% {
        left: 75%;
        top: 50%;
        transform: translate(-50%, -50%) scale(1);
    }

    50% {
        top: 30%;
        transform: translate(-50%, -50%) scale(0.8);
    }

    100% {
        left: 25%;
        top: 50%;
        transform: translate(-50%, -50%) scale(1);
    }
}

@keyframes ballTravelToUser {
    0% {
        left: 25%;
        top: 50%;
        transform: translate(-50%, -50%) scale(1);
    }

    50% {
        top: 70%;
        transform: translate(-50%, -50%) scale(0.8);
    }

    100% {
        left: 75%;
        top: 50%;
        transform: translate(-50%, -50%) scale(1);
    }
}

.ball.travel-to-ai {
    animation: ballTravelToAI 1s ease-in-out forwards;
}

.ball.travel-to-user {
    animation: ballTravelToUser 1s ease-in-out forwards;
}

/* ===================================
   SPEECH BUBBLES
   =================================== */
.speech-bubble {
    position: absolute;
    max-width: 320px;
    min-height: 80px;
    padding: var(--spacing-md);
    background: rgba(255, 255, 255, 0.6);
    backdrop-filter: blur(20px);
    border-radius: 20px;
    border: 1px solid var(--glass-border);

    box-shadow:
        4px 4px 12px rgba(163, 177, 198, 0.3),
        -2px -2px 8px rgba(255, 255, 255, 0.5);

    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.4s ease, transform 0.4s ease;
    z-index: 5;
}

.speech-bubble.visible {
    opacity: 1;
    transform: translateY(0);
}

.bubble-mpp {
    left: 5%;
    top: 10%;
}

.bubble-user {
    right: 5%;
    bottom: 10%;
}

.bubble-text {
    font-size: 1.1rem;
    line-height: 1.6;
    color: var(--text-primary);
    word-wrap: break-word;
}

/* Typewriter cursor */
.bubble-text.typing::after {
    content: '|';
    animation: blink 0.7s infinite;
    margin-left: 2px;
}

@keyframes blink {

    0%,
    50% {
        opacity: 1;
    }

    51%,
    100% {
        opacity: 0;
    }
}

/* ===================================
   BOTTOM SELECTOR UI
   =================================== */
.selector-container {
    position: fixed;
    bottom: var(--spacing-lg);
    left: 50%;
    transform: translateX(-50%);

    display: flex;
    align-items: center;
    gap: var(--spacing-lg);

    padding: var(--spacing-md) var(--spacing-lg);
    background: var(--glass-bg);
    backdrop-filter: blur(30px);
    border-radius: 100px;
    border: 1px solid var(--glass-border);

    box-shadow:
        8px 8px 20px rgba(163, 177, 198, 0.4),
        -4px -4px 12px rgba(255, 255, 255, 0.6);
}

.mode-selector {
    display: flex;
    gap: var(--spacing-sm);
}

.mode-btn {
    flex: 1;
    padding: var(--spacing-sm) var(--spacing-md);
    background: var(--bg-primary);
    border: none;
    border-radius: 20px;
    font-family: 'MainFont', sans-serif;
    cursor: pointer;

    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    height: 72px;
    /* Standardized height */
    min-width: 100px;

    box-shadow:
        4px 4px 8px var(--shadow-dark),
        -4px -4px 8px var(--shadow-light);

    transition: all 0.3s ease;
}

.mode-btn:hover {
    transform: translateY(-2px);
    box-shadow:
        6px 6px 12px var(--shadow-dark),
        -6px -6px 12px var(--shadow-light);
}

.mode-btn.active {
    box-shadow:
        inset 3px 3px 6px var(--shadow-inset-dark),
        inset -3px -3px 6px var(--shadow-inset-light);
    transform: scale(0.98);
}

.mode-label {
    font-size: 14px;
    font-weight: 500;
    text-transform: uppercase;
    color: var(--text-primary);
}

.mode-desc {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.end-game-btn {
    padding: var(--spacing-sm) var(--spacing-md);
    background: var(--bg-primary);
    border: none;
    border-radius: 20px;
    font-family: 'MainFont', sans-serif;
    font-size: 14px;
    font-weight: 500;
    text-transform: uppercase;
    color: var(--text-primary);
    cursor: pointer;

    /* Match height of mode buttons exactly */
    height: 72px;
    display: flex;
    align-items: center;
    justify-content: center;

    box-shadow:
        4px 4px 8px var(--shadow-dark),
        -4px -4px 8px var(--shadow-light);

    transition: all 0.3s ease;
}

.end-game-btn:hover {
    transform: translateY(-2px);
    box-shadow:
        6px 6px 12px var(--shadow-dark),
        -6px -6px 12px var(--shadow-light);
}

.end-game-btn:active {
    transform: scale(0.98);
    box-shadow:
        inset 3px 3px 6px var(--shadow-inset-dark),
        inset -3px -3px 6px var(--shadow-inset-light);
}

/* ===================================
   MICROPHONE STATUS
   =================================== */
.mic-status {
    position: fixed;
    top: var(--spacing-lg);
    /* Align with logo and FAB button */
    left: 50%;
    transform: translateX(-50%) scale(0.8);
    /* 20% smaller */
    z-index: 100;

    display: flex;
    align-items: center;
    gap: var(--spacing-sm);

    padding: var(--spacing-sm) var(--spacing-md);
    background: var(--bg-primary);
    border-radius: 24px;

    box-shadow:
        4px 4px 8px var(--shadow-dark),
        -4px -4px 8px var(--shadow-light);

    transition: all 0.3s ease;
    cursor: pointer;
}

.mic-status:hover {
    transform: translateX(-50%) scale(0.8) translateY(-2px);
    /* Maintain scale on hover */
    box-shadow:
        6px 6px 16px rgba(163, 177, 198, 0.4),
        -3px -3px 10px rgba(255, 255, 255, 0.6);
}

.mic-icon {
    font-size: 1.5rem;
    animation: pulse 2s ease-in-out infinite;
}

.mic-status.listening .mic-icon {
    animation: pulse 0.8s ease-in-out infinite;
}

.mic-status.busy {
    opacity: 0.5;
}

.mic-status.busy .mic-icon {
    animation: none;
}

@keyframes pulse {

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

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

.mic-text {
    font-size: 0.95rem;
    color: var(--text-primary);
}

/* ===================================
   FAB BUTTON
   =================================== */
.fab-btn {
    position: fixed;
    top: var(--spacing-lg);
    right: var(--spacing-lg);

    width: 33.6px;
    height: 33.6px;
    border-radius: 50%;
    border: none;

    background: var(--bg-primary);
    cursor: pointer;

    display: flex;
    align-items: center;
    justify-content: center;

    box-shadow:
        6px 6px 12px var(--shadow-dark),
        -6px -6px 12px var(--shadow-light);

    transition: all 0.3s ease;
    z-index: 100;
}

.fab-btn:hover {
    transform: translateY(-2px);
    box-shadow:
        8px 8px 16px var(--shadow-dark),
        -8px -8px 16px var(--shadow-light);
}

.fab-btn:active {
    transform: scale(0.95);
    box-shadow:
        inset 4px 4px 8px var(--shadow-inset-dark),
        inset -4px -4px 8px var(--shadow-inset-light);
}

.fab-icon {
    font-size: 1.2rem;
    font-weight: 300;
    color: var(--text-primary);
    transition: transform 0.3s ease;
    line-height: 1;
}

.fab-btn.active .fab-icon {
    transform: rotate(45deg);
}

/* ===================================
   LOGO
   =================================== */
.logo {
    position: fixed;
    top: var(--spacing-lg);
    left: var(--spacing-lg);

    width: 42px;
    /* 30% smaller: 60px * 0.7 */
    height: 42px;

    border-radius: 50%;

    /* Flat PNG - no neumorphic shadow */
    transition: all 0.3s ease;
    z-index: 100;

    /* Prevent image distortion */
    object-fit: contain;
}

.logo:hover {
    transform: scale(1.05);
}

/* ===================================
   INFO PANEL
   =================================== */
.info-panel {
    position: fixed;
    top: 0;
    right: 0;
    width: 100%;
    max-width: 500px;
    height: 100vh;

    background: var(--bg-primary);
    backdrop-filter: blur(10px);

    box-shadow:
        -12px 0 24px rgba(163, 177, 198, 0.3);

    transform: translateX(100%);
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);

    z-index: 99;
    overflow-y: auto;
}

.info-panel.visible {
    transform: translateX(0);
}

.info-panel.hidden {
    transform: translateX(100%);
}

.info-content {
    padding: var(--spacing-xl);
    padding-top: 100px;
    max-width: 450px;
}

.info-content h2 {
    font-size: 2.5rem;
    margin-bottom: var(--spacing-lg);
    color: var(--text-primary);
    line-height: 1.2;
}

.info-body {
    font-size: 1.1rem;
    line-height: 1.8;
    color: var(--text-primary);
    margin-bottom: var(--spacing-xl);
}

.info-signature {
    font-size: 0.95rem;
    color: var(--text-secondary);
    font-weight: 300;
    font-style: italic;
}

/* ===================================
   MESSAGE OVERLAY
   =================================== */
.message-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(240, 242, 245, 0.95);
    backdrop-filter: blur(10px);

    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;

    transition: opacity 0.4s ease;
}

.message-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.message-box {
    background: var(--bg-primary);
    padding: var(--spacing-xl);
    border-radius: 32px;
    max-width: 600px;
    /* Increased by 20% from 500px */
    min-width: 320px;
    /* Added min-width for mobile */
    width: 90%;
    /* Responsive width */
    text-align: center;

    box-shadow:
        12px 12px 24px var(--shadow-dark),
        -12px -12px 24px var(--shadow-light);
}

.message-box h2 {
    font-size: 2rem;
    margin-bottom: var(--spacing-md);
    color: var(--text-primary);
}

.message-box p {
    font-size: 1.1rem;
    line-height: 1.6;
    color: var(--text-secondary);
    margin-bottom: var(--spacing-lg);
}

.message-btn {
    padding: var(--spacing-sm) var(--spacing-lg);
    background: var(--bg-primary);
    border: none;
    border-radius: 100px;
    font-family: 'MainFont', sans-serif;
    font-size: 1.1rem;
    color: var(--text-primary);
    cursor: pointer;

    box-shadow:
        6px 6px 12px var(--shadow-dark),
        -6px -6px 12px var(--shadow-light);

    transition: all 0.3s ease;
}

.message-btn:hover {
    transform: translateY(-2px);
    box-shadow:
        8px 8px 16px var(--shadow-dark),
        -8px -8px 16px var(--shadow-light);
}

.message-btn:active {
    transform: scale(0.98);
    box-shadow:
        inset 4px 4px 8px var(--shadow-inset-dark),
        inset -4px -4px 8px var(--shadow-inset-light);
}

.secondary-btn {
    margin-top: var(--spacing-sm);
}

.secondary-btn.hidden {
    display: none;
}

/* ===================================
   RESPONSIVE DESIGN
   =================================== */
/* ===================================
   RESPONSIVE DESIGN - DESKTOP
   =================================== */
@media (min-width: 1025px) {

    /* Larger listening button on desktop */
    .mic-status {
        transform: translateX(-50%) scale(1.0);
        /* 20% larger than mobile (was 0.8) */
        padding: calc(var(--spacing-sm) * 1.2) calc(var(--spacing-md) * 1.2);
    }

    .mic-status:hover {
        transform: translateX(-50%) scale(1.0) translateY(-2px);
    }

    .mic-icon {
        font-size: 1.8rem;
        /* 20% larger */
    }

    .mic-text {
        font-size: 1.14rem;
        /* 20% larger */
    }

    /* Increase vertical spacing from table */
    .table-container {
        margin-top: 130px;
        /* Fix overlap with Listening button */
        margin-bottom: 50px;
    }
}

/* ===================================
   RESPONSIVE DESIGN - MOBILE
   =================================== */
@media (max-width: 1024px) {
    .table {
        width: 600px;
        height: 300px;
    }

    .paddle {
        width: 14px;
        height: 100px;
    }

    .speech-bubble {
        max-width: 240px;
    }
}

@media (max-width: 768px) {

    /* Vertical table layout for mobile */
    .table-container {
        flex-direction: column;
        gap: var(--spacing-sm);
        padding: 2rem;
        /* Increased padding for negative space */
    }

    .table {
        width: 87vw;
        /* Reduced by 3% for breathing room */
        height: 60vh;
    }

    /* Horizontal paddles for vertical layout */
    .paddle {
        width: 100px;
        height: 14px;
    }

    /* Ms. Ping Pong at top */
    .paddle-mpp {
        order: -1;
    }

    /* Horizontal net for mobile (was vertical) */
    .net {
        width: 100%;
        height: 1px;
        position: absolute;
        top: 50%;
        left: 0;
        transform: translateY(-50%);
    }

    /* Horizontal button layout with better tap targets */
    .selector-container {
        flex-direction: row;
        /* Horizontal layout */
        justify-content: center;
        gap: 10px;
        /* Tight spacing */
        padding: var(--spacing-md);
    }

    .mode-selector {
        flex-direction: row;
        /* Keep buttons horizontal */
        gap: 10px;
        width: auto;
    }

    /* Scale buttons down 30% */
    .mode-btn {
        min-width: 98px;
        /* 140px * 0.7 */
        width: auto;
        padding: 6px 10px;
        /* Reduced by ~30% */
    }

    .mode-label {
        font-size: 10px;
        /* 14px * 0.7 ≈ 10px */
    }

    .mode-desc {
        font-size: 0.6rem;
        /* Scaled down proportionally */
    }

    .end-game-btn {
        min-width: 98px;
        width: auto;
        padding: 6px 10px;
        /* Match Blip/Flow padding exactly */
        height: auto;
        font-size: 10px;
    }

    /* Responsive bubble text */
    .speech-bubble {
        max-width: 200px;
    }

    .bubble-text {
        font-size: 0.9rem;
    }
}

/* Mobile: FAB Button Scaling */
@media (max-width: 600px) {
    .fab-btn {
        width: 26.88px;
        /* 20% smaller: 33.6px * 0.8 */
        height: 26.88px;
    }

    .fab-icon {
        font-size: 0.96rem;
        /* 20% smaller: 1.2rem * 0.8 */
    }
}

/* Mobile: Modal Responsive Sizing */
@media (max-width: 768px) {
    .message-box {
        width: 60%;
        max-width: none;
        padding: var(--spacing-lg);
        text-align: center;
    }

    .message-box h2 {
        font-size: 1.5rem;
    }

    .message-box p {
        font-size: 1rem;
    }
}

/* Mobile: Vertical Ball Animations */
@keyframes ballTravelToAIMobile {
    0% {
        top: 75%;
        left: 50%;
        transform: translate(-50%, -50%) scale(1);
    }

    50% {
        left: 30%;
        transform: translate(-50%, -50%) scale(0.8);
    }

    100% {
        top: 25%;
        left: 50%;
        transform: translate(-50%, -50%) scale(1);
    }
}

@keyframes ballTravelToUserMobile {
    0% {
        top: 25%;
        left: 50%;
        transform: translate(-50%, -50%) scale(1);
    }

    50% {
        left: 70%;
        transform: translate(-50%, -50%) scale(0.8);
    }

    100% {
        top: 75%;
        left: 50%;
        transform: translate(-50%, -50%) scale(1);
    }
}

.ball.travel-to-ai-mobile {
    animation: ballTravelToAIMobile 1s ease-in-out forwards;
}

.ball.travel-to-user-mobile {
    animation: ballTravelToUserMobile 1s ease-in-out forwards;
}