:root {
    --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --radius: 10px;
    --transition: 0.15s ease;
}

[data-theme="dark"] {
    --bg-0: #0a0a0a;
    --bg-1: #141414;
    --bg-2: #1f1f1f;
    --bg-3: #2a2a2a;
    --text-1: #ffffff;
    --text-2: #b3b3b3;
    --text-3: #8a8a8a;
    --border: #2a2a2a;
    --accent: #2563eb;
    --accent-hover: #1d4ed8;
    --accent-soft: rgba(59, 130, 246, 0.15);
    --danger: #ef4444;
    --danger-soft: rgba(239, 68, 68, 0.15);
    --success: #22c55e;
    --success-soft: rgba(34, 197, 94, 0.15);
    --warning: #eab308;
    --warning-soft: rgba(234, 179, 8, 0.15);
    --impostor: #ec4899;
    --impostor-soft: rgba(236, 72, 153, 0.15);
}

[data-theme="light"] {
    --bg-0: #ffffff;
    --bg-1: #f5f5f5;
    --bg-2: #e5e5e5;
    --bg-3: #d4d4d4;
    --text-1: #171717;
    --text-2: #4a4a4a;
    --text-3: #737373;
    --border: #e5e5e5;
    --accent: #2563eb;
    --accent-hover: #1d4ed8;
    --accent-soft: rgba(37, 99, 235, 0.1);
    --danger: #dc2626;
    --danger-soft: rgba(220, 38, 38, 0.1);
    --success: #16a34a;
    --success-soft: rgba(22, 163, 74, 0.1);
    --warning: #ca8a04;
    --warning-soft: rgba(202, 138, 4, 0.1);
    --impostor: #db2777;
    --impostor-soft: rgba(219, 39, 119, 0.1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font);
    background: var(--bg-0);
    color: var(--text-1);
    /* Mobile improvements */
    touch-action: manipulation;
    overscroll-behavior: none;
    -webkit-tap-highlight-color: transparent;
    min-height: 100vh;
    transition: background var(--transition), color var(--transition);
}

.app {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

header {
    padding: 14px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border);
    background: var(--bg-1);
}

.logo {
    font-size: 1rem;
    font-weight: 700;
    letter-spacing: -0.3px;
}

.theme-btn {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--bg-2);
    color: var(--text-2);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
}

.theme-btn:hover {
    background: var(--bg-3);
    color: var(--text-1);
}

.theme-btn svg {
    width: 18px;
    height: 18px;
}

main {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.container {
    width: 100%;
    max-width: 400px;
}

.screen {
    display: none;
    animation: fadeIn 0.2s ease;
}

.screen.active {
    display: block;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(6px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

h1 {
    font-size: 1.75rem;
    font-weight: 700;
    letter-spacing: -0.5px;
    margin-bottom: 4px;
}

h2 {
    font-size: 1.25rem;
    font-weight: 600;
    letter-spacing: -0.3px;
    margin-bottom: 4px;
}

h3 {
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--text-2);
    margin-bottom: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.subtitle {
    color: var(--text-3);
    font-size: 0.9375rem;
    margin-bottom: 28px;
}

.input-group {
    margin-bottom: 14px;
}

.input-group label {
    display: block;
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-2);
    margin-bottom: 6px;
}

input,
select {
    width: 100%;
    padding: 11px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-1);
    color: var(--text-1);
    font-family: var(--font);
    font-size: 0.9375rem;
    transition: all var(--transition);
}

input:focus,
select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}

input::placeholder {
    color: var(--text-3);
}

select {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%23666' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10l-5 5z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
}

.btn {
    width: 100%;
    padding: 11px 18px;
    border: none;
    border-radius: var(--radius);
    font-family: var(--font);
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
}

.btn-primary {
    background: var(--accent);
    color: #fff;
}

.btn-primary:hover {
    background: var(--accent-hover);
}

.btn-primary:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.btn-secondary {
    background: var(--bg-2);
    color: var(--text-1);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    background: var(--bg-3);
}

.btn-ghost {
    background: transparent;
    color: var(--text-2);
}

