.spin-wrapper {
    display: grid;
    grid-template-columns: 320px 1fr;
    gap: 30px;
    align-items: flex-start;
    max-width: 980px;
    min-height: 450px;
    /* Reserve space to prevent CLS */
    margin: 40px auto 70px;
    background: #fff;
    padding: 25px;
    border-radius: 16px;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.08);
    border: 1px solid #e9e9e9;
}

.config-panel {
    background: #f7f7fa;
    padding: 16px;
    border-radius: 12px;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.06);
}

.config-panel h2 {
    margin-top: 0;
    font-size: 22px;
    text-align: center;
    margin-bottom: 15px;
}

.spin-wrapper .config-input {
    width: 100%;
    padding: 8px 10px;
    margin: 8px 0;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 16px;
    background-color: #fff;
    transition: border-color 0.2s, box-shadow 0.2s;
}

/* Wrapper for custom select arrow */
.select-wrapper {
    position: relative;
    margin: 4px 0 8px;
}

.select-wrapper::after {
    content: '';
    position: absolute;
    top: 50%;
    right: 12px;
    transform: translateY(-50%);
    width: 18px;
    height: 18px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23555' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: center;
    pointer-events: none;
}

/* Style for select elements to hide default arrow */
.select-wrapper select.config-input {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    padding-right: 40px;
    /* Make space for the arrow */
    margin: 0;
}

/* Hide spinners from number inputs */
.config-input[type=number]::-webkit-outer-spin-button,
.config-input[type=number]::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.config-input[type=number] {
    appearance: textfield;
    -moz-appearance: textfield;
    /* Firefox */
}

.wheel-panel {
    position: relative;
    width: 100%;
    max-width: 450px;
    margin: 0 auto;
    /* Center it within the grid cell */
    aspect-ratio: 1 / 1;
}

.wheel-pointer {
    width: 0;
    height: 0;
    border-left: 15px solid transparent;
    border-right: 15px solid transparent;
    border-top: 30px solid #000000;
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    top: -15px;
    z-index: 10;
    filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.3));
}

#spin-wheel:focus-visible {
    outline: 2px solid #4e54c8;
    outline-offset: 4px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15), 0 0 0 4px #fff, 0 0 0 6px #4e54c8;
}

#spin-wheel {
    border-radius: 50%;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
    background: #fff;
    width: 100%;
    height: 100%;
}

.spin-button {
    padding: 7px 13px;
    font-size: 17px;
    border: none;
    border-radius: 8px;
    background: linear-gradient(90deg, #4e54c8, #8f94fb);
    color: #fff;
    letter-spacing: 1px;
    font-weight: 500;
    cursor: pointer;
}

.button-container {
    display: flex;
    gap: 10px;
    margin-top: 20px;
    justify-content: center;
    align-items: center;
}

/* New styles for text list */
#text-list-container {
    margin-bottom: 8px;
    max-height: 150px;
    overflow-y: auto;
}

.text-list-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 8px;
    background: #e9e9f0;
    margin-bottom: 4px;
    border-radius: 4px;
    font-size: 14px;
}

.item-controls {
    display: flex;
    align-items: center;
}

.remove-item-btn {
    cursor: pointer;
    color: #ff3b7a;
    font-weight: bold;
    font-size: 20px;
    padding: 0 5px;
}

.edit-item-btn {
    cursor: pointer;
    padding: 0 5px;
    margin-right: 2px;
    display: flex;
    align-items: center;
}

.edit-item-btn svg {
    width: 16px;
    height: 16px;
    stroke: #555;
    transition: stroke 0.2s;
}

.save-item-btn {
    cursor: pointer;
    padding: 0 5px;
    display: flex;
    align-items: center;
}

.save-item-btn svg {
    width: 16px;
    height: 16px;
    stroke: #28a745;
}

.add-item-form {
    display: flex;
    gap: 8px;
}

.add-item-form .config-input {
    margin: 0;
}

.spin-button-small {
    padding: 5px 10px;
    border: 1px solid transparent;
    background: #1a6fa8e6;
    color: white;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 500;
    font-size: 16px;
}

