/* ==================== DESIGN SYSTEM ==================== */
@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;600;700;800&family=Playfair+Display:wght@700;800&display=swap');

:root {
    /* Core palette — deep midnight with teal-emerald accents */
    --bg-deep: #0a0e1a;
    --bg-mid: #111827;
    --accent-primary: #34d399;
    --accent-warm: #f59e0b;
    --accent-danger: #ef4444;
    --accent-info: #38bdf8;
    --accent-glow: rgba(52, 211, 153, 0.4);
    --glass-bg: rgba(255, 255, 255, 0.06);
    --glass-border: rgba(255, 255, 255, 0.12);
    --glass-highlight: rgba(255, 255, 255, 0.18);
    --text-primary: #f1f5f9;
    --text-muted: rgba(241, 245, 249, 0.6);
    --text-accent: #34d399;
    --shadow-glass: 0 8px 32px rgba(0, 0, 0, 0.4);
    --blur-amount: 20px;
    --radius-sm: 8px;
    --radius-md: 14px;
    --radius-lg: 24px;
    --radius-xl: 40px;
}

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

body {
    font-family: 'Outfit', sans-serif;
    background: var(--bg-deep);
    color: var(--text-primary);
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    /* Animated mesh gradient background */
    background-image:
        radial-gradient(ellipse at 20% 80%, rgba(52, 211, 153, 0.12) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 20%, rgba(56, 189, 248, 0.08) 0%, transparent 50%),
        radial-gradient(ellipse at 50% 50%, rgba(245, 158, 11, 0.05) 0%, transparent 60%);
    background-attachment: fixed;
}

/* Floating ambient particles via pseudo-elements */
body::before {
    content: '';
    position: fixed;
    width: 600px;
    height: 600px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(52, 211, 153, 0.08), transparent 70%);
    top: -200px;
    right: -200px;
    animation: float-orb 20s ease-in-out infinite;
    pointer-events: none;
    z-index: 0;
}

body::after {
    content: '';
    position: fixed;
    width: 500px;
    height: 500px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(56, 189, 248, 0.06), transparent 70%);
    bottom: -150px;
    left: -150px;
    animation: float-orb 25s ease-in-out infinite reverse;
    pointer-events: none;
    z-index: 0;
}

@keyframes float-orb {

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

    25% {
        transform: translate(30px, -40px) scale(1.05);
    }

    50% {
        transform: translate(-20px, 20px) scale(0.95);
    }

    75% {
        transform: translate(40px, 30px) scale(1.02);
    }
}

/* ==================== GLASSMORPHISM CORE ==================== */

.glass {
    background: var(--glass-bg);
    backdrop-filter: blur(var(--blur-amount));
    -webkit-backdrop-filter: blur(var(--blur-amount));
    border: 1px solid var(--glass-border);
    box-shadow: var(--shadow-glass);
}

/* ==================== GAME TABLE ==================== */

.table {
    width: 92vw;
    height: 92vh;
    max-width: 1100px;
    max-height: 850px;
    background:
        radial-gradient(circle at 30% 40%, rgba(52, 211, 153, 0.08) 0%, transparent 50%),
        radial-gradient(circle at 70% 60%, rgba(56, 189, 248, 0.05) 0%, transparent 50%),
        rgba(15, 23, 42, 0.7);
    backdrop-filter: blur(30px);
    -webkit-backdrop-filter: blur(30px);
    border-radius: 200px;
    border: 1px solid var(--glass-border);
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.05),
        inset 0 0 80px rgba(52, 211, 153, 0.03),
        0 20px 60px rgba(0, 0, 0, 0.5),
        0 0 120px rgba(52, 211, 153, 0.05);
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 1;
}

.center-area {
    text-align: center;
    z-index: 10;
    margin-top: -30px;
}