.btn-ghost:hover {
    color: var(--text-1);
}

.btn-vote {
    background: var(--bg-1);
    color: var(--text-1);
    border: 1px solid var(--border);
    margin-bottom: 8px;
}

.btn-vote:hover {
    border-color: var(--accent);
    background: var(--accent-soft);
}

.btn-row {
    display: flex;
    gap: 10px;
    margin-top: 14px;
}

.btn-row .btn {
    flex: 1;
}

.card {
    background: var(--bg-1);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px;
    margin-bottom: 14px;
}

.card-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.card-head h3 {
    margin-bottom: 0;
}

.room-code-box {
    background: var(--bg-1);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    text-align: center;
    margin-bottom: 14px;
    cursor: pointer;
    transition: all var(--transition);
}

.room-code-box:hover {
    border-color: var(--accent);
}

.room-code-label {
    font-size: 0.6875rem;
    font-weight: 600;
    color: var(--text-3);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 6px;
}

.room-code {
    font-family: 'SF Mono', 'Fira Code', monospace;
    font-size: 1.75rem;
    font-weight: 600;
    letter-spacing: 4px;
    color: var(--accent);
}

.room-code-hint {
    font-size: 0.6875rem;
    color: var(--text-3);
    margin-top: 6px;
}

#toastContainer {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 8px;
    align-items: center;
    pointer-events: none;
}

.toast {
    padding: 12px 20px;
    border-radius: var(--radius);
    font-size: 0.875rem;
    font-weight: 600;
    animation: slideUp 0.2s ease;
    pointer-events: auto;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.toast-info {
    background: var(--bg-3);
    color: var(--text-1);
    border: 1px solid var(--border);
}

.toast-error {
    background: var(--danger);
    color: #fff;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.player-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.player-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    background: var(--bg-2);
    border-radius: 8px;
    border-left: 3px solid transparent;
}

.player-item.host {
    border-left-color: var(--accent);
}

.player-item.dead {
    opacity: 0.35;
}

.player-item.dead .player-name {
    text-decoration: line-through;
}

.player-name {
    font-size: 0.875rem;
    font-weight: 500;
}

.badge {
    font-size: 0.625rem;
    font-weight: 600;
    text-transform: uppercase;
    padding: 3px 6px;
    border-radius: 4px;
    background: var(--accent-soft);
    color: var(--accent);
}

.count {
    color: var(--text-3);
    font-size: 0.8125rem;
}

.config-row {
    display: flex;
    gap: 10px;
}

.config-row>* {
    flex: 1;
}

.random-btn {
    margin-top: 12px;
    background: transparent;
    border: 1px dashed var(--border);
    color: var(--text-2);
    font-size: 0.8125rem;
}

.random-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.role-card {
    text-align: center;
    padding: 36px 20px;
    border-radius: var(--radius);
    margin-bottom: 14px;
}

.role-card.innocent {
    background: var(--accent-soft);
    border: 1px solid var(--accent);
}

.role-card.impostor {
    background: var(--impostor-soft);
    border: 1px solid var(--impostor);
}

.role-label {
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 4px;
}

.role-card.innocent .role-label {
    color: var(--accent);
}

.role-card.impostor .role-label {
    color: var(--impostor);
}

.role-title {
    font-size: 1.125rem;
    font-weight: 700;
    margin-bottom: 12px;
}

.role-card.innocent .role-title {
    color: var(--accent);
}

.role-card.impostor .role-title {
    color: var(--impostor);
}

.word-display {
    font-size: 1.75rem;
    font-weight: 700;
    margin-bottom: 10px;
}

.role-hint {
    color: var(--text-2);
    font-size: 0.8125rem;
}

.category-tag {
    font-size: 0.75rem;
    color: var(--text-3);
    margin-top: 10px;
}

.voting-status {
    background: var(--warning-soft);
    border: 1px solid var(--warning);
    border-radius: var(--radius);
    padding: 12px;
    text-align: center;
    margin-bottom: 14px;
}

.voting-status.my-turn {
    background: var(--accent-soft);
    border-color: var(--accent);
}

.voting-label {
    font-size: 0.625rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--warning);
    margin-bottom: 2px;
}

