:root {
    --sea: #0f8b8d;
    --sea-rgb: 15, 139, 141;
    --sea-dark: #0a6567;
    /* Texto sobre --sea/--sun: recalculado em JS (applyTheme) toda vez que a
       Equipe ou a plataforma trocam de cor, pra nunca ficar ilegível — nunca
       edite estes dois na mão. */
    --sea-contrast: #fff;
    --sea-overlay: rgba(255,255,255,0.15);
    --sand: #fbf4e2;
    --sand-dark: #f0e2c0;
    --sun: #f4a259;
    --sun-rgb: 244, 162, 89;
    --sun-contrast: #fff;
    --ink: #1f2a2b;
    /* --text é o "cor do texto" personalizável (padrão = mesmo valor de
       --ink). --ink em si fica fixo — usado em lugares estruturais como o
       fundo do toast, não em texto — pra nunca virar ilegível por causa de
       uma cor de texto customizada. */
    --text: #1f2a2b;
    --muted: #6b7a7b;
    --card-bg: #fff;
    --danger: #d64550;
    --win: #2e9e5b;
    --loss: #c94f4f;
    --radius: 16px;
    --tab-bar-height: 64px;
}

/* Modo escuro: paleta própria e testada, não derivada das cores
   personalizadas (--sea/--sun continuam vindo do tema e já se ajustam
   sozinhos por cima de qualquer fundo, claro ou escuro). */
:root[data-theme="dark"] {
    --sand: #14181a;
    --sand-dark: #1c2224;
    --card-bg: #1f2427;
    --text: #e8ecec;
    --muted: #9aa5a6;
}

* {
    box-sizing: border-box;
}

.hidden {
    display: none !important;
}

html, body {
    margin: 0;
    padding: 0;
    height: 100%;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: linear-gradient(180deg, var(--sand) 0%, var(--sand-dark) 100%);
    color: var(--text);
    display: flex;
    flex-direction: column;
    min-height: 100dvh;
}

.app-loading {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100dvh;
}

