:root {
    --bg: #0b0b11;
    --surface: #13131d;
    --surface2: #1b1b28;
    --surface3: #232336;
    --border: rgba(255, 255, 255, 0.08);
    --text: #f4f5fb;
    --muted: #9ea3b5;
    --accent: #7c5cff;
    --accent-2: #10d7a0;
    --danger: #ff5e6c;
    --warning: #ffc857;
    --mono: "Space Mono", monospace;
    --sans: "DM Sans", sans-serif;
    --shadow: 0 18px 42px rgba(0, 0, 0, 0.35);
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    padding: 0;
    min-height: 100%;
    background:
            radial-gradient(circle at top, rgba(124, 92, 255, 0.14), transparent 30%),
            radial-gradient(circle at bottom right, rgba(16, 215, 160, 0.10), transparent 25%),
            var(--bg);
    color: var(--text);
    font-family: var(--sans), sans-serif;
}

body {
    min-height: 100vh;
}

.hidden {
    display: none !important;
}

.text-center {
    text-align: center;
}

a {
    color: inherit;
    text-decoration: none;
}

button,
input,
select,
textarea {
    font: inherit;
}

button {
    cursor: pointer;
    border: none;
}

input,
select,
textarea {
    width: 100%;
    border-radius: 14px;
    border: 1px solid var(--border);
    background: var(--surface2);
    color: var(--text);
    padding: 12px 14px;
    outline: none;
}

input:focus,
select:focus,
textarea:focus {
    border-color: rgba(124, 92, 255, 0.55);
    box-shadow: 0 0 0 3px rgba(124, 92, 255, 0.14);
}

textarea {
    resize: vertical;
}

#topbar {
    height: 74px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px;
    border-bottom: 1px solid var(--border);
    background: rgba(10, 10, 18, 0.78);
    backdrop-filter: blur(12px);
    position: sticky;
    top: 0;
    z-index: 20;
}

#logo-wrap {
    display: flex;
    align-items: center;
    gap: 12px;
}

#logo-text {
    font-family: var(--mono), monospace;
    font-weight: 700;
    letter-spacing: 0.05em;
}

#topbar-right {
    display: flex;
    align-items: center;
    gap: 10px;
}

#logo-dice,
#hero-dice {
    position: relative;
    background: linear-gradient(180deg, #ffffff 0%, #dfe3f2 100%);
    border-radius: 18px;
    box-shadow: var(--shadow);
}

#logo-dice {
    width: 34px;
    height: 34px;
    flex: 0 0 34px;
}

#hero-dice-wrap {
    perspective: 900px;
}

#hero-dice {
    width: 104px;
    height: 104px;
    margin: 0 auto;
    border-radius: 24px;
}

.pip {
    position: absolute;
    width: 11px;
    height: 11px;
    border-radius: 999px;
    background: #101018;
    transform: translate(-50%, -50%);
    box-shadow: inset 0 -1px 0 rgba(255,255,255,.18);
}

#hero-dice .pip {
    width: 14px;
    height: 14px;
}

.pip-1 { top: 25%; left: 25%; }
.pip-2 { top: 25%; left: 75%; }
.pip-3 { top: 50%; left: 50%; }
.pip-4 { top: 75%; left: 25%; }
.pip-5 { top: 75%; left: 75%; }

#logo-dice.is-searching,
#hero-dice.is-searching {
    animation: diceLaunch 0.9s ease-out, diceSpin 1s linear infinite 0.9s;
    transform-origin: center;
}

@keyframes diceLaunch {
    0% { transform: translateY(0) rotate(0deg) scale(1); }
    35% { transform: translateY(-65px) rotate(120deg) scale(1.06); }
    65% { transform: translateY(-18px) rotate(240deg) scale(0.98); }
    100% { transform: translateY(0) rotate(360deg) scale(1); }
}

@keyframes diceSpin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

#app {
    min-height: calc(100vh - 74px);
}