.voting-status.my-turn .voting-label {
    color: var(--accent);
}

.voting-text {
    font-weight: 600;
    font-size: 0.9375rem;
}

.votes-log {
    max-height: 160px;
    overflow-y: auto;
}

.vote-entry {
    padding: 8px 10px;
    background: var(--bg-2);
    border-radius: 6px;
    font-size: 0.8125rem;
    margin-bottom: 6px;
}

.vote-entry span {
    color: var(--accent);
    font-weight: 600;
}

.result-banner {
    text-align: center;
    padding: 36px 20px;
    border-radius: var(--radius);
    margin-bottom: 14px;
}

.result-banner.eliminated {
    background: var(--danger-soft);
    border: 1px solid var(--danger);
}

.result-banner.eliminated h2 {
    color: var(--danger);
}

.result-banner.tie {
    background: var(--warning-soft);
    border: 1px solid var(--warning);
}

.result-banner.tie h2 {
    color: var(--warning);
}

.result-banner.innocents {
    background: var(--success-soft);
    border: 1px solid var(--success);
}

.result-banner.innocents h2 {
    color: var(--success);
}

.result-banner.impostors {
    background: var(--impostor-soft);
    border: 1px solid var(--impostor);
}

.result-banner.impostors h2 {
    color: var(--impostor);
}

.result-sub {
    color: var(--text-2);
    font-size: 0.875rem;
    margin-top: 4px;
}

.reveal-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    background: var(--bg-2);
    border-radius: 6px;
    margin-bottom: 6px;
}

.reveal-item.impostor {
    background: var(--impostor-soft);
}

.reveal-role {
    font-size: 0.625rem;
    font-weight: 600;
    text-transform: uppercase;
    padding: 3px 6px;
    border-radius: 4px;
}

.reveal-item.impostor .reveal-role {
    background: var(--impostor);
    color: #fff;
}

.reveal-item:not(.impostor) .reveal-role {
    background: var(--success-soft);
    color: var(--success);
}

.word-reveal {
    background: var(--bg-1);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px;
    text-align: center;
    margin-bottom: 14px;
}

.word-reveal-label {
    font-size: 0.6875rem;
    color: var(--text-3);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 4px;
}

.word-reveal-word {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--accent);
}

.round-badge {
    text-align: center;
    padding: 8px;
    background: var(--bg-1);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 14px;
    font-size: 0.8125rem;
    color: var(--text-2);
}

.round-badge strong {
    color: var(--text-1);
}

.waiting {
    text-align: center;
    color: var(--text-3);
    font-size: 0.875rem;
    padding: 20px 0;
}

.hint {
    text-align: center;
    color: var(--text-3);
    font-size: 0.6875rem;
    margin-top: 6px;
}

@media (max-width: 480px) {
    header {
        padding: 8px 12px;
    }

    main {
        padding: 12px;
        padding-bottom: 80px;
        /* Space for fixed footer */
    }

    h1,
    h2 {
        font-size: 1.25rem;
    }

    .room-code {
        font-size: 1.3rem;
        letter-spacing: 2px;
    }

    .word-display {
        font-size: 1.3rem;
    }

    .config-row {
        flex-direction: column;
        gap: 0;
    }

    /* Compact cards for mobile */
    .card {
        padding: 10px;
        margin-bottom: 10px;
    }

    .card-head {
        margin-bottom: 8px;
    }

    .card-head h3 {
        font-size: 0.85rem;
    }

    /* Compact leaderboard */
    .room-leaderboard {
        padding: 10px;
    }

    .room-leaderboard h3 {
        font-size: 0.9rem;
        margin-bottom: 8px;
    }

    .room-leaderboard table {
        font-size: 0.8rem;
    }

    /* Smaller inputs and buttons */
    input,
    select {
        padding: 10px 12px;
        font-size: 0.9rem;
    }

    .btn {
        padding: 10px 16px;
        font-size: 0.9rem;
    }

    /* Compact player list */
    .player {
        padding: 6px 10px;
        font-size: 0.85rem;
    }

    /* Compact footer on mobile */
    .site-footer {
        padding: 6px 12px;
    }

    .site-footer p {
        font-size: 0.75rem;
        margin: 1px 0;
    }

    .footer-credits {
        display: none;
        /* Hide credits on very small screens */
    }

    /* Subtitle smaller */
    .subtitle {
        font-size: 0.85rem;
        margin-bottom: 12px;
    }

    /* Screen header compact */
    .screen>h1:first-child,
    .screen>h2:first-child {
        margin-bottom: 8px;
    }
}

