/* ========== RESET & BASE ========== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    /* Marca (iguais nos 2 temas) */
    --vermelho: #C91212;
    --vermelho-vivo: #FF0000;
    --mesclado: #6D251D;
    --cinza: #E1DCDD;
    --cinza-escuro: #2D3438;
    --preto: #000000;

    --radius-sm: 10px;
    --radius-md: 16px;
    --radius-lg: 24px;

    --t-fast: .18s cubic-bezier(.4, 0, .2, 1);
    --t-med: .35s cubic-bezier(.4, 0, .2, 1);
    --t-slow: .6s cubic-bezier(.4, 0, .2, 1);

    /* DARK (padrão) */
    --bg-0: #1a1f23;
    --bg-1: #242a2f;
    --bg-2: #2d3438;
    --bg-3: #383f44;
    --text: #E1DCDD;
    --text-dim: #9aa3a8;
    --text-soft: #c5cbce;

    --surface: linear-gradient(180deg, var(--bg-1) 0%, var(--bg-2) 100%);
    --surface-overlay: rgba(0, 0, 0, .2);
    --surface-overlay-strong: rgba(0, 0, 0, .35);
    --border-soft: rgba(225, 220, 221, .06);
    --border-med: rgba(225, 220, 221, .1);
    --hover-soft: rgba(225, 220, 221, .06);
    --hover-med: rgba(225, 220, 221, .1);
    --cell-bg: rgba(0, 0, 0, .2);
    --cell-border: rgba(225, 220, 221, .05);

    --body-bg:
        radial-gradient(circle at 50% -8%, rgba(245, 200, 66, .10), transparent 42%),
        radial-gradient(ellipse at top left, rgba(201, 18, 18, .16), transparent 52%),
        radial-gradient(ellipse at bottom right, rgba(232, 89, 12, .12), transparent 55%),
        radial-gradient(circle, rgba(255, 255, 255, .022) 1.5px, transparent 1.6px) 0 0 / 26px 26px,
        linear-gradient(135deg, #1a1f23 0%, #231c1a 55%, #2d2622 100%);

    --glow-red: 0 0 40px rgba(255, 0, 0, .35), 0 0 80px rgba(201, 18, 18, .25);
    --shadow-card: 0 20px 60px rgba(0, 0, 0, .45), 0 0 0 1px rgba(255, 255, 255, .04);
    --shadow-btn: 0 8px 20px rgba(0, 0, 0, .4);

    --idle-ball: radial-gradient(circle at 30% 25%, #4a5258 0%, var(--cinza-escuro) 50%, #1a1f23 100%);
    --idle-ball-text: rgba(225, 220, 221, .3);
}

/* LIGHT */
[data-theme="light"] {
    --bg-0: #f4f1f2;
    --bg-1: #ffffff;
    --bg-2: #faf7f8;
    --bg-3: #efebec;
    --text: #2d3438;
    --text-dim: #6f7780;
    --text-soft: #4a5258;

    --surface: linear-gradient(180deg, #fffdf7 0%, #fdf4e6 100%);
    --surface-overlay: rgba(45, 52, 56, .04);
    --surface-overlay-strong: rgba(45, 52, 56, .07);
    --border-soft: rgba(45, 52, 56, .08);
    --border-med: rgba(45, 52, 56, .14);
    --hover-soft: rgba(45, 52, 56, .05);
    --hover-med: rgba(45, 52, 56, .08);
    --cell-bg: rgba(45, 52, 56, .04);
    --cell-border: rgba(45, 52, 56, .08);

    --body-bg:
        radial-gradient(circle at 50% -8%, rgba(245, 200, 66, .32), transparent 42%),
        radial-gradient(ellipse at top left, rgba(201, 18, 18, .08), transparent 52%),
        radial-gradient(ellipse at bottom right, rgba(232, 89, 12, .12), transparent 55%),
        radial-gradient(circle, rgba(201, 18, 18, .05) 1.5px, transparent 1.6px) 0 0 / 26px 26px,
        linear-gradient(135deg, #fbf3e1 0%, #f6ead0 100%);

    --glow-red: 0 0 30px rgba(255, 0, 0, .25), 0 0 60px rgba(201, 18, 18, .18);
    --shadow-card: 0 12px 40px rgba(45, 52, 56, .08), 0 0 0 1px rgba(45, 52, 56, .04);
    --shadow-btn: 0 6px 16px rgba(201, 18, 18, .25);

    --idle-ball: radial-gradient(circle at 30% 25%, #e8e3e4 0%, #c8c2c4 50%, #9a9295 100%);
    --idle-ball-text: rgba(45, 52, 56, .35);
}

html, body {
    height: 100%;
    font-family: 'Poppins', -apple-system, system-ui, sans-serif;
    color: var(--text);
    background: var(--bg-0);
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    transition: background var(--t-med), color var(--t-med);
}

body {
    background: var(--body-bg);
    min-height: 100vh;
}

button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input { font-family: inherit; }
svg { width: 100%; height: 100%; display: block; }

/* ========== LAYOUT ========== */
.app {
    height: 100vh;
    display: grid;
    grid-template-rows: auto auto 1fr;
    overflow: hidden;
}

.app > .header { grid-row: 1; }
.app > .winner-banner { grid-row: 2; }
.app > .main { grid-row: 3; }

/* ========== HEADER ========== */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 18px 32px;
    background: var(--surface-overlay-strong);
    border-bottom: 1px solid var(--border-soft);
    backdrop-filter: blur(10px);
}

.brand { display: flex; align-items: center; gap: 14px; }

.brand-logo {
    height: 64px;
    width: auto;
    display: block;
    filter: drop-shadow(0 4px 14px rgba(201, 18, 18, .3));
}

.brand-mark {
    width: 52px; height: 52px;
    display: grid; place-items: center;
    background: linear-gradient(135deg, var(--vermelho) 0%, var(--mesclado) 100%);
    border-radius: var(--radius-sm);
    font-weight: 800;
    font-size: 22px;
    letter-spacing: -1px;
    color: white;
    box-shadow: 0 6px 16px rgba(201, 18, 18, .4), inset 0 1px 0 rgba(255, 255, 255, .2);
}


.brand-text h1 {
    font-weight: 700;
    font-size: 18px;
    letter-spacing: 2.5px;
    line-height: 1;
    color: var(--text);
}

.brand-text span {
    display: block;
    font-size: 11px;
    color: var(--text-dim);
    letter-spacing: 3px;
    margin-top: 4px;
    text-transform: uppercase;
    font-weight: 500;
}

.header-controls { display: flex; gap: 10px; }

.icon-btn {
    width: 44px; height: 44px;
    display: grid; place-items: center;
    background: var(--hover-soft);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-sm);
    color: var(--text-soft);
    transition: var(--t-fast);
}

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

.icon-btn:hover {
    background: rgba(201, 18, 18, .15);
    border-color: rgba(201, 18, 18, .3);
    color: var(--vermelho);
    transform: translateY(-1px);
}

.icon-btn.muted { opacity: .4; }

/* ========== MAIN ========== */
.main {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 28px;
    padding: 56px 32px 32px;
    overflow: hidden;
    position: relative;
}

/* Bandeirinhas de festa junina no topo da área de jogo */
.main::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 46px;
    background: url("data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20width='200'%20height='46'%20viewBox='0%200%20200%2046'%3E%3Cline%20x1='0'%20y1='5'%20x2='200'%20y2='5'%20stroke='%236d251d'%20stroke-width='2.5'/%3E%3Cpolygon%20points='0,5%2040,5%2020,44'%20fill='%23C91212'/%3E%3Cpolygon%20points='40,5%2080,5%2060,44'%20fill='%23F5C842'/%3E%3Cpolygon%20points='80,5%20120,5%20100,44'%20fill='%232F9E44'/%3E%3Cpolygon%20points='120,5%20160,5%20140,44'%20fill='%231C7ED6'/%3E%3Cpolygon%20points='160,5%20200,5%20180,44'%20fill='%23E8590C'/%3E%3C/svg%3E") repeat-x top center;
    background-size: auto 46px;
    filter: drop-shadow(0 3px 2px rgba(0, 0, 0, .18));
    pointer-events: none;
    z-index: 0;
}

/* ========== DISPLAY SECTION ========== */
.display-section {
    display: flex;
    flex-direction: column;
    gap: 18px;
    min-height: 0;
}

.display-card {
    flex: 1;
    background: var(--surface);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-lg);
    padding: 28px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    box-shadow: var(--shadow-card);
    position: relative;
    overflow: hidden;
    min-height: 0;
}

