/* styles.css */

:root {
    --bg-color: #060e0a;
    --card-bg-color: rgba(255, 255, 255, 0.95);
    --text-primary: #f8fafc;
    --text-secondary: #a7f3d0;
    --accent-color: #10b981;
    --danger-color: #f43f5e;
    --success-color: #34d399;
    --warning-color: #fbbf24;
    --card-width-mob: 60px;
    --card-height-mob: 88px;
    --card-width-dt: 90px;
    --card-height-dt: 130px;
    --felt-color: rgba(16, 185, 129, 0.08);
    --border-radius: 16px;
    --card-radius: 9px;
    --font-primary: 'Outfit', sans-serif;
    --font-logo: 'Comfortaa', cursive;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: var(--font-primary);
    background: radial-gradient(circle at center, #1b382b 0%, #0d1e16 70%, #060e0a 100%);
    color: var(--text-primary);
    overflow: hidden;
    width: 100vw;
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    user-select: none;
}

.app-container {
    width: 100%;
    max-width: 600px;
    height: 100%;
    display: flex;
    flex-direction: column;
    padding: 12px;
    position: relative;
}

/* HEADER */
header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 50px;
    border-bottom: 1px solid rgba(148, 163, 184, 0.1);
    margin-bottom: 10px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 6px;
}

.logo h1 {
    font-family: var(--font-logo);
    font-size: 1.2rem;
    font-weight: 700;
    background: linear-gradient(135deg, #a78bfa, #6366f1);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.game-meta {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    font-size: 0.75rem;
}

#lobby-id {
    color: var(--text-secondary);
}

.status-badge {
    background: rgba(99, 102, 241, 0.2);
    color: #a5b4fc;
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: 600;
    margin-top: 2px;
    letter-spacing: 0.5px;
    font-size: 0.65rem;
}

/* SECTION BASICS */
.opponent-section, .my-section {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.player-info {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
    padding: 4px 10px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.05);
    align-self: flex-start;
    transition: all 0.3s ease;
}

.active-turn-glow {
    border-color: var(--accent-color);
    box-shadow: 0 0 10px rgba(99, 102, 241, 0.25);
    background: rgba(99, 102, 241, 0.05);
}

.cards-count {
    color: var(--text-secondary);
    font-weight: 600;
}

.role-badge {
    font-size: 0.7rem;
    background: var(--accent-color);
    padding: 1px 6px;
    border-radius: 4px;
    color: white;
}

.cards-container {
    height: 105px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    padding: 0 15px;
}

.my-cards {
    height: 115px;
    overflow: hidden;
    white-space: nowrap;
    justify-content: center;
}

.opponent-cards {
    height: 105px;
    overflow: hidden;
    justify-content: center;
}

/* PLAY FIELD */
.play-field-container {
    flex: 1;
    display: flex;
    gap: 8px;
    background: radial-gradient(circle at center, rgba(16, 185, 129, 0.15) 0%, rgba(6, 78, 59, 0.25) 100%);
    border: 1.5px solid rgba(16, 185, 129, 0.2);
    border-radius: var(--border-radius);
    padding: 8px;
    position: relative;
    box-shadow: inset 0 10px 30px rgba(0, 0, 0, 0.6), 0 4px 20px rgba(0, 0, 0, 0.3);
    margin: 6px 0;
}

/* DECK AREA */
.deck-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 70px;
    flex-shrink: 0;
    position: relative;
    border-right: 1px solid rgba(255, 255, 255, 0.05);
    padding-right: 6px;
}

.deck-pile {
    position: relative;
    width: var(--card-width-mob);
    height: var(--card-height-mob);
    display: flex;
    justify-content: center;
    align-items: center;
}

.trump-card-display {
    position: absolute;
    transform: rotate(90deg);
    transform-origin: center;
    z-index: 1;
    left: 10px;
}

.deck-back {
    position: absolute;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #7f1d1d, #450a0a);
    border: 1.5px solid #b91c1c;
    border-radius: var(--card-radius);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2;
    box-shadow: -2px 2px 5px rgba(0, 0, 0, 0.5);
}

#deck-count {
    font-weight: 800;
    font-size: 1.1rem;
    color: #fee2e2;
    text-shadow: 0 2px 4px rgba(0,0,0,0.5);
}

.trump-suit-indicator {
    font-size: 2.2rem;
    opacity: 0.15;
    margin-top: 10px;
}

/* TABLE AREA */
.table-area {
    flex: 1;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(2, 1fr);
    gap: 8px;
    align-items: center;
    justify-items: center;
    position: relative;
}

.empty-table-text {
    grid-column: 1 / -1;
    grid-row: 1 / -1;
    color: var(--text-secondary);
    font-size: 0.8rem;
    text-align: center;
    opacity: 0.5;
    pointer-events: none;
}

.card-pair {
    position: relative;
    width: var(--card-width-mob);
    height: var(--card-height-mob);
}