.spinner {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    border: 3px solid var(--sand-dark);
    border-top-color: var(--sea);
    animation: spin 0.7s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.app-header {
    background: var(--sea);
    color: var(--sea-contrast);
    padding: env(safe-area-inset-top, 0) 16px 14px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.app-header h1 {
    margin: 10px 0 0;
    font-size: 1.25rem;
    letter-spacing: 0.02em;
    text-align: center;
}

.brand-logo {
    width: 28px;
    height: 28px;
    object-fit: contain;
    border-radius: 6px;
    margin-top: 10px;
    margin-right: 8px;
}

.admin-btn {
    position: absolute;
    right: 14px;
    top: calc(env(safe-area-inset-top, 0) + 12px);
    background: var(--sea-overlay);
    color: var(--sea-contrast);
    border: none;
    border-radius: 999px;
    padding: 6px 12px;
    font-size: 0.72rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.admin-btn.logged-in {
    background: rgba(255,255,255,0.9);
    color: var(--sea-dark);
}

.view {
    flex: 1;
    overflow-y: auto;
    padding: 16px 16px calc(var(--tab-bar-height) + 24px);
    max-width: 560px;
    width: 100%;
    margin: 0 auto;
}

.tab-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: calc(var(--tab-bar-height) + env(safe-area-inset-bottom, 0));
    padding-bottom: env(safe-area-inset-bottom, 0);
    display: flex;
    background: #fff;
    border-top: 1px solid rgba(0,0,0,0.08);
    box-shadow: 0 -2px 10px rgba(0,0,0,0.08);
}

.tab-btn {
    position: relative;
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    background: none;
    border: none;
    color: var(--muted);
    font-size: 0.7rem;
    font-family: inherit;
    padding: 6px 0;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.tab-btn .tab-icon {
    font-size: 1.35rem;
    line-height: 1;
}

.tab-btn.active {
    color: var(--sea);
    font-weight: 600;
}

.tab-badge {
    position: absolute;
    top: 2px;
    right: 22%;
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    border-radius: 999px;
    background: var(--danger);
    color: #fff;
    font-size: 0.62rem;
    font-weight: 700;
    line-height: 16px;
    text-align: center;
    box-shadow: 0 0 0 2px #fff;
}

.tab-btn-desktop-only {
    display: none;
}

.card {
    background: var(--card-bg);
    color: var(--text);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 14px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}

.section-title {
    font-size: 1rem;
    font-weight: 700;
    margin: 4px 0 12px;
    color: var(--sea-dark);
}

.empty-state {
    text-align: center;
    color: var(--muted);
    padding: 32px 16px;
}

/* Ranking */
.ranking-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.ranking-item {
    display: flex;
    align-items: center;
    gap: 12px;
    background: #fff;
    border-radius: var(--radius);
    padding: 12px 14px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}

.ranking-pos {
    width: 32px;
    height: 32px;
    flex-shrink: 0;
    border-radius: 50%;
    background: var(--sand-dark);
    color: var(--sea-dark);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.9rem;
}

/* Avatar de jogador: foto de perfil circular, ou um círculo com a inicial do
   nome quando não há foto — reaproveitado em várias telas (ver
   playerAvatarHtml() em app.js). Tamanho padrão 32px; .player-avatar-sm
   (22px) pra contextos mais apertados (linha da escalação, chips do sorteio). */
.player-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
    background: var(--sand-dark);
}

.player-avatar-fallback {
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.85rem;
    color: var(--sea-dark);
}

.player-avatar-sm {
    width: 22px;
    height: 22px;
    font-size: 0.7rem;
}

.ranking-item.pos-1 .ranking-pos { background: var(--sun); color: var(--sun-contrast); }
.ranking-item.pos-1 { box-shadow: 0 0 0 2px color-mix(in srgb, var(--sun) 45%, transparent), 0 1px 4px rgba(0,0,0,0.06); }
.ranking-item.pos-2 .ranking-pos { background: #dfe4e8; color: #3a4145; }
.ranking-item.pos-3 .ranking-pos { background: #e7b78a; color: #5a3313; }

.ranking-info {
    flex: 1;
    min-width: 0;
}

.ranking-name {
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ranking-sub {
    font-size: 0.78rem;
    color: var(--muted);
    margin-top: 2px;
}

.ranking-points {
    text-align: right;
    flex-shrink: 0;
}

.ranking-points strong {
    font-size: 1.25rem;
    color: var(--sea);
    display: block;
    line-height: 1;
}

.ranking-points span {
    font-size: 0.68rem;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

/* Forms */
label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--muted);
    margin: 14px 0 6px;
}

label:first-child {
    margin-top: 0;
}

input[type="text"], input[type="password"], input[type="number"], input[type="time"], input[type="date"], select {
    width: 100%;
    padding: 12px 14px;
    border-radius: 12px;
    border: 1px solid #d9cfb8;
    background: #fff;
    font-size: 1rem;
    font-family: inherit;
    color: var(--text);
    transition: border-color .15s ease;
}

input[type="text"]:focus, input[type="password"]:focus, input[type="number"]:focus,
input[type="time"]:focus, input[type="date"]:focus, select:focus {
    outline: 2px solid var(--sea);
    outline-offset: 1px;
    border-color: var(--sea);
}

/* Evita o azul/amarelo feio do autofill do navegador por cima do input estilizado */
input[type="text"]:-webkit-autofill,
input[type="password"]:-webkit-autofill {
    -webkit-text-fill-color: var(--text);
    -webkit-box-shadow: 0 0 0 1000px #fff inset;
    box-shadow: 0 0 0 1000px #fff inset;
    transition: background-color 9999s ease-in-out 0s;
}

.password-field {
    position: relative;
}

.password-field input[type="password"],
.password-field input[type="text"] {
    padding-right: 44px;
}

.password-toggle {
    position: absolute;
    right: 4px;
    top: 50%;
    transform: translateY(-50%);
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    border-radius: 8px;
    padding: 0;
    cursor: pointer;
    color: var(--muted);
    -webkit-tap-highlight-color: transparent;
}

.password-toggle:hover {
    background: rgba(31, 42, 43, 0.06);
    color: var(--text);
}

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

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 13px 16px;
    border-radius: 14px;
    border: none;
    font-size: 1rem;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.btn-primary {
    background: var(--sea);
    color: var(--sea-contrast);
    margin-top: 18px;
}

.btn-primary:active {
    background: var(--sea-dark);
}

.btn-primary:disabled {
    opacity: 0.5;
}

.btn-secondary {
    background: none;
    color: var(--muted);
    margin-top: 8px;
}

/* Icon buttons (editar/remover/aprovar/suspender/salvar...) */
.icon-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    border: none;
    border-radius: 10px;
    padding: 7px 12px;
    font-family: inherit;
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    -webkit-tap-highlight-color: transparent;
    transition: background-color 0.15s ease, transform 0.05s ease;
}

.icon-btn:active {
    transform: scale(0.96);
}

.icon-btn-edit {
    background: rgba(var(--sea-rgb), 0.1);
    color: var(--sea-dark);
}

.icon-btn-delete {
    background: rgba(214, 69, 80, 0.1);
    color: var(--danger);
}

.icon-btn-delete.confirming {
    background: var(--danger);
    color: #fff;
}

.icon-btn-save {
    background: rgba(46, 158, 91, 0.12);
    color: var(--win);
}

/* Fixa (não segue a cor de fundo personalizada) de propósito: é o botão de
   ação "neutra" (editar horário, resetar senha...), então precisa continuar
   legível mesmo se a Equipe escolher uma "cor de fundo" parecida com --muted. */
.icon-btn-neutral {
    background: #eef1f1;
    color: #4a5556;
}

.icon-btn-approve {
    background: rgba(46, 158, 91, 0.12);
    color: var(--win);
}

.icon-btn-suspend {
    background: rgba(var(--sun-rgb), 0.18);
    color: #8a5a1e;
}

/* Custom file picker (substitui o <input type="file"> nativo) */
.file-picker {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 12px;
}

.file-picker-input {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.file-picker-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 16px;
    border-radius: 12px;
    background: var(--sand-dark);
    color: var(--sea-dark);
    font-weight: 600;
    font-size: 0.85rem;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.file-picker-input:focus-visible + .file-picker-name,
.file-picker-btn:hover {
    background: #e8d9ae;
}

.file-picker-name {
    font-size: 0.8rem;
    color: var(--muted);
}

/* Login modal */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 42, 43, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    padding: 16px;
}

.modal-overlay.hidden {
    display: none;
}

.modal-card {
    background: #fff;
    border-radius: var(--radius);
    padding: 20px;
    width: 100%;
    max-width: 360px;
}

/* Variante maior, usada pelo ajuste de foto — precisa de mais espaço que o
   modal-card padrão pra dar uma área de arrastar/zoom confortável. */
.modal-card-wide {
    max-width: 440px;
}

/* Ajuste de foto de perfil (arrastar + zoom, ver openAvatarCropModal em app.js) */
.avatar-crop-hint {
    text-align: center;
    font-size: 0.78rem;
    color: var(--muted);
    margin-bottom: 12px;
}

.avatar-crop-stage {
    position: relative;
    max-width: 100%;
    margin: 0 auto 14px;
    border-radius: 12px;
    overflow: hidden;
    background: #1a1a1a;
    touch-action: none;
}

.avatar-crop-stage canvas {
    position: absolute;
    top: 0;
    left: 0;
    cursor: grab;
}

.avatar-crop-stage canvas:active {
    cursor: grabbing;
}

.avatar-crop-mask {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    box-shadow: 0 0 0 2000px rgba(0, 0, 0, 0.55);
    pointer-events: none;
}

input[type="range"] {
    width: 100%;
    margin: 6px 0 4px;
    accent-color: var(--sea);
}

.player-avatar-clickable {
    cursor: pointer;
    display: inline-flex;
    -webkit-tap-highlight-color: transparent;
}

/* Select compacto embutido no meio de um texto (ex: vínculo de jogador em
   "Membros com acesso") — o <select> padrão do app é sempre width:100%. */
.inline-select {
    width: auto;
    display: inline-block;
    padding: 3px 6px;
    font-size: 0.82rem;
    margin-left: 4px;
}

/* Team picker */
.team-block {
    border: 2px solid var(--sand-dark);
    border-radius: 14px;
    padding: 12px;
    margin-bottom: 12px;
}

.team-block.team-a { border-color: #9fd6c9; }
.team-block.team-b { border-color: #f4c99f; }

.team-block-title {
    font-weight: 700;
    font-size: 0.9rem;
    margin-bottom: 8px;
}

.winner-select {
    display: flex;
    gap: 10px;
    margin-top: 6px;
}

.winner-option {
    flex: 1;
    text-align: center;
    padding: 12px;
    border-radius: 12px;
    border: 2px solid #d9cfb8;
    background: #fff;
    font-weight: 700;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.winner-option.selected {
    border-color: var(--sea);
    background: rgba(var(--sea-rgb), 0.1);
    color: var(--sea-dark);
}

/* Escalação de partida (Nova Partida / editar partida) — 1 linha por jogador,
   com gols/assistências/goleiro quando a modalidade da Equipe usa isso. */
.match-roster-row {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 8px;
}

.match-roster-row .match-player-select {
    flex: 2;
    min-width: 0;
}

/* Cabeçalho das colunas de gols/assistências/goleiro — sem ele os campos
   ficam sem rótulo visível (o placeholder some assim que o valor vira "0"). */
.match-roster-header {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 6px;
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

.match-roster-header-player {
    flex: 2;
    min-width: 0;
}

.match-roster-header > span:not(.match-roster-header-player) {
    flex: 1;
    min-width: 48px;
    text-align: center;
}

.match-roster-header-gk {
    flex-basis: 90px;
}

.match-stat-input {
    flex: 1;
    min-width: 48px;
    width: 0;
    padding: 10px 6px;
    border-radius: 10px;
    border: 1px solid #d9cfb8;
    background: #fff;
    color: var(--text);
    font-size: 0.85rem;
    text-align: center;
}

.match-gk-label {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 3px;
    font-size: 0.78rem;
    color: var(--muted);
    white-space: nowrap;
}

/* Em telas estreitas some o texto "Goleiro" e sobra só a luva + o cabeçalho
   da coluna (.match-roster-header-gk) pra não espremer a linha da escalação */
.match-gk-label-text {
    display: none;
}

@media (min-width: 480px) {
    .match-gk-label-text {
        display: inline;
    }
}

.match-gk-label input {
    width: 16px;
    height: 16px;
    accent-color: var(--sea);
}

.match-gk-conceded {
    flex: 1;
    min-width: 60px;
    width: 0;
    padding: 10px 6px;
    border-radius: 10px;
    border: 1px solid #d9cfb8;
    background: #fff;
    color: var(--text);
    font-size: 0.85rem;
    text-align: center;
}

.match-score-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 6px;
}

.match-score-row input {
    flex: 1;
    padding: 10px 12px;
    border-radius: 10px;
    border: 1px solid #d9cfb8;
    background: #fff;
    color: var(--text);
    text-align: center;
}

/* Players list */
.player-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    row-gap: 8px;
    padding: 12px 4px;
    border-bottom: 1px solid var(--sand-dark);
}

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

.player-row-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.player-row-info {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 130px;
}

.player-row-name-wrap {
    display: flex;
    flex-direction: column;
    min-width: 0;
    gap: 2px;
}

.player-row-actions {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-wrap: wrap;
    flex-shrink: 0;
    max-width: 100%;
}

.btn-link {
    background: none;
    border: none;
    color: var(--sea);
    font-family: inherit;
    font-size: 0.8rem;
    font-weight: 600;
    padding: 6px 8px;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.player-row .edit-name-input {
    flex: 1;
    margin-right: 8px;
    padding: 8px 10px;
}

/* History */
.match-item {
    display: flex;
    flex-direction: column;
    gap: 3px;
    padding: 12px 0;
    border-bottom: 1px solid var(--sand-dark);
}

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

.match-team {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 0.9rem;
}

.match-team.winner {
    font-weight: 700;
    color: var(--win);
}

.match-trophy {
    flex-shrink: 0;
}

.match-team-players {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px 6px;
    min-width: 0;
}

.match-player {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    white-space: nowrap;
}

.match-player-sep {
    color: var(--muted);
    font-size: 0.8rem;
}

.match-score {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--muted);
    margin: 2px 0 0 20px;
}

.match-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-top: 4px;
}

.match-date {
    font-size: 0.72rem;
    color: var(--muted);
}

.match-actions {
    display: flex;
    gap: 2px;
}

.match-actions .icon-btn {
    padding: 6px 8px;
    font-size: 0.85rem;
}

.match-edit-form .team-block {
    margin-bottom: 8px;
}

.match-edit-form select {
    margin-bottom: 8px;
}

.day-header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 10px;
    flex-wrap: wrap;
}

.day-label {
    font-weight: 700;
    color: var(--sea-dark);
    font-size: 0.95rem;
}

.day-mvp {
    font-size: 0.75rem;
    color: color-mix(in srgb, var(--sun) 70%, var(--text));
    font-weight: 600;
}

.toast {
    position: fixed;
    left: 50%;
    bottom: calc(var(--tab-bar-height) + env(safe-area-inset-bottom, 0) + 14px);
    transform: translate(-50%, 20px);
    background: var(--ink);
    color: #fff;
    padding: 10px 18px;
    border-radius: 999px;
    font-size: 0.85rem;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease, transform 0.2s ease;
    max-width: 90%;
    text-align: center;
    z-index: 50;
}

.toast.show {
    opacity: 1;
    transform: translate(-50%, 0);
}

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

/* Segmented control (Placar: Pontos / Desempenho) */
.segmented {
    display: flex;
    background: rgba(var(--sea-rgb), 0.08);
    border-radius: 999px;
    padding: 4px;
    margin-bottom: 14px;
}

.segmented-option {
    flex: 1;
    min-width: 0;
    border: none;
    background: none;
    padding: 9px 2px;
    border-radius: 999px;
    font-family: inherit;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--sea-dark);
    cursor: pointer;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    -webkit-tap-highlight-color: transparent;
}

.segmented-option.active {
    background: var(--sea);
    color: var(--sea-contrast);
}

.streak-badge {
    display: inline-block;
    margin-left: 4px;
    color: var(--sun);
    font-weight: 700;
}

.player-badge {
    font-size: 0.85rem;
    cursor: default;
}

/* Back link (sub-views under "Mais") */
.back-link {
    background: none;
    border: none;
    color: var(--sea-dark);
    font-family: inherit;
    font-size: 0.85rem;
    font-weight: 600;
    padding: 8px 4px;
    margin-bottom: 4px;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

/* More menu */
.menu-list {
    display: flex;
    flex-direction: column;
}

.menu-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 4px;
    border-bottom: 1px solid var(--sand-dark);
    background: none;
    border-left: none;
    border-right: none;
    border-top: none;
    text-align: left;
    font-family: inherit;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

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

.menu-icon {
    font-size: 1.4rem;
    flex-shrink: 0;
}

.menu-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.menu-title {
    font-weight: 700;
    color: var(--text);
    font-size: 0.95rem;
}

.menu-desc {
    font-size: 0.75rem;
    color: var(--muted);
}

.menu-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    margin-left: 6px;
    border-radius: 999px;
    background: var(--danger);
    color: #fff;
    font-size: 0.68rem;
    font-weight: 700;
    vertical-align: middle;
}

/* Draw (sorteio) */
.checkbox-list {
    display: flex;
    flex-direction: column;
    max-height: 260px;
    overflow-y: auto;
    margin-bottom: 14px;
    border: 1px solid var(--sand-dark);
    border-radius: 12px;
    padding: 4px 10px;
}

.checkbox-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 2px;
    border-bottom: 1px solid var(--sand-dark);
    font-size: 0.9rem;
}

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

.checkbox-row input {
    width: 18px;
    height: 18px;
    accent-color: var(--sea);
}

/* Seleção de jogadores presentes no Sorteio: grid de chips, sem precisar
   rolar dentro de uma caixinha pequena — a página inteira rola normalmente. */
.player-toggle-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 14px;
}

