:root {
    --bg: #f4f5f7;
    --card-bg: #ffffff;
    --text: #1f2430;
    --muted: #6b7280;
    --primary: #4f46e5;
    --primary-dark: #4338ca;
    --border: #e2e4e9;
    --green: #16a34a;
    --amber: #d97706;
    --red: #dc2626;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
}

.wrap {
    max-width: 1280px;
    margin: 0 auto;
    padding: 24px 16px 60px;
}

.wrap-narrow {
    max-width: 520px;
}

h1 { font-size: 1.6rem; margin: 0 0 4px; }
h2 { font-size: 1.1rem; margin: 0 0 12px; }

.subtitle { color: var(--muted); margin: 0 0 20px; }

.auth-bar {
    justify-content: flex-end;
    margin: 0 0 16px;
}

.auth-bar .hint { margin: 0; display: flex; align-items: center; }

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

label {
    display: block;
    font-size: 0.85rem;
    color: var(--muted);
    margin-bottom: 12px;
}

.inline-label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin: 0;
}

label.checkbox {
    display: flex;
    align-items: center;
    gap: 8px;
}

input[type=text], input[type=number], select, textarea {
    display: block;
    width: 100%;
    margin-top: 4px;
    padding: 9px 10px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 0.95rem;
    background: #fff;
    color: var(--text);
    font-family: inherit;
}

fieldset {
    border: 1px dashed var(--border);
    border-radius: 8px;
    margin-bottom: 12px;
    padding: 12px;
}

legend { font-size: 0.85rem; color: var(--muted); padding: 0 6px; }

.hint { font-size: 0.82rem; color: var(--muted); }

button {
    background: var(--primary);
    color: #fff;
    border: none;
    padding: 10px 18px;
    border-radius: 8px;
    font-size: 0.9rem;
    cursor: pointer;
}

button:hover { background: var(--primary-dark); }

button:disabled { opacity: 0.45; cursor: not-allowed; }

button.secondary {
    background: #fff;
    color: var(--text);
    border: 1px solid var(--border);
}

button.secondary:hover { background: #f0f0f2; }

.link-btn {
    display: inline-flex;
    align-items: center;
    background: var(--card-bg);
    border: 1px solid var(--border);
    color: var(--primary);
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 0.8rem;
    line-height: 1.3;
    text-decoration: none;
    cursor: pointer;
    transition: background .15s ease, border-color .15s ease;
}

.link-btn:hover { background: #eef2ff; border-color: var(--primary); }

.link-btn-danger { color: var(--red); }
.link-btn-danger:hover { background: #fef2f2; border-color: var(--red); }

.btn-row {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
}

.error { color: var(--red); }

.room-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
}

.room-header .subtitle { margin-bottom: 0; }

/* Em telas largas, participantes/histórico viram uma coluna lateral em vez
   de empilhar embaixo de tudo — evita rolagem desnecessária num monitor
   grande. No celular (abaixo de 900px) fica em bloco só, então a ordem no
   HTML (fluxo de votação primeiro, sidebar depois) já é a ordem certa. */
.room-layout { display: block; }

@media (min-width: 900px) {
    .room-layout {
        display: grid;
        grid-template-columns: minmax(0, 1fr) 380px;
        gap: 20px;
        align-items: start;
    }
}

.header-links {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    column-gap: 8px;
    row-gap: 6px;
    margin-top: 8px;
    font-size: 0.85rem;
}

.header-links .link-btn { white-space: nowrap; }

.mobile-only { display: none; }

.timebox-details {
    margin-top: 10px;
    font-size: 0.85rem;
}

.timebox-details summary {
    color: var(--muted);
    cursor: pointer;
    user-select: none;
}

.timebox-details summary:hover { color: var(--text); }

.timer {
    font-size: 1.6rem;
    font-variant-numeric: tabular-nums;
    font-weight: 600;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 8px 16px;
    min-width: 90px;
    text-align: center;
}

.timer.low { color: var(--red); border-color: var(--red); }

.round-label { color: var(--muted); font-size: 0.85rem; margin: 0; }

.deck {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.poker-card {
    width: 64px;
    height: 92px;
    border: 2px solid var(--border);
    border-radius: 10px;
    background: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    font-weight: 700;
    cursor: pointer;
    transition: transform .1s, border-color .1s;
    user-select: none;
}

.poker-card:hover { transform: translateY(-4px); border-color: var(--primary); }

.poker-card.selected {
    border-color: var(--primary);
    background: var(--primary);
    color: #fff;
}

#participantsList .group-heading {
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--muted);
    margin: 14px 0 6px;
}

#participantsList .group-heading:first-child { margin-top: 0; }

.participant-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 0;
    border-bottom: 1px solid var(--border);
    font-size: 0.9rem;
}

.participant-row:last-child { border-bottom: none; }

.p-name { display: flex; align-items: center; gap: 8px; }

.dot {
    width: 8px; height: 8px; border-radius: 50%;
    background: var(--border);
    flex-shrink: 0;
}

.dot.online { background: var(--green); }

.badge {
    font-size: 0.68rem;
    padding: 2px 7px;
    border-radius: 999px;
    background: #eef2ff;
    color: var(--primary);
}

.badge.observer { background: #f3f4f6; color: var(--muted); }

.status-icon { font-size: 0.85rem; color: var(--muted); }
.status-icon.voted { color: var(--green); }

.remove-btn {
    background: none;
    border: none;
    color: var(--red);
    cursor: pointer;
    font-size: 0.8rem;
    padding: 2px 6px;
}

.votes-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 16px;
}

