/* ═══════════════════════════════════════
   Fortune Wheel — Epic Redesign
   ═══════════════════════════════════════ */

/* ── Animations (GPU-optimized) ── */

@keyframes jackpotFlash {
    0%, 100% { opacity: 0.7; }
    50%      { opacity: 1; }
}

@keyframes pulseBtn {
    0%, 100% { transform: scale(1); }
    50%      { transform: scale(1.03); }
}

@keyframes spinBtnIcon {
    0%   { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* ── Wheel Page Layout ── */
.template_wheel .template__wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;
}

.template_wheel .heading_h3 {
    position: relative;
    z-index: 2;
}

/* ── Warning Banner ── */
.wheel-warning {
    background: linear-gradient(135deg, rgba(255, 152, 0, 0.12), rgba(255, 87, 34, 0.08));
    border: 1px solid rgba(255, 152, 0, 0.3);
    border-left: 4px solid #ff9800;
    border-radius: 10px;
    padding: 12px 20px;
    color: #fff;
    font-size: 0.85rem;
    max-width: 600px;
    text-align: center;
    line-height: 1.4;
}

/* ── Wheel Container ── */
.wheel-stage {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem 0;
}

.wheel-stage canvas#wheel-particles {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 10;
}

/* ── Core Wheel Structure ── */
.wheel {
    --wheel-size: 580px;
    width: var(--wheel-size);
    height: var(--wheel-size);
    position: relative;
    border-radius: 50%;
    transform: rotate(45deg);
    display: flex;
    justify-content: center;
    align-items: center;
    contain: layout style;
}

/* Outer glow ring */
.wheel__ring {
    position: absolute;
    inset: -14px;
    border-radius: 50%;
    border: 4px solid transparent;
    background:
        linear-gradient(#1a1035, #1a1035) padding-box,
        linear-gradient(135deg, #ffd700, #fd1966, #7c4dff, #ffd700) border-box;
    z-index: 0;
    pointer-events: none;
}
.wheel__ring::after {
    content: "";
    position: absolute;
    inset: -6px;
    border-radius: 50%;
    border: 2px solid rgba(255, 215, 0, 0.15);
}

/* Inner wheel disc */
.wheel__container {
    width: 100%;
    height: 100%;
    position: relative;
    overflow: hidden;
    border-radius: 50%;
    z-index: 1;
    box-shadow: inset 0 0 30px rgba(0, 0, 0, 0.4);
}

.wheel__wrapper {
    position: absolute;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
}

/* Radial shading overlay */
.wheel__wrapper::before {
    content: "";
    position: absolute;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
    background: radial-gradient(circle at center,
        transparent 0%,
        transparent 55%,
        rgba(0, 0, 0, 0.15) 75%,
        rgba(0, 0, 0, 0.35) 100%
    );
    z-index: 2;
    pointer-events: none;
}

/* Prize segments */
.prize {
    position: absolute;
    height: 50%;
    width: 50%;
    transform-origin: bottom right;
    transform: rotate(calc(27.6923deg * var(--i)));
    clip-path: polygon(0 0, 44% 0, 100% 100%, 0 38%);
    display: flex;
    align-items: center;
    justify-content: center;
    user-select: none;
    background: #2a1f4e;
}
.prize:nth-child(odd) {
    background: #1e1838;
}
.prize:nth-child(even) {
    background: #342660;
}
.prize_accent {
    background: linear-gradient(135deg, #4a1942, #6b2fa0) !important;
}

.prize img {
    position: absolute;
    width: 7.5rem;
    height: 7.5rem;
    object-fit: contain;
    /* Bisector of segment polygon: from center (100%,100%) toward outer midpoint (22%,19%) */
    /* Placed at 75% distance from center to edge along bisector */
    left: calc(100% - 0.75 * 78%);
    top: calc(100% - 0.75 * 81%);
    transform: translate(-50%, -50%) rotate(-45deg);
    filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.5));
    pointer-events: none;
}

/* Center hub */
.wheel__center {
    position: absolute;
    width: 80px;
    height: 80px;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    border-radius: 50%;
    background: linear-gradient(145deg, #ffd700, #f0a800);
    z-index: 3;
    box-shadow:
        0 0 0 4px #1a1035,
        0 0 0 7px rgba(255, 215, 0, 0.3),
        0 4px 15px rgba(0, 0, 0, 0.5);
}
.wheel__center::before {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) rotate(-45deg);
    font-size: 2rem;
    line-height: 1;
}

/* Pointer — outside wheel, top center of wheel-stage */
.wheel__pointer {
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    z-index: 20;
    border-left: 16px solid transparent;
    border-right: 16px solid transparent;
    border-top: 48px solid #ffd700;
    filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.6));
}