#sidebar {
    border-right: 1px solid var(--border);
    background: rgba(19, 19, 29, 0.78);
    padding: 16px;
}

#sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-family: var(--mono), monospace;
    margin-bottom: 12px;
}

#friends-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.friend-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 12px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.friend-card-main {
    flex: 1;
    min-width: 0;
}

.friend-card-name {
    font-weight: 600;
}

.friend-card-meta {
    color: var(--muted);
    font-size: .82rem;
}

.friend-online {
    color: var(--accent-2);
}

.friend-offline {
    color: var(--muted);
}

#main {
    min-width: 0;
    padding: 22px;
    display: flex;
    flex-direction: column;
}

#screen-idle {
    flex: 1;
    min-height: calc(100vh - 130px);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    text-align: center;
    gap: 16px;
    padding: 32px 20px;
}

#hero-title {
    font-size: clamp(2.2rem, 5vw, 4rem);
    line-height: 0.95;
    margin: 0;
    letter-spacing: -0.04em;
}

#hero-subtitle {
    margin: 0;
    max-width: 620px;
    color: var(--muted);
    font-size: 1.05rem;
    line-height: 1.55;
}

#hero-actions {
    display: flex;
    flex-direction: column;
    gap: 12px;
    align-items: center;
    margin-top: 8px;
}

#queue-info {
    color: var(--muted);
    font-size: .9rem;
}

#screen-chat {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: calc(100vh - 130px);
    gap: 12px;
}

#chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 18px;
    padding: 12px 14px;
    box-shadow: var(--shadow);
}

#partner-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

#partner-color {
    width: 14px;
    height: 14px;
    border-radius: 999px;
    background: #fff;
    border: 2px solid rgba(255,255,255,.18);
}

#partner-label {
    font-weight: 600;
}

.badge-rank {
    background: transparent;
    border: none;
    padding: 0;
}

#chat-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

#messages {
    flex: 1;
    min-height: 320px;
    overflow: auto;
    background: rgba(19, 19, 29, 0.65);
    border: 1px solid var(--border);
    border-radius: 18px;
    padding: 16px;
    box-shadow: var(--shadow);
}

.bubble-wrap {
    display: flex;
    flex-direction: column;
    margin-bottom: 10px;
    max-width: 74%;
}

.bubble-wrap.mine {
    margin-left: auto;
    align-items: flex-end;
}

.bubble-wrap.other {
    margin-right: auto;
    align-items: flex-start;
}

.bubble-meta {
    margin-bottom: 6px;
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--muted);
    font-size: .78rem;
}

.color-dot {
    width: 10px;
    height: 10px;
    border-radius: 999px;
}

.bubble {
    background: var(--surface2);
    border: 1px solid var(--border);
    padding: 11px 13px;
    border-radius: 16px;
    line-height: 1.45;
    white-space: pre-wrap;
    word-break: break-word;
}

.bubble-wrap.mine .bubble {
    background: rgba(124, 92, 255, 0.16);
    border-color: rgba(124, 92, 255, 0.34);
}

.bubble-wrap.other .bubble {
    border-left: 3px solid var(--user-color, var(--border));
}

.bubble-time {
    color: var(--muted);
    font-size: .75rem;
    margin-top: 4px;
}

.sys-msg {
    color: var(--muted);
    font-size: .84rem;
    text-align: center;
    margin: 12px 0;
}

#typing-indicator {
    min-height: 20px;
    color: var(--muted);
    font-size: .82rem;
    padding: 0 4px;
}

#input-area,
#dm-input-area {
    display: flex;
    gap: 10px;
}

#input-area input,
#dm-input-area input {
    flex: 1;
}

#mutual-banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 12px 14px;
}

.mutual-title {
    font-weight: 700;
}

.mutual-subtitle {
    color: var(--muted);
    font-size: .82rem;
}

.mutual-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

#session-timer {
    font-family: var(--mono), monospace;
    font-weight: 700;
    color: var(--warning);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border-radius: 14px;
    padding: 10px 14px;
    transition: .18s ease;
    font-weight: 600;
}

