/* ===========================
   Design Tokens (matched to dashboard)
   =========================== */
:root {
    --bg-base: #0d0d14;
    --bg-surface: rgba(21, 21, 28, 0.85);
    --bg-card: rgba(28, 28, 40, 0.85);
    --bg-hover: rgba(38, 38, 54, 0.9);
    --bg-input: rgba(26, 26, 38, 0.6);

    --accent: #06b6d4;
    --accent-hover: #0891b2;
    --accent-dim: rgba(6, 182, 212, 0.15);
    --accent-glow: rgba(6, 182, 212, 0.35);
    --warm: #f59e0b;
    --warm-dim: rgba(245, 158, 11, 0.15);
    --text: #eeeef2;
    --text-2: #9898b0;
    --text-3: #5a5a72;
    --border: #2a2a3c;
    --success: #22c55e;
    --danger: #ef4444;
    --warning: #f59e0b;
    --radius: 12px;
    --radius-sm: 8px;
    --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --transition: 0.2s ease;
}

/* ===========================
   Reset
   =========================== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { height: 100%; overflow-x: hidden; }
body {
    font-family: var(--font);
    background: var(--bg-base);
    color: var(--text);
    line-height: 1.5;
    min-height: 100vh;
    overflow-x: hidden;
}
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input { font-family: inherit; }
a { text-decoration: none; color: inherit; }
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* ===========================
   Overlay / Modal
   =========================== */
.overlay {
    position: fixed; inset: 0; z-index: 1000;
    display: flex; align-items: center; justify-content: center;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(16px);
}
.modal-card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 36px;
    width: 420px;
    max-width: 90vw;
    text-align: center;
}
.modal-card h3 { margin-bottom: 14px; font-size: 1.1rem; }
.modal-card input {
    width: 100%; padding: 11px 14px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--bg-input);
    color: var(--text); font-size: 0.95rem;
    margin-bottom: 12px; outline: none;
    transition: border var(--transition);
}
.modal-card input:focus { border-color: var(--accent); }
.modal-btns { display: flex; gap: 8px; }
.modal-btns > * { flex: 1; }

/* ===========================
   Buttons
   =========================== */
.btn-accent {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    padding: 10px 20px; border-radius: var(--radius-sm);
    background: var(--accent); color: #000; font-weight: 600; font-size: 0.9rem;
    transition: all var(--transition);
}
.btn-accent:hover { background: var(--accent-hover); box-shadow: 0 2px 16px var(--accent-glow); }
.btn-ghost {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 8px 14px; border-radius: var(--radius-sm);
    background: var(--bg-card); border: 1px solid var(--border);
    color: var(--text-2); font-size: 0.85rem;
    transition: all var(--transition);
}
.btn-ghost:hover { background: var(--bg-hover); color: var(--text); border-color: var(--accent); }
.btn-sm { padding: 7px 14px; font-size: 0.82rem; }

/* ===========================
   Top Bar
   =========================== */
.topbar {
    display: flex; align-items: center;
    padding: 14px 24px; gap: 16px;
    background: var(--bg-surface);
    backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border);
    position: sticky; top: 0; z-index: 100;
}
.topbar-brand {
    display: flex; align-items: center; gap: 8px;
    font-weight: 700; font-size: 1.1rem;
    flex-shrink: 0;
    transition: color var(--transition);
}
.topbar-brand:hover { color: var(--accent); }
.topbar-brand i { color: var(--accent); }
.topbar-title {
    display: flex; align-items: center; gap: 8px;
    font-weight: 600; font-size: 1rem;
    color: var(--text-2);
    padding-left: 16px;
    border-left: 1px solid var(--border);
}
.topbar-title i { color: var(--warm); }
.topbar-actions {
    display: flex; align-items: center; gap: 12px;
    margin-left: auto;
}

/* ===========================
   Content
   =========================== */
.content {
    max-width: 900px;
    margin: 0 auto;
    padding: 30px 20px 100px; /* extra bottom padding for mini player */
}

/* ===========================
   Sections
   =========================== */
.section {
    margin-bottom: 32px;
}
.section-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 16px;
}
.section-header h2 {
    font-size: 1rem; font-weight: 700;
    display: flex; align-items: center; gap: 8px;
    color: var(--text);
}
.section-header h2 i {
    color: var(--accent);
    font-size: 0.9rem;
}

/* ===========================
   Games Grid
   =========================== */
