@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700&display=swap');

:root {
    --bg-body: #0F172A; 
    --bg-app: #FFFFFF; 
    --primary: #3B82F6; 
    --primary-hover: #2563EB;
    --accent: #E11D48; 
    --accent-hover: #BE123C; 
    --text-main: #1E293B; 
    --text-light: #64748B;
    --surface: #F8FAFC; 
    --border-color: #E2E8F0;
    --card-back: linear-gradient(135deg, #1E293B 0%, #0F172A 100%);
    --gold: #F59E0B;
}

/* --- THEMES --- */
body.theme-dark {
    --bg-body: #020617;
    --bg-app: #1E293B;
    --surface: #334155;
    --text-main: #F8FAFC;
    --text-light: #94A3B8;
    --border-color: #475569;
}

body.theme-gold {
    --bg-body: #451A03;
    --bg-app: #FFFBEB;
    --surface: #FEF3C7;
    --primary: #D97706;
    --primary-hover: #B45309;
    --text-main: #451A03;
    --text-light: #78350F;
    --border-color: #FCD34D;
    --card-back: linear-gradient(135deg, #B45309 0%, #78350F 100%);
}

/* ANTI-COPY & NO TAP HIGHLIGHT FOR NATIVE APP FEEL */
* { 
    -webkit-tap-highlight-color: transparent; 
}

body { 
    font-family: 'Poppins', sans-serif; 
    background: var(--bg-body); 
    color: var(--text-main); 
    margin: 0; 
    display: flex; 
    justify-content: center; 
    align-items: center; 
    min-height: 100dvh; 
    overflow: hidden; 
    user-select: none; 
    -webkit-user-select: none; 
    transition: background 0.3s ease;
}

/* Keep inputs typable */
input, select { 
    user-select: text; 
    -webkit-user-select: text; 
    background: var(--bg-app);
    color: var(--text-main);
}

#game-container { 
    background: var(--bg-app); 
    width: 100%; 
    max-width: 480px; 
    height: 100dvh; 
    display: flex; 
    flex-direction: column; 
    position: relative; 
    transition: background 0.3s ease, color 0.3s ease;
}

@media (min-width: 500px) { 
    #game-container { 
        height: 95dvh; 
        border-radius: 24px; 
        box-shadow: 0 25px 50px -12px rgba(0,0,0,0.5); 
    } 
}

header { 
    background: var(--bg-app); 
    padding: 15px 20px; 
    display: flex; 
    justify-content: space-between; 
    align-items: center; 
    border-bottom: 1px solid var(--border-color); 
    flex-shrink: 0;
}

header h1 { 
    margin: 0; 
    font-size: 1.2rem; 
    font-weight: 700; 
    color: var(--text-main); 
}

/* Buttons */
button { 
    background: var(--primary); 
    color: white; 
    border: none; 
    padding: 10px 16px; 
    border-radius: 10px; 
    font-weight: 600; 
    cursor: pointer; 
    transition: 0.2s; 
    font-family: inherit; 
}

button:hover:not(:disabled) { 
    background: var(--primary-hover); 
}

button:active:not(:disabled) { 
    transform: scale(0.95); 
}

button:disabled { 
    opacity: 0.7; 
    cursor: not-allowed; 
}

button.danger { 
    background: var(--accent); 
}

button.danger:hover:not(:disabled) { 
    background: var(--accent-hover); 
}

.btn-outline { 
    background: transparent; 
    color: var(--text-main); 
    border: 2px solid var(--border-color); 
}

/* Screens & Layouts */
.screen { 
    display: none; 
    padding: 20px; 
    flex-grow: 1; 
    flex-direction: column; 
    overflow-y: auto; 
    gap: 15px; 
}

.screen.active { 
    display: flex; 
}

input, select { 
    width: 100%; 
    padding: 12px; 
    font-size: 1rem; 
    border: 2px solid var(--border-color); 
    border-radius: 10px; 
    box-sizing: border-box; 
    font-family: inherit; 
    margin-bottom: 10px;
}

.card-panel { 
    background: var(--surface); 
    padding: 20px; 
    border-radius: 16px; 
    border: 1px solid var(--border-color); 
    display: flex; 
    flex-direction: column; 
    gap: 10px; 
    flex-shrink: 0;
}

/* PREMIUM OVERLAYS */
.overlay { 
    display: none; 
    position: absolute; 
    top: 0; 
    left: 0; 
    width: 100%; 
    height: 100%; 
    background: rgba(15, 23, 42, 0.9); 
    z-index: 1000; 
    justify-content: center; 
    align-items: center; 
    padding: 20px; 
    box-sizing: border-box; 
    backdrop-filter: blur(5px); 
}