.display-card::before {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(ellipse at top, rgba(255, 0, 0, .08), transparent 60%);
    pointer-events: none;
}

.display-label {
    font-size: 12px;
    letter-spacing: 5px;
    color: var(--text-dim);
    font-weight: 600;
    z-index: 1;
}

.ball-stage {
    flex: 1;
    display: grid;
    place-items: center;
    width: 100%;
    z-index: 1;
    perspective: 800px;
}

.ball {
    width: min(340px, 40vh);
    height: min(340px, 40vh);
    aspect-ratio: 1;
    border-radius: 50%;
    background:
        radial-gradient(circle at 30% 25%, #ff4444 0%, var(--vermelho-vivo) 30%, var(--vermelho) 65%, var(--mesclado) 100%);
    box-shadow:
        var(--glow-red),
        inset -20px -25px 60px rgba(0, 0, 0, .4),
        inset 15px 15px 40px rgba(255, 255, 255, .15),
        0 30px 60px rgba(0, 0, 0, .5);
    display: grid;
    place-items: center;
    position: relative;
    transition: transform var(--t-slow);
}

.ball.idle {
    background: var(--idle-ball);
    box-shadow:
        inset -20px -25px 60px rgba(0, 0, 0, .25),
        inset 15px 15px 40px rgba(255, 255, 255, .15),
        0 30px 60px rgba(0, 0, 0, .25);
}

.ball.spinning {
    animation: spin .08s linear infinite;
}

.ball.reveal {
    animation: reveal .8s cubic-bezier(.34, 1.56, .64, 1);
}

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

@keyframes reveal {
    0% { transform: scale(.3) rotate(-180deg); opacity: 0; }
    60% { transform: scale(1.15) rotate(10deg); opacity: 1; }
    100% { transform: scale(1) rotate(0); opacity: 1; }
}

.ball-number {
    font-size: clamp(80px, 16vh, 180px);
    font-weight: 900;
    color: white;
    text-shadow: 0 6px 20px rgba(0, 0, 0, .5), 0 2px 0 rgba(0, 0, 0, .3);
    letter-spacing: -4px;
    z-index: 2;
    line-height: 1;
    user-select: none;
}

.ball.idle .ball-number {
    color: var(--idle-ball-text);
    text-shadow: none;
}

.ball-shine {
    position: absolute;
    top: 12%; left: 18%;
    width: 30%; height: 25%;
    background: radial-gradient(ellipse, rgba(255, 255, 255, .55), transparent 70%);
    border-radius: 50%;
    pointer-events: none;
    filter: blur(2px);
}

.display-footer {
    display: flex;
    align-items: center;
    gap: 32px;
    z-index: 1;
}

.stat { text-align: center; }
.stat-label {
    display: block;
    font-size: 10px;
    letter-spacing: 3px;
    color: var(--text-dim);
    font-weight: 600;
    margin-bottom: 4px;
}
.stat-value {
    font-size: 28px;
    font-weight: 700;
    color: var(--text);
    line-height: 1;
}
.stat-divider {
    width: 1px;
    height: 32px;
    background: var(--border-med);
}

/* ========== RECENT STRIP ========== */
.recent-strip {
    display: flex;
    align-items: center;
    gap: 16px;
    background: var(--surface-overlay);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-md);
    padding: 12px 20px;
    min-height: 64px;
}