.clear-button {
    padding: 7px 13px;
    font-size: 17px;
    border: none;
    border-radius: 8px;
    background: #7c7272;
    color: #fff;
    letter-spacing: 1px;
    font-weight: 500;
    cursor: pointer;
}

.mute-button {
    width: 48px;
    height: 41px;
    border: none;
    border-radius: 8px;
    background: #7c7272;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 0;
}

.mute-button svg {
    width: 20px;
    height: 20px;
    stroke: #fff;
}

.drop-zone {
    position: relative;
    border: 2px dashed #ccc;
    border-radius: 8px;
    padding: 25px;
    text-align: center;
    color: #777;
    cursor: pointer;
    margin-top: 8px;
    transition: border-color 0.2s, background-color 0.2s;
}

.drop-zone.loading {
    cursor: wait;
}

.drop-zone .spinner {
    display: none;
    border: 4px solid rgba(0, 0, 0, 0.1);
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border-left-color: #36A2EB;
    animation: spinner-spin 1s linear infinite;
    position: absolute;
    top: 50%;
    left: 50%;
    margin-top: -18px;
    margin-left: -18px;
    z-index: 1;
}

.drop-zone.loading .spinner {
    display: block;
}

.drop-zone.loading>p,
.drop-zone.loading>#browse-btn {
    visibility: hidden;
}

.drop-zone.drag-over {
    border-color: #36A2EB;
    background-color: #f0f8ff;
}

.drop-zone p {
    margin: 0 0 10px 0;
}

@keyframes spinner-spin {
    to {
        transform: rotate(360deg);
    }
}

#image-preview-container {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 10px;
}

.img-preview-wrapper {
    position: relative;
}

.img-preview {
    width: 50px;
    height: 50px;
    object-fit: cover;
    border-radius: 4px;
    border: 1px solid #ddd;
}

.remove-img-btn {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #ff3b7a;
    color: white;
    border-radius: 50%;
    width: 18px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: bold;
    cursor: pointer;
    line-height: 18px;
}

.remove-img-btn:hover {
    background: #e0004c;
}

#text-config>label,
#images-config>label {
    font-weight: 500;
    color: #333;
    display: block;
    margin-bottom: 8px;
}

.shuffle-container {
    display: flex;
    justify-content: flex-start;
    margin: 8px 0;
}

.shuffle-button {
    background: #f0f0f0;
    color: #222222;
    border: 1px solid #ccc;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    padding: 6px 12px;
    line-height: 1;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 6px;
}

.shuffle-button svg {
    width: 15px;
    height: 15px;
    stroke: #333;
}

.shuffle-button.clicked,
.spin-button.clicked,
.clear-button.clicked,
.mute-button.clicked {
    animation: button-click-effect 0.3s ease-in-out;
}

@keyframes button-click-effect {
    0% {
        transform: scale(1);
    }

    50% {
        transform: scale(0.92);
    }

    100% {
        transform: scale(1);
    }
}

/* Popup Styles */
.popup-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    display: none;
    /* Hidden by default */
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.popup-content {
    background: #fff;
    padding: 50px 40px 30px;
    border-radius: 12px;
    text-align: center;
    position: relative;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
    font-size: 36px;
    font-weight: 500;
    width: 400px;
    max-width: 90vw;
    box-sizing: border-box;
}

.popup-title {
    position: absolute;
    top: 15px;
    left: 20px;
    font-size: 22px;
    font-weight: 500;
    color: #777;
}

button.popup-close {
    border: none;
    background: none;
    padding: 0;
}

button.fullscreen-close {
    border: none;
    padding: 0;
}

.popup-close,
.fullscreen-close {
    position: absolute;
    top: 10px;
    right: 15px;
    font-size: 30px;
    font-weight: 500;
    color: #777;
    cursor: pointer;
    line-height: 1;
    outline: none;
}

#result-popup .popup-close:hover,
#result-popup .popup-close:focus,
#result-popup .popup-close:active {
    color: #777;
    background: none;
    border: none;
    box-shadow: none;
    outline: none;
}

#popup-result-content {
    animation: bounceInEffect 0.6s ease-out;
    overflow-wrap: break-word;
    line-height: 1.2;
    color: #581eb8;
}

