/* กันเลื่อนซ้าย-ขวาบนมือถือ (วงล้อเงา + เมนูล่าง) ทำให้ popup/ผลลัพธ์ดูไม่กึ่งกลาง */
html.lucky-spin-wheel-page,
body.lucky-spin-wheel-page {
    overflow-x: clip;
    max-width: 100%;
}

.lucky-spin-stage-wrap {
    position: relative;
    width: min(100%, 360px);
    max-width: 100%;
    margin-inline: auto;
    overflow: visible;
    box-sizing: border-box;
}

/* เงาวงกลม — ไม่ใช้ filter + overflow:hidden บน stage (จะตัดเป็นกรอบสี่เหลี่ยม) */
.lucky-spin-stage-wrap::before {
    content: '';
    position: absolute;
    left: 50%;
    top: 50%;
    z-index: 0;
    width: 92%;
    aspect-ratio: 1;
    transform: translate(-50%, -50%);
    border-radius: 50%;
    box-shadow:
        0 16px 36px rgba(127, 29, 29, 0.22),
        0 6px 14px rgba(127, 29, 29, 0.12);
    pointer-events: none;
}

.lucky-spin-stage {
    position: relative;
    z-index: 1;
    width: 100%;
    margin-inline: auto;
    aspect-ratio: 1;
    overflow: visible;
}

.lucky-spin-stage::before {
    content: '';
    position: absolute;
    inset: 4%;
    border-radius: 9999px;
    background: radial-gradient(circle at 50% 45%, rgba(254, 243, 199, 0.5) 0%, rgba(254, 226, 226, 0.15) 40%, transparent 70%);
    pointer-events: none;
    z-index: 0;
}

.lucky-spin-stage.is-ring-spinning::after {
    content: '';
    position: absolute;
    inset: 8%;
    border-radius: 9999px;
    border: 2px solid rgba(251, 191, 36, 0.45);
    box-shadow: 0 0 24px rgba(251, 191, 36, 0.35);
    pointer-events: none;
    z-index: 0;
    animation: lucky-spin-stage-glow 0.85s ease-in-out infinite alternate;
}

@keyframes lucky-spin-stage-glow {
    from {
        opacity: 0.35;
        transform: scale(0.98);
    }

    to {
        opacity: 0.85;
        transform: scale(1.01);
    }
}

.lucky-spin-rings {
    pointer-events: none;
}

/* เข็มบน — แดงเต็ม + ขอบทอง (หมุนที่ฐาน ปลายล่างส่าย) */
.lucky-spin-pointer-pivot {
    position: absolute;
    left: 50%;
    top: 2px;
    z-index: 30;
    width: 28px;
    height: 26px;
    transform: translateX(-50%) rotate(0deg);
    transform-origin: 50% 0%;
    will-change: transform;
}