.overlay.active { 
    display: flex; 
    animation: fadeIn 0.3s ease; 
}

.modal-box { 
    background: var(--bg-app); 
    padding: 25px; 
    border-radius: 20px; 
    width: 100%; 
    max-width: 350px; 
    text-align: center; 
    max-height: 80vh; 
    overflow-y: auto; 
    box-shadow: 0 20px 40px rgba(0,0,0,0.4); 
    border: 1px solid rgba(255,255,255,0.2);
}

@keyframes fadeIn { 
    from { opacity: 0; transform: translateY(10px); } 
    to { opacity: 1; transform: translateY(0); } 
}

/* UNOBTRUSIVE PAUSE BANNER */
#pause-banner { 
    display: none; 
    background: #FEF2F2; 
    color: #E11D48; 
    padding: 12px; 
    text-align: center; 
    font-weight: 600; 
    font-size: 0.85rem; 
    border-bottom: 1px solid #FECDD3; 
    flex-shrink: 0; 
}

#room-info { 
    display: flex; 
    flex-direction: column; 
    align-items: center; 
    gap: 8px; 
    background: var(--card-back); 
    color: white; 
    padding: 15px; 
    border-radius: 12px; 
    flex-shrink: 0;
}

#room-info p { 
    margin: 0; 
    font-weight: 500; 
}

#room-info strong { 
    color: #38BDF8; 
    font-size: 1.2rem; 
}

.room-actions { 
    display: flex; 
    gap: 8px; 
    flex-wrap: wrap; 
    justify-content: center; 
    width: 100%; 
    margin-top: 5px;
}

#host-requests { 
    display: none; 
    background: #FEF3C7; 
    border: 2px solid #F59E0B; 
    padding: 15px; 
    border-radius: 12px; 
}

.request-item { 
    display: flex; 
    justify-content: space-between; 
    align-items: center; 
    margin-bottom: 8px; 
    background: var(--bg-app); 
    padding: 8px; 
    border-radius: 8px; 
    font-size: 0.9rem;
}

/* CARDS & TABLE */
#card-table { 
    display: grid; 
    grid-template-columns: 1fr 1fr; 
    gap: 12px; 
    perspective: 1000px; 
    flex-shrink: 0;
}

#card-table.six-players { 
    grid-template-columns: 1fr 1fr 1fr; 
}

#card-table.eight-players { 
    grid-template-columns: 1fr 1fr 1fr 1fr; 
}

@media (max-width: 400px) { 
    #card-table.eight-players { 
        grid-template-columns: 1fr 1fr 1fr; 
    } 
}

.card { 
    background: var(--card-back); 
    height: 110px; 
    border-radius: 12px; 
    display: flex; 
    justify-content: center; 
    align-items: center; 
    text-align: center; 
    color: white; 
    font-weight: 600; 
    cursor: pointer; 
    transition: transform 0.4s, box-shadow 0.3s, border-color 0.3s; 
    user-select: none; 
    border: 2px solid rgba(255,255,255,0.1); 
    transform-style: preserve-3d; 
    position: relative;
}

.card.flipped { 
    background: var(--bg-app); 
    color: var(--text-main); 
    border: 2px solid var(--primary); 
    transform: rotateY(180deg); 
}

.card.my-card { 
    border: 3px solid var(--gold) !important; 
    box-shadow: 0 0 15px rgba(245, 158, 11, 0.4) !important; 
    z-index: 5;
}

.card.suspect-glow { 
    box-shadow: 0 0 15px 4px rgba(225, 29, 72, 0.7) !important; 
    border-color: var(--accent) !important; 
    animation: pulseGlow 1.5s infinite; 
    cursor: pointer !important; 
    z-index: 10;
}

.card-inner-text { 
    transform: rotateY(180deg); 
    width: 100%; 
    height: 100%; 
    display: flex; 
    flex-direction: column; 
    align-items: center; 
    justify-content: center; 
    gap: 2px; 
    position: relative;
} 

.card-avatar { 
    width: 36px; 
    height: 36px; 
    border-radius: 50%; 
    border: 2px solid var(--primary); 
    object-fit: cover; 
    margin-bottom: 4px; 
    background: white;
}

/* ANIMATIONS */
@keyframes pulseGlow { 
    0% { box-shadow: 0 0 10px 2px rgba(225, 29, 72, 0.5); } 
    50% { box-shadow: 0 0 20px 6px rgba(225, 29, 72, 0.8); } 
    100% { box-shadow: 0 0 10px 2px rgba(225, 29, 72, 0.5); } 
}