.btn:hover {
    transform: translateY(-1px);
}

.btn-green {
    background: linear-gradient(180deg, #16e0aa 0%, #11b688 100%);
    color: #08120f;
}

.btn-accent {
    background: linear-gradient(180deg, #8a6cff 0%, #6944ff 100%);
    color: white;
}

.btn-danger {
    background: linear-gradient(180deg, #ff7c87 0%, #ff4f60 100%);
    color: white;
}

.btn-ghost {
    background: var(--surface2);
    color: var(--text);
    border: 1px solid var(--border);
}

.badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 8px 12px;
    color: var(--muted);
    font-size: .82rem;
}

.dot {
    width: 9px;
    height: 9px;
    border-radius: 999px;
    background: var(--accent-2);
    box-shadow: 0 0 12px rgba(16, 215, 160, 0.6);
}

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(2, 4, 9, 0.68);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 18px;
    z-index: 100;
}

.modal {
    width: min(100%, 480px);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 22px;
    box-shadow: var(--shadow);
    padding: 18px;
}

.modal h3 {
    margin-top: 0;
    margin-bottom: 10px;
}

.modal p {
    color: var(--muted);
    line-height: 1.45;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 14px;
    flex-wrap: wrap;
}

.modal-actions-split > * {
    flex: 1;
}

.auth-modal {
    width: min(100%, 420px);
}

.auth-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 14px;
}

.auth-tab.active {
    background: rgba(124, 92, 255, 0.16);
    border-color: rgba(124, 92, 255, 0.34);
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.auth-divider {
    text-align: center;
    color: var(--muted);
    margin: 14px 0 10px;
    font-size: .86rem;
}

.auth-google-link {
    display: block;
}

.auth-google-link .btn {
    width: 100%;
}

.check-row {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--muted);
    font-size: .86rem;
}

.check-row input {
    width: auto;
    margin: 0;
}

.requests-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.request-card {
    border: 1px solid var(--border);
    background: var(--surface2);
    border-radius: 16px;
    padding: 12px;
}

.request-card-top {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}

.request-card-name {
    font-weight: 600;
}

.request-card-actions {
    display: flex;
    gap: 8px;
}

.avatar {
    width: 40px;
    height: 40px;
    border-radius: 999px;
    object-fit: cover;
    background: var(--surface3);
    border: 1px solid var(--border);
}

#settings-profile {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.settings-profile-top {
    display: flex;
    align-items: center;
    gap: 12px;
}

.settings-profile-text {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

#settings-name {
    font-family: var(--mono), monospace;
    font-size: .95rem;
}

#settings-email {
    font-size: .84rem;
    color: var(--muted);
}

.settings-color-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

#settings-color-dot {
    width: 12px;
    height: 12px;
    border-radius: 999px;
    border: 1.5px solid var(--border);
}

.session-summary-box {
    background: var(--surface2);
    padding: 16px;
    border-radius: 14px;
    text-align: center;
}

.session-summary-label {
    font-size: .8rem;
    color: var(--muted);
    margin-bottom: 4px;
}

#session-duration {
    font-size: 1.5rem;
    font-weight: 700;
    font-family: var(--mono), monospace;
}

.continue-card {
    background: linear-gradient(180deg, rgba(124, 92, 255, 0.28), rgba(124, 92, 255, 0.15));
    padding: 20px;
    border-radius: 16px;
    margin: 8px 0;
    color: white;
}

.continue-avatar {
    width: 64px;
    height: 64px;
    border: 2px solid white;
    margin-bottom: 10px;
}

.continue-name {
    font-weight: 700;
    font-size: 1.05rem;
}

.continue-rank {
    font-size: .84rem;
    opacity: .92;
}

#xp-notification {
    position: fixed;
    right: 18px;
    bottom: 18px;
    z-index: 110;
    background: rgba(16, 215, 160, 0.14);
    border: 1px solid rgba(16, 215, 160, 0.28);
    color: var(--text);
    padding: 14px 16px;
    border-radius: 16px;
    box-shadow: var(--shadow);
    opacity: 0;
    transform: translateY(12px);
    pointer-events: none;
    transition: .24s ease;
}