.recent-label {
    font-size: 10px;
    letter-spacing: 3px;
    color: var(--text-dim);
    font-weight: 600;
    flex-shrink: 0;
}

.recent-balls {
    display: flex;
    gap: 10px;
    align-items: center;
    flex: 1;
    min-height: 40px;
}

.recent-ball {
    width: 40px; height: 40px;
    border-radius: 50%;
    background: radial-gradient(circle at 30% 25%, #ff4444, var(--vermelho) 60%, var(--mesclado));
    display: grid;
    place-items: center;
    font-weight: 700;
    font-size: 14px;
    color: white;
    box-shadow: inset -3px -4px 8px rgba(0, 0, 0, .3), inset 2px 2px 4px rgba(255, 255, 255, .15), 0 4px 10px rgba(0, 0, 0, .3);
    animation: pop .4s cubic-bezier(.34, 1.56, .64, 1);
}

.recent-ball:nth-child(1) { opacity: .5; transform: scale(.8); }
.recent-ball:nth-child(2) { opacity: .65; transform: scale(.86); }
.recent-ball:nth-child(3) { opacity: .8; transform: scale(.92); }
.recent-ball:nth-child(4) { opacity: .9; transform: scale(.96); }
.recent-ball:nth-child(5) { opacity: 1; transform: scale(1); }

@keyframes pop {
    0% { transform: scale(0) rotate(180deg); opacity: 0; }
    100% { transform: scale(1) rotate(0); opacity: 1; }
}

/* ========== ACTIONS ========== */
.actions {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 14px;
}

.actions-secondary {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 16px 24px;
    border-radius: var(--radius-md);
    font-weight: 600;
    font-size: 14px;
    letter-spacing: 2px;
    transition: var(--t-fast);
    position: relative;
    overflow: hidden;
    text-transform: uppercase;
}

.btn svg { width: 20px; height: 20px; flex-shrink: 0; }

.btn kbd {
    margin-left: 6px;
    padding: 2px 8px;
    font-size: 10px;
    font-weight: 500;
    background: rgba(0, 0, 0, .25);
    border-radius: 4px;
    letter-spacing: .5px;
    font-family: inherit;
}

.btn-primary {
    background: linear-gradient(135deg, var(--vermelho) 0%, var(--mesclado) 100%);
    color: white;
    box-shadow: var(--shadow-btn), inset 0 1px 0 rgba(255, 255, 255, .2);
    font-size: 16px;
    padding: 20px 28px;
    letter-spacing: 3px;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 28px rgba(201, 18, 18, .5), inset 0 1px 0 rgba(255, 255, 255, .2);
}

.btn-primary:active { transform: translateY(0); }

.btn-primary:disabled {
    opacity: .5;
    cursor: not-allowed;
    transform: none !important;
}

.btn-bingo {
    background: linear-gradient(135deg, #f5c842 0%, #d49b22 100%);
    color: var(--bg-0);
    font-size: 16px;
    padding: 20px 24px;
    letter-spacing: 3px;
    box-shadow: 0 8px 20px rgba(212, 155, 34, .4), inset 0 1px 0 rgba(255, 255, 255, .3);
}

.btn-bingo:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 28px rgba(212, 155, 34, .55), inset 0 1px 0 rgba(255, 255, 255, .3);
}

.btn-ghost {
    background: var(--hover-soft);
    border: 1px solid var(--border-med);
    color: var(--text-soft);
}

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

.btn-danger {
    background: rgba(201, 18, 18, .1);
    border: 1px solid rgba(201, 18, 18, .25);
    color: var(--vermelho);
}

.btn-danger:hover {
    background: var(--vermelho);
    color: white;
    border-color: var(--vermelho);
}

.btn-finish {
    background: rgba(245, 200, 66, .1);
    border: 1px solid rgba(245, 200, 66, .35);
    color: #d49b22;
}

[data-theme="dark"] .btn-finish { color: #f5c842; }

.btn-finish:hover {
    background: linear-gradient(135deg, #f5c842 0%, #d49b22 100%);
    color: var(--bg-0);
    border-color: transparent;
    transform: translateY(-1px);
    box-shadow: 0 8px 20px rgba(212, 155, 34, .4);
}

/* ========== GRID SECTION ========== */
.grid-section {
    background: var(--surface);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-lg);
    padding: 24px 28px;
    display: flex;
    flex-direction: column;
    gap: 18px;
    box-shadow: var(--shadow-card);
    min-height: 0;
}

.grid-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
}

.grid-header h2 {
    font-size: 14px;
    font-weight: 700;
    letter-spacing: 4px;
    color: var(--text);
}

.grid-subtitle {
    font-size: 11px;
    letter-spacing: 2px;
    color: var(--text-dim);
    font-weight: 500;
}

.number-grid {
    flex: 1;
    display: grid;
    grid-template-columns: repeat(10, 1fr);
    gap: 6px;
    align-content: start;
    overflow: auto;
    padding-right: 4px;
}

.number-grid::-webkit-scrollbar { width: 6px; }
.number-grid::-webkit-scrollbar-track { background: transparent; }
.number-grid::-webkit-scrollbar-thumb { background: var(--border-med); border-radius: 3px; }

.num-cell {
    aspect-ratio: 1;
    display: grid;
    place-items: center;
    background: var(--cell-bg);
    border: 1px solid var(--cell-border);
    border-radius: 10px;
    font-weight: 600;
    font-size: clamp(14px, 1.8vw, 22px);
    color: var(--text-soft);
    transition: var(--t-med);
    position: relative;
    overflow: hidden;
}

.num-cell.drawn {
    background: linear-gradient(135deg, var(--vermelho) 0%, var(--mesclado) 100%);
    color: white;
    border-color: var(--vermelho);
    box-shadow: 0 4px 12px rgba(201, 18, 18, .4), inset 0 1px 0 rgba(255, 255, 255, .2);
    animation: drawn-pop .5s cubic-bezier(.34, 1.56, .64, 1);
}

.num-cell.just-drawn {
    animation: drawn-pop .5s cubic-bezier(.34, 1.56, .64, 1), pulse-glow 1.5s ease-in-out 2;
}

@keyframes drawn-pop {
    0% { transform: scale(.5); }
    60% { transform: scale(1.15); }
    100% { transform: scale(1); }
}

@keyframes pulse-glow {
    0%, 100% { box-shadow: 0 4px 12px rgba(201, 18, 18, .4), inset 0 1px 0 rgba(255, 255, 255, .2), 0 0 0 0 rgba(255, 0, 0, .6); }
    50% { box-shadow: 0 4px 12px rgba(201, 18, 18, .4), inset 0 1px 0 rgba(255, 255, 255, .2), 0 0 0 8px rgba(255, 0, 0, 0); }
}

/* ========== TOAST ========== */
.toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(120%);
    background: var(--bg-3);
    border: 1px solid var(--border-med);
    color: var(--text);
    padding: 14px 24px;
    border-radius: var(--radius-md);
    font-size: 14px;
    font-weight: 500;
    box-shadow: 0 12px 30px rgba(0, 0, 0, .35);
    z-index: 100;
    transition: transform var(--t-med);
    pointer-events: none;
}