.card-pair .card {
    position: absolute;
    top: 0;
    left: 0;
}

.card-pair .defense-card {
    top: 24px;
    left: 18px;
    z-index: 5;
    transform: rotate(6deg);
    box-shadow: -4px 4px 12px rgba(0, 0, 0, 0.5);
}

/* CARD DESIGN */
.card {
    width: var(--card-width-mob);
    height: var(--card-height-mob);
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border-radius: var(--card-radius);
    border: 1px solid rgba(255, 255, 255, 0.6);
    color: #0f172a;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 6px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.25), inset 0 1px 1px rgba(255, 255, 255, 0.8);
    position: relative;
    transition: transform 0.25s cubic-bezier(0.25, 0.8, 0.25, 1), box-shadow 0.25s ease, border-color 0.2s ease;
    cursor: pointer;
}

/* Suit colors */
.card.suit-H, .card.suit-D {
    color: #f43f5e; /* Vibrant Red */
}

.card.suit-C, .card.suit-S {
    color: #0f172a; /* Deep Slate */
}

.card-top {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    line-height: 1;
}

.card-top .rank {
    font-size: 0.85rem;
    font-weight: 800;
}

.card-top .suit {
    font-size: 0.75rem;
}

.card-center {
    font-size: 1.6rem;
    align-self: center;
    line-height: 1;
}

.card-bottom {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    transform: rotate(180deg);
    line-height: 1;
}

.card-bottom .rank {
    font-size: 0.85rem;
    font-weight: 800;
}

.card-bottom .suit {
    font-size: 0.75rem;
}