/* ── Sound Toggle ── */
.sound-toggle {
    position: absolute;
    top: 12px;
    right: 12px;
    z-index: 25;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, 0.15);
    background: rgba(0, 0, 0, 0.4);
    color: #fff;
    font-size: 1.1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, border-color 0.2s;
    line-height: 1;
}
.sound-toggle:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.3);
}
.sound-toggle::before {
    content: "\1F50A";
}
.sound-toggle.muted::before {
    content: "\1F507";
}

/* ── Fast Spin Toggle ── */
.fast-toggle {
    position: absolute;
    top: 12px;
    right: 56px;
    z-index: 25;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, 0.15);
    background: rgba(0, 0, 0, 0.4);
    color: #fff;
    font-size: 1.1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, border-color 0.2s, color 0.2s, box-shadow 0.2s;
    line-height: 1;
}
.fast-toggle:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.3);
}
.fast-toggle::before {
    content: "\26A1";
}
.fast-toggle.active {
    background: rgba(255, 215, 0, 0.18);
    border-color: rgba(255, 215, 0, 0.7);
    color: #ffd700;
    box-shadow: 0 0 10px rgba(255, 215, 0, 0.45);
}

/* ── Spin Button ── */
.spin-btn {
    width: 100%;
    max-width: 380px;
    padding: 16px 32px;
    font-size: 1.2rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    border: none;
    border-radius: 14px;
    cursor: pointer;
    color: #fff;
    background: linear-gradient(135deg, #fd1966 0%, #ff4d7d 50%, #fd1966 100%);
    background-size: 200% 100%;
    animation: pulseBtn 2s ease-in-out infinite;
    box-shadow: 0 4px 20px rgba(253, 25, 102, 0.4);
    transition: filter 0.2s ease;
    position: relative;
    overflow: hidden;
    will-change: transform;
}
.spin-btn:hover:not(:disabled) {
    filter: brightness(1.15);
    animation-play-state: paused;
}
.spin-btn:active:not(:disabled) {
    transform: scale(0.97) !important;
    animation: none;
}
.spin-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    animation: none;
}
.spin-btn.spinning {
    animation: none;
    opacity: 0.7;
}
.spin-btn .spin-icon {
    display: inline-block;
    margin-right: 8px;
    font-size: 1.3em;
}
.spin-btn.spinning .spin-icon {
    animation: spinBtnIcon 1s linear infinite;
}

/* ── Balance Display ── */
.wheel-balance {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.1rem;
    font-weight: 700;
    color: #fff;
    background: rgba(255, 255, 255, 0.06);
    padding: 10px 24px;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}
