/* Vòng quay Party — ưu tiên điện thoại */
:root {
    --ink: #2f3437;
    --muted: #6b7280;
    --btn: #45484d; /* xám đậm cho nút "Nhấn để xoay" */
    --card: rgba(255, 255, 255, 0.9);
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    min-height: 100%;
    overflow-x: hidden;
}

body {
    min-height: 100vh;
    min-height: 100dvh;
    font-family: "Nunito", "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
    color: var(--ink);
    background: radial-gradient(circle at 20% 10%, #fff7e6 0%, #fdeff4 45%, #eaf4ff 100%);
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    background-attachment: fixed;
    -webkit-tap-highlight-color: transparent;
}

.party-app {
    max-width: 1200px;
    margin: 0 auto;
    padding: max(10px, env(safe-area-inset-top)) 14px max(20px, env(safe-area-inset-bottom));
}

/* ----- Thanh trên ----- */
.party-top {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
}

.party-top-left {
    display: flex;
    gap: 6px;
}

.party-title {
    margin: 0;
    font-size: clamp(1.5rem, 5vw, 2.3rem);
    font-weight: 800;
    letter-spacing: 0.5px;
    color: #3a4047;
    text-align: center;
    white-space: nowrap;
}

.icon-btn {
    width: 40px;
    height: 40px;
    border: 0;
    border-radius: 12px;
    background: var(--card);
    color: var(--ink);
    font-size: 1.25rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    cursor: pointer;
}

/* ----- Bố cục ----- */
.party-main {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 340px;
    gap: 24px;
    align-items: start;
}

.wheel-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
}

/* ----- Vòng quay ----- */
.party-wheel {
    position: relative;
    width: min(92vw, 78vh, 680px);
    aspect-ratio: 1;
}

.party-wheel-svg {
    width: 100%;
    height: 100%;
    display: block;
    overflow: visible;
    filter: drop-shadow(0 10px 24px rgba(60, 40, 80, 0.18));
}

/* Nhóm hình được xoay quanh tâm vòng quay (500,500 trong viewBox) */
#wheel-rot {
    transform-box: view-box;
    transform-origin: 500px 500px;
    will-change: transform;
}

.party-wheel-svg text {
    font-family: "Nunito", "Segoe UI", system-ui, sans-serif;
    font-weight: 700;
    user-select: none;
}

.spin-btn {
    position: absolute;
    left: 50%;
    top: 50%;
    width: 24%;
    transform: translate(-50%, -60%);
    padding: 0;
    border: 0;
    background: none;
    cursor: pointer;
    transition: transform 0.15s ease;
    -webkit-user-select: none;
    user-select: none;
}

.spin-btn:active {
    transform: translate(-50%, -60%) scale(0.94);
}

.spin-btn:disabled {
    cursor: default;
}

.spin-btn-default {
    width: 100%;
    display: block;
    overflow: visible;
}

.spin-btn-shape {
    fill: var(--btn);
    stroke: #fff;
    stroke-width: 9;
    stroke-linejoin: round;
    filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.25));
}

.spin-btn-text {
    fill: #fff;
    font-size: 31px;
    font-weight: 800;
    text-anchor: middle;
    font-family: "Nunito", "Segoe UI", system-ui, sans-serif;
}

/* Ảnh nút quay do admin tải lên: tâm ảnh trùng tâm vòng quay */
.spin-btn.has-image {
    width: 26%;
    transform: translate(-50%, -50%);
}

.spin-btn.has-image:active {
    transform: translate(-50%, -50%) scale(0.94);
}

.spin-btn-image {
    width: 100%;
    display: block;
    filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.25));
}

.spin-btn-image[hidden] {
    display: none;
}

.spinning .spin-btn {
    pointer-events: none;
}

/* ----- Thanh công cụ ----- */
.party-toolbar {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
}

.pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 42px;
    padding: 0 14px;
    border: 0;
    border-radius: 999px;
    background: var(--card);
    color: var(--ink);
    font: inherit;
    font-weight: 700;
    font-size: 0.95rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    cursor: pointer;
}

