:root {
    --bg-dark: #0f0a14;
    --bg-panel: #1a1424;
    --border-color: #3d2c54;
    --text-main: #e0d6eb;
    --text-muted: #8a7a9e;
    --accent-gold: #cfaa56;
    --accent-purple: #7b4eb3;
    --accent-red: #8f2d3a;
    --accent-green: #357a58;
}

body { 
    background-color: var(--bg-dark); 
    color: var(--text-main); 
    padding-bottom: 150px; 
    font-family: 'Georgia', serif; 
}

.cursor-pointer {
    cursor: pointer;
}
.cursor-pointer:hover {
    text-decoration: underline;
}

/* --- OVERRIDES --- */
.navbar { background-color: var(--bg-panel) !important; border-bottom: 1px solid var(--border-color); }
.navbar-brand { color: var(--accent-gold) !important; font-weight: bold; letter-spacing: 1px; }

.card { background-color: var(--bg-panel); border: 1px solid var(--border-color); color: var(--text-main); }
.list-group-item { background-color: #241c30; color: var(--text-main); border-color: var(--border-color); }

.modal-content { background-color: var(--bg-panel); border: 1px solid var(--accent-gold); box-shadow: 0 0 20px rgba(0,0,0,0.8); }
.modal-header, .modal-footer { border-color: var(--border-color); }
.btn-close { filter: invert(1); }

.text-muted {
    color: #d1d5db !important;
}

.form-control, .form-select { 
    background-color: #0a060e; 
    border: 1px solid var(--border-color); 
    color: var(--text-main); 
}
.form-control:focus, .form-select:focus {
    background-color: #150d1f;
    color: #fff;
    border-color: var(--accent-purple);
    box-shadow: 0 0 5px var(--accent-purple);
}

/* --- CUSTOM BUTTONS --- */
.btn-primary { background-color: var(--accent-purple); border-color: var(--accent-purple); }
.btn-primary:hover { background-color: #633b96; }
.btn-outline-light { border-color: var(--text-muted); color: var(--text-muted); }
.btn-outline-light:hover { background-color: var(--text-muted); color: #000; }
.btn-success { background-color: var(--accent-green); border: none; }

/* --- GAME ELEMENTS --- */

/* Game Board Cards */
.board-card { 
    width: 100px; 
    height: 140px; 
    object-fit: cover; 
    margin: 5px; 
    border-radius: 4px; 
    border: 1px solid #444;
    transition: transform 0.2s, border 0.2s, box-shadow 0.2s;
    cursor: pointer;
    filter: sepia(0.3) contrast(1.1);
}
.board-card:hover { transform: scale(1.05); z-index: 10; box-shadow: 0 5px 15px rgba(0,0,0,0.5); }
.board-card.selected-vote { 
    border: 3px solid var(--accent-gold); 
    transform: scale(1.1); 
    box-shadow: 0 0 15px var(--accent-gold);
    z-index: 20;
}
.board-card.correct { 
    border: 3px solid var(--accent-green); 
    opacity: 0.4; 
    pointer-events: none; 
    filter: grayscale(1);
}

/* Blocked Card (Already Solved/Guessed) */
.board-card.blocked {
    opacity: 0.3;
    filter: grayscale(1) blur(1px);
    pointer-events: none;
    cursor: not-allowed;
    border: 2px solid #333;
}

/* Ghost Target Highlight */
.board-card.target-highlight {
    border: 3px solid var(--accent-red);
    box-shadow: 0 0 20px var(--accent-red);
    animation: pulseTarget 1.5s infinite;
    z-index: 30;
}

@keyframes pulseTarget {
    0% { border-color: var(--accent-red); box-shadow: 0 0 10px var(--accent-red); }
    50% { border-color: #ff6b6b; box-shadow: 0 0 25px #ff6b6b; }
    100% { border-color: var(--accent-red); box-shadow: 0 0 10px var(--accent-red); }
}

/* Vision Cards */
.vision-card {
    width: 120px; 
    height: 180px; 
    object-fit: cover; 
    margin: 0 5px; 
    border-radius: 6px; 
    border: 1px solid #555; 
    cursor: pointer; 
    transition: transform 0.2s;
    box-shadow: 0 4px 8px rgba(0,0,0,0.5);
}
.vision-card:hover { transform: translateY(-5px); }
.vision-card.selected { 
    border: 3px solid var(--accent-gold); 
    transform: translateY(-15px); 
    box-shadow: 0 0 20px var(--accent-gold);
}

/* Ghost Hand Container */
#ghost-hud {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(to top, #0f0a14 90%, transparent);
    border-top: 1px solid var(--border-color);
    padding: 15px;
    z-index: 1000;
}

.clue-display { 
    min-height: 120px; 
    background: rgba(0,0,0,0.3); 
    border: 1px dashed var(--border-color); 
    border-radius: 8px; 
}

/* Chat Styles */
#chat-ui-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 1050;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

#chat-window {
    width: 300px;
    height: 350px;
    margin-bottom: 10px;
    box-shadow: 0 5px 25px rgba(0,0,0,0.8);
    background-color: var(--bg-panel);
    border: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
}

#chat-history {
    flex-grow: 1;
    overflow-y: auto;
    background-color: #0a060e;
    border: 1px solid #333;
    border-radius: 4px;
    padding: 10px;
    margin-bottom: 5px;
    font-size: 0.9rem;
    font-family: sans-serif;
    height: 100%; /* Fill flex space */
}

#chat-toggle-btn {
    width: 60px;
    height: 60px;
    font-size: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: var(--accent-purple);
    border: 2px solid var(--border-color);
    transition: transform 0.2s;
}
#chat-toggle-btn:hover { transform: scale(1.1); }