#xp-notification.show {
    opacity: 1;
    transform: translateY(0);
}

#xp-gain-text {
    font-size: 1.4rem;
    font-weight: 700;
}

#xp-message-text {
    font-size: .82rem;
    color: var(--muted);
}

#dm-panel {
    position: fixed;
    right: 16px;
    bottom: 16px;
    width: min(380px, calc(100vw - 32px));
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 18px;
    box-shadow: var(--shadow);
    z-index: 90;
    overflow: hidden;
}

#dm-header {
    padding: 12px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

#dm-title {
    font-weight: 700;
}

#btn-dm-close {
    padding: 4px 8px;
    font-size: .75rem;
}

#dm-messages {
    max-height: 320px;
    overflow: auto;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.dm-bubble {
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 10px 12px;
    font-size: .9rem;
    line-height: 1.4;
}

.dm-bubble.mine {
    background: rgba(124, 92, 255, 0.16);
    border-color: rgba(124, 92, 255, 0.34);
}

.dm-meta {
    margin-top: 4px;
    color: var(--muted);
    font-size: .72rem;
}

#dm-input-area {
    padding: 12px;
    border-top: 1px solid var(--border);
}

#toast {
    position: fixed;
    left: 50%;
    bottom: 20px;
    transform: translateX(-50%) translateY(10px);
    background: rgba(19, 19, 29, 0.96);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 10px 14px;
    border-radius: 999px;
    box-shadow: var(--shadow);
    opacity: 0;
    pointer-events: none;
    transition: .2s ease;
    z-index: 120;
}

#toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

#user-stats-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-left: 8px;
}

#rank-badge {
    font-size: 1.1rem;
}

#xp-container {
    display: flex;
    flex-direction: column;
    gap: 3px;
    min-width: 140px;
}

#level-display,
#xp-text {
    font-size: .76rem;
    color: var(--muted);
}

#xp-bar-bg {
    width: 100%;
    height: 6px;
    background: rgba(255,255,255,.08);
    border-radius: 999px;
    overflow: hidden;
}

#xp-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--accent), var(--accent-2));
    border-radius: inherit;
}

@media (max-width: 980px) {
    #app {
        grid-template-columns: 1fr;
    }

    #sidebar {
        display: none !important;
    }

    #main {
        padding: 14px;
    }

    #chat-header {
        flex-direction: column;
        align-items: stretch;
    }

    #chat-actions {
        justify-content: flex-start;
    }

    .bubble-wrap {
        max-width: 88%;
    }
}

@media (max-width: 640px) {
    #topbar {
        flex-direction: column;
        height: auto;
        align-items: stretch;
        gap: 10px;
    }

    #topbar-right {
        justify-content: space-between;
    }

    #logo-wrap {
        justify-content: space-between;
        flex-wrap: wrap;
    }

    #hero-title {
        font-size: 2.2rem;
    }

    .modal {
        padding: 14px;
    }

    #mutual-banner {
        flex-direction: column;
        align-items: stretch;
    }
}
/* ── Chat de grupo (pivot grupos fixos) ────────────────────────────────────── */

#members-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 8px 14px;
    border-bottom: 1px solid var(--border);
}

.member-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 10px;
    border: 1px solid var(--border);
    border-radius: 999px;
    font-size: .76rem;
    color: var(--muted);
    background: var(--surface2);
}

.bubble-sender {
    font-size: .74rem;
    color: var(--muted);
    margin-left: 4px;
}

.bubble-wrap.selected .bubble {
    outline: 2px solid var(--accent, #8257E5);
    outline-offset: 2px;
}

.member-chip-clickable {
    cursor: pointer;
}

.member-chip-clickable:hover {
    border-color: var(--accent, #8257E5);
    color: var(--text);
}