@keyframes dealCards { 
    0% { transform: translateY(-50px) scale(0.5); opacity: 0; } 
    100% { transform: translateY(0) scale(1); opacity: 1; } 
}

.deal-anim { 
    animation: dealCards 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards; 
    opacity: 0; 
}

@keyframes guessWrong { 
    0%, 100% { transform: translateX(0) rotateY(180deg); } 
    20%, 60% { transform: translateX(-10px) rotateY(180deg); } 
    40%, 80% { transform: translateX(10px) rotateY(180deg); } 
}

.card.guess-wrong { 
    animation: guessWrong 0.5s ease forwards; 
    border-color: var(--accent) !important; 
    box-shadow: 0 0 15px 4px rgba(225, 29, 72, 0.7) !important; 
    z-index: 10; 
}

@keyframes guessCorrect { 
    0%, 100% { transform: scale(1) rotateY(180deg); } 
    50% { transform: scale(1.1) rotateY(180deg); box-shadow: 0 0 25px 8px rgba(16, 185, 129, 0.9); } 
}

.card.guess-correct { 
    animation: guessCorrect 0.6s ease forwards; 
    border-color: #10B981 !important; 
    box-shadow: 0 0 15px 4px rgba(16, 185, 129, 0.7) !important; 
    z-index: 10; 
}

@keyframes pulseAttention { 
    0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(59, 130, 246, 0.7); } 
    50% { transform: scale(1.05); box-shadow: 0 0 15px 5px rgba(59, 130, 246, 0.4); } 
    100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(59, 130, 246, 0); } 
}

.attention-btn { 
    animation: pulseAttention 1.5s infinite; 
}

.attention-btn.danger { 
    animation: pulseAttentionDanger 1.5s infinite; 
}

@keyframes pulseAttentionDanger { 
    0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(225, 29, 72, 0.7); } 
    50% { transform: scale(1.05); box-shadow: 0 0 15px 5px rgba(225, 29, 72, 0.4); } 
    100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(225, 29, 72, 0); } 
}

#dialogue-box { 
    background: var(--surface); 
    color: var(--primary); 
    padding: 15px; 
    border-radius: 12px; 
    text-align: center; 
    font-weight: 500; 
    border-left: 4px solid var(--primary); 
    font-size: 0.95rem; 
    min-height: 24px; 
    flex-shrink: 0;
}

#guess-section { 
    display: none; 
    background: rgba(225, 29, 72, 0.1); 
    padding: 15px; 
    border-radius: 12px; 
    text-align: center; 
    border: 1px solid rgba(225, 29, 72, 0.3); 
    flex-shrink: 0;
}

#guess-section button { 
    margin: 5px; 
}

/* UPGRADED LIVE SCOREBOARD */
#player-list { 
    list-style: none; 
    padding: 0; 
    margin: 0; 
    display: flex; 
    flex-direction: column; 
    gap: 8px; 
    flex-shrink: 0;
}

.player-row { 
    background: var(--surface); 
    border: 1px solid var(--border-color); 
    border-radius: 12px; 
    padding: 8px 12px; 
    display: flex; 
    justify-content: space-between; 
    align-items: center; 
    box-shadow: 0 2px 5px rgba(0,0,0,0.03); 
    transition: 0.2s;
}

.player-row.is-me { 
    border-color: var(--primary); 
    background: rgba(59, 130, 246, 0.1); 
}

.score-pill { 
    background: var(--text-main); 
    color: var(--bg-app); 
    padding: 4px 12px; 
    border-radius: 20px; 
    font-size: 0.85rem; 
    font-weight: 700; 
    min-width: 35px; 
    text-align: center;
}

.status-dot { 
    height: 10px; 
    width: 10px; 
    border-radius: 50%; 
    display: inline-block; 
    margin-right: 6px; 
}

.status-online { 
    background-color: #10B981; 
    box-shadow: 0 0 5px #10B981; 
}

.status-offline { 
    background-color: #94A3B8; 
}

/* UPGRADED END GAME SCOREBOARD */
.final-player-card { 
    display: flex; 
    justify-content: space-between; 
    align-items: center; 
    padding: 12px; 
    background: var(--surface); 
    border-radius: 12px; 
    margin-bottom: 8px; 
    border: 1px solid var(--border-color); 
}

