.random-assignment-toolkit {
    position: relative;
}

.random-assignment-toolkit__layout {
    display: grid;
    gap: 1rem;
}

.random-assignment-toolkit__config,
.random-assignment-toolkit__stage-column,
.random-assignment-list-editor__composer,
.random-assignment-settings-grid,
.random-assignment-mode-grid {
    display: grid;
    gap: 1rem;
}

.random-assignment-mode-grid {
    grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr));
}

.random-assignment-toolkit__config {
    grid-template-columns: 1fr;
}

.random-assignment-mode-card {
    display: grid;
    gap: 0.25rem;
    border: 1px solid var(--line);
    border-radius: 1rem;
    background: var(--surface);
    color: var(--ink);
    padding: 0.9rem 1rem;
    text-align: left;
    transition: border-color 180ms ease, box-shadow 180ms ease, background-color 180ms ease;
}

.random-assignment-mode-card.is-active,
.random-assignment-mode-card:hover,
.random-assignment-mode-card:focus-visible {
    border-color: var(--brand);
    box-shadow: none;
    background: var(--surface-strong);
}

.random-assignment-mode-card small {
    color: var(--muted);
}

.random-assignment-settings-grid {
    grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr));
}

.random-assignment-setting {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.random-assignment-stage {
    min-height: 14rem;
    border-radius: 1rem;
    border: 1px solid var(--line);
    background: var(--surface);
    padding: 1rem;
    display: grid;
    place-items: center;
    overflow: hidden;
}

.random-stage-wheel,
.random-stage-cards,
.random-stage-mystery,
.random-stage-slot,
.random-stage-hat {
    width: 100%;
    display: grid;
    gap: 1rem;
}

.random-stage-wheel {
    grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr));
}

.random-stage-wheel--single {
    grid-template-columns: minmax(12rem, 16rem) minmax(0, 1fr);
    align-items: center;
}

.random-stage-mystery,
.random-stage-slot,
.random-stage-hat,
.random-stage-cards {
    grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr));
}

.random-wheel,
.random-card,
.random-stage-instant,
.random-mystery-box,
.random-slot,
.random-hat {
    border-radius: 1rem;
    border: 1px solid var(--line);
    background: #fff;
    padding: 1rem;
    display: grid;
    gap: 0.5rem;
    min-height: 10rem;
    align-content: center;
    text-align: center;
}

.random-wheel-action {
    display: grid;
    place-items: center;
    cursor: pointer;
    min-width: 0;
}

.random-wheel-action:focus-visible {
    outline: 2px solid var(--brand);
    outline-offset: 6px;
    border-radius: 1rem;
}

.random-wheel-participant {
    display: grid;
    gap: 0.4rem;
    align-content: center;
    justify-items: start;
    text-align: left;
    padding: 1.25rem;
    border: 1px solid var(--line);
    border-radius: 1rem;
    background: #fff;
}

.random-wheel-participant span {
    color: var(--muted);
    font-size: 0.85rem;
}

.random-wheel-participant strong {
    font-size: 1.35rem;
    line-height: 1.2;
}

.random-wheel-participant--active strong,
.random-wheel-participant--result strong {
    color: var(--brand-dark);
}

.random-wheel.is-active,
.random-card.is-flipping {
    animation: random-assignment-pulse 0.65s ease-in-out infinite alternate;
}

.random-wheel.is-result,
.random-card.is-result,
.random-mystery-box.is-result,
.random-slot.is-result,
.random-hat.is-result,
.random-stage-instant strong {
    color: var(--accent);
}

.random-stage-instant {
    width: 100%;
}

.random-wheel__disc {
    position: relative;
    margin: 0 auto;
    width: min(22rem, 70vw);
    height: min(22rem, 70vw);
    min-width: 0;
    border-radius: 50%;
    border: 8px solid rgba(15, 118, 110, 0.14);
    background:
        conic-gradient(
            from 0deg,
            rgba(15, 118, 110, 0.07) 0deg 45deg,
            rgba(217, 119, 6, 0.08) 45deg 90deg,
            rgba(15, 118, 110, 0.11) 90deg 135deg,
            rgba(217, 119, 6, 0.06) 135deg 180deg,
            rgba(15, 118, 110, 0.08) 180deg 225deg,
            rgba(217, 119, 6, 0.1) 225deg 270deg,
            rgba(15, 118, 110, 0.06) 270deg 315deg,
            rgba(217, 119, 6, 0.08) 315deg 360deg
        );
    box-shadow: inset 0 0 0 1px rgba(17, 65, 61, 0.05);
    transform: rotate(0deg);
}

.random-wheel__disc--spin {
    animation: random-wheel-spin 2.2s cubic-bezier(0.1, 0.8, 0.16, 1) forwards;
}

.random-wheel__center {
    position: absolute;
    inset: 50%;
    width: 5.25rem;
    height: 5.25rem;
    transform: translate(-50%, -50%);
    border-radius: 50%;
    background: var(--brand);
    color: white;
    display: grid;
    place-items: center;
    padding: 0.65rem;
    text-align: center;
    font-weight: 700;
    font-size: 0.78rem;
    box-shadow: none;
    z-index: 2;
}