.lucky-spin-pointer {
    position: absolute;
    left: 50%;
    bottom: 0;
    width: 26px;
    height: 22px;
    transform: translateX(-50%);
    background: linear-gradient(180deg, #fde68a 0%, #fbbf24 42%, #f59e0b 72%, #d97706 100%);
    clip-path: polygon(50% 100%, 0 0, 100% 0);
    filter: drop-shadow(0 3px 7px rgba(127, 29, 29, 0.38));
}

.lucky-spin-pointer::before {
    content: '';
    position: absolute;
    left: 50%;
    top: 2px;
    width: 20px;
    height: 17px;
    transform: translateX(-50%);
    background: linear-gradient(180deg, #fecaca 0%, #f87171 22%, #ef4444 52%, #dc2626 78%, #b91c1c 100%);
    clip-path: polygon(50% 100%, 0 0, 100% 0);
    box-shadow: inset 0 1px 3px rgba(255, 255, 255, 0.42);
}

.lucky-spin-pointer::after {
    content: '';
    position: absolute;
    left: 50%;
    top: 4px;
    width: 9px;
    height: 4px;
    transform: translateX(-50%);
    background: rgba(255, 255, 255, 0.5);
    border-radius: 9999px;
    filter: blur(0.5px);
    pointer-events: none;
}

.lucky-spin-stage.is-pointer-settling .lucky-spin-pointer-pivot {
    animation: lucky-spin-pointer-settle 0.78s cubic-bezier(0.28, 0.85, 0.32, 1) 1;
}

@keyframes lucky-spin-pointer-settle {
    0% {
        transform: translateX(-50%) rotate(10deg);
    }

    40% {
        transform: translateX(-50%) rotate(-7deg);
    }

    72% {
        transform: translateX(-50%) rotate(3deg);
    }

    100% {
        transform: translateX(-50%) rotate(0deg);
    }
}

.lucky-spin-rings {
    position: absolute;
    inset: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: visible;
    z-index: 1;
}

.lucky-spin-ring {
    position: absolute;
    border-radius: 9999px;
    transition: box-shadow 0.3s ease;
    overflow: visible;
}

/* ขอบวงล้อ — บางลง + สีเข้ากับแถบแต่ละวง */
.lucky-spin-ring--outer {
    box-shadow:
        0 14px 32px rgba(185, 28, 28, 0.28),
        0 0 0 1.5px #b91c1c,
        inset 0 0 0 1.5px #fde68a;
}

.lucky-spin-ring--middle {
    box-shadow:
        0 12px 28px rgba(217, 119, 6, 0.26),
        0 0 0 1.5px #f57c00,
        inset 0 0 0 1.5px #ffeb3b;
}

.lucky-spin-ring--inner {
    box-shadow:
        0 10px 24px rgba(225, 29, 72, 0.24),
        0 0 0 1.5px #f50057,
        inset 0 0 0 1.5px #ff8a80;
}

.lucky-spin-ring.is-hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

/* สุ่ม 2 ตัว: วงนอก + กลาง | สุ่ม 3 ตัว: เพิ่มวงใน */
.lucky-spin-stage[data-mode="bot2"] .lucky-spin-ring--inner {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.lucky-spin-ring--outer {
    z-index: 1;
    width: 100%;
    height: 100%;
    --ball-inset: 4.2%;
}

.lucky-spin-ring--middle {
    z-index: 2;
    width: 64%;
    height: 64%;
    --ball-inset: 5.8%;
}

.lucky-spin-ring--inner {
    z-index: 3;
    width: 32%;
    height: 32%;
    --ball-inset: 6.2%;
}

.lucky-spin-ring-disk {
    position: relative;
    width: 100%;
    height: 100%;
    border-radius: 9999px;
    overflow: visible;
    --wheel-spin-ease: cubic-bezier(0.06, 0.78, 0.1, 1);
    transition: transform 4.2s var(--wheel-spin-ease);
    will-change: transform;
}

.lucky-spin-ring-disk::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 9999px;
    background: linear-gradient(
        145deg,
        rgba(255, 255, 255, 0.35) 0%,
        rgba(255, 255, 255, 0) 42%,
        rgba(0, 0, 0, 0.08) 100%
    );
    pointer-events: none;
}

/* วงนอก — ไล่สีแดงเข้ม (ธีมสายหวย) */
.lucky-spin-ring--outer .lucky-spin-ring-disk {
    background:
        radial-gradient(circle at 50% 32%, rgba(255, 255, 255, 0.28) 0%, transparent 52%),
        conic-gradient(
            #fff7ed 0deg 36deg,
            #ef4444 36deg 72deg,
            #fecaca 72deg 108deg,
            #b91c1c 108deg 144deg,
            #fef3c7 144deg 180deg,
            #dc2626 180deg 216deg,
            #fee2e2 216deg 252deg,
            #991b1b 252deg 288deg,
            #fde68a 288deg 324deg,
            #ef4444 324deg 360deg
        );
}

/* วงกลาง — ทอง-ส้มสด */
.lucky-spin-ring--middle .lucky-spin-ring-disk {
    background:
        radial-gradient(circle at 50% 32%, rgba(255, 255, 255, 0.18) 0%, transparent 52%),
        conic-gradient(
            #fff176 0deg 36deg,
            #ff8f00 36deg 72deg,
            #ffca28 72deg 108deg,
            #ff6f00 108deg 144deg,
            #ffeb3b 144deg 180deg,
            #f57c00 180deg 216deg,
            #ffc400 216deg 252deg,
            #e65100 252deg 288deg,
            #ffd600 288deg 324deg,
            #ff9100 324deg 360deg
        );
}

/* วงใน — ชมพู-แดงสด */
.lucky-spin-ring--inner .lucky-spin-ring-disk {
    background:
        radial-gradient(circle at 50% 32%, rgba(255, 255, 255, 0.16) 0%, transparent 50%),
        conic-gradient(
            #ff8a80 0deg 36deg,
            #ff1744 36deg 72deg,
            #ff5252 72deg 108deg,
            #d50000 108deg 144deg,
            #ff6e40 144deg 180deg,
            #ff3d00 180deg 216deg,
            #ff5252 216deg 252deg,
            #c51162 252deg 288deg,
            #ff6090 288deg 324deg,
            #f50057 324deg 360deg
        );
}

.lucky-spin-ring-disk.is-spinning {
    transition-duration: 4.2s;
    transition-timing-function: var(--wheel-spin-ease);
    filter: brightness(1.08) saturate(1.12);
}

.lucky-spin-stage.is-mode-show .lucky-spin-ring-disk.is-spinning {
    transition-duration: 2.8s;
    transition-timing-function: var(--wheel-spin-ease);
}

.lucky-spin-spoke {
    position: absolute;
    inset: 0;
    /* +18deg = กึ่งกลางช่องสี (ไม่ทับเส้นแบ่ง 0°, 36°, 72°...) */
    transform: rotate(calc(var(--segment-index) * 36deg + 18deg));
    pointer-events: none;
}

.lucky-spin-ball {
    position: absolute;
    left: 50%;
    top: var(--ball-inset, 8%);
    z-index: 2;
    display: flex;
    flex-shrink: 0;
    align-items: center;
    justify-content: center;
    aspect-ratio: 1;
    border-radius: 9999px;
    font-weight: 900;
    line-height: 1;
    transform: translateX(-50%);
    box-shadow:
        0 3px 8px rgba(127, 29, 29, 0.28),
        inset 0 2px 4px rgba(255, 255, 255, 0.65),
        inset 0 -3px 6px rgba(127, 29, 29, 0.12);
}

.lucky-spin-ring--outer .lucky-spin-ball {
    width: 2.35rem;
    height: 2.35rem;
    font-size: 1.2rem;
    color: #7f1d1d;
    background: radial-gradient(circle at 32% 28%, #ffffff 0%, #fff7ed 38%, #fde68a 72%, #fbbf24 100%);
    border: 3px solid #b91c1c;
    box-shadow:
        0 4px 10px rgba(185, 28, 28, 0.35),
        inset 0 2px 5px rgba(255, 255, 255, 0.8),
        inset 0 -3px 6px rgba(153, 27, 27, 0.22);
}

.lucky-spin-ring--middle .lucky-spin-ball {
    width: 2.05rem;
    height: 2.05rem;
    font-size: 1.05rem;
    color: #78350f;
    background: radial-gradient(circle at 32% 28%, #ffffff 0%, #fffbeb 40%, #fde68a 75%, #f59e0b 100%);
    border: 2.5px solid #d97706;
    box-shadow:
        0 4px 10px rgba(180, 83, 9, 0.35),
        inset 0 2px 5px rgba(255, 255, 255, 0.78),
        inset 0 -3px 6px rgba(146, 64, 14, 0.22);
}

.lucky-spin-ring--inner .lucky-spin-ball {
    width: 1.22rem;
    height: 1.22rem;
    min-width: 1.22rem;
    min-height: 1.22rem;
    font-size: 0.72rem;
    color: #9f1239;
    background: radial-gradient(circle at 32% 26%, #ffffff 0%, #fff1f2 35%, #fecdd3 68%, #fb7185 100%);
    border: 1.5px solid #e11d48;
    box-shadow:
        0 2px 6px rgba(190, 18, 60, 0.28),
        inset 0 1px 4px rgba(255, 255, 255, 0.75),
        inset 0 -2px 4px rgba(159, 18, 57, 0.18);
}

.lucky-spin-action-row,
.lucky-spin-mode-row,
.lucky-spin-power-wrap,
.lucky-spin-action-btn,
.lucky-spin-mode-btn,
.lucky-spin-core {
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
}

.lucky-spin-action-btn,
.lucky-spin-core.is-clickable {
    touch-action: none;
}

.lucky-spin-core.is-clickable {
    cursor: pointer;
}

.lucky-spin-core.is-clickable:hover {
    filter: brightness(1.08);
}

.lucky-spin-core.is-clickable:active {
    transform: translate(-50%, -50%) scale(0.96);
}

.lucky-spin-core {
    position: absolute;
    left: 50%;
    top: 50%;
    z-index: 10;
    width: 11%;
    height: 11%;
    min-width: 2.75rem;
    min-height: 2.75rem;
    margin: 0;
    padding: 0;
    transform: translate(-50%, -50%);
    border-radius: 9999px;
    background: radial-gradient(circle at 32% 26%, #fff1f2 0%, #fecaca 38%, #ef4444 72%, #b91c1c 100%);
    border: 1px solid #b91c1c;
    box-shadow:
        0 0 10px rgba(239, 68, 68, 0.35),
        0 6px 16px rgba(127, 29, 29, 0.32),
        inset 0 2px 6px rgba(255, 255, 255, 0.55),
        inset 0 -4px 8px rgba(153, 27, 27, 0.35);
    pointer-events: none;
    transition: filter 0.2s ease, transform 0.15s ease;
    -webkit-appearance: none;
    appearance: none;
}

.lucky-spin-core.is-clickable {
    pointer-events: auto;
}

.lucky-spin-core:disabled {
    pointer-events: none;
    cursor: default;
}

.lucky-spin-core::after {
    content: '';
    position: absolute;
    inset: 22%;
    border-radius: 9999px;
    background: radial-gradient(circle at 38% 32%, #fee2e2 0%, #ef4444 55%, #b91c1c 100%);
    opacity: 0.95;
}

.lucky-spin-mode-btn {
    flex: 1;
    border-radius: 1rem;
    border: 2px solid #fecaca;
    background: #fff;
    padding: 0.75rem 1rem;
    font-size: 0.95rem;
    font-weight: 800;
    color: #991b1b;
    transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease, box-shadow 0.2s ease;
}

.lucky-spin-mode-btn.is-active {
    border-color: #b91c1c;
    background: linear-gradient(180deg, #ef4444 0%, #b91c1c 100%);
    color: #fff;
    box-shadow: 0 8px 20px rgba(185, 28, 28, 0.28);
}

.lucky-spin-controls-locked .lucky-spin-mode-row,
.lucky-spin-controls-locked .lucky-spin-action-row {
    pointer-events: none;
    user-select: none;
}

.lucky-spin-controls-locked .lucky-spin-mode-btn,
.lucky-spin-controls-locked .lucky-spin-action-btn,
.lucky-spin-controls-locked .lucky-spin-core {
    opacity: 0.72;
    cursor: not-allowed;
}

/* คอม — ปุ่มไม่ยืดเต็มจอ */
@media (min-width: 768px) {
    .lucky-spin-mode-row {
        justify-content: center;
        max-width: 22rem;
        margin-inline: auto;
    }

    .lucky-spin-mode-btn {
        flex: 0 1 auto;
        min-width: 7.5rem;
        padding: 0.55rem 1rem;
        font-size: 0.875rem;
    }

    .lucky-spin-action-row {
        justify-content: center;
        max-width: 20rem;
        margin-inline: auto;
    }

    .lucky-spin-action-btn {
        flex: 0 1 auto;
        min-width: 6.5rem;
        padding: 0.6rem 1.15rem !important;
        font-size: 0.875rem !important;
    }
}

.lucky-spin-spin-btn {
    border: 1px solid #b91c1c;
    background: linear-gradient(180deg, #fecaca 0%, #ef4444 48%, #b91c1c 100%);
    color: #fff;
    box-shadow: 0 8px 18px rgba(185, 28, 28, 0.28);
}

.lucky-spin-spin-btn:hover {
    filter: brightness(1.06);
}

.lucky-spin-spin-btn:active {
    filter: brightness(0.98);
}

.lucky-spin-reset-btn {
    border: 1px solid #d97706;
    background: linear-gradient(180deg, #fef3c7 0%, #fbbf24 48%, #f59e0b 100%);
    color: #78350f;
    box-shadow: 0 8px 18px rgba(217, 119, 6, 0.28);
}

.lucky-spin-reset-btn:hover {
    filter: brightness(1.06);
}

.lucky-spin-reset-btn:active {
    filter: brightness(0.98);
}

.lucky-spin-power-wrap {
    max-width: 22rem;
    margin-inline: auto;
}

.lucky-spin-power-bar {
    height: 12px;
    border-radius: 9999px;
    background: rgba(15, 23, 42, 0.08);
    border: 1px solid rgba(148, 163, 184, 0.45);
    overflow: hidden;
    box-shadow: inset 0 2px 6px rgba(15, 23, 42, 0.08);
}

.lucky-spin-power-fill {
    height: 100%;
    width: 0%;
    border-radius: 9999px;
    background: linear-gradient(90deg, #fbbf24 0%, #ef4444 55%, #b91c1c 100%);
    box-shadow: 0 10px 22px rgba(185, 28, 28, 0.25);
    transition: width 0.08s linear;
}

.lucky-spin-power-hint {
    margin: 0.5rem 0 0;
    text-align: center;
    font-size: 0.75rem;
    font-weight: 700;
    color: rgba(100, 116, 139, 0.95);
}

.lucky-spin-result-panel.is-hidden {
    display: none;
}

.lucky-spin-digit-display {
    letter-spacing: 0.12em;
    padding-inline: 0.12em;
    font-size: clamp(2.5rem, 8vw, 3.25rem);
    font-weight: 900;
    color: #0f172a;
    text-align: center;
}

/* Popup แสดงผลหลังหมุนเสร็จ */
.lucky-spin-popup {
    position: fixed;
    inset: 0;
    z-index: 60;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.2s ease, visibility 0.2s ease;
}

.lucky-spin-popup.is-open {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

.lucky-spin-popup__backdrop {
    position: fixed;
    inset: 0;
    z-index: 60;
    background: rgba(15, 23, 42, 0.42);
    backdrop-filter: blur(3px);
}

.lucky-spin-popup__card {
    position: fixed;
    top: 50%;
    left: 50%;
    z-index: 61;
    display: flex;
    align-items: center;
    justify-content: center;
    width: min(72vw, 12.5rem);
    height: min(72vw, 12.5rem);
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    border-radius: 50%;
    background:
        radial-gradient(circle at 32% 26%, rgba(255, 255, 255, 0.98) 0%, rgba(255, 247, 237, 0.98) 48%, rgba(254, 242, 242, 0.98) 100%);
    border: 3px solid rgba(251, 191, 36, 0.75);
    box-shadow:
        0 0 0 4px rgba(185, 28, 28, 0.18),
        0 0 0 7px rgba(251, 191, 36, 0.22),
        0 22px 60px rgba(15, 23, 42, 0.38),
        inset 0 2px 14px rgba(255, 255, 255, 0.92),
        inset 0 -6px 18px rgba(251, 191, 36, 0.12);
    transform: translate(-50%, -50%) scale(0.9);
    transition: transform 0.22s cubic-bezier(0.34, 1.4, 0.64, 1);
}

.lucky-spin-popup__card::before {
    content: '';
    position: absolute;
    inset: 0.55rem;
    border-radius: 50%;
    border: 1px dashed rgba(251, 191, 36, 0.45);
    pointer-events: none;
}

.lucky-spin-popup.is-open .lucky-spin-popup__card {
    transform: translate(-50%, -50%) scale(1);
}

.lucky-spin-popup__card.is-digits-2 .lucky-spin-popup__value {
    font-size: clamp(2.75rem, 14vw, 3.35rem);
    letter-spacing: 0.18em;
    text-indent: 0.18em;
}

.lucky-spin-popup__card.is-digits-3 .lucky-spin-popup__value {
    font-size: clamp(2.15rem, 11vw, 2.85rem);
    letter-spacing: 0.1em;
    text-indent: 0.1em;
}

.lucky-spin-popup__value {
    position: relative;
    z-index: 1;
    margin: 0;
    width: 100%;
    text-align: center;
    font-weight: 950;
    font-variant-numeric: tabular-nums;
    line-height: 1;
    color: #0f172a;
    text-shadow: 0 1px 0 rgba(255, 255, 255, 0.85);
}

@media (max-width: 380px) {
    .lucky-spin-stage-wrap {
        width: min(100%, 320px);
    }

    .lucky-spin-ring--outer {
        --ball-inset: 4.8%;
    }

    .lucky-spin-ring--outer .lucky-spin-ball {
        width: 2rem;
        height: 2rem;
        font-size: 1.05rem;
    }

    .lucky-spin-ring--middle {
        width: 66%;
        height: 66%;
        --ball-inset: 6.2%;
    }

    .lucky-spin-ring--middle .lucky-spin-ball {
        width: 1.78rem;
        height: 1.78rem;
        font-size: 0.95rem;
    }

    .lucky-spin-ring--inner {
        width: 32%;
        height: 32%;
        --ball-inset: 6.8%;
    }

    .lucky-spin-ring--inner .lucky-spin-ball {
        width: 1.1rem;
        height: 1.1rem;
        min-width: 1.1rem;
        min-height: 1.1rem;
        font-size: 0.65rem;
    }
}