/* Nuevos estilos para features */
.voting-timer-label {
    margin-top: 5px;
    color: var(--text-2);
    font-size: 12px;
}

.emoji-btn {
    background: var(--bg-2);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 8px 12px;
    margin: 0 4px;
    cursor: pointer;
    font-size: 20px;
    transition: all var(--transition);
}

.emoji-btn:hover {
    background: var(--bg-3);
    border-color: var(--accent);
}

.emoji-btn:active {
    transform: scale(0.95);
}

.order-item {
    padding: 6px 0;
    font-size: 12px;
    color: var(--text-2);
    border-bottom: 1px solid var(--border);
}

.order-item:last-child {
    border-bottom: none;
}

.reaction-popup {
    background: var(--bg-2);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 8px 12px;
    font-weight: 600;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

@keyframes fadeOut {
    0% {
        opacity: 1;
        transform: translateY(0);
    }

    100% {
        opacity: 0;
        transform: translateY(-20px);
    }
}

/* Panel de jugadores en vivo */
.live-players-panel {
    position: fixed;
    top: 80px;
    left: 20px;
    /* Moved to left */
    width: 220px;
    background: var(--bg-1);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
    z-index: 100;
    max-height: 60vh;
    overflow-y: auto;
}

.live-players-header {
    font-size: 12px;
    font-weight: 700;
    color: var(--text-2);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 10px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
}

.live-players-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.live-player-item {
    padding: 8px 10px;
    background: var(--bg-2);
    border-radius: 6px;
    font-size: 13px;
    color: var(--text-1);
    border: 1px solid transparent;
    transition: all var(--transition);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.live-player-item.alive {
    border-color: var(--border);
}

.live-player-item.voted {
    background: var(--accent-soft);
    border-color: var(--accent);
    color: var(--accent);
    font-weight: 600;
}

.live-player-item.eliminated {
    background: var(--danger-soft);
    border-color: var(--danger);
    color: var(--danger);
    text-decoration: line-through;
    opacity: 0.6;
}

.live-player-name {
    flex: 1;
    word-break: break-word;
}

.live-player-status {
    font-size: 11px;
    margin-left: 6px;
    opacity: 0.7;
}

/* ============================================
   CHAT STYLES
   ============================================ */

.chat-container {
    position: fixed;
    top: 65px;
    right: 0;
    bottom: 0;
    width: 320px;
    background: var(--bg-1);
    border-left: 1px solid var(--border);
    display: flex;
    /* Always flex, we toggle via transform or class */
    flex-direction: column;
    z-index: 1000;
    /* High z-index to be safe */
    transform: translateX(0);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: -4px 0 16px rgba(0, 0, 0, 0.2);
}

/* We will control visibility with a class .active or direct style display */
/* Current logic uses style.display toggle. Let's make sure it handles flex properly */


/* Removed complex attribute selector to avoid confusion */

.chat-container {
    position: fixed;
    top: 65px;
    right: 0;
    bottom: 0;
    width: 320px;
    background: var(--bg-1);
    border-left: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    z-index: 1000;
    transform: translateX(0);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: -4px 0 16px rgba(0, 0, 0, 0.2);
}

.chat-container[style*="display: none"] {
    display: none !important;
}

.chat-header {
    padding: 14px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--bg-2);
}

.chat-header h3 {
    margin: 0;
    font-size: 0.9375rem;
    color: var(--text-1);
}

.chat-toggle-btn {
    background: transparent;
    border: none;
    color: var(--text-2);
    cursor: pointer;
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
}

.chat-toggle-btn:hover {
    color: var(--text-1);
    background: var(--bg-3);
}

.chat-toggle-btn svg {
    width: 20px;
    height: 20px;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    scrollbar-width: thin;
}

.chat-system-msg {
    text-align: center;
    font-size: 0.75rem;
    color: var(--text-3);
    margin: 8px 0;
    font-style: italic;
}

.chat-message {
    display: flex;
    flex-direction: column;
    max-width: 85%;
}

.chat-message.others {
    align-self: flex-start;
}

.chat-message.mine {
    align-self: flex-end;
    align-items: flex-end;
}

.chat-msg-header {
    font-size: 0.6875rem;
    color: var(--text-3);
    margin-bottom: 2px;
    display: flex;
    gap: 6px;
}

.chat-message.mine .chat-msg-header {
    flex-direction: row-reverse;
}

.chat-msg-bubble {
    padding: 8px 12px;
    border-radius: 12px;
    font-size: 0.875rem;
    line-height: 1.4;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.chat-message.others .chat-msg-bubble {
    background: var(--bg-2);
    color: var(--text-1);
    border-top-left-radius: 2px;
}

.chat-message.mine .chat-msg-bubble {
    background: var(--accent);
    color: #fff;
    border-top-right-radius: 2px;
}

.chat-message.spectator .chat-msg-bubble {
    background: var(--bg-3);
    border: 1px dashed var(--text-3);
    opacity: 0.8;
}

#chatForm {
    padding: 14px;
    border-top: 1px solid var(--border);
    display: flex;
    gap: 8px;
    background: var(--bg-2);
}

#chatInput {
    flex: 1;
    padding: 10px;
    font-size: 0.875rem;
}