.random-wheel__pointer {
    position: absolute;
    top: -1.2rem;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 1rem solid transparent;
    border-right: 1rem solid transparent;
    border-top: 1.5rem solid var(--brand-dark);
    z-index: 3;
}

.random-wheel__item {
    position: absolute;
    left: 50%;
    top: 50%;
    width: 5.5rem;
    font-size: 0.78rem;
    line-height: 1.2;
    text-align: center;
    color: var(--ink);
    z-index: 1;
}

.random-wheel__item.is-selected {
    font-weight: 800;
    color: var(--brand-dark);
}

.random-card {
    position: relative;
    min-height: 10rem;
    perspective: 1200px;
    overflow: hidden;
}

.random-card__face {
    position: absolute;
    inset: 1.25rem;
    border-radius: 0.9rem;
    display: grid;
    place-content: center;
    gap: 0.6rem;
    text-align: center;
    backface-visibility: hidden;
    transition: transform 700ms ease;
}

.random-card__face--front {
    background: #fff;
    transform: rotateY(180deg);
}

.random-card__face--back {
    background: var(--brand);
    color: white;
    transform: rotateY(0deg);
}

.random-card.is-flipping .random-card__face--front,
.random-card.is-result .random-card__face--front {
    transform: rotateY(0deg);
}

.random-card.is-flipping .random-card__face--back,
.random-card.is-result .random-card__face--back {
    transform: rotateY(-180deg);
}

.random-mystery-box {
    position: relative;
    min-height: 10rem;
    overflow: hidden;
}

.random-mystery-box__lid {
    position: absolute;
    top: 1.15rem;
    left: 1.2rem;
    right: 1.2rem;
    height: 2rem;
    border-radius: 0.75rem;
    background: var(--brand);
    transform-origin: left bottom;
    box-shadow: none;
}

.random-mystery-box__body {
    position: absolute;
    inset: 3rem 1.2rem 1.2rem;
    border-radius: 0.9rem;
    background: #fff;
    display: grid;
    place-content: center;
    gap: 0.5rem;
    text-align: center;
    padding: 1rem;
}

.random-mystery-box.is-opening .random-mystery-box__lid,
.random-mystery-box.is-result .random-mystery-box__lid {
    animation: random-box-open 1.1s ease forwards;
}

.random-slot {
    min-height: 10rem;
}

.random-slot__window {
    position: relative;
    height: 8rem;
    overflow: hidden;
    border-radius: 0.9rem;
    border: 1px solid rgba(15, 65, 61, 0.12);
    background: #fff;
}

.random-slot__window::before,
.random-slot__window::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    height: 1.8rem;
    z-index: 1;
}

.random-slot__window::before {
    top: 0;
    background: linear-gradient(180deg, rgba(255,253,248,0.92), transparent);
}

.random-slot__window::after {
    bottom: 0;
    background: linear-gradient(0deg, rgba(255,253,248,0.92), transparent);
}

.random-slot__reel {
    display: grid;
    gap: 0.45rem;
    padding: 0.85rem 0.75rem;
}

.random-slot__reel span {
    display: grid;
    place-items: center;
    min-height: 2.1rem;
    border-radius: 0.75rem;
    background: rgba(15, 118, 110, 0.06);
    font-weight: 600;
}

.random-slot__reel.is-spinning {
    animation: random-slot-spin 1.4s cubic-bezier(0.16, 0.82, 0.18, 1);
}

.random-hat {
    position: relative;
    min-height: 10rem;
    overflow: hidden;
}

.random-hat__ticket {
    position: absolute;
    left: 50%;
    top: 1.1rem;
    transform: translateX(-50%);
    min-width: 10rem;
    max-width: calc(100% - 2rem);
    padding: 0.8rem 1rem;
    border-radius: 0.8rem;
    background: #fff;
    box-shadow: none;
    text-align: center;
    font-weight: 700;
}

.random-hat__shape {
    position: absolute;
    left: 50%;
    bottom: 1.2rem;
    transform: translateX(-50%);
    width: 9rem;
    height: 4.8rem;
    border-radius: 0 0 4rem 4rem;
    background: var(--brand);
}

.random-hat__shape::before {
    content: "";
    position: absolute;
    left: -1.2rem;
    right: -1.2rem;
    bottom: -0.8rem;
    height: 1.2rem;
    border-radius: 999px;
    background: var(--brand-dark);
}

.random-hat.is-drawing .random-hat__ticket,
.random-hat.is-result .random-hat__ticket {
    animation: random-hat-draw 1s ease forwards;
}

.random-assignment-result {
    border-radius: 1rem;
    border: 1px solid var(--line);
    background: var(--surface);
    padding: 1rem;
}