.toast.show { transform: translateX(-50%) translateY(0); }
.toast.success { background: linear-gradient(135deg, #1f7a3f, #145a2c); color: white; }
.toast.error { background: linear-gradient(135deg, var(--vermelho), var(--mesclado)); color: white; }

/* ========== MODAL ========== */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .65);
    display: grid;
    place-items: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--t-med);
    z-index: 200;
    padding: 20px;
    visibility: hidden;
}

.modal-backdrop.open {
    opacity: 1;
    pointer-events: auto;
    visibility: visible;
    backdrop-filter: blur(8px);
}

.modal {
    background: var(--surface);
    border: 1px solid var(--border-med);
    border-radius: var(--radius-lg);
    padding: 32px;
    width: 100%;
    max-width: 480px;
    box-shadow: 0 30px 80px rgba(0, 0, 0, .45);
    transform: scale(.95) translateY(20px);
    transition: transform var(--t-med);
    position: relative;
    overflow: hidden;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
}

.modal-backdrop.open .modal { transform: scale(1) translateY(0); }

.modal-bingo {
    text-align: center;
    max-width: 460px;
}

.confetti-layer {
    position: absolute;
    inset: 0;
    pointer-events: none;
    overflow: hidden;
}

.confetti-piece {
    position: absolute;
    width: 8px; height: 14px;
    top: -20px;
    animation: confetti-fall 2.5s linear forwards;
}