.btn-chat-send {
    background: var(--accent);
    border: none;
    border-radius: var(--radius);
    color: white;
    width: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
}

.btn-chat-send:hover {
    background: var(--accent-hover);
}

.btn-chat-send svg {
    width: 18px;
    height: 18px;
}

@media (max-width: 768px) {
    .app {
        display: flex;
        flex-direction: column;
    }

    header {
        width: 100%;
    }

    .chat-container {
        position: fixed;
        top: auto;
        /* Not from top */
        bottom: 0;
        left: 0;
        right: 0;
        width: 100%;
        height: 60vh;
        /* 60% of viewport height */
        max-height: 400px;
        z-index: 200;
        border-left: none;
        border-top: 1px solid var(--border);
        border-radius: 16px 16px 0 0;
        padding-top: 0;
        transform: translateX(0);
        box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.3);
    }

    .chat-container[style*="display: none"] {
        display: none !important;
    }

    .live-players-panel {
        left: unset;
        right: 10px;
        width: 180px;
        top: 70px;
    }
}

/* =========================================
   STATS & MODALS
   ========================================= */

.modal {
    display: none;
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    align-items: center;
    justify-content: center;
}

.modal-content {
    background-color: var(--bg-1);
    margin: auto;
    width: 90%;
    max-width: 500px;
    border-radius: 12px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
    border: 1px solid var(--border);
    overflow: hidden;
    animation: zoomIn 0.2s ease;
}

@keyframes zoomIn {
    from {
        transform: scale(0.9);
        opacity: 0;
    }

    to {
        transform: scale(1);
        opacity: 1;
    }
}

.modal-header {
    padding: 16px 20px;
    background: var(--bg-2);
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    margin: 0;
    font-size: 1.1rem;
}

.close-modal {
    background: none;
    border: none;
    color: var(--text-2);
    font-size: 24px;
    cursor: pointer;
    line-height: 1;
}

.close-modal:hover {
    color: var(--text-1);
}

.modal-body {
    padding: 20px;
}

/* Stats Table */
.stats-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.stats-table th,
.stats-table td {
    padding: 10px;
    text-align: center;
    border-bottom: 1px solid var(--border);
}

.stats-table th {
    text-align: left;
    color: var(--text-2);
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
}

.stats-table th:not(:first-child) {
    text-align: center;
}