@keyframes bounceInEffect {
    0% {
        opacity: 0;
        transform: scale(0.3);
    }

    50% {
        opacity: 1;
        transform: scale(1.05);
    }

    70% {
        transform: scale(0.9);
    }

    100% {
        transform: scale(1);
    }
}

#popup-result-content img {
    max-width: 150px;
    height: auto;
    margin-top: 10px;
    border-radius: 8px;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.2);
}

.popup-image-wrapper {
    position: relative;
    display: inline-block;
    /* To make it wrap the image size */
    line-height: 0;
    /* Removes extra space below image */
}

.fullscreen-icon {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 32px;
    height: 32px;
    background-color: rgba(0, 0, 0, 0.5);
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    transition: background-color 0.2s;
}

.fullscreen-icon:hover {
    background-color: rgba(0, 0, 0, 0.7);
}

.fullscreen-icon svg {
    width: 18px;
    height: 18px;
    stroke: white;
}

/* Fullscreen Viewer Styles */
.fullscreen-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.9);
    display: none;
    /* Hidden by default */
    justify-content: center;
    align-items: center;
    z-index: 2000;
    /* Higher than the result popup */
}

.fullscreen-overlay img {
    max-width: 95%;
    max-height: 95%;
    object-fit: contain;
}

.fullscreen-close {
    position: absolute;
    top: 20px;
    right: 25px;
    font-size: 40px;
    font-weight: bold;
    color: #fff;
    cursor: pointer;
    line-height: 1;
    background-color: rgba(0, 0, 0, 0.5);
    width: 44px;
    height: 44px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

select.config-input:hover,
select.config-input:active,
input[type="text"].config-input:hover,
input[type="text"].config-input:active,
input[type="number"].config-input:hover,
input[type="number"].config-input:active {
    border-color: #ddd;
    box-shadow: none;
    outline: none;
}

/* Inputs and Selects */
select.config-input:focus,
input[type="text"].config-input:focus,
input[type="number"].config-input:focus {
    background-color: #fff;
    border-color: #8f94fb;
    box-shadow: 0 0 0 1px rgba(143, 148, 251, 0.25);
    outline: none;
}

/* Main Buttons */
button.spin-button:hover,
button.spin-button:focus,
button.spin-button:active {
    background: linear-gradient(90deg, #4e54c8, #8f94fb);
    border: none;
    outline: none;
}

button.clear-button:hover,
button.clear-button:focus,
button.clear-button:active {
    background: #7c7272;
    border: none;
    outline: none;
}

button.mute-button:hover,
button.mute-button:focus,
button.mute-button:active {
    background: #7c7272;
    border: none;
    outline: none;
}

/* Smaller Buttons */
button.spin-button-small:hover,
button.spin-button-small:focus,
button.spin-button-small:active {
    background: #1a6fa8e6;
    border-color: transparent;
    outline: none;
}

button.shuffle-button:hover,
button.shuffle-button:focus,
button.shuffle-button:active {
    background: #f0f0f0;
    color: #222222;
    border: 1px solid #ccc;
    outline: none;
}

/* Inline icon buttons */
.remove-item-btn:hover {
    color: #e0004c;
}

.edit-item-btn:hover svg {
    stroke: #555;
}

.save-item-btn:hover svg {
    stroke: #28a745;
}

.faq-list {
    margin-top: 1rem;
}

.faq-list dt {
    font-weight: 500;
    font-size: 1.1em;
}

.faq-list dd {
    margin-left: 0;
    margin-top: 0.5rem;
    margin-bottom: 1rem;
    padding-left: 1rem;
    padding-bottom: 10px;
    border-bottom: 1px dashed #ddd;
}

@media (max-width: 768px) {
    .spin-wrapper {
        display: block;
        min-height: 0;
        /* Override desktop min-height */
        background: transparent;
        padding: 20px 9px;
        margin: 10px 0 60px 0;
        border: 0;
        border-radius: 10px;
    }

    .config-panel {
        background: transparent;
        padding: 0;
        box-shadow: none;
        margin-bottom: 30px;
        /* Add space between config and wheel */
    }

    .spin-button {
        padding: 8px 13px;
    }

    .clear-button {
        padding: 8px 13px;
    }

    #spin-wheel:focus-visible {
        outline: none;
        box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
    }
}