:root {
    --bg: #0f1720;
    --panel: rgba(23, 35, 48, 0.92);
    --panel-soft: rgba(29, 43, 57, 0.92);
    --text: #f5f8fb;
    --muted: #a9bac8;
    --line: rgba(255, 255, 255, 0.14);
    --accent: #4ecdc4;
    --danger: #ef476f;
    --gold: #ffd166;
}

* { box-sizing: border-box; }

* {
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 209, 102, 0.8) rgba(17, 27, 37, 0.82);
}

*::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

*::-webkit-scrollbar-track {
    background: rgba(17, 27, 37, 0.82);
    border-radius: 999px;
}

*::-webkit-scrollbar-thumb {
    border: 2px solid rgba(17, 27, 37, 0.82);
    border-radius: 999px;
    background: linear-gradient(180deg, var(--gold), var(--danger));
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: Poppins, Arial, sans-serif;
    color: var(--text);
    background:
        radial-gradient(circle at 16% 18%, rgba(255, 107, 107, 0.18), transparent 30%),
        radial-gradient(circle at 88% 12%, rgba(78, 205, 196, 0.14), transparent 28%),
        var(--bg);
}

.random-app {
    width: min(1360px, calc(100% - 32px));
    margin: 0 auto;
    padding: 28px 0 40px;
}

.random-header {
    margin-bottom: 20px;
}

.home-link {
    color: var(--accent);
    text-decoration: none;
    font-weight: 700;
}

h1, h2, p {
    margin: 0;
    letter-spacing: 0;
}

h1 {
    margin-top: 8px;
    font-size: clamp(2rem, 5vw, 3.4rem);
}

.random-header p {
    max-width: 760px;
    margin-top: 8px;
    color: var(--muted);
    line-height: 1.6;
}

.workspace {
    display: grid;
    grid-template-columns: minmax(360px, 0.95fr) minmax(360px, 1fr) minmax(280px, 0.75fr);
    gap: 16px;
    align-items: start;
}

.wheel-panel,
.input-panel,
.results-panel {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
    padding: 18px;
    min-width: 0;
}

.wheel-panel {
    display: grid;
    justify-items: center;
    gap: 18px;
}

.wheel-shell {
    position: relative;
    width: min(100%, 440px);
    aspect-ratio: 1;
    display: grid;
    place-items: center;
}

.wheel {
    position: relative;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    overflow: hidden;
    border: 8px solid var(--gold);
    box-shadow: 0 18px 50px rgba(0, 0, 0, 0.35), inset 0 0 36px rgba(0, 0, 0, 0.22);
    transform-origin: center;
    will-change: transform;
    background: #142231;
}

.wheel canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    display: block;
}

.wheel::after {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: 50%;
    background: radial-gradient(circle, transparent 0 28%, rgba(0, 0, 0, 0.16) 29% 100%);
    pointer-events: none;
}

.empty-wheel {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    padding: 28px;
    text-align: center;
    color: var(--muted);
    background: #142231;
    z-index: 2;
}

.wheel:not(.is-empty) .empty-wheel {
    display: none;
}

.wheel-center {
    position: absolute;
    width: 72px;
    height: 72px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    background: #fff;
    border: 5px solid var(--gold);
    z-index: 4;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}

.wheel-center img {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    object-fit: cover;
}

.pointer {
    position: absolute;
    top: -2px;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 18px solid transparent;
    border-right: 18px solid transparent;
    border-top: 42px solid var(--danger);
    z-index: 5;
    filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.42));
}

.controls,
.panel-heading,
.meta-row {
    display: flex;
    gap: 10px;
    align-items: center;
    justify-content: space-between;
}

.controls {
    width: 100%;
    justify-content: center;
    flex-wrap: wrap;
}

button {
    border: 0;
    border-radius: 8px;
    background: var(--accent);
    color: #09201e;
    padding: 12px 16px;
    font: inherit;
    font-weight: 700;
    cursor: pointer;
}

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

.danger-button {
    background: var(--danger);
    color: #fff;
}

.ghost-button {
    background: transparent;
    border: 1px solid var(--line);
    color: var(--text);
}

.sound-button {
    min-width: 112px;
}

.winner-display,
.counter {
    width: 100%;
    text-align: center;
    border-radius: 8px;
}

.winner-display {
    padding: 14px;
    background: rgba(255, 209, 102, 0.16);
    border: 1px solid rgba(255, 209, 102, 0.5);
    color: #ffe7a8;
    font-weight: 700;
}

.counter {
    color: var(--muted);
}

.panel-heading {
    margin-bottom: 12px;
}

textarea {
    width: 100%;
    min-height: 250px;
    resize: vertical;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 14px;
    background: #111b25;
    color: var(--text);
    font: inherit;
    line-height: 1.5;
    letter-spacing: 0;
}

.meta-row {
    margin: 10px 0 12px;
    color: var(--muted);
    font-size: 0.9rem;
}

.error-message {
    color: #ffd3d3;
}

.source-list,
.results-list {
    display: grid;
    gap: 8px;
    max-height: 360px;
    overflow: auto;
    padding-right: 4px;
}

.elimination-details {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.035);
    overflow: hidden;
}

.elimination-details summary {
    cursor: pointer;
    padding: 11px 12px;
    color: var(--muted);
    font-weight: 700;
    list-style: none;
}

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

.elimination-details summary::after {
    content: "▾";
    float: right;
    color: var(--gold);
    transition: transform 0.2s ease;
}

.elimination-details[open] summary::after {
    transform: rotate(180deg);
}

.elimination-details .source-list {
    max-height: 320px;
    padding: 0 10px 10px;
}

.source-item,
.results-list li {
    display: grid;
    grid-template-columns: 36px 1fr;
    gap: 10px;
    align-items: center;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel-soft);
    padding: 9px 10px;
}

.source-item.picked span:last-child {
    text-decoration: line-through;
    color: var(--muted);
}

.rank {
    display: grid;
    place-items: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.08);
    color: var(--gold);
    font-weight: 700;
}

.results-list {
    margin: 0;
    padding-left: 28px;
}

.results-list li {
    display: list-item;
    padding: 10px 12px;
}

.results-list span {
    font-weight: 700;
}

.results-list small {
    display: block;
    color: var(--muted);
    margin-top: 3px;
}

@media (max-width: 1120px) {
    .workspace {
        grid-template-columns: 1fr 1fr;
    }

    .results-panel {
        grid-column: 1 / -1;
    }
}

@media (max-width: 760px) {
    .random-app {
        width: min(100% - 20px, 1360px);
        padding-top: 12px;
    }

    .workspace {
        grid-template-columns: 1fr;
    }

    .wheel-shell {
        width: min(100%, 340px);
    }

    .wheel-center {
        width: 58px;
        height: 58px;
    }

    .wheel-center img {
        width: 42px;
        height: 42px;
    }

    .controls {
        display: grid;
        grid-template-columns: 1fr;
    }

    textarea {
        min-height: 210px;
    }
}

@media (max-width: 390px) {
    .wheel-shell {
        width: min(100%, 292px);
    }

    .panel-heading,
    .meta-row {
        align-items: flex-start;
        flex-direction: column;
    }
}