.stats-table td:first-child {
    text-align: left;
    font-weight: 600;
    color: var(--text-1);
}

/* Local Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 15px;
}

.stat-card {
    background: var(--bg-2);
    padding: 15px;
    border-radius: 10px;
    text-align: center;
    border: 1px solid var(--border);
}

.stat-card.impostor {
    border-color: var(--impostor-soft);
    background: radial-gradient(circle at top right, var(--impostor-soft), transparent 60%);
}

.stat-card.innocent {
    border-color: var(--success-soft);
    background: radial-gradient(circle at top right, var(--success-soft), transparent 60%);
}

.stat-card.survivor {
    border-color: var(--accent-soft);
    background: radial-gradient(circle at top right, var(--accent-soft), transparent 60%);
}

.stat-icon {
    font-size: 24px;
    margin-bottom: 5px;
}

.stat-value {
    font-size: 24px;
    font-weight: 800;
    color: var(--text-1);
}

.stat-label {
    font-size: 0.8rem;
    color: var(--text-2);
}

/* =========================================
   LOBBY GRID LAYOUT
   ========================================= */
.lobby-grid {
    display: flex;
    flex-direction: column;
    gap: 15px;
    width: 100%;
}

.main-column,
.side-column {
    width: 100%;
}

/* Desktop: Side-by-side layout */
@media (min-width: 900px) {

    /* Expand container when lobby-grid is inside */
    .container:has(.lobby-grid) {
        max-width: 800px;
    }

    .lobby-grid {
        display: grid;
        grid-template-columns: 1fr 280px;
        gap: 20px;
        align-items: start;
    }

    .side-column .card.full-height {
        position: sticky;
        top: 20px;
        max-height: calc(100vh - 100px);
        display: flex;
        flex-direction: column;
    }

    .side-column .leaderboard-container {
        flex: 1;
        overflow-y: auto;
    }
}

/* Leaderboard Styles */
.leaderboard-container {
    max-height: 250px;
    overflow-y: auto;
    margin-top: 10px;
}

.small-table th,
.small-table td {
    padding: 8px 6px;
    font-size: 0.85rem;
}

.small-table th {
    font-size: 1rem;
}

.waiting-text {
    color: var(--text-3);
    font-style: italic;
    padding: 15px !important;
}

/* Custom Scrollbar for leaderboard */
.leaderboard-container::-webkit-scrollbar {
    width: 6px;
}

.leaderboard-container::-webkit-scrollbar-track {
    background: var(--bg-1);
}

.leaderboard-container::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
}

/* Voting Screen Layout Improvements */
#votingButtons {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    margin-top: 15px;
}

#votingButtons .btn {
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Description order display - horizontal wrapping */
#descriptionOrderDisplay {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
}

#descriptionOrderDisplay span {
    background: var(--bg-2);
    padding: 4px 10px;
    border-radius: 15px;
    font-size: 0.8rem;
}

#descriptionOrderDisplay span.current {
    background: var(--accent);
    color: white;
}

#descriptionOrderDisplay span.done {
    opacity: 0.5;
    text-decoration: line-through;
}

/* Make voting screen more compact */
#votingScreen .card {
    margin-bottom: 10px;
}

#votingScreen h2 {
    margin-bottom: 10px;
}

/* Responsive: single column on very small screens */
@media (max-width: 400px) {
    #votingButtons {
        grid-template-columns: 1fr;
    }
}

/* ============================================
   FOOTER - Cafecito
   ============================================ */
.site-footer {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--bg-1);
    border-top: 1px solid var(--border);
    padding: 8px 16px;
    text-align: center;
    font-size: 0.85rem;
    color: var(--text-2);
    z-index: 100;
}

.site-footer p {
    margin: 2px 0;
}

.cafecito-link {
    color: var(--accent);
    text-decoration: none;
    font-weight: 600;
    transition: color var(--transition);
}

.cafecito-link:hover {
    color: var(--accent-hover);
    text-decoration: underline;
}

.footer-credits {
    font-size: 0.75rem;
    color: var(--text-3);
}