.wheel-balance__coins {
    color: #FFD700;
    font-size: 1.3rem;
}
.wheel-balance__label {
    color: var(--text-light-muted, #aaa);
    font-weight: 400;
    font-size: 0.85rem;
}

/* ── Jackpot Board ── */
.jackpot-board {
    background: linear-gradient(135deg, #1a1035 0%, #2d1b69 50%, #1a1035 100%);
    border: 3px solid #ffd700;
    border-radius: 14px;
    padding: 14px 20px;
    width: 100%;
    max-width: 650px;
    overflow: hidden;
    position: relative;
    contain: layout style paint;
}
.jackpot-board__title {
    text-align: center;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.15em;
    color: #ffd700;
    margin-bottom: 8px;
    font-weight: 700;
}

.ticker-container {
    width: 100%;
    overflow: hidden;
    contain: layout paint;
}
.ticker {
    display: inline-flex;
    white-space: nowrap;
}

.winner, .no-winners {
    flex: 0 0 auto;
    margin-right: 40px;
    white-space: nowrap;
    font-weight: 700;
    font-size: 0.85rem;
    padding: 5px 12px;
    border-radius: 6px;
}
.winner:nth-child(6n+1), .no-winners { color: #ffd700; background: rgba(255, 215, 0, 0.08); }
.winner:nth-child(6n+2) { color: #ff6b6b; background: rgba(255, 107, 107, 0.08); }
.winner:nth-child(6n+3) { color: #4caf50; background: rgba(76, 175, 80, 0.08); }
.winner:nth-child(6n+4) { color: #2196f3; background: rgba(33, 150, 243, 0.08); }
.winner:nth-child(6n+5) { color: #e040fb; background: rgba(224, 64, 251, 0.08); }
.winner:nth-child(6n)   { color: #ff9800; background: rgba(255, 152, 0, 0.08); }

.nickname { font-size: 0.85rem; }
.achievement { font-size: 0.75rem; font-style: italic; opacity: 0.85; }

/* ── Prize Categories ── */
.prize-categories {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.prize-category {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 14px;
    padding: 16px 20px;
    overflow: hidden;
}
.prize-category__header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
    padding-bottom: 10px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}
.prize-category__icon {
    display: none;
}
.prize-category__title {
    font-weight: 700;
    font-size: 1rem;
    color: #fff;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.prize-category__hint {
    font-size: 0.7rem;
    color: var(--text-light-muted, #888);
    margin-left: auto;
    font-style: italic;
}

/* Rate-specific borders */
.prize-category--regular  { border-left: 3px solid #9e9e9e; }
.prize-category--good     { border-left: 3px solid #4caf50; }
.prize-category--great    { border-left: 3px solid #2196f3; }
.prize-category--super    { border-left: 3px solid #e040fb; }
.prize-category--jackpot  { border-left: 3px solid #ffd700; background: linear-gradient(135deg, rgba(255, 215, 0, 0.04), rgba(255, 64, 129, 0.04)); }

/* ── Prize Items inside categories ── */
.prize-category .shop__items {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 10px;
    padding-top: 0;
}

.prize-category .shop__item.item-content {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    padding: 12px 8px;
    box-shadow: none;
    gap: 6px;
    transition: background 0.2s ease, border-color 0.2s ease;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
}
.prize-category .shop__item.item-content:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.15);
}

.prize-category--regular .shop__item.item-content:hover  { border-color: rgba(158, 158, 158, 0.4); }
.prize-category--good .shop__item.item-content:hover     { border-color: rgba(76, 175, 80, 0.4); }
.prize-category--great .shop__item.item-content:hover    { border-color: rgba(33, 150, 243, 0.4); }
.prize-category--super .shop__item.item-content:hover    { border-color: rgba(224, 64, 251, 0.4); }
.prize-category--jackpot .shop__item.item-content:hover  { border-color: rgba(255, 215, 0, 0.4); }

.prize-category .item-content__img {
    width: 64px;
    height: 64px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.06);
    box-shadow: none;
    overflow: hidden;
    flex-shrink: 0;
}
.prize-category .item-content__img img {
    width: 100%;
    height: 100%;
    object-fit: contain !important;
}

.prize-category .item-content__title {
    font-size: 0.72rem;
    font-weight: 600;
    color: #fff;
    line-height: 1.3;
    margin-bottom: 2px;
    overflow-wrap: break-word;
    word-break: normal;
    text-wrap: pretty;
}

.prize-category .item-content__text {
    font-size: 0.68rem;
    color: #ffd700;
    font-weight: 700;
    margin-bottom: 0;
    line-height: 1;
}

.prize-category .item-content__body {
    flex: 0 0 auto;
}

/* Jackpot flash effect on wheel */
.wheel.jackpot-flash {
    animation: jackpotFlash 0.4s ease-in-out 5;
    will-change: opacity;
}

/* ── Prize Modal Redesign ── */
#prizeModal {
    display: none;
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 9999;
    align-items: center;
    justify-content: center;
}
#prizeModal.open {
    display: flex;
    animation: modalFadeIn 0.4s ease forwards;
}

@keyframes modalFadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}
@keyframes modalSlideUp {
    from { transform: translate(-50%, -45%); opacity: 0; }
    to   { transform: translate(-50%, -50%); opacity: 1; }
}

#prizeModal .modal__content {
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    width: 90%;
    max-width: 500px;
    max-height: 85vh;
    overflow-y: auto;
    background: linear-gradient(145deg, #1e1e3a, #2a1f4e);
    border: 1px solid rgba(255, 215, 0, 0.2);
    border-radius: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 2rem 1.5rem;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5), 0 0 40px rgba(124, 77, 255, 0.15);
    animation: modalSlideUp 0.5s ease forwards;
}

#prizeModal .modal__title {
    color: #ffd700 !important;
    font-size: 1.4rem !important;
    margin-bottom: 1.5rem !important;
    text-align: center;
    text-shadow: 0 0 20px rgba(255, 215, 0, 0.3);
}

#prizeModal .modal__items {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
    width: 100%;
    margin-bottom: 1.5rem;
}
#prizeModal .modal__items.disabled { pointer-events: none; }

#prizeModal .modal__item {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 90px;
    cursor: pointer;
    padding: 8px;
    border-radius: 12px;
    border: 2px solid transparent;
    background: rgba(255, 255, 255, 0.04);
    transition: all 0.2s ease;
    position: relative;
}
#prizeModal .modal__item:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.15);
}
#prizeModal .modal__item.selected {
    border-color: #ffd700;
    background: rgba(255, 215, 0, 0.1);
    box-shadow: 0 0 16px rgba(255, 215, 0, 0.2);
}
#prizeModal .modal__item img {
    width: 64px;
    height: 64px;
    object-fit: contain;
    border-radius: 8px;
    margin-bottom: 4px;
}
#prizeModal .modal__item-amount {
    font-size: 0.7rem;
    color: #ffd700;
    font-weight: 700;
    line-height: 1;
}
#prizeModal .modal__item-name {
    font-size: 0.62rem;
    color: var(--text-light-muted, #aaa);
    text-align: center;
    line-height: 1.2;
    word-break: break-word;
}
#prizeModal .modal__item input[type="radio"] { display: none; }

