:root {
    --bg-main: #0f172a;
    --bg-panel: #1e293b;
    --border-color: #334155;
    --primary: #3b82f6;
    --primary-hover: #2563eb;
    --secondary: #475569;
    --secondary-hover: #334155;
    --text: #f8fafc;
    --text-muted: #94a3b8;
    --card-face: #ffffff;
    --card-text: #0f172a;
    --success-bg: rgba(16, 185, 129, 0.1);
    --success-text: #10b981;
    --radius: 8px;
}

* { box-sizing: border-box; margin: 0; padding: 0; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; }

body { background-color: var(--bg-main); color: var(--text); display: flex; flex-direction: column; min-height: 100vh; }

.view { display: none; }
#setup-view.active { display: flex; justify-content: center; align-items: center; min-height: 100vh; animation: fadeIn 0.3s ease;}
#room-view.active { display: block; animation: fadeIn 0.3s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

/* Setup Screen */
.setup-card { background: var(--bg-panel); padding: 2.5rem; border-radius: 16px; width: 100%; max-width: 450px; box-shadow: 0 10px 15px -3px rgba(0,0,0,0.3); border: 1px solid var(--border-color); }
.setup-card h1 { text-align: center; margin-bottom: 0.5rem; }
.subtitle { text-align: center; color: var(--text-muted); margin-bottom: 2rem; }

.input-group { margin-bottom: 1rem; }
.input-group label { display: block; font-size: 0.85rem; color: var(--text-muted); margin-bottom: 0.5rem; text-transform: uppercase; letter-spacing: 0.5px; }
input { width: 100%; padding: 0.8rem 1rem; background: var(--bg-main); border: 1px solid var(--border-color); border-radius: var(--radius); color: var(--text); font-size: 1rem; }
input:focus { outline: none; border-color: var(--primary); }

button { padding: 0.8rem 1.5rem; border: none; border-radius: var(--radius); font-size: 1rem; font-weight: 600; cursor: pointer; transition: 0.2s; color: white; }
button.primary { background: var(--primary); width: 100%; }
button.primary:hover { background: var(--primary-hover); }
button.secondary { background: var(--secondary); }
button.secondary:hover { background: var(--secondary-hover); }
button.small { padding: 0.5rem 1rem; font-size: 0.85rem; }
button.large { padding: 1rem 2rem; font-size: 1.1rem; box-shadow: 0 4px 12px rgba(0,0,0,0.2); }

.host-actions { background: rgba(0,0,0,0.2); padding: 1.5rem; border-radius: var(--radius); margin-bottom: 1rem; }
.join-group { display: flex; gap: 0.5rem; }
.join-group input { margin-bottom: 0; }