.player-toggle {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 16px 6px 6px;
    border-radius: 999px;
    border: 2px solid #d9cfb8;
    background: #fff;
    color: var(--text);
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.player-toggle.selected {
    border-color: var(--sea);
    background: rgba(var(--sea-rgb), 0.12);
    color: var(--sea-dark);
}

.player-toggle-actions {
    display: flex;
    gap: 16px;
    margin-bottom: 10px;
}

.player-toggle-actions button {
    background: none;
    border: none;
    padding: 0;
    color: var(--sea-dark);
    font-size: 0.82rem;
    font-weight: 700;
    cursor: pointer;
    text-decoration: underline;
}

/* Explicação do sorteio, dentro da própria tela de Sorteio (colapsável) */
.draw-explainer {
    margin-top: 14px;
}

.draw-explainer summary {
    cursor: pointer;
    font-weight: 700;
    color: var(--sea-dark);
    list-style: none;
}

.draw-explainer summary::-webkit-details-marker {
    display: none;
}

.draw-explainer summary::before {
    content: '▸ ';
}

.draw-explainer[open] summary::before {
    content: '▾ ';
}

.draw-explainer-body {
    margin-top: 10px;
}

.draw-explainer-body > div {
    margin-bottom: 12px;
}

.draw-explainer-body .subtitle {
    font-weight: 700;
    margin-bottom: 4px;
}

/* Seleção de modalidade (tela própria "Modalidade") */
.modality-option {
    display: block;
    width: 100%;
    text-align: left;
    padding: 14px;
    border-radius: 12px;
    border: 2px solid #d9cfb8;
    background: #fff;
    cursor: pointer;
    margin-bottom: 10px;
    -webkit-tap-highlight-color: transparent;
}

.modality-option:last-child {
    margin-bottom: 0;
}

.modality-option.selected {
    border-color: var(--sea);
    background: rgba(var(--sea-rgb), 0.1);
}

.modality-option-name {
    font-weight: 700;
    color: var(--text);
    margin-bottom: 3px;
}

.modality-option-desc {
    font-size: 0.82rem;
    color: var(--muted);
}

/* Seletor de dias da semana (horário de costume da Equipe) */
.weekday-picker {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.weekday-btn {
    flex: 1;
    min-width: 40px;
    padding: 10px 0;
    border-radius: 10px;
    border: 1px solid #d9cfb8;
    background: #fff;
    color: var(--text);
    font-weight: 600;
    font-size: 0.8rem;
    font-family: inherit;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.weekday-btn.active {
    background: var(--sea);
    border-color: var(--sea);
    color: var(--sea-contrast);
}

.court-card {
    border: 2px solid var(--sand-dark);
    border-radius: 14px;
    padding: 12px;
    margin-bottom: 12px;
}

.court-title {
    font-weight: 700;
    font-size: 0.85rem;
    color: var(--sea-dark);
    margin-bottom: 8px;
}

.court-teams {
    display: flex;
    align-items: center;
    gap: 10px;
}

.court-team {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
    font-size: 0.88rem;
}

.court-team span {
    font-size: 0.7rem;
    color: var(--muted);
}

.court-vs {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--muted);
    flex-shrink: 0;
}

.sitting-out-box {
    margin-top: 14px;
    padding: 12px 14px;
    background: rgba(var(--sun-rgb), 0.15);
    border: 1px solid rgba(var(--sun-rgb), 0.4);
    border-radius: 12px;
}

.sitting-out-title {
    font-weight: 700;
    font-size: 0.85rem;
    color: var(--text);
    margin-bottom: 4px;
}

.sitting-out-names {
    font-size: 0.88rem;
    color: var(--text);
}

.extra-pair-box {
    margin-top: 12px;
    padding: 12px 14px;
    background: rgba(var(--sea-rgb), 0.1);
    border: 1px solid rgba(var(--sea-rgb), 0.3);
    border-radius: 12px;
}

.extra-pair-title {
    font-weight: 700;
    font-size: 0.85rem;
    color: var(--text);
    margin-bottom: 4px;
}

.extra-pair-names {
    font-size: 0.88rem;
    font-weight: 700;
    color: var(--sea-dark);
}

/* Auth screen (login / cadastro de Equipe) */
.auth-screen {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px 16px;
    min-height: 100dvh;
}

.auth-wrapper {
    width: 100%;
    max-width: 380px;
}

.auth-hero {
    display: none;
}

.auth-card {
    background: var(--card-bg);
    color: var(--text);
    border-radius: var(--radius);
    padding: 28px 22px;
    width: 100%;
    max-width: 380px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.08);
    text-align: center;
}

.auth-logo {
    width: 56px;
    height: 56px;
    object-fit: contain;
    border-radius: 12px;
    margin-bottom: 10px;
}

.auth-site-name {
    margin: 0 0 4px;
    font-size: 1.4rem;
    color: var(--sea-dark);
}

.auth-tagline {
    margin: 0 0 18px;
    color: var(--muted);
    font-size: 0.85rem;
}

.auth-card form {
    text-align: left;
}

.auth-message {
    margin-top: 14px;
    padding: 10px 14px;
    border-radius: 10px;
    background: rgba(var(--sea-rgb), 0.1);
    color: var(--sea-dark);
    font-size: 0.85rem;
    text-align: left;
}

.auth-message.error {
    background: rgba(214, 69, 80, 0.1);
    color: var(--danger);
}

/* Team branding editor */
.logo-preview {
    max-width: 140px;
    max-height: 140px;
    border-radius: 12px;
    display: block;
    object-fit: contain;
}

input[type="color"] {
    width: 100%;
    height: 44px;
    padding: 4px;
    border-radius: 10px;
    border: 1px solid #d9cfb8;
    background: #fff;
}

/* Legenda logo abaixo de cada seletor de cor, explicando o que ela afeta */
.field-hint {
    font-size: 0.75rem;
    color: var(--muted);
    line-height: 1.4;
    margin: 6px 0 2px;
}

.theme-preview {
    display: flex;
    align-items: center;
    gap: 14px;
    margin: 16px 0 4px;
    padding: 12px 14px;
    background: var(--sand);
    border: 1px solid var(--sand-dark);
    border-radius: 12px;
}

.theme-preview-label {
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.theme-preview-btn {
    width: auto;
    margin: 0;
    padding: 8px 16px;
    font-size: 0.85rem;
}

.theme-preview-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    font-weight: 700;
    font-size: 0.85rem;
    background: var(--sun);
    color: var(--sun-contrast);
}

.theme-preview-text {
    padding: 6px 10px;
    border-radius: 8px;
    font-size: 0.82rem;
    font-weight: 600;
}

.dark-mode-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text);
    margin: 14px 0 6px;
    cursor: pointer;
}