#prizeModal .modal__button {
    background: linear-gradient(135deg, #fd1966 0%, #ff4d7d 100%);
    color: #fff;
    border: none;
    padding: 12px 40px;
    border-radius: 12px;
    cursor: pointer;
    font-weight: 700;
    font-size: 1rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    transition: all 0.2s ease;
    box-shadow: 0 4px 16px rgba(253, 25, 102, 0.3);
}
#prizeModal .modal__button:hover:not(:disabled) {
    transform: scale(1.05);
    box-shadow: 0 6px 24px rgba(253, 25, 102, 0.5);
}
#prizeModal .modal__button._disable,
#prizeModal .modal__button:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none;
}

/* ── History Link ── */
.wheel-history-link {
    color: var(--text-light-muted, #aaa);
    font-size: 0.85rem;
    text-decoration: none;
    border-bottom: 1px dashed rgba(255, 255, 255, 0.2);
    transition: color 0.2s, border-color 0.2s;
}
.wheel-history-link:hover {
    color: #ffd700;
    border-color: #ffd700;
}

/* ── Responsive ── */
@media (max-width: 768px) {
    .wheel { --wheel-size: 300px; }
    .wheel__ring { inset: -10px; border-width: 3px; }
    .wheel__ring::after { inset: -4px; }
    .prize img { width: 3rem; height: 3rem; }
    .wheel__center { width: 40px; height: 40px; }
    .wheel__center::before { font-size: 1rem; }
    .wheel__pointer { border-left-width: 12px; border-right-width: 12px; border-top-width: 36px; }

    /* Lift the sound/fast toggles into the gap above the wheel so they don't
       overlap the rim — the shrunken mobile wheel reaches into the corners. */
    .sound-toggle { top: -12px; right: 12px; }
    .fast-toggle  { top: -12px; right: 56px; }

    .jackpot-board { padding: 10px 14px; }
    .winner, .no-winners { margin-right: 24px; padding: 4px 8px; font-size: 0.75rem; }
    .spin-btn { max-width: 100%; font-size: 1rem; padding: 14px 24px; }
    .prize-category { padding: 12px 14px; }
    .prize-category__hint { display: none; }
    .prize-category .shop__items { grid-template-columns: repeat(auto-fill, minmax(90px, 1fr)); gap: 8px; }
    .prize-category .item-content__img { width: 52px; height: 52px; }
    .prize-category .item-content__title { font-size: 0.65rem; }
    #prizeModal .modal__content { padding: 1.5rem 1rem; }
    #prizeModal .modal__item { width: 75px; padding: 6px; }
    #prizeModal .modal__item img { width: 52px; height: 52px; }
}

@media (max-width: 480px) {
    .wheel { --wheel-size: 260px; }
    .prize img { width: 2.5rem; height: 2.5rem; }
    .wheel__center { width: 34px; height: 34px; }
    .wheel__center::before { font-size: 0.85rem; }
    .wheel-balance { padding: 8px 16px; font-size: 0.95rem; }
    .spin-btn { font-size: 0.9rem; border-radius: 10px; }
}