.game-title {
    font-family: 'Playfair Display', serif;
    font-size: 36px;
    font-weight: 800;
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-info), var(--accent-warm));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-shadow: none;
    margin-bottom: 12px;
    letter-spacing: 6px;
    filter: drop-shadow(0 2px 8px rgba(52, 211, 153, 0.3));
}

.rule-display {
    font-size: 15px;
    background: var(--glass-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border);
    color: var(--text-primary);
    padding: 10px 20px;
    border-radius: var(--radius-md);
    margin-bottom: 15px;
    display: inline-block;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    letter-spacing: 0.5px;
}

.multiplier-text {
    color: var(--accent-danger);
    font-weight: 700;
    font-size: 20px;
    text-shadow: 0 0 12px rgba(239, 68, 68, 0.5);
}

.game-message {
    font-size: 14px;
    background: var(--glass-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border);
    padding: 10px 20px;
    border-radius: var(--radius-md);
    margin-bottom: 15px;
    max-width: 420px;
    word-break: break-all;
    overflow-wrap: break-word;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
    line-height: 1.6;
    margin-left: auto;
    margin-right: auto;
}

/* ==================== BUTTONS ==================== */

.btn {
    padding: 12px 28px;
    font-size: 16px;
    font-family: 'Outfit', sans-serif;
    font-weight: 600;
    background: linear-gradient(135deg, var(--accent-primary), #059669);
    color: var(--bg-deep);
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(52, 211, 153, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.2);
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    letter-spacing: 0.5px;
    position: relative;
    overflow: hidden;
}

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

.btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 24px rgba(52, 211, 153, 0.4);
}

.btn:hover::before {
    left: 100%;
}

.btn:active {
    transform: translateY(1px);
    box-shadow: 0 2px 8px rgba(52, 211, 153, 0.3);
}

.hidden {
    display: none !important;
}

/* ==================== PLAYER AREA ==================== */

.player {
    position: absolute;
    display: flex;
    flex-direction: column;
    align-items: center;
    transition: all 0.3s ease;
}

.info {
    font-size: 14px;
    font-weight: 400;
    background: var(--glass-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border);
    padding: 8px 16px;
    border-radius: var(--radius-md);
    margin-bottom: 10px;
    text-align: center;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    min-width: 100px;
}

.loser-tag {
    background: rgba(239, 68, 68, 0.25) !important;
    border: 1px solid rgba(239, 68, 68, 0.6) !important;
    box-shadow: 0 0 20px rgba(239, 68, 68, 0.3), inset 0 0 20px rgba(239, 68, 68, 0.1) !important;
}

.score {
    display: block;
    color: var(--accent-warm);
    font-size: 13px;
    margin-top: 4px;
    font-weight: 600;
}

/* ==================== CARDS ==================== */

.cards {
    display: flex;
    gap: -25px;
    min-height: 100px;
    min-width: 70px;
    perspective: 600px;
}

.card {
    width: 72px;
    height: 104px;
    background: linear-gradient(145deg, #ffffff, #f0f0f0);
    border-radius: 10px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.8);
    display: inline-flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    font-size: 20px;
    font-weight: bold;
    margin: 0 -14px;
    position: relative;
    transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.35s ease;
    user-select: none;
    border: 1px solid rgba(200, 200, 200, 0.5);
}

.card[data-suit="hearts"],
.card[data-suit="diamonds"] {
    color: #dc2626;
}

.card[data-suit="spades"],
.card[data-suit="clubs"] {
    color: #1e293b;
}

/* Card corner labels */
.card-corner {
    position: absolute;
    font-size: 11px;
    line-height: 1.1;
    font-weight: 700;
    text-align: center;
}

.card-corner-tl {
    top: 3px;
    left: 4px;
}

.card-corner-br {
    bottom: 3px;
    right: 4px;
    transform: rotate(180deg);
}

/* Pip container */
.card-pips {
    position: absolute;
    inset: 0;
    pointer-events: none;
}

