:root {
    --bg: #0f1221;
    --panel: #1a1d36;
    --panel-2: #252a4a;
    --text: #eef0ff;
    --muted: #9aa0c7;
    --accent: #ff5c7a;
    --accent-2: #5cc8ff;
    --good: #58d68d;
    --danger: #ff4d6d;
    --border: #2d325a;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
    margin: 0;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    background: radial-gradient(1200px 800px at 20% -10%, #1b2050 0%, var(--bg) 55%);
    color: var(--text);
    height: 100%;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

header {
    text-align: center;
    padding: 0.5rem 1rem 0.35rem;
    flex-shrink: 0;
}

h1 {
    margin: 0;
    font-size: clamp(1.3rem, 2.5vw, 2rem);
    letter-spacing: 0.5px;
    background: linear-gradient(90deg, var(--accent), var(--accent-2));
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

.tagline {
    margin: 0.1rem 0 0;
    color: var(--muted);
    font-size: 0.8rem;
}

main {
    display: grid;
    grid-template-columns: minmax(180px, 0.65fr) minmax(0, 2fr) minmax(220px, 0.65fr);
    gap: 0.75rem;
    max-width: 1600px;
    width: 100%;
    margin: 0 auto;
    padding: 0.5rem 1rem;
    flex: 1;
    min-height: 0;
    align-items: stretch;
    overflow: hidden;
}

@media (max-width: 1100px) {
    main { grid-template-columns: minmax(160px, 0.7fr) minmax(0, 1.8fr) minmax(180px, 0.7fr); }
}

@media (max-width: 900px) {
    body { overflow-y: auto; }
    main { grid-template-columns: 1fr; overflow: visible; }
}

.recent-panel {
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
}

.recent-panel h2 { margin: 0 0 0.15rem; font-size: 0.95rem; }
.recent-panel .hint { margin: 0 0 0.4rem; font-size: 0.78rem; }

.recent-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding-right: 0.5rem;
    scrollbar-width: thin;
    scrollbar-color: var(--accent) var(--panel);
}

.recent-list::-webkit-scrollbar { width: 8px; }
.recent-list::-webkit-scrollbar-track { background: var(--panel); border-radius: 4px; }
.recent-list::-webkit-scrollbar-thumb {
    background: linear-gradient(var(--accent), #ff8a5c);
    border-radius: 4px;
}

.recent-empty {
    color: var(--muted);
    font-style: italic;
    margin: 0;
}

.recent-card {
    background: linear-gradient(135deg, #2a1a2c, #1a1d36);
    border: 2px solid var(--accent);
    border-radius: 12px;
    padding: 0.75rem 1rem;
    text-align: center;
    box-shadow: 0 6px 20px rgba(0,0,0,0.35), 0 0 16px rgba(255,92,122,0.15);
    animation: recent-in 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.recent-card.fading {
    opacity: 0.55;
    border-color: #6a3048;
    box-shadow: 0 4px 12px rgba(0,0,0,0.25);
}

.recent-card .modal-label {
    font-size: 0.7rem;
    letter-spacing: 2px;
    margin-bottom: 0.25rem;
}

.recent-card .recent-name {
    font-size: clamp(1rem, 2.2vw, 1.4rem);
    font-weight: 800;
    color: var(--text);
    word-break: break-word;
}

.recent-card .recent-sub {
    margin-top: 0.2rem;
    color: var(--muted);
    font-size: 0.75rem;
}

@keyframes recent-in {
    0% { transform: scale(0.7) translateY(-8px); opacity: 0; }
    100% { transform: scale(1) translateY(0); opacity: 1; }
}


.wheel-panel {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.4rem;
    min-height: 0;
    overflow: hidden;
    justify-content: center;
}

.wheel-wrap {
    position: relative;
    width: min(100%, min(700px, calc(100vh - 200px)));
    aspect-ratio: 1 / 1;
    flex-shrink: 1;
    min-height: 0;
}

#wheel {
    width: 100%;
    height: 100%;
    display: block;
    border-radius: 50%;
    box-shadow: 0 20px 60px rgba(0,0,0,0.5), inset 0 0 0 8px #0f1221;
    background: #0f1221;
}

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

button {
    font: inherit;
    font-weight: 700;
    letter-spacing: 1px;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 8px;
    background: linear-gradient(135deg, var(--accent), #ff8a5c);
    color: white;
    cursor: pointer;
    transition: transform 0.1s ease, filter 0.2s ease;
    box-shadow: 0 6px 20px rgba(255,92,122,0.35);
}

button:hover:not(:disabled) { filter: brightness(1.1); }
button:active:not(:disabled) { transform: translateY(1px); }
button:disabled { opacity: 0.5; cursor: not-allowed; filter: grayscale(0.4); }

button.secondary {
    background: var(--panel-2);
    color: var(--text);
    box-shadow: none;
    border: 1px solid var(--border);
}

.spin-row {
    display: flex;
    gap: 0.75rem;
    align-items: center;
    flex-wrap: wrap;
    justify-content: center;
}

#spinBtn {
    font-size: 1.1rem;
    padding: 0.7rem 2.2rem;
}

button.danger {
    background: linear-gradient(135deg, var(--danger), #c1272d);
    box-shadow: 0 6px 20px rgba(255,77,109,0.35);
    font-size: 1rem;
    padding: 0.7rem 1.5rem;
}

button.neutral {
    background: linear-gradient(135deg, #7aa2f7, #bb9af7);
    box-shadow: 0 6px 20px rgba(122,162,247,0.3);
    font-size: 1rem;
    padding: 0.7rem 1.5rem;
}

.custom-spin {
    display: flex;
    gap: 0.25rem;
    align-items: stretch;
}

.custom-spin input {
    width: 70px;
    background: var(--panel-2);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 0.5rem 0.6rem;
    border-radius: 8px;
    font: inherit;
    font-size: 0.95rem;
    text-align: center;
    -moz-appearance: textfield;
}

.custom-spin input::-webkit-outer-spin-button,
.custom-spin input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.custom-spin input:focus { outline: 2px solid var(--accent-2); outline-offset: 1px; }

.multi-row {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    justify-content: center;
}

button.multi {
    background: linear-gradient(135deg, var(--accent-2), #6a8cff);
    box-shadow: 0 4px 14px rgba(92,200,255,0.3);
    font-size: 0.85rem;
    padding: 0.45rem 0.9rem;
    letter-spacing: 0.5px;
}

.status {
    min-height: 1.4em;
    margin: 0;
    color: var(--muted);
    font-size: 1.05rem;
    text-align: center;
}

.status.winner { color: var(--good); font-weight: 700; font-size: 1.4rem; }
.status.eliminated { color: var(--accent); font-weight: 600; }

.controls {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 0.75rem 1rem;
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow-y: auto;
}

.controls h2, .controls h3 {
    margin: 0 0 0.3rem;
}

.controls h2 { font-size: 1rem; }
.controls h3 { margin-top: 0.6rem; font-size: 0.9rem; color: var(--muted); }

.hint { color: var(--muted); margin: 0 0 0.35rem; font-size: 0.8rem; }

textarea {
    width: 100%;
    background: var(--panel-2);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 0.75rem;
    border-radius: 8px;
    font: inherit;
    font-size: 0.95rem;
    resize: vertical;
}

textarea:focus { outline: 2px solid var(--accent-2); outline-offset: 1px; }

.btn-row {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.75rem;
}

.name-list {
    list-style: none;
    padding: 0;
    margin: 0.2rem 0 0;
    max-height: 80px;
    overflow-y: auto;
    display: flex;
    flex-wrap: wrap;
    gap: 0.3rem;
}

.name-list li {
    background: var(--panel-2);
    border: 1px solid var(--border);
    padding: 0.25rem 0.6rem;
    border-radius: 999px;
    font-size: 0.9rem;
}

.name-list.eliminated {
    list-style: decimal inside;
    display: block;
}

.name-list.eliminated li {
    display: inline-block;
    margin: 0 0.35rem 0.35rem 0;
    text-decoration: line-through;
    color: var(--muted);
    border-color: #3a2040;
    background: #241a2c;
}

.hint-inline {
    color: var(--muted);
    font-weight: 400;
    font-size: 0.8rem;
}

/* Footer */
footer {
    text-align: center;
    padding: 0.35rem 1rem;
    border-top: 1px solid var(--border);
    flex-shrink: 0;
}

.footer-inner {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.6rem;
    flex-wrap: wrap;
}

.footer-text {
    color: var(--muted);
    font-size: 0.9rem;
}

.footer-link {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    color: #9147ff;
    text-decoration: none;
    font-weight: 700;
    font-size: 0.95rem;
    transition: color 0.2s;
}

.footer-link:hover { color: #b57bff; }

.twitch-icon {
    width: 1em;
    height: 1em;
    flex-shrink: 0;
}

.live-wrap {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    background: rgba(255, 40, 40, 0.15);
    border: 1px solid rgba(255, 40, 40, 0.4);
    border-radius: 999px;
    padding: 0.2rem 0.6rem;
}

.live-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #ff2828;
    animation: pulse-live 1.4s ease-in-out infinite;
    flex-shrink: 0;
}

.live-label {
    font-size: 0.7rem;
    font-weight: 800;
    letter-spacing: 1.5px;
    color: #ff6060;
}

@keyframes pulse-live {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.4; transform: scale(0.75); }
}

/* Elimination popup modal */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(5, 8, 20, 0.65);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
    z-index: 1000;
    backdrop-filter: blur(4px);
}

.modal.open {
    opacity: 1;
    pointer-events: auto;
}

.modal-card {
    background: linear-gradient(135deg, #2a1a2c, #1a1d36);
    border: 2px solid var(--accent);
    border-radius: 16px;
    padding: 2rem 3rem;
    text-align: center;
    box-shadow: 0 20px 80px rgba(0,0,0,0.6), 0 0 40px rgba(255,92,122,0.3);
    transform: scale(0.8);
    transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
    min-width: 280px;
    max-width: 90vw;
    cursor: pointer;
}

.modal.open .modal-card {
    transform: scale(1);
}

.modal-card.winner {
    border-color: var(--good);
    box-shadow: 0 20px 80px rgba(0,0,0,0.6), 0 0 40px rgba(88,214,141,0.4);
}

.modal-label {
    font-size: 0.85rem;
    letter-spacing: 3px;
    text-transform: uppercase;
    color: var(--accent);
    margin-bottom: 0.5rem;
    font-weight: 700;
}

.modal-card.winner .modal-label { color: var(--good); }

.modal-name {
    font-size: clamp(1.8rem, 5vw, 2.6rem);
    font-weight: 800;
    color: var(--text);
    word-break: break-word;
}

.modal-sub {
    margin-top: 0.75rem;
    color: var(--muted);
    font-size: 0.95rem;
}