.dark-mode-toggle input {
    width: 18px;
    height: 18px;
    accent-color: var(--sea);
}

.contrast-warning {
    color: var(--danger) !important;
    font-weight: 600;
}

.fields-disabled {
    opacity: 0.45;
    pointer-events: none;
}

/* Super Admin: teams list */
.team-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 14px 4px;
    border-bottom: 1px solid var(--sand-dark);
    flex-wrap: wrap;
}

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

.team-row-info {
    min-width: 0;
    flex: 1;
    display: flex;
    align-items: center;
    gap: 12px;
}

.team-row-logo {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    object-fit: contain;
    background: var(--sand);
    flex-shrink: 0;
}

.team-row-logo-placeholder {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: var(--sand-dark);
    color: var(--sea-dark);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1rem;
    flex-shrink: 0;
}

.team-row-name {
    font-weight: 700;
}

.status-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
}

.status-badge.status-pending {
    background: rgba(var(--sun-rgb), 0.2);
    color: #8a5a1e;
}

.status-badge.status-active {
    background: rgba(46, 158, 91, 0.15);
    color: var(--win);
}

.status-badge.status-suspended {
    background: rgba(214, 69, 80, 0.15);
    color: var(--danger);
}

.password-reveal {
    border: 2px solid var(--win);
}