/* Individual pip */
.card-pip {
    position: absolute;
    font-size: 14px;
    line-height: 1;
    transform: translate(-50%, -50%);
}

.card-pip.pip-flip {
    transform: translate(-50%, -50%) rotate(180deg);
}

/* Face card letter (J/Q/K) */
.card-face-letter {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 28px;
    font-weight: 800;
    font-family: 'Playfair Display', serif;
    opacity: 0.85;
}

.card.face-down {
    background: #1a2756;
    border: 2.5px solid #c8b87c;
    color: transparent !important;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
    overflow: hidden;
}

/* Outer decorative border */
.card.face-down::before {
    content: '';
    position: absolute;
    inset: 3px;
    border: 1.5px solid rgba(200, 184, 124, 0.6);
    border-radius: 3px;
    background:
        /* Center diamond */
        linear-gradient(45deg, transparent 42%, rgba(200, 184, 124, 0.25) 42%, rgba(200, 184, 124, 0.25) 58%, transparent 58%),
        linear-gradient(-45deg, transparent 42%, rgba(200, 184, 124, 0.25) 42%, rgba(200, 184, 124, 0.25) 58%, transparent 58%),
        /* Ornate grid pattern */
        repeating-linear-gradient(0deg, transparent, transparent 8px, rgba(200, 184, 124, 0.08) 8px, rgba(200, 184, 124, 0.08) 9px),
        repeating-linear-gradient(90deg, transparent, transparent 8px, rgba(200, 184, 124, 0.08) 8px, rgba(200, 184, 124, 0.08) 9px),
        /* Diagonal filigree */
        repeating-linear-gradient(45deg, transparent, transparent 6px, rgba(200, 184, 124, 0.06) 6px, rgba(200, 184, 124, 0.06) 7px),
        repeating-linear-gradient(-45deg, transparent, transparent 6px, rgba(200, 184, 124, 0.06) 6px, rgba(200, 184, 124, 0.06) 7px);
    display: block !important;
    z-index: 1;
}

/* Inner ornate frame + center emblem */
.card.face-down::after {
    content: '♠';
    position: absolute;
    inset: 8px;
    border: 1px solid rgba(200, 184, 124, 0.35);
    border-radius: 2px;
    display: flex !important;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    color: rgba(200, 184, 124, 0.4);
    text-shadow: 0 0 6px rgba(200, 184, 124, 0.2);
    z-index: 2;
    background: radial-gradient(ellipse at center, rgba(200, 184, 124, 0.06) 0%, transparent 60%);
}




.card.selectable {
    cursor: pointer;
}

.card.selectable:hover {
    transform: translateY(-18px) rotateX(5deg);
    box-shadow: 0 12px 28px rgba(52, 211, 153, 0.25), 0 4px 8px rgba(0, 0, 0, 0.3);
    z-index: 10;
}

.card.selected {
    transform: translateY(-28px) rotateX(5deg) !important;
    border: 2px solid var(--accent-primary);
    box-shadow: 0 16px 36px rgba(52, 211, 153, 0.35), 0 0 20px rgba(52, 211, 153, 0.2);
    z-index: 10;
}

.status {
    margin-top: 10px;
    font-size: 13px;
    font-weight: 600;
    color: var(--accent-primary);
    text-shadow: 0 0 8px rgba(52, 211, 153, 0.3);
}

/* ==================== ANIMATIONS ==================== */

.loser-anim {
    animation: loser-pulse 0.6s ease-in-out;
}

.loser-anim .info {
    border-color: rgba(239, 68, 68, 0.6);
    color: #fca5a5;
    box-shadow: 0 0 24px rgba(239, 68, 68, 0.2);
}

.winner-anim {
    animation: winner-glow 1.2s ease-in-out;
}

.winner-anim .info {
    border-color: rgba(52, 211, 153, 0.6);
    box-shadow: 0 0 24px rgba(52, 211, 153, 0.15);
}