.divider { text-align: center; margin: 1.5rem 0; position: relative; color: var(--text-muted); font-size: 0.85rem; }
.divider::before, .divider::after { content: ""; position: absolute; top: 50%; width: 30%; height: 1px; background: var(--border-color); }
.divider::before { left: 0; } .divider::after { right: 0; }
.error { color: #ef4444; margin-top: 1rem; text-align: center; font-size: 0.9rem; }

/* Room Screen - Top Bar */
.top-bar { display: flex; justify-content: space-between; align-items: center; padding: 1rem 2rem; background: var(--bg-panel); border-bottom: 1px solid var(--border-color); }
.nav-left { display: flex; align-items: center; gap: 1rem; }
.logo { font-size: 1.5rem; }
.room-title { font-size: 1.25rem; font-weight: bold; }
.nav-right { display: flex; align-items: center; gap: 1rem; }
.badge { background: var(--primary); padding: 0.3rem 0.6rem; border-radius: 4px; font-size: 0.75rem; font-weight: bold; text-transform: uppercase; }
.room-id-pill { background: var(--bg-main); padding: 0.4rem 0.8rem; border-radius: 20px; font-size: 0.9rem; border: 1px solid var(--border-color); }
.highlight { color: var(--primary); font-family: monospace; font-size: 1.1rem; letter-spacing: 1px; }

/* Game Board */
.game-board { flex: 1; display: flex; flex-direction: column; padding: 2rem; max-width: 1000px; margin: 0 auto; width: 100%; }

.issue-header { text-align: center; margin-bottom: 2rem; }
.issue-header h2 { font-size: 2rem; margin-bottom: 1rem; }
.edit-issue { display: flex; justify-content: center; gap: 0.5rem; max-width: 500px; margin: 0 auto; }

/* Grid Dashboard Area (COMPACT) */
.dashboard-container { flex: 1; display: flex; flex-direction: column; align-items: center; position: relative; margin-bottom: 2rem; }
.participants-grid { 
    display: grid; 
    /* Shrink the minimum width from 160px to 90px to fit many more per row */
    grid-template-columns: repeat(auto-fit, minmax(90px, 1fr)); 
    gap: 0.75rem; 
    width: 100%; 
    max-width: 900px;
    margin-bottom: 1.5rem;
}

/* Individual Participant Card (COMPACT) */
.participant-card {
    background: var(--bg-panel);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 0.75rem 0.5rem; /* Tighter padding */
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem; /* Tighter spacing between card and name */
    box-shadow: 0 2px 4px -1px rgba(0, 0, 0, 0.1);
    transition: transform 0.2s, border-color 0.2s;
}
.participant-card:hover { transform: translateY(-2px); border-color: var(--secondary); }

.participant-name { 
    font-size: 0.75rem; /* Smaller text */
    font-weight: 500; 
    text-align: center; 
    width: 100%; 
    overflow: hidden; 
    text-overflow: ellipsis; 
    white-space: nowrap; 
    color: var(--text-muted);
}

/* Vote Indicator inside Card (COMPACT) */
.vote-display { 
    width: 45px; height: 65px; border-radius: 4px; /* Smaller card dimensions */
    display: flex; justify-content: center; align-items: center; 
    font-size: 1.2rem; font-weight: bold; transition: all 0.2s;
    background: var(--bg-main); border: 2px dashed var(--border-color); color: var(--text-muted);
}
.vote-display.voted { 
    border-style: solid; border-color: var(--success-text); 
    background: var(--success-bg); color: var(--success-text); font-size: 1.1rem;
}
.vote-display.revealed { 
    background: var(--card-face); color: var(--card-text); border: none;
    box-shadow: 0 4px 8px rgba(0,0,0,0.2); font-size: 1.5rem;
}

.host-controls { display: flex; gap: 1rem; margin-top: 0.5rem; }
/* Vote Indicator inside Card */
.vote-display { 
    width: 60px; height: 85px; border-radius: 6px; 
    display: flex; justify-content: center; align-items: center; 
    font-size: 1.5rem; font-weight: bold; transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    background: var(--bg-main); border: 2px dashed var(--border-color); color: var(--text-muted);
}
.vote-display.voted { 
    border-style: solid; border-color: var(--success-text); 
    background: var(--success-bg); color: var(--success-text); font-size: 1.2rem;
}
.vote-display.revealed { 
    background: var(--card-face); color: var(--card-text); border: none;
    box-shadow: 0 4px 10px rgba(0,0,0,0.2); font-size: 2rem;
}

.host-controls { display: flex; gap: 1rem; margin-top: 1rem; }

/* My Hand (Bottom Area) */
.my-hand { background: var(--bg-panel); padding: 1.5rem; border-radius: 16px; border: 1px solid var(--border-color); text-align: center; }
.hand-title { color: var(--text-muted); margin-bottom: 1rem; font-size: 0.9rem; text-transform: uppercase; letter-spacing: 1px; }
.cards-container { display: flex; justify-content: center; gap: 0.8rem; flex-wrap: wrap; }
.poker-card { 
    width: 55px; height: 85px; background: var(--card-face); color: var(--card-text); 
    border-radius: var(--radius); display: flex; justify-content: center; align-items: center; 
    font-size: 1.5rem; font-weight: bold; cursor: pointer; transition: 0.2s; 
    box-shadow: 0 4px 6px rgba(0,0,0,0.1); border: 3px solid transparent;
}
.poker-card:hover { transform: translateY(-10px); }
.poker-card.selected { background: var(--primary); color: white; border-color: white; transform: translateY(-15px); box-shadow: 0 10px 15px rgba(59, 130, 246, 0.4); }

/* --- NEW ACTION BAR STYLES --- */
.action-bar {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap; /* Allows wrapping on very small mobile screens */
    gap: 1rem;
    margin-bottom: 2rem;
    background: var(--bg-panel);
    padding: 1rem 1.5rem;
    border-radius: 12px;
    border: 1px solid var(--border-color);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.action-bar h2 {
    margin-bottom: 0; /* Remove default margin so it centers vertically */
    font-size: 1.5rem;
    white-space: nowrap;
}

#host-action-bar {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

#host-action-bar input {
    margin-bottom: 0;
    width: 220px;
    padding: 0.6rem 0.8rem;
}

#host-action-bar button {
    margin: 0;
    white-space: nowrap;
}

.divider-vertical {
    width: 1px;
    height: 30px;
    background: var(--border-color);
    margin: 0 0.5rem;
}

/* --- NEW STYLES FOR LINKS & BUTTONS --- */
button.danger { background: #ef4444; color: white; }
button.danger:hover { background: #dc2626; }

.action-bar {
    display: flex; align-items: center; justify-content: center; flex-wrap: wrap; 
    gap: 1rem; margin-bottom: 2rem; background: var(--bg-panel); padding: 1rem 1.5rem; 
    border-radius: 12px; border: 1px solid var(--border-color); box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}
.action-bar h2 { margin-bottom: 0; font-size: 1.5rem; white-space: nowrap; }

#host-action-bar { display: flex; align-items: center; gap: 0.5rem; }
#host-action-bar input { margin-bottom: 0; width: 220px; padding: 0.6rem 0.8rem; }
#host-action-bar button { margin: 0; white-space: nowrap; }

.divider-vertical { width: 1px; height: 30px; background: var(--border-color); margin: 0 0.5rem; }