/*
 * Roleta — roleta.php.
 * Usa gerador.css e sorteio.css; aqui ficam a roleta, a seta e o resultado.
 */

.wheel-layout {
    display: grid;
    grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr);
    gap: 20px;
    align-items: start;
}

.wheel-stage {
    text-align: center;
}

/* Roleta */
.wheel {
    position: relative;
    width: 100%;
    max-width: 480px;
    margin: 0 auto;
    padding-top: 14px;
}

.wheel canvas {
    display: block;
    width: 100%;
    aspect-ratio: 1;
    border-radius: 50%;
    cursor: grab;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
    filter: drop-shadow(0 12px 24px rgba(10, 60, 110, .22));
}

.wheel canvas.is-dragging {
    cursor: grabbing;
}

.wheel.is-spinning canvas {
    cursor: default;
}

/* Seta no topo */
.wheel__pointer {
    position: absolute;
    top: 0;
    left: 50%;
    z-index: 2;
    width: 34px;
    height: 42px;
    margin-left: -17px;
    background: var(--cta);
    clip-path: polygon(0 0, 100% 0, 50% 100%);
    filter: drop-shadow(0 3px 3px rgba(0, 0, 0, .25));
    transform-origin: 50% 0;
}

.wheel__pointer.is-tick {
    animation: wheel-tick .12s ease-out;
}

@keyframes wheel-tick {
    40% { transform: rotate(-14deg); }
}

/* Botão central */
.wheel .wheel__hub {
    position: absolute;
    top: calc(50% + 7px);
    left: 50%;
    z-index: 2;
    width: 22%;
    height: auto;
    aspect-ratio: 1;
    margin: 0;
    padding: 0;
    border: 4px solid #fff;
    border-radius: 50%;
    background: #1d2b3a;
    color: #fff;
    font: inherit;
    font-size: clamp(12px, 3.4vw, 16px);
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: .04em;
    cursor: pointer;
    box-shadow: 0 6px 16px rgba(0, 0, 0, .3);
    transform: translate(-50%, -50%);
    transition: transform .15s ease, background-color .15s ease;
}

.wheel .wheel__hub:hover:not(:disabled) {
    background: var(--brand-dark);
    transform: translate(-50%, -50%) scale(1.05);
}

.wheel .wheel__hub:disabled {
    cursor: default;
}

.wheel .wheel__hub:focus-visible {
    outline: none;
    box-shadow: 0 0 0 4px rgba(10, 127, 209, .45);
}

.wheel-hint {
    margin-top: 12px;
    text-align: center;
}

.wheel-hint.is-winner {
    color: var(--brand-dark);
    font-size: 20px;
    font-weight: 800;
    overflow-wrap: anywhere;
    animation: draw-pop .3s ease both;
}

/* Opções */
.wheel-options textarea {
    min-height: 260px;
}

.wheel-tools {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.list-field + .wheel-tools {
    margin-top: 12px;
}

/* Resultado */
.wheel-layout + .draw-result {
    margin: 24px 0 0;
}

.wheel-winner {
    margin: 0;
    padding: 18px 16px;
    border-radius: 14px;
    background: var(--brand-soft);
    color: var(--brand-dark);
    font-size: clamp(1.5rem, 5vw, 2.2rem);
    font-weight: 800;
    line-height: 1.2;
    text-align: center;
    overflow-wrap: anywhere;
}

.wheel-winner.is-new {
    animation: draw-pop .3s ease both;
}

/* Histórico e contagem */
.wheel-history-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr);
    gap: 20px;
    margin-top: 20px;
}

.wheel-history h3 {
    margin: 0 0 10px;
    color: var(--ink-soft);
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .04em;
}

.wheel-history h3 span {
    font-weight: 600;
    text-transform: none;
    letter-spacing: 0;
}

.wheel-history__list,
.wheel-stats {
    max-height: 340px;
    margin: 0;
    padding: 0;
    overflow-y: auto;
    list-style: none;
}

.wheel-history__item {
    display: grid;
    grid-template-columns: auto auto minmax(0, 1fr);
    align-items: center;
    gap: 2px 10px;
    padding: 8px 10px;
    border-radius: 10px;
}

.wheel-history__item + .wheel-history__item {
    border-top: 1px solid var(--line);
}

.wheel-history__item.is-latest {
    background: var(--brand-soft);
}

.wheel-history__num {
    min-width: 34px;
    color: var(--ink-soft);
    font-size: 12px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.wheel-history__dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--dot);
}

.wheel-history__item strong {
    color: var(--ink);
    font-size: 15px;
    overflow-wrap: anywhere;
}

.wheel-history__item small {
    grid-column: 3;
    color: var(--ink-soft);
    font-size: 12px;
}

.wheel-stats__row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 4px 10px;
    padding: 6px 0;
}

.wheel-stats__name {
    color: var(--ink);
    font-size: 14px;
    font-weight: 700;
    overflow-wrap: anywhere;
}

.wheel-stats__value {
    color: var(--ink-soft);
    font-size: 13px;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.wheel-stats__bar {
    grid-column: 1 / -1;
    height: 8px;
    border-radius: 999px;
    background: #eef3f8;
    overflow: hidden;
}

.wheel-stats__bar::before {
    content: '';
    display: block;
    width: var(--size);
    height: 100%;
    border-radius: inherit;
    background: var(--dot);
}

@media (max-width: 820px) {
    .wheel-layout {
        grid-template-columns: minmax(0, 1fr);
    }

    .wheel-options textarea {
        min-height: 180px;
    }

    .wheel-history-grid {
        grid-template-columns: minmax(0, 1fr);
    }
}

@media (prefers-reduced-motion: reduce) {
    .wheel__pointer.is-tick,
    .wheel-winner.is-new {
        animation: none;
    }
}