.random-assignment-pools {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.random-assignment-history-table {
    overflow-x: auto;
}

.random-assignment-history-table table {
    width: 100%;
    border-collapse: collapse;
}

.random-assignment-history-table th,
.random-assignment-history-table td {
    border-bottom: 1px solid var(--line);
    padding: 0.75rem;
    text-align: left;
}

.random-assignment-stage-panel .tool-form__actions {
    align-items: stretch;
}

.random-assignment-stage-panel .tool-form__actions button {
    min-width: 0;
}

.random-assignment-list-editor__inline,
.random-assignment-entry-row {
    display: grid;
    gap: 0.75rem;
    grid-template-columns: minmax(0, 1fr) auto;
}

.random-assignment-list-editor__entries {
    display: grid;
    gap: 0.75rem;
    max-height: 22rem;
    overflow: auto;
}

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

.random-assignment-confetti span {
    position: absolute;
    top: 0;
    width: 0.5rem;
    height: 0.8rem;
    border-radius: 999px;
    background: var(--brand);
    animation: random-assignment-confetti 1.6s ease forwards;
}

@keyframes random-assignment-pulse {
    from {
        transform: scale(0.985);
        box-shadow: 0 0 0 rgba(217, 119, 6, 0);
    }

    to {
        transform: scale(1.015);
        box-shadow: 0 8px 18px rgba(15, 118, 110, 0.08);
    }
}

@keyframes random-assignment-confetti {
    from {
        transform: translateY(0) rotate(0deg);
        opacity: 1;
    }

    to {
        transform: translateY(18rem) rotate(240deg);
        opacity: 0;
    }
}

@keyframes random-wheel-spin {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(var(--wheel-target-rotation, 1800deg));
    }
}

@keyframes random-box-open {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(-28deg) translateY(-0.7rem);
    }
}

@keyframes random-slot-spin {
    0% {
        transform: translateY(0);
    }

    100% {
        transform: translateY(-10rem);
    }
}

@keyframes random-hat-draw {
    0% {
        transform: translateX(-50%) translateY(2.5rem);
        opacity: 0;
    }

    65% {
        transform: translateX(-50%) translateY(-0.35rem);
        opacity: 1;
    }

    100% {
        transform: translateX(-50%) translateY(0);
        opacity: 1;
    }
}

@media (min-width: 72rem) {
    .random-assignment-toolkit__config {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        align-items: start;
    }
}

@media (min-width: 96rem) {
    .random-assignment-toolkit__layout {
        grid-template-columns: minmax(0, 1.05fr) minmax(0, 0.95fr);
        align-items: start;
    }

    .random-assignment-toolkit__config {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 52rem) {
    .random-stage-wheel--single {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .random-wheel-participant {
        justify-items: center;
        text-align: center;
    }

    .random-assignment-stage {
        min-height: unset;
        padding: 0.85rem;
    }

    .random-stage-wheel,
    .random-stage-cards,
    .random-stage-mystery,
    .random-stage-slot,
    .random-stage-hat {
        grid-template-columns: 1fr;
    }

    .random-wheel__disc {
        width: min(16.5rem, calc(100vw - 8rem));
        height: min(16.5rem, calc(100vw - 8rem));
    }

    .random-wheel__item {
        width: 3.85rem;
        font-size: 0.65rem;
    }

    .random-wheel__center {
        width: 3.7rem;
        height: 3.7rem;
        font-size: 0.7rem;
        padding: 0.45rem;
    }

    .random-assignment-stage-panel .tool-form__actions {
        grid-template-columns: 1fr;
    }

    .random-assignment-stage-panel .tool-form__actions button {
        width: 100%;
    }
}

@media (max-width: 34rem) {
    .random-assignment-toolkit__layout {
        gap: 0.85rem;
    }

    .random-assignment-stage {
        padding: 0.7rem;
    }

    .random-wheel-participant {
        padding: 0.85rem;
    }

    .random-wheel-participant strong {
        font-size: 1.05rem;
    }

    .random-wheel__disc {
        width: min(14rem, calc(100vw - 7rem));
        height: min(14rem, calc(100vw - 7rem));
        border-width: 5px;
    }

    .random-wheel__item {
        width: 3.2rem;
        font-size: 0.58rem;
    }

    .random-wheel__pointer {
        top: -0.95rem;
        border-left-width: 0.75rem;
        border-right-width: 0.75rem;
        border-top-width: 1.15rem;
    }

    .random-wheel__center {
        width: 3.15rem;
        height: 3.15rem;
        font-size: 0.62rem;
    }

    .random-slot__window {
        height: 6.8rem;
    }

    .random-hat__ticket {
        min-width: 0;
        width: calc(100% - 1rem);
    }
}

@media (prefers-reduced-motion: reduce) {
    .random-assignment-mode-card,
    .random-wheel.is-active,
    .random-card.is-flipping,
    .random-mystery-box.is-opening .random-mystery-box__lid,
    .random-slot__reel.is-spinning,
    .random-hat.is-drawing .random-hat__ticket,
    .random-assignment-confetti span {
        animation: none !important;
        transition: none !important;
    }
}