.games-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 12px;
}
.game-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    transition: all 0.3s ease;
    cursor: default;
    position: relative;
    overflow: hidden;
}
.game-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--accent), transparent);
    opacity: 0;
    transition: opacity 0.3s;
}
.game-card:hover {
    border-color: var(--accent);
    transform: translateY(-2px);
    box-shadow: 0 8px 32px rgba(6, 182, 212, 0.1);
}
.game-card:hover::before { opacity: 1; }
.game-card-icon {
    width: 48px; height: 48px;
    border-radius: var(--radius-sm);
    background: var(--accent-dim);
    display: flex; align-items: center; justify-content: center;
    font-size: 1.2rem;
    color: var(--accent);
    margin-bottom: 12px;
}
.game-card-name {
    font-size: 1rem; font-weight: 700;
    margin-bottom: 4px;
}
.game-card-desc {
    font-size: 0.8rem; color: var(--text-3);
    margin-bottom: 12px;
    line-height: 1.4;
}
.game-card-meta {
    display: flex; align-items: center; gap: 12px;
    font-size: 0.75rem; color: var(--text-3);
}
.game-card-meta span {
    display: flex; align-items: center; gap: 4px;
}

/* ===========================
   Rooms List
   =========================== */
.rooms-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.room-card {
    display: flex; align-items: center;
    gap: 14px; padding: 14px 18px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    transition: all 0.25s ease;
}
.room-card:hover {
    border-color: var(--accent);
    background: var(--bg-hover);
}
.room-card-icon {
    width: 40px; height: 40px;
    border-radius: var(--radius-sm);
    background: var(--accent-dim);
    display: flex; align-items: center; justify-content: center;
    color: var(--accent);
    font-size: 1rem;
    flex-shrink: 0;
}
.room-card-info {
    flex: 1; min-width: 0;
}
.room-card-name {
    font-weight: 600; font-size: 0.9rem;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.room-card-meta {
    font-size: 0.75rem; color: var(--text-3);
    display: flex; align-items: center; gap: 8px;
}
.room-card-players {
    display: flex; align-items: center; gap: 4px;
    color: var(--success);
    font-weight: 600;
}
.room-card-players.full { color: var(--danger); }
.room-join-btn {
    padding: 8px 18px;
    border-radius: 20px;
    background: var(--accent-dim);
    color: var(--accent);
    font-size: 0.82rem; font-weight: 600;
    transition: all var(--transition);
    flex-shrink: 0;
}
.room-join-btn:hover { background: var(--accent); color: #000; }

/* ===========================
   Empty State
   =========================== */
.empty-state {
    text-align: center; padding: 40px 16px;
    color: var(--text-3);
}
.empty-state i { font-size: 1.5rem; margin-bottom: 8px; display: block; opacity: 0.5; }
.empty-state p { font-size: 0.85rem; }
.empty-hint { font-size: 0.75rem; color: var(--text-3); opacity: 0.6; margin-top: 4px; }

/* ===========================
   Game Select in Modal
   =========================== */
.modal-game-select {
    display: flex; flex-direction: column; gap: 8px;
    margin-bottom: 14px;
    max-height: 200px;
    overflow-y: auto;
}
.modal-game-option {
    display: flex; align-items: center; gap: 12px;
    padding: 12px 14px;
    border-radius: var(--radius-sm);
    background: var(--bg-card);
    border: 2px solid var(--border);
    cursor: pointer;
    transition: all 0.2s;
    text-align: left;
}
.modal-game-option:hover {
    border-color: var(--text-3);
    background: var(--bg-hover);
}
.modal-game-option.selected {
    border-color: var(--accent);
    background: var(--accent-dim);
}
.modal-game-option i {
    font-size: 1.1rem;
    color: var(--accent);
    width: 24px; text-align: center;
}
.modal-game-option .game-opt-name {
    font-weight: 600; font-size: 0.85rem;
}
.modal-game-option .game-opt-desc {
    font-size: 0.7rem; color: var(--text-3);
}

/* ===========================
   Game View
   =========================== */
.game-view {
    position: fixed; inset: 0;
    z-index: 50;
    background: var(--bg-base);
    display: flex; flex-direction: column;
}
.game-header {
    display: flex; align-items: center;
    padding: 10px 16px; gap: 16px;
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border);
    z-index: 51;
}
.game-room-info {
    display: flex; align-items: center; gap: 10px;
}
.room-name { font-weight: 600; font-size: 0.9rem; }
.room-players { font-size: 0.8rem; color: var(--text-3); }
#gameCanvas {
    flex: 1;
    width: 100%;
    background: var(--bg-base);
}
.game-overlay {
    position: absolute;
    inset: 0;
    display: flex; align-items: center; justify-content: center;
    pointer-events: none;
}
.waiting-state {
    text-align: center;
    color: var(--text-3);
}
.waiting-state i { font-size: 2rem; margin-bottom: 12px; display: block; color: var(--accent); }
.waiting-state p { font-size: 0.9rem; }

/* ===========================
   Responsive
   =========================== */
@media (max-width: 600px) {
    .content { padding: 16px 12px 120px; }
    .topbar { padding: 12px 14px; gap: 10px; }
    .topbar-actions span { display: none; }
    .topbar-title span { display: none; }
    .games-grid { grid-template-columns: 1fr; }

    .game-header { padding: 8px 12px; }
}