@keyframes loser-pulse {

    0%,
    100% {
        transform: translate(0, 0);
    }

    10% {
        transform: translate(-4px, -2px);
    }

    20% {
        transform: translate(4px, 0);
    }

    30% {
        transform: translate(-2px, 2px);
    }

    40% {
        transform: translate(2px, -2px);
    }

    50% {
        transform: translate(-4px, 0);
    }

    60% {
        transform: translate(4px, 2px);
    }

    70% {
        transform: translate(0, -2px);
    }

    80% {
        transform: translate(-2px, 2px);
    }

    90% {
        transform: translate(2px, 0);
    }
}

@keyframes winner-glow {
    0% {
        filter: brightness(1);
    }

    30% {
        filter: brightness(1.2);
    }

    60% {
        filter: brightness(1.05);
    }

    100% {
        filter: brightness(1);
    }
}

/* ==================== LOBBY & ROOM ==================== */

#lobby,
#room-waiting {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100vw;
    height: 100vh;
    position: fixed;
    top: 0;
    left: 0;
    z-index: 100;
}

.lobby-box {
    background: var(--glass-bg);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    padding: 48px 40px;
    max-width: 640px;
    width: 92%;
    text-align: center;
    box-shadow:
        0 24px 80px rgba(0, 0, 0, 0.5),
        inset 0 1px 0 rgba(255, 255, 255, 0.06),
        0 0 60px rgba(52, 211, 153, 0.04);
    animation: lobby-enter 0.6s cubic-bezier(0.16, 1, 0.3, 1) both;
}

@keyframes lobby-enter {
    from {
        opacity: 0;
        transform: translateY(30px) scale(0.96);
    }

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

.lobby-box h1 {
    font-family: 'Playfair Display', serif;
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-info));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    filter: drop-shadow(0 2px 6px rgba(52, 211, 153, 0.3));
    margin-bottom: 24px;
    font-size: 32px;
}

.lobby-box h2 {
    color: var(--text-primary);
}

.lobby-box h3 {
    margin-bottom: 12px;
}

.lobby-section {
    margin: 24px 0;
    color: var(--text-primary);
}

.lobby-section label {
    display: block;
    margin-bottom: 10px;
    font-weight: 600;
    color: var(--accent-primary);
    letter-spacing: 0.5px;
}

.lobby-box input[type="text"],
.lobby-box input[type="number"] {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    padding: 10px 14px;
    font-family: 'Outfit', sans-serif;
    font-size: 16px;
    outline: none;
    transition: border-color 0.3s, box-shadow 0.3s;
}

.lobby-box input:focus {
    border-color: var(--accent-primary);
    box-shadow: 0 0 16px rgba(52, 211, 153, 0.15);
}

.lobby-btn {
    padding: 12px 24px;
    font-size: 15px;
    color: var(--bg-deep) !important;
    font-weight: 700;
    border-radius: var(--radius-sm);
}

.lobby-btn:hover {
    opacity: 0.92;
}

/* Remove player button */
.lobby-box button[onclick*="removePlayer"] {
    background: rgba(239, 68, 68, 0.2) !important;
    border: 1px solid rgba(239, 68, 68, 0.4) !important;
    color: #fca5a5 !important;
    backdrop-filter: blur(8px);
    transition: all 0.2s;
}

.lobby-box button[onclick*="removePlayer"]:hover {
    background: rgba(239, 68, 68, 0.35) !important;
}

/* ==================== SCROLLBAR ==================== */

::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
}

/* ==================== MISC LEGACY POSITIONS (kept for compat) ==================== */

.player-top {
    top: 15px;
    left: 50%;
    transform: translateX(-50%);
}

.player-bottom {
    bottom: -30px;
    left: 50%;
    transform: translateX(-50%);
}

.player-right {
    right: 50px;
    top: 50%;
    transform: translateY(-50%);
}

.player-left {
    left: 50px;
    top: 50%;
    transform: translateY(-50%);
}