.chat-msg { margin-bottom: 5px; word-wrap: break-word; }
.chat-system { color: var(--accent-gold); font-style: italic; border-bottom: 1px solid #333; padding-bottom: 2px; margin-bottom: 8px; }
.chat-ghost { color: var(--accent-red); opacity: 0.8; letter-spacing: 1px; }
.chat-psychic { color: #8fd3ff; }
.chat-spectator { color: var(--text-muted); }

#lobby-chat-box {
    scrollbar-width: thin;
    scrollbar-color: var(--accent-purple) transparent;
}
#lobby-chat-box::-webkit-scrollbar { width: 6px; }
#lobby-chat-box::-webkit-scrollbar-thumb { background: var(--accent-purple); border-radius: 10px; }

/* Room Code Display */
.room-code-display {
    font-family: 'Courier New', monospace;
    letter-spacing: 3px;
    font-size: 1.4rem;
    border: 1px solid var(--accent-gold);
    color: var(--accent-gold);
    background: rgba(207, 170, 86, 0.1);
    padding: 5px 15px;
    border-radius: 4px;
    cursor: pointer;
    font-weight: bold;
}

/* Custom Tooltip */
.custom-tooltip {
    visibility: hidden;
    width: 80px;
    background-color: var(--accent-gold);
    color: #000;
    text-align: center;
    border-radius: 6px;
    padding: 5px 0;
    position: absolute;
    z-index: 1;
    bottom: 125%;
    left: 50%;
    margin-left: -40px;
    opacity: 0;
    transition: opacity 0.3s;
    font-size: 0.8rem;
    font-family: sans-serif;
    font-weight: bold;
}

.custom-tooltip::after {
    content: "";
    position: absolute;
    top: 100%;
    left: 50%;
    margin-left: -5px;
    border-width: 5px;
    border-style: solid;
    border-color: var(--accent-gold) transparent transparent transparent;
}

.show-tooltip {
    visibility: visible;
    opacity: 1;
}

/* Resolution Overlay */
#resolution-overlay {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background-color: rgba(0,0,0,0.9);
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
}

.res-card-wrapper {
    position: relative;
    width: 120px;
    margin: 10px;
    text-align: center;
    opacity: 0;
}

.res-card-img {
    width: 100%;
    height: 160px;
    object-fit: cover;
    border-radius: 6px;
    border: 2px solid #555;
    box-shadow: 0 5px 15px rgba(0,0,0,0.5);
}

.res-status-icon {
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%) scale(0);
    font-size: 4rem;
    text-shadow: 0 0 10px rgba(0,0,0,0.8);
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.res-name {
    margin-top: 5px;
    font-size: 0.9rem;
    color: var(--text-main);
}

/* Magnification */
.magnify-overlay {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.85);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: zoom-out;
}

.magnified-card {
    max-width: 90vw;
    max-height: 90vh;
    border: 2px solid var(--accent-gold);
    border-radius: 8px;
    box-shadow: 0 0 50px rgba(0,0,0,1);
    object-fit: contain;
    animation: popIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

/* --- ANIMATIONS --- */

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

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

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

@keyframes pulseRed {
    0% { box-shadow: 0 0 0 0 rgba(143, 45, 58, 0.7); }
    70% { box-shadow: 0 0 0 10px rgba(143, 45, 58, 0); }
    100% { box-shadow: 0 0 0 0 rgba(143, 45, 58, 0); }
}

@keyframes popIn {
    0% { opacity: 0; transform: scale(0.5); }
    100% { opacity: 1; transform: scale(1); }
}

.anim-slide-in { animation: slideInUp 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards; }
.anim-fade-in { animation: fadeIn 0.4s ease-out forwards; }
.anim-pop-in { animation: popIn 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards; }
.slide-in-bottom { animation: slideInBottom 0.3s ease-out forwards; }
.timer-warning { animation: pulseRed 1.5s infinite; border-radius: 4px; }

/* --- MOBILE / RESPONSIVE --- */
@media (max-width: 768px) {
    body { padding-bottom: 96px; font-family: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial; }
    .board-card { width: 28vw; height: 40vw; }
    .vision-card { width: 32vw; height: 48vw; }
    #chat-window { width: 92vw; height: 50vh; right: 4vw; bottom: 80px; }
    #ghost-hud { padding: 10px; }
    .room-code-display { font-size: 1rem; padding: 6px 10px; }
    .card { border-radius: 10px; }

    /* Make buttons full-width and larger touch targets */
    .btn { min-height: 48px; min-width: 48px; padding: 12px 16px; font-size: 1rem; }
    .d-grid .btn { width: 100%; }

    /* Bottom navigation */
    #bottom-nav { position: fixed; left: 0; right: 0; bottom: 0; height: 64px; background: linear-gradient(to top, rgba(10,6,14,0.98), rgba(10,6,14,0.9)); border-top: 1px solid var(--border-color); display:flex; align-items:center; justify-content:space-around; z-index:1200; }
    #bottom-nav button { background: transparent; border: none; color: var(--text-muted); display:flex; flex-direction:column; align-items:center; justify-content:center; gap:4px; font-size: 0.8rem; }
    #bottom-nav button.active { color: var(--accent-gold); }

    /* Make lobby & player lists single column */
    #lobby-screen .col-md-5, #lobby-screen .col-md-8 { flex: 0 0 100%; max-width: 100%; }

    /* Compact header */
    .navbar-brand img { height: 1.1em; }
    .navbar .d-flex { gap: 6px; }
}