.vote-chip {
    border: 2px solid var(--border);
    border-radius: 10px;
    padding: 10px 14px;
    text-align: center;
    min-width: 70px;
}

.vote-chip .val { font-size: 1.2rem; font-weight: 700; }
.vote-chip .who { font-size: 0.72rem; color: var(--muted); margin-top: 2px; }
.vote-chip.outlier-low { border-color: var(--amber); }
.vote-chip.outlier-high { border-color: var(--red); }

.stats-box {
    display: flex;
    flex-wrap: wrap;
    gap: 18px;
    font-size: 0.85rem;
    padding-top: 10px;
    border-top: 1px solid var(--border);
}

.stats-box b { display: block; font-size: 1.1rem; }

.consensus-banner {
    background: #ecfdf5;
    color: var(--green);
    border-radius: 8px;
    padding: 8px 12px;
    font-size: 0.85rem;
    margin-bottom: 10px;
}

.group-stat-row {
    display: flex;
    justify-content: space-between;
    font-size: 0.82rem;
    padding: 4px 0;
    border-bottom: 1px dashed var(--border);
}

.history-item {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
    font-size: 0.88rem;
}

.history-item:last-child { border-bottom: none; }
.history-item .final { font-weight: 700; }

/* Wizard */
.wizard-progress {
    display: flex;
    gap: 6px;
    margin-bottom: 20px;
}

.wp-step {
    flex: 1;
    text-align: center;
    font-size: 0.72rem;
    color: var(--muted);
    padding-bottom: 8px;
    border-bottom: 3px solid var(--border);
}

.wp-step span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--border);
    color: #fff;
    font-size: 0.7rem;
    margin-right: 4px;
}

.wp-step.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
    font-weight: 600;
}

.wp-step.active span,
.wp-step.done span { background: var(--primary); }

.wp-step.done { color: var(--text); border-bottom-color: var(--primary); }

.wizard-step h3 { margin: 0 0 12px; font-size: 1rem; }

.wizard-nav { margin-top: 18px; }

.small-btn {
    padding: 6px 12px;
    font-size: 0.82rem;
}

.group-chips {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 10px;
}

.group-chip {
    display: flex;
    gap: 8px;
    align-items: center;
}

.group-chip input {
    margin: 0;
}

.chip-remove {
    background: none;
    border: 1px solid var(--border);
    color: var(--red);
    width: 32px;
    height: 32px;
    flex-shrink: 0;
    border-radius: 8px;
    font-size: 1rem;
    line-height: 1;
    padding: 0;
}

.chip-remove:hover { background: #fef2f2; }

.review-list {
    margin: 0;
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 8px 16px;
    font-size: 0.9rem;
}

.review-list dt { color: var(--muted); }
.review-list dd { margin: 0; font-weight: 500; }

.team-mode-options {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin: 14px 0;
}

.radio-option {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 10px 12px;
    cursor: pointer;
    margin: 0;
}

.radio-option:has(input:checked) {
    border-color: var(--primary);
    background: #eef2ff;
}

.radio-option input { width: auto; margin: 3px 0 0; }

.radio-option div { display: flex; flex-direction: column; gap: 2px; }
.radio-option strong { font-size: 0.9rem; color: var(--text); }
.radio-option span { font-size: 0.78rem; color: var(--muted); }

.team-roster-block {
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 10px;
    margin-bottom: 10px;
}

.team-roster-header {
    display: flex;
    gap: 8px;
    margin-bottom: 8px;
}

.team-name-input { margin: 0; font-weight: 600; }

.team-roster-textarea {
    font-family: inherit;
    resize: vertical;
}

.team-user-picker {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px dashed var(--border);
    max-height: 140px;
    overflow-y: auto;
}

.team-user-checkbox-row {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
    margin-bottom: 4px;
}

.team-user-checkbox-row input { width: auto; margin: 0; }

/* Team management board (facilitator drag-and-drop) */
.team-board {
    display: flex;
    gap: 12px;
    overflow-x: auto;
    padding-bottom: 4px;
}

.team-column {
    flex: 0 0 180px;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 10px;
    background: #fafafa;
    min-height: 90px;
}

.team-column.drag-over {
    border-color: var(--primary);
    background: #eef2ff;
}

.team-column-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.8rem;
    font-weight: 600;
    margin-bottom: 8px;
}

.team-chip {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 6px 8px;
    font-size: 0.82rem;
    margin-bottom: 6px;
    cursor: grab;
}

.team-chip:active { cursor: grabbing; }

.observer-list {
    margin-top: 14px;
    font-size: 0.85rem;
}

.observer-row {
    display: flex;
    justify-content: space-between;
    padding: 4px 0;
    border-bottom: 1px solid var(--border);
}

@media (max-width: 640px) {
    .wrap { padding: 16px 12px 40px; }
    .card { padding: 16px; }
    h1 { font-size: 1.35rem; }
    .timer { font-size: 1.3rem; padding: 6px 12px; min-width: 76px; }
    .mobile-only { display: inline; }
    .team-column { flex: 0 0 150px; }

    /* Hint that there's more to see sideways — only relevant once the
       board is narrower than its content, which is the common case here. */
    .team-board {
        -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 24px), transparent);
        mask-image: linear-gradient(to right, #000 calc(100% - 24px), transparent);
    }
}