@keyframes confetti-fall {
    to { transform: translateY(120vh) rotate(720deg); opacity: 0; }
}

.bingo-trophy {
    width: 80px; height: 80px;
    margin: 0 auto 16px;
    color: #f5c842;
    filter: drop-shadow(0 8px 20px rgba(245, 200, 66, .4));
    animation: trophy-pop .6s cubic-bezier(.34, 1.56, .64, 1);
}

@keyframes trophy-pop {
    0% { transform: scale(0) rotate(-30deg); opacity: 0; }
    60% { transform: scale(1.15) rotate(5deg); }
    100% { transform: scale(1) rotate(0); opacity: 1; }
}

.modal-title {
    font-size: 42px;
    font-weight: 800;
    letter-spacing: 6px;
    background: linear-gradient(135deg, #f5c842 0%, #ffb347 50%, var(--vermelho) 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 8px;
}

.modal-title-sm {
    font-size: 20px;
    font-weight: 700;
    color: var(--text);
    letter-spacing: 1px;
}

.modal-subtitle {
    color: var(--text-dim);
    font-size: 14px;
    margin-bottom: 28px;
    letter-spacing: 1px;
}

.modal-subtitle-sm {
    font-size: 13px;
    color: var(--text-dim);
    margin-top: 4px;
}

.modal-text {
    color: var(--text-soft);
    font-size: 14px;
    margin-bottom: 24px;
    line-height: 1.5;
    text-align: center;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border-soft);
}

/* ========== FORM ========== */
.form { display: flex; flex-direction: column; gap: 16px; text-align: left; }

.field { display: flex; flex-direction: column; gap: 8px; }

.field label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-soft);
    letter-spacing: 1.5px;
    text-transform: uppercase;
}

.field .optional {
    color: var(--text-dim);
    font-weight: 400;
    text-transform: none;
    letter-spacing: 0;
    font-size: 11px;
}

.field input {
    padding: 14px 16px;
    background: var(--surface-overlay-strong);
    border: 1px solid var(--border-med);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-size: 15px;
    transition: var(--t-fast);
    outline: none;
}

.field input:focus {
    border-color: var(--vermelho);
    background: var(--surface-overlay);
    box-shadow: 0 0 0 3px rgba(201, 18, 18, .15);
}

.field input::placeholder { color: var(--text-dim); }

.modal-actions {
    display: flex;
    gap: 12px;
    margin-top: 8px;
    justify-content: flex-end;
}

.modal-actions .btn { padding: 12px 22px; font-size: 13px; letter-spacing: 1.5px; }

/* ========== CONFIRM MODAL ========== */
.modal-confirm {
    max-width: 400px;
    text-align: center;
    align-items: center;
}

.confirm-icon {
    width: 60px; height: 60px;
    margin: 0 auto 16px;
    color: #f5c842;
    background: rgba(245, 200, 66, .12);
    border-radius: 50%;
    padding: 14px;
}

/* ========== HISTORY ========== */
.modal-history {
    max-width: 640px;
    max-height: 85vh;
}

.history-list {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 20px;
    padding-right: 6px;
    max-height: 55vh;
}

.history-list::-webkit-scrollbar { width: 6px; }
.history-list::-webkit-scrollbar-thumb { background: var(--border-med); border-radius: 3px; }

.history-item {
    background: var(--surface-overlay);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-md);
    padding: 16px 18px;
    transition: var(--t-fast);
}

.history-item:hover {
    border-color: rgba(201, 18, 18, .3);
    background: var(--surface-overlay-strong);
}

.history-top {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 10px;
}

.history-winner {
    font-weight: 700;
    font-size: 16px;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 8px;
}

.history-prize {
    display: block;
    font-size: 12px;
    color: #f5c842;
    font-weight: 500;
    margin-top: 2px;
    letter-spacing: .5px;
}

.history-meta {
    font-size: 11px;
    color: var(--text-dim);
    text-align: right;
    line-height: 1.5;
    flex-shrink: 0;
}

.history-numbers {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 8px;
}

.history-num {
    min-width: 24px;
    height: 24px;
    padding: 0 6px;
    display: grid;
    place-items: center;
    background: rgba(201, 18, 18, .15);
    border: 1px solid rgba(201, 18, 18, .3);
    border-radius: 6px;
    font-size: 11px;
    font-weight: 600;
    color: var(--vermelho);
}