.final-player-card.winner { 
    background: linear-gradient(to right, rgba(254, 243, 199, 0.8), rgba(254, 240, 138, 0.8)); 
    border: 1px solid #F59E0B; 
    transform: scale(1.02); 
    box-shadow: 0 4px 12px rgba(245, 158, 11, 0.2); 
}
body.theme-dark .final-player-card.winner {
    background: linear-gradient(to right, #451A03, #78350F);
}

.final-rank { 
    font-size: 1.2rem; 
    font-weight: bold; 
    width: 30px; 
    text-align: left; 
}

.final-title { 
    font-size: 0.8rem; 
    color: var(--text-light); 
    text-transform: uppercase; 
    font-weight: 700; 
    letter-spacing: 1px;
}

.final-score-val { 
    font-size: 1.2rem; 
    font-weight: bold; 
    color: var(--primary); 
}

/* CHAT SYSTEM */
#chat-wrapper { 
    transition: 0.3s; 
    margin-top: auto; 
    display: flex; 
    flex-direction: column; 
    flex-shrink: 0;
}

#chat-box { 
    background: var(--bg-app); 
    border: 1px solid var(--border-color); 
    border-radius: 12px; 
    display: flex; 
    flex-direction: column; 
    height: 160px; 
    border-top-right-radius: 0;
}

.chat-header { 
    display: flex; 
    justify-content: flex-end; 
}

.chat-header button { 
    border-radius: 12px 12px 0 0; 
    border-bottom: none; 
    background: var(--surface); 
    padding: 4px 12px; 
    font-size: 0.75rem; 
    border: 1px solid var(--border-color); 
    border-bottom: none;
}

#emoji-bar { 
    display: flex; 
    justify-content: space-around; 
    background: var(--surface); 
    padding: 8px; 
    border-bottom: 1px solid var(--border-color); 
    font-size: 1.2rem; 
    border-radius: 12px 0 0 0;
}

.emoji-btn { 
    cursor: pointer; 
    transition: 0.2s; 
    user-select: none; 
}

.emoji-btn:active { 
    transform: scale(1.3); 
}

#chat-messages { 
    flex-grow: 1; 
    overflow-y: auto; 
    padding: 10px; 
    font-size: 0.85rem; 
    display: flex; 
    flex-direction: column; 
    gap: 6px; 
}

.chat-msg { 
    background: var(--surface); 
    padding: 6px 10px; 
    border-radius: 8px; 
    align-self: flex-start; 
    max-width: 85%; 
    word-wrap: break-word;
}

.chat-controls { 
    display: flex; 
    border-top: 1px solid var(--border-color); 
}

#chat-input { 
    border: none; 
    border-radius: 0 0 0 12px; 
    padding: 10px; 
    margin: 0; 
    flex-grow: 1;
}

#send-chat-btn { 
    border-radius: 0 0 12px 0; 
    padding: 0 15px; 
}

/* FLOATING EMOJIS */
.floating-emoji { 
    position: fixed; 
    bottom: 20%; 
    left: 50%; 
    font-size: 4rem; 
    transform: translateX(-50%); 
    animation: floatUp 2s forwards; 
    z-index: 2000; 
    pointer-events: none;
}

@keyframes floatUp { 
    0% { bottom: 20%; opacity: 1; transform: translateX(-50%) scale(0.5); } 
    20% { opacity: 1; transform: translateX(-50%) scale(1.2); } 
    100% { bottom: 70%; opacity: 0; transform: translateX(-50%) scale(1); } 
}

.react-emoji { 
    position: absolute; 
    top: -20px; 
    right: -10px; 
    font-size: 2rem; 
    animation: floatReact 2s forwards; 
    z-index: 20; 
}

@keyframes floatReact { 
    0% { transform: translateY(0) scale(0.5); opacity: 1; } 
    20% { transform: translateY(-20px) scale(1.2); opacity: 1; } 
    100% { transform: translateY(-60px) scale(1); opacity: 0; } 
}

/* CREATOR BRANDING */
.creator-branding { 
    text-align: center; 
    font-size: 0.8rem; 
    color: var(--text-light); 
    margin-top: auto; 
    padding-top: 10px; 
    flex-shrink: 0;
}

.creator-branding a { 
    color: var(--primary); 
    text-decoration: none; 
    font-weight: 600;
}

/* SCROLLBAR CUSTOMIZATION */
::-webkit-scrollbar { 
    width: 6px; 
}

::-webkit-scrollbar-track { 
    background: transparent; 
}

::-webkit-scrollbar-thumb { 
    background: var(--text-light); 
    border-radius: 10px; 
}