/* Opponent hidden cards - gold micro-pattern back */
.card-back {
    background: radial-gradient(circle, rgba(245, 158, 11, 0.15) 20%, transparent 20%),
                radial-gradient(circle, rgba(245, 158, 11, 0.15) 20%, transparent 20%),
                linear-gradient(45deg, #090d16 25%, transparent 25%, transparent 75%, #090d16 75%),
                linear-gradient(-45deg, #090d16 25%, transparent 25%, transparent 75%, #090d16 75%),
                linear-gradient(135deg, #1e1b4b, #020617);
    background-size: 8px 8px, 8px 8px, 8px 8px, 8px 8px, 100% 100%;
    background-position: 0 0, 4px 4px, 0 0, 0 0, 0 0;
    border: 2px solid #fbbf24;
    box-shadow: 0 5px 12px rgba(0, 0, 0, 0.4), inset 0 0 12px rgba(251, 191, 36, 0.25);
    position: relative;
    color: transparent !important;
}

.card-back::after {
    content: '🃏';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 1.5rem;
    color: rgba(251, 191, 36, 0.9);
    filter: drop-shadow(0 0 4px rgba(251, 191, 36, 0.6));
}

/* Interactivity in hand */
.my-cards .card {
    flex-shrink: 0;
    position: relative;
}

.my-cards .card:hover, .my-cards .card:active {
    transform: translateY(-16px);
    z-index: 10;
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.4);
}

.my-cards .card.selected {
    transform: translateY(-24px);
    border: 2px solid var(--accent-color);
    box-shadow: 0 0 10px rgba(99, 102, 241, 0.5);
    z-index: 10;
}

.my-cards .card.playable {
    border: 1.5px solid var(--success-color);
    box-shadow: 0 0 6px rgba(16, 185, 129, 0.4);
}

/* CONTROLS SECTION */
.controls-section {
    display: flex;
    justify-content: center;
    gap: 12px;
    height: 42px;
    margin-bottom: 6px;
}

.btn {
    font-family: var(--font-primary);
    font-size: 0.85rem;
    font-weight: 700;
    border: none;
    border-radius: 8px;
    padding: 8px 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: all 0.2s ease;
}

.btn-primary {
    background: linear-gradient(135deg, #10b981, #059669);
    color: white;
    box-shadow: 0 4px 10px rgba(16, 185, 129, 0.3);
}

.btn-primary:active {
    transform: scale(0.97);
}

.btn-warning {
    background: linear-gradient(135deg, #f59e0b, #d97706);
    color: white;
    box-shadow: 0 4px 10px rgba(245, 158, 11, 0.3);
}

.btn-warning:active {
    transform: scale(0.97);
}

.btn-danger {
    background: rgba(239, 68, 68, 0.15);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: #fca5a5;
    width: 100%;
}

.btn-danger:active {
    background: rgba(239, 68, 68, 0.25);
}

.action-footer {
    margin-top: auto;
    height: 38px;
    display: flex;
    align-items: flex-end;
}

/* OVERLAYS */
.loading-overlay, .win-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(13, 17, 23, 0.85);
    backdrop-filter: blur(8px);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(99, 102, 241, 0.1);
    border-top-color: var(--accent-color);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-bottom: 12px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.win-card {
    background: #1e293b;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 16px;
    padding: 24px;
    text-align: center;
    width: 85%;
    max-width: 320px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
    animation: popUp 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes popUp {
    from { transform: scale(0.8); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

.win-emoji {
    font-size: 3rem;
    margin-bottom: 8px;
}

.win-card h2 {
    font-family: var(--font-logo);
    margin-bottom: 8px;
}

.win-card p {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 18px;
}

/* TOASTS */
.toast-container {
    position: absolute;
    bottom: 70px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 2000;
    width: 90%;
    max-width: 320px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    background: #1e293b;
    border-left: 4px solid var(--accent-color);
    color: var(--text-primary);
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 0.8rem;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    animation: slideUp 0.2s ease-out;
}

.toast.danger {
    border-left-color: var(--danger-color);
}

.toast.success {
    border-left-color: var(--success-color);
}

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

/* RESPONSIVE SCALING FOR DESKTOP SCREEN */
@media (min-width: 600px) {
    :root {
        --card-width-mob: var(--card-width-dt);
        --card-height-mob: var(--card-height-dt);
    }
    
    .game-container {
        max-width: 850px;
        border-radius: 12px;
        margin: 20px auto;
        height: calc(100vh - 40px);
        box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6);
        border: 1px solid rgba(255, 255, 255, 0.05);
    }
    
    .play-field-container {
        gap: 12px;
        padding: 12px;
        margin: 8px 0;
    }
    
    .table-area {
        gap: 12px;
    }
    
    .cards-container {
        height: 145px;
    }
    
    .my-cards {
        height: 155px;
    }
    
    .deck-area {
        width: 120px;
    }
    
    .deck-pile {
        transform: none;
    }
    
    .trump-card-display {
        left: 45px;
    }
    
    .card-pair .defense-card {
        top: 32px;
        left: 24px;
    }
    
    .card {
        padding: 6px;
    }
    
    .card-top .rank {
        font-size: 1.1rem;
    }
    
    .card-top .suit {
        font-size: 0.9rem;
    }
    
    .card-center {
        font-size: 2.2rem;
    }
    
    .card-bottom .rank {
        font-size: 1.1rem;
    }
    
    .card-bottom .suit {
        font-size: 0.9rem;
    }
}

/* Card Animations */
@keyframes playCard {
    from {
        transform: translateY(20px) scale(0.95);
        opacity: 0;
    }
    to {
        transform: translateY(0) scale(1);
        opacity: 1;
    }
}

@keyframes playDefenseCard {
    from {
        transform: translate(-10px, -10px) rotate(2deg) scale(0.95);
        opacity: 0;
    }
    to {
        transform: translate(0, 0) rotate(4deg) scale(1);
        opacity: 1;
    }
}

@keyframes drawCard {
    from {
        transform: translateY(-150px) rotate(15deg) scale(0.8);
        opacity: 0;
    }
    to {
        transform: translateY(0) rotate(0deg) scale(1);
        opacity: 1;
    }
}

.table-area .card-pair .card:first-child {
    animation: playCard 0.25s cubic-bezier(0.25, 1, 0.5, 1) forwards;
}

.table-area .card-pair .defense-card {
    animation: playDefenseCard 0.3s cubic-bezier(0.25, 1, 0.5, 1) forwards;
}

.my-cards .card {
    animation: drawCard 0.28s cubic-bezier(0.25, 1, 0.5, 1) forwards;
}

/* Active Hand Glowing Border */
.cards-container {
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    border: 1.5px solid transparent;
    border-radius: var(--border-radius);
}

.cards-container.active-hand-glow {
    border-color: rgba(16, 185, 129, 0.45);
    background: rgba(16, 185, 129, 0.03);
    box-shadow: 0 0 18px rgba(16, 185, 129, 0.15), inset 0 0 10px rgba(16, 185, 129, 0.05);
}

/* Drag Hover Board Highlights */
.table-area {
    transition: background-color 0.25s ease, border-color 0.25s ease, box-shadow 0.25s ease;
}

.table-area.drag-hover {
    border-color: rgba(16, 185, 129, 0.6) !important;
    box-shadow: inset 0 0 25px rgba(16, 185, 129, 0.25), inset 0 10px 30px rgba(0, 0, 0, 0.6);
    background: radial-gradient(circle at center, rgba(16, 185, 129, 0.2) 0%, rgba(6, 78, 59, 0.3) 100%) !important;
}

/* Drag Hover Card Highlights for Defending */
.table-area .card-pair .card {
    transition: transform 0.25s cubic-bezier(0.25, 0.8, 0.25, 1), border-color 0.25s ease, box-shadow 0.25s ease;
}

.table-area .card-pair .card.drag-hover {
    border-color: #fbbf24 !important;
    box-shadow: 0 0 22px #fbbf24, inset 0 0 8px rgba(251, 191, 36, 0.5) !important;
    transform: scale(1.08) !important;
    z-index: 1000 !important;
}