.history-num.winning {
    background: linear-gradient(135deg, #f5c842, #d49b22);
    border-color: #d49b22;
    color: var(--bg-0);
}

.history-empty {
    text-align: center;
    padding: 48px 20px;
    color: var(--text-dim);
}

.history-empty svg { width: 48px; height: 48px; margin: 0 auto 12px; opacity: .4; }
.history-empty p { font-size: 14px; }

.history-actions {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding-top: 16px;
    border-top: 1px solid var(--border-soft);
}

.history-actions .btn { padding: 10px 18px; font-size: 12px; letter-spacing: 1px; }

/* ========== WINNER BANNER (persistente até nova rodada) ========== */
.winner-banner {
    align-items: center;
    gap: 18px;
    padding: 14px 32px;
    background: linear-gradient(100deg, var(--vermelho) 0%, var(--mesclado) 55%, #45160f 100%);
    border-bottom: 2px solid rgba(245, 200, 66, .6);
    box-shadow: 0 10px 30px rgba(0, 0, 0, .35);
    position: relative;
    overflow: hidden;
    animation: banner-in .5s cubic-bezier(.34, 1.56, .64, 1);
}
.winner-banner:not([hidden]) { display: flex; }

@keyframes banner-in {
    from { transform: translateY(-100%); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.winner-banner::after {
    content: '';
    position: absolute; inset: 0;
    background: linear-gradient(100deg, transparent 35%, rgba(255, 255, 255, .16) 50%, transparent 65%);
    transform: translateX(-100%);
    animation: banner-shine 4s ease-in-out infinite;
    pointer-events: none;
}
@keyframes banner-shine {
    0%, 55% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

.wb-trophy {
    width: 40px; height: 40px;
    color: #f5c842;
    flex-shrink: 0; z-index: 1;
    filter: drop-shadow(0 2px 6px rgba(0, 0, 0, .4));
    animation: trophy-bounce 2s ease-in-out infinite;
}
@keyframes trophy-bounce {
    0%, 100% { transform: translateY(0) rotate(-4deg); }
    50% { transform: translateY(-4px) rotate(4deg); }
}

.wb-info { display: flex; flex-direction: column; line-height: 1.1; flex: 1; min-width: 0; z-index: 1; }
.wb-label {
    font-size: 11px; letter-spacing: 3px; font-weight: 600;
    color: rgba(255, 255, 255, .82); text-transform: uppercase;
}
.wb-name {
    font-size: clamp(20px, 2.6vw, 34px);
    font-weight: 800; color: #fff; letter-spacing: .5px;
    text-shadow: 0 2px 8px rgba(0, 0, 0, .35);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.wb-prize {
    background: linear-gradient(135deg, #f5c842, #d49b22);
    color: #2d1a02; font-weight: 700; font-size: 14px;
    padding: 8px 16px; border-radius: 999px; letter-spacing: .5px;
    box-shadow: 0 4px 12px rgba(212, 155, 34, .4);
    z-index: 1; flex-shrink: 0; white-space: nowrap;
}
.wb-prize:not([hidden]) { display: inline-block; }
.wb-prize[hidden] { display: none; }

.wb-expand {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 9px 16px;
    background: rgba(255, 255, 255, .14);
    border: 1px solid rgba(255, 255, 255, .25);
    border-radius: var(--radius-sm);
    color: #fff; font-weight: 600; font-size: 12px;
    letter-spacing: 1px; text-transform: uppercase;
    transition: var(--t-fast); z-index: 1; flex-shrink: 0;
}
.wb-expand svg { width: 15px; height: 15px; }
.wb-expand:hover { background: rgba(255, 255, 255, .26); }

/* ========== WINNER OVERLAY (celebração em tela cheia) ========== */
.winner-overlay {
    position: fixed; inset: 0;
    z-index: 180;
    display: grid; place-items: center;
    padding: 24px;
    background: radial-gradient(ellipse at center, rgba(45, 24, 18, .9), rgba(0, 0, 0, .94));
    opacity: 0; visibility: hidden; pointer-events: none;
    transition: opacity var(--t-med), visibility var(--t-med);
    overflow: hidden;
}
.winner-overlay.open { opacity: 1; visibility: visible; pointer-events: auto; }

.winner-glow {
    position: absolute; inset: 0;
    background: radial-gradient(circle at center, rgba(255, 0, 0, .2), transparent 55%);
    animation: glow-pulse 3s ease-in-out infinite;
    pointer-events: none;
}
@keyframes glow-pulse {
    0%, 100% { opacity: .55; transform: scale(1); }
    50% { opacity: 1; transform: scale(1.12); }
}

.winner-card {
    position: relative; z-index: 2;
    text-align: center;
    display: flex; flex-direction: column; align-items: center; gap: 4px;
    max-width: 92vw;
}
.winner-overlay.open .winner-card { animation: winner-pop .7s cubic-bezier(.34, 1.56, .64, 1); }
@keyframes winner-pop {
    0% { transform: scale(.6) translateY(40px); opacity: 0; }
    60% { transform: scale(1.05); opacity: 1; }
    100% { transform: scale(1) translateY(0); }
}

.winner-trophy {
    width: clamp(90px, 12vw, 150px);
    height: clamp(90px, 12vw, 150px);
    color: #f5c842;
    filter: drop-shadow(0 10px 30px rgba(245, 200, 66, .5));
    animation: trophy-bounce 2.2s ease-in-out infinite;
}
.winner-congrats {
    font-size: clamp(40px, 7vw, 92px);
    font-weight: 900; letter-spacing: 4px; line-height: 1;
    background: linear-gradient(180deg, #fff 0%, #f5c842 60%, #d49b22 100%);
    -webkit-background-clip: text; background-clip: text;
    -webkit-text-fill-color: transparent;
    filter: drop-shadow(0 6px 20px rgba(245, 200, 66, .35));
}
.winner-sub {
    font-size: clamp(14px, 1.8vw, 22px);
    font-weight: 600; letter-spacing: 6px;
    color: rgba(255, 255, 255, .7);
    text-transform: uppercase; margin-top: 12px;
}
.winner-name {
    font-size: clamp(46px, 9vw, 128px);
    font-weight: 900; line-height: 1.05;
    color: #fff; letter-spacing: 1px;
    text-shadow: 0 4px 30px rgba(201, 18, 18, .6), 0 2px 4px rgba(0, 0, 0, .4);
    margin: 4px 0 10px; max-width: 92vw; word-break: break-word;
}
.winner-prize {
    font-size: clamp(16px, 2vw, 26px);
    font-weight: 700;
    background: linear-gradient(135deg, #f5c842, #d49b22);
    color: #2d1a02; padding: 10px 28px; border-radius: 999px;
    letter-spacing: 1px; box-shadow: 0 8px 24px rgba(212, 155, 34, .45);
}
.winner-prize:not([hidden]) { display: inline-block; }
.winner-prize[hidden] { display: none; }

.winner-overlay-actions {
    display: flex; gap: 16px; margin-top: 28px;
    flex-wrap: wrap; justify-content: center;
}
.winner-overlay-actions .btn { padding: 16px 32px; }

/* ========== RANKING / MURAL DE GANHADORES ========== */
.ranking-overlay {
    position: fixed; inset: 0;
    z-index: 185;
    display: grid; place-items: center;
    padding: 32px;
    background: radial-gradient(ellipse at top, rgba(45, 52, 56, .97), rgba(0, 0, 0, .96));
    opacity: 0; visibility: hidden; pointer-events: none;
    transition: opacity var(--t-med), visibility var(--t-med);
    overflow: hidden;
}
.ranking-overlay.open { opacity: 1; visibility: visible; pointer-events: auto; }

.ranking-inner {
    position: relative; z-index: 2;
    width: 100%; max-width: 1100px; max-height: 92vh;
    display: flex; flex-direction: column; gap: 22px;
}
.ranking-overlay.open .ranking-inner { animation: winner-pop .6s cubic-bezier(.34, 1.56, .64, 1); }

.ranking-head {
    display: flex; justify-content: space-between; align-items: flex-start; gap: 16px;
}
.ranking-title {
    font-size: clamp(28px, 4vw, 54px);
    font-weight: 900; letter-spacing: 3px; line-height: 1;
    background: linear-gradient(135deg, #f5c842 0%, #ffb347 45%, var(--vermelho) 100%);
    -webkit-background-clip: text; background-clip: text;
    -webkit-text-fill-color: transparent;
}
.ranking-subtitle {
    font-size: clamp(12px, 1.4vw, 16px);
    letter-spacing: 4px; color: rgba(255, 255, 255, .55);
    text-transform: uppercase; font-weight: 500; margin-top: 8px;
}
.ranking-overlay .icon-btn {
    background: rgba(255, 255, 255, .08); color: #fff;
    border-color: rgba(255, 255, 255, .15); flex-shrink: 0;
}
.ranking-overlay .icon-btn:hover { background: rgba(201, 18, 18, .5); color: #fff; }

/* Pódio */
.podium {
    display: grid; grid-template-columns: 1fr 1fr 1fr;
    align-items: end; gap: 18px;
    max-width: 820px; margin: 0 auto; width: 100%;
}
.podium-place {
    display: flex; flex-direction: column; align-items: center; gap: 10px;
    animation: podium-rise .6s cubic-bezier(.34, 1.56, .64, 1) backwards;
}
.podium-place.empty { visibility: hidden; }
.podium-place.p1 { animation-delay: .15s; }
.podium-place.p2 { animation-delay: .3s; }
.podium-place.p3 { animation-delay: .45s; }
@keyframes podium-rise {
    from { transform: translateY(40px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.podium-medal {
    width: 64px; height: 64px; border-radius: 50%;
    display: grid; place-items: center;
    font-size: 28px; font-weight: 900;
    box-shadow: 0 8px 24px rgba(0, 0, 0, .4), inset 0 2px 4px rgba(255, 255, 255, .4);
}
.p1 .podium-medal { background: linear-gradient(135deg, #ffe17a, #f5c842, #d49b22); color: #5a3d00; width: 78px; height: 78px; font-size: 36px; }
.p2 .podium-medal { background: linear-gradient(135deg, #eef1f4, #c3cad1, #9aa3ab); color: #3a4147; }
.p3 .podium-medal { background: linear-gradient(135deg, #f0b083, #cd7f4e, #a85f33); color: #3d1e08; }

.podium-name {
    font-size: clamp(15px, 1.8vw, 22px);
    font-weight: 700; color: #fff; text-align: center;
    max-width: 100%; word-break: break-word; line-height: 1.15;
}
.podium-prize {
    font-size: 12px; color: #f5c842; font-weight: 600;
    text-align: center; letter-spacing: .3px;
}
.podium-bar {
    width: 100%; border-radius: 14px 14px 0 0;
    display: grid; place-items: start center; padding-top: 12px;
    font-size: 38px; font-weight: 900; color: rgba(255, 255, 255, .85);
    border: 1px solid rgba(255, 255, 255, .08); border-bottom: none;
}
.p1 .podium-bar { height: 150px; background: linear-gradient(180deg, rgba(245, 200, 66, .35), rgba(245, 200, 66, .06)); }
.p2 .podium-bar { height: 110px; background: linear-gradient(180deg, rgba(195, 202, 209, .3), rgba(195, 202, 209, .05)); }
.p3 .podium-bar { height: 82px; background: linear-gradient(180deg, rgba(205, 127, 78, .3), rgba(205, 127, 78, .05)); }

/* Restante (4º em diante) */
.ranking-rest {
    display: flex; flex-direction: column; gap: 8px;
    overflow-y: auto; padding-right: 6px;
    max-width: 820px; margin: 0 auto; width: 100%;
}
.ranking-rest:empty { display: none; }
.ranking-rest::-webkit-scrollbar { width: 6px; }
.ranking-rest::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, .15); border-radius: 3px; }
.rank-row {
    display: flex; align-items: center; gap: 16px;
    background: rgba(255, 255, 255, .05);
    border: 1px solid rgba(255, 255, 255, .08);
    border-radius: var(--radius-md); padding: 12px 18px;
}
.rank-pos { font-size: 18px; font-weight: 800; color: #f5c842; min-width: 38px; text-align: center; }
.rank-name { font-size: 16px; font-weight: 600; color: #fff; flex: 1; min-width: 0; }
.rank-prize { font-size: 12px; color: #f5c842; font-weight: 600; flex-shrink: 0; }

.ranking-foot {
    display: flex; justify-content: space-between; align-items: center; gap: 16px;
    border-top: 1px solid rgba(255, 255, 255, .1); padding-top: 18px;
}
.ranking-total { color: rgba(255, 255, 255, .6); font-size: 14px; font-weight: 500; letter-spacing: 1px; }
.ranking-overlay .btn-ghost { background: rgba(255, 255, 255, .08); border-color: rgba(255, 255, 255, .15); color: #fff; }
.ranking-overlay .btn-ghost:hover { background: rgba(255, 255, 255, .16); color: #fff; }

.ranking-empty { text-align: center; color: rgba(255, 255, 255, .5); padding: 60px 20px; font-size: 16px; }
.ranking-empty svg { width: 56px; height: 56px; opacity: .4; margin: 0 auto 16px; }

/* ========== RESPONSIVE ========== */
@media (max-width: 1100px) {
    .main {
        grid-template-columns: 1fr;
        grid-template-rows: auto auto;
        overflow-y: auto;
    }
    .ball { width: min(280px, 35vh); height: min(280px, 35vh); }
    .podium { gap: 12px; }
    .p1 .podium-bar { height: 120px; }
    .p2 .podium-bar { height: 90px; }
    .p3 .podium-bar { height: 66px; }
}

@media (max-width: 640px) {
    .header { padding: 12px 16px; }
    .brand-text h1 { font-size: 14px; letter-spacing: 1.5px; }
    .brand-text span { font-size: 9px; }
    .brand-mark { width: 42px; height: 42px; font-size: 18px; }
    .main { padding: 44px 16px 16px; gap: 16px; }
    .main::before { height: 32px; background-size: auto 32px; }
    .display-card { padding: 18px; }
    .actions { grid-template-columns: 1fr; }
    .actions-secondary { grid-template-columns: 1fr; }
    .btn kbd { display: none; }
    .modal { padding: 22px; }
    .modal-title { font-size: 32px; letter-spacing: 4px; }

    /* Banner do ganhador */
    .winner-banner { flex-wrap: wrap; gap: 12px; padding: 12px 16px; }
    .wb-info { flex-basis: 60%; }
    .wb-expand { display: none; }

    /* Overlay de celebração */
    .winner-overlay-actions { flex-direction: column; width: 100%; }
    .winner-overlay-actions .btn { width: 100%; }

    /* Ranking / pódio */
    .ranking-overlay { padding: 18px; }
    .podium { gap: 8px; }
    .podium-medal { width: 48px; height: 48px; font-size: 22px; }
    .p1 .podium-medal { width: 56px; height: 56px; font-size: 26px; }
    .podium-bar { font-size: 26px; }
    .p1 .podium-bar { height: 96px; }
    .p2 .podium-bar { height: 72px; }
    .p3 .podium-bar { height: 54px; }
}