.password-reveal-value {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 1.2rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    background: var(--sand);
    border-radius: 10px;
    padding: 10px 14px;
    text-align: center;
    color: var(--text);
}

.admin-picker-select {
    padding: 8px 10px;
    border-radius: 10px;
    border: 1px solid #d9cfb8;
    font-family: inherit;
    font-size: 0.85rem;
}

.activity-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 12px 4px;
    border-bottom: 1px solid var(--sand-dark);
    font-size: 0.85rem;
    flex-wrap: wrap;
}

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

.super-stats {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    margin-bottom: 14px;
}

.super-stat-card {
    background: #fff;
    border-radius: 14px;
    padding: 14px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
    text-align: center;
}

.super-stat-card strong {
    display: block;
    font-size: 1.4rem;
    color: var(--sea-dark);
    line-height: 1.2;
}

.super-stat-card span {
    font-size: 0.68rem;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

/* ==========================================================================
   Hover feedback (mouse-driven devices only — never sticks on touch/tap)
   ========================================================================== */
@media (hover: hover) and (pointer: fine) {
    .btn-primary:hover { background: var(--sea-dark); }
    .icon-btn-edit:hover { background: rgba(var(--sea-rgb), 0.18); }
    .icon-btn-delete:hover:not(.confirming) { background: rgba(214, 69, 80, 0.18); }
    .icon-btn-save:hover { background: rgba(46, 158, 91, 0.2); }
    .icon-btn-neutral:hover { background: #e2e7e7; }
    .icon-btn-approve:hover { background: rgba(46, 158, 91, 0.2); }
    .icon-btn-suspend:hover { background: rgba(var(--sun-rgb), 0.28); }
    .file-picker-btn:hover { background: #e8d9ae; }
    .btn-link:hover, .back-link:hover { color: var(--sea-dark); text-decoration: underline; }
    .menu-item:hover { background: var(--sand); }
    .ranking-item:hover, .team-row:hover, .court-card:hover { box-shadow: 0 2px 10px rgba(0,0,0,0.1); }
    .checkbox-row:hover { background: var(--sand); }
    .player-row:hover .player-row-name { color: var(--sea-dark); }
    .winner-option:hover { border-color: var(--sea); }
    .segmented-option:not(.active):hover { background: rgba(var(--sea-rgb), 0.12); }
}

/* ==========================================================================
   Desktop layout (>= 900px): sidebar navigation, wider content, split login
   ========================================================================== */
@media (min-width: 900px) {
    body {
        background: var(--sand);
    }

    /* --- Login / cadastro: painel dividido --- */
    .auth-screen {
        padding: 40px;
    }

    .auth-wrapper {
        max-width: 860px;
        display: flex;
        align-items: stretch;
        border-radius: 24px;
        overflow: hidden;
        box-shadow: 0 20px 60px rgba(15, 42, 43, 0.18);
    }

    .auth-hero {
        display: flex;
        flex-direction: column;
        justify-content: center;
        flex: 1;
        padding: 48px 40px;
        background: linear-gradient(160deg, var(--sea) 0%, var(--sea-dark) 65%, color-mix(in srgb, var(--sun) 55%, var(--sea-dark)) 100%);
        color: var(--sea-contrast);
        text-align: left;
    }

    .auth-hero-icon {
        font-size: 3rem;
        margin-bottom: 18px;
    }

    .auth-hero-title {
        font-size: 1.7rem;
        line-height: 1.25;
        margin: 0 0 14px;
    }

    .auth-hero-tagline {
        font-size: 0.95rem;
        color: var(--sea-contrast);
        opacity: 0.85;
        margin: 0 0 24px;
        max-width: 320px;
    }

    .auth-hero-features {
        list-style: none;
        margin: 0;
        padding: 0;
        display: flex;
        flex-direction: column;
        gap: 10px;
        font-size: 0.88rem;
        color: var(--sea-contrast);
    }

    .auth-hero-features li {
        background: var(--sea-overlay);
        padding: 9px 14px;
        border-radius: 10px;
    }

    .auth-card {
        flex: 1;
        max-width: none;
        border-radius: 0;
        box-shadow: none;
        padding: 44px 40px;
        display: flex;
        flex-direction: column;
        justify-content: center;
    }

    /* --- App shell: topo horizontal + grade de navegação --- */
    #app-shell {
        display: flex;
        flex-direction: column;
        min-height: 100dvh;
    }

    .app-header {
        flex-direction: row;
        align-items: center;
        justify-content: flex-start;
        gap: 16px;
        padding: 18px 32px;
        position: relative;
        box-shadow: 0 2px 10px rgba(0,0,0,0.08);
    }

    .brand-logo {
        width: 52px;
        height: 52px;
        margin: 0;
        border-radius: 12px;
        background: var(--sea-overlay);
        padding: 4px;
    }

    .app-header h1 {
        margin: 0;
        font-size: 1.3rem;
        text-align: left;
    }

    .admin-btn {
        position: static;
        margin-left: auto;
        background: var(--sea-overlay);
    }

    .tab-bar {
        position: static;
        height: auto;
        width: 100%;
        max-width: 1080px;
        margin: 20px auto 0;
        display: grid;
        grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
        gap: 12px;
        background: transparent;
        border-top: none;
        box-shadow: none;
        padding: 0 32px;
    }

    .tab-btn {
        flex: none;
        flex-direction: column;
        justify-content: center;
        gap: 8px;
        padding: 18px 10px;
        border: 1px solid var(--sand-dark);
        border-radius: 16px;
        background: #fff;
        box-shadow: 0 1px 4px rgba(0,0,0,0.05);
        font-size: 0.8rem;
        color: var(--muted);
        aspect-ratio: 1.3;
        transition: transform 0.12s ease, box-shadow 0.12s ease;
    }

    .tab-btn .tab-icon {
        font-size: 1.6rem;
    }

    .tab-btn.active {
        background: rgba(var(--sea-rgb), 0.1);
        border-color: var(--sea);
        color: var(--sea-dark);
    }

    .tab-badge {
        top: 10px;
        right: 10px;
    }

    .tab-btn-desktop-only {
        display: flex;
    }

    .tab-btn-mobile-only {
        display: none;
    }

    .back-link {
        display: none;
    }

    .view {
        max-width: 1080px;
        padding: 28px 32px 60px;
        margin: 0 auto;
    }

    .toast {
        bottom: 24px;
    }

    /* --- "Mais": grade de botões quadrados em vez de lista --- */
    .menu-list {
        display: grid;
        grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
        gap: 16px;
    }

    .menu-item {
        flex-direction: column;
        justify-content: center;
        text-align: center;
        gap: 10px;
        aspect-ratio: 1.1;
        padding: 24px 16px;
        border: 1px solid var(--sand-dark);
        border-radius: 18px;
        background: #fff;
        box-shadow: 0 1px 4px rgba(0,0,0,0.05);
        transition: transform 0.12s ease, box-shadow 0.12s ease;
    }

    .menu-item:last-child {
        border: 1px solid var(--sand-dark);
    }

    .menu-item:hover {
        transform: translateY(-2px);
        box-shadow: 0 8px 20px rgba(0,0,0,0.1);
        background: #fff;
    }

    .menu-icon {
        font-size: 2.4rem;
    }

    .menu-text {
        align-items: center;
    }

    .menu-title {
        font-size: 1rem;
    }

    .menu-desc {
        font-size: 0.78rem;
    }

    /* --- Super Admin: cards de resumo --- */
    .super-stats {
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
        gap: 16px;
        margin-bottom: 20px;
    }

    .super-stat-card {
        background: #fff;
        border-radius: 16px;
        padding: 20px;
        box-shadow: 0 1px 4px rgba(0,0,0,0.06);
        text-align: center;
    }

    .super-stat-card strong {
        display: block;
        font-size: 1.8rem;
        color: var(--sea-dark);
        line-height: 1.2;
    }

    .super-stat-card span {
        font-size: 0.78rem;
        color: var(--muted);
        text-transform: uppercase;
        letter-spacing: 0.03em;
    }

    .team-row {
        border: 1px solid var(--sand-dark);
        border-radius: 14px;
        padding: 16px;
        margin-bottom: 10px;
    }

    .team-row:last-child {
        border-bottom: 1px solid var(--sand-dark);
    }
}