.pill .li {
    font-size: 1.1rem;
}

.pill-select select {
    border: 0;
    background: transparent;
    font: inherit;
    color: inherit;
    max-width: 150px;
    outline: none;
    cursor: pointer;
}

/* ----- Danh sách tên ----- */
.names-panel {
    background: var(--card);
    border-radius: 20px;
    padding: 16px;
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.08);
    backdrop-filter: blur(6px);
}

.names-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 10px;
}

.names-header h2 {
    margin: 0;
    font-size: 1.15rem;
    display: flex;
    align-items: center;
    gap: 6px;
}

.count {
    background: #ece7f5;
    border-radius: 999px;
    padding: 0 10px;
    font-size: 0.9rem;
}

.names-actions {
    display: flex;
    gap: 4px;
}

.link-btn {
    border: 0;
    background: none;
    font: inherit;
    font-size: 0.9rem;
    font-weight: 700;
    color: #5b5fc7;
    padding: 4px 6px;
    cursor: pointer;
}

.link-btn.danger {
    color: #d14343;
}

#names-input {
    width: 100%;
    height: 340px;
    resize: vertical;
    border: 2px solid #ece7f5;
    border-radius: 14px;
    padding: 12px;
    font: inherit;
    font-size: 1rem;
    line-height: 1.6;
    color: var(--ink);
    background: #fff;
    outline: none;
}

#names-input:focus {
    border-color: #b9a7e6;
}

.names-hint {
    margin: 8px 2px 0;
    font-size: 0.8rem;
    color: var(--muted);
}

/* ----- Kết quả ----- */
.result-overlay {
    position: fixed;
    inset: 0;
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: rgba(30, 25, 45, 0.45);
    backdrop-filter: blur(3px);
    animation: fade-in 0.2s ease;
}

.result-overlay[hidden] {
    display: none;
}

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

.result-card {
    position: relative;
    width: min(420px, 100%);
    background: #fff;
    border-radius: 24px;
    padding: 28px 22px 22px;
    text-align: center;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: pop-in 0.35s cubic-bezier(0.2, 1.4, 0.4, 1);
}

.result-close {
    position: absolute;
    z-index: 2;
    top: 10px;
    right: 10px;
    width: 36px;
    height: 36px;
    border: 0;
    border-radius: 50%;
    background: #f3f4f6;
    font-size: 1.1rem;
    cursor: pointer;
}

.result-label {
    color: var(--muted);
    font-weight: 700;
    margin-bottom: 10px;
}

.result-name {
    display: inline-block;
    max-width: 100%;
    font-size: clamp(1.8rem, 8vw, 2.6rem);
    font-weight: 800;
    line-height: 1.2;
    padding: 12px 22px;
    border-radius: 18px;
    word-break: break-word;
    margin-bottom: 20px;
}

.result-actions {
    display: flex;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
}

.btn-soft,
.btn-main {
    height: 46px;
    padding: 0 18px;
    border: 0;
    border-radius: 14px;
    font: inherit;
    font-weight: 800;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
}

.btn-soft {
    background: #f3f4f6;
    color: var(--ink);
}

.btn-main {
    background: var(--btn);
    color: #fff;
}

@keyframes fade-in {
    from {
        opacity: 0;
    }
}

@keyframes pop-in {
    from {
        transform: scale(0.7);
        opacity: 0;
    }
}

/* ----- Điện thoại / màn hình dọc ----- */
@media (max-width: 900px) {
    body {
        background-attachment: scroll;
    }

    .party-main {
        grid-template-columns: 1fr;
        gap: 18px;
    }

    .party-wheel {
        width: min(94vw, 64vh, 620px);
    }

    #names-input {
        height: 220px;
    }
}

@media (max-width: 420px) {
    .pill {
        padding: 0 11px;
        font-size: 0.9rem;
    }

    .pill-select select {
        max-width: 110px;
    }
}
