body.modal-open {
    overflow: hidden;
}


/* =========================================================
   MODAL / Shared 共用規格
========================================================= */
.ui-modal {
    position: fixed;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 24px;
    z-index: 2050;
}

.ui-modal.is-open {
    display: flex;
}

.ui-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(69, 38, 65, .58);
    backdrop-filter: blur(1px);
}


.ui-modal-dialog {
    position: relative;
    z-index: 1;
    width: min(600px, 92vw);
    aspect-ratio: 1152 / 1308;
}

/*Modal 底圖樣式框*/
.ui-modal-frame {
    position: absolute;
    z-index: 1;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    margin-left: -5px;
}

/*Modal 標題*/
.ui-modal-title {
    position: absolute;
    z-index: 4;
    left: 50%;
    top: -5%;
    width: 48%;

    transform: translateX(-50%);
    pointer-events: none;
}
/*Modal 副題*/
.ui-modal-subtitle {
    position: absolute;
    z-index: 5;
    top: 6.5%;
    left: 50%;
    margin: 0;
    color: #775482;
    font-size: clamp(16px, 2.1vw, 24px);
    font-weight: 900;
    letter-spacing: .08em;
    text-align: center;
    text-shadow: 0 2px 0 rgba(255, 255, 255, .85);
    transform: translateX(-50%);
}



/*Modal 關閉按鈕*/
.ui-modal-close {
    position: absolute;
    z-index: 6;
    top: -1%;
    right: -2.2%;
    width: 15%;
    padding: 0;
    border: 0;
    background: transparent;
    transition: transform .2s ease;
}
.ui-modal-close:hover {
    transform: scale(1.06) rotate(5deg);
}
.ui-modal-close img,
.ui-image-btn img {
    display: block;
    width: 100%;
}


/*Modal 下方按鈕*/
.ui-image-btn {
    width: 43%;
    margin: auto auto 0;
    padding: 0;
    border: 0;
    background: transparent;
    transition: transform .2s ease, filter .2s ease;
}
.ui-image-btn:hover {
    transform: translateY(-2px) scale(1.2);
    /* filter: (1.05); */
}


/*Modal 欄位區塊*/
.ui-form{
    position: absolute;
    top: 9.5%;
    right: 10%;
    bottom: 12%;
    left: 12%;
    z-index: 3;
    display: flex;
    flex-direction: column;
    gap: 10px;
    color: #8a5983;
    font-size: 16px;
}

/*Modal 欄位*/
.ui-form-field {
    display: flex;
    flex-direction: column;
    gap: 5px;
}
.ui-form-field label {
    font-weight: 800;
    margin-top: .5rem;
}
.ui-form-field input,
.ui-form-field textarea {
    width: 100%;
    border: 1px solid #df8eb0;
    border-radius: 5px;
    outline: 0;
    background: rgba(255, 255, 255, .92);
    color: #55536b;
    transition: border-color .2s ease, box-shadow .2s ease;
}
.ui-form-field input{
    height: 38px;
    padding: 6px 10px;
    font-size: 14px;
}
.ui-form-field input:focus,
.ui-form-field textarea:focus {
    border-color: #d66ba7;
    box-shadow: 0 0 0 3px rgba(214, 107, 167, .14);
}
.ui-form-field input.is-invalid,
.ui-form-field textarea.is-invalid {
    border-color: #d84b70;
}


/*Modal 勾選區塊*/
.ui-agreements{
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-top: 12px;

}

.ui-agree {
    display: flex;
    align-items: center;
    gap: 7px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 700;
    margin-top: 2px;
}
.ui-agree input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}
.ui-agree a {
    color: #49649f;
    border-bottom: 1px solid #49649f;
}

/*Modal 勾選方框*/
.ui-check {
    position: relative;
    flex: 0 0 20px;
    width: 20px;
    height: 20px;
    border: 2px solid #8168ac;
    border-radius: 7px;
    background: #fff;
    box-shadow: inset 0 0 0 2px #f2d6f0;
}
.ui-agree input:checked + .ui-check::after {
    content: "✓";
    position: absolute;
    top: 50%;
    left: 50%;
    color: #d34d91;
    font-size: 20px;
    font-weight: 900;
    transform: translate(-50%, -55%);
}


/*Modal 注意事項文字*/
.ui-message,
.ui-note{
    min-height: 18px;
    margin: 0;
    color: #c94d72;
    font-size: 12px;
    /* text-align: center; */
}
.ui-note{
    line-height: 1.5;
}



@media (min-width: 1442px) {
    .ui-modal-dialog{
        width:min(680px, 92vw);
    }
}

@media (max-width: 1442px) {
    .ui-modal-title{
        width: 50%;
        top: -3%;
    }
}


@media (max-width: 767.98px) {
    .ui-modal {
        padding: 14px;
    }

    .ui-modal-dialog/*,
    .work-detail-dialog */{
        width: min(560px, 96vw);
    }
    .ui-form {
        top: 10%;
        right: 9%;
        bottom: 7%;
        left: 9%;
        gap: 7px;
        font-size: 12px;
    }
    .ui-agree{
        font-size: 12px;
    }

}

@media (max-width: 575.98px) {
    .ui-modal-title {
        width: 65%;
        top: -6%;
    }

    .ui-form {
        top: 10%;
        right: 8.5%;
        bottom:14.5%;
        left: 12.5%;
        gap: 5px;
    }
    .ui-modal-dialog/*,
    .work-detail-dialog */{
        width: min(430px, 98vw);
        aspect-ratio: 1118 / 1500;
    }

    .ui-modal-close {
        width: 20%;
    }

    .ui-check {
        flex-basis: 22px;
        width: 22px;
        height: 22px;
    }

    .ui-form-field input{
        height: 34px;
    }
    .ui-agreements {
        gap: 10px;
        margin-top: 4px;
    }
    .ui-image-btn {
        width: 50%;
        margin-top: .5rem;
    }
}



/* =========================================================
  MODAL / Contribute 我要投稿
========================================================= */


#contributeModal textarea {
    min-height: 112px;
    padding: 8px 10px;
    resize: vertical;
    font-size: 14px;

}

#contributeImageHelp.ui-note {
    color: #a76d8f;
    text-align: justify;
}

.contribute-ch {
    position: absolute;
    z-index: 5;
    right: -25%;
    bottom: -0%;
    width: 37%;
    pointer-events: none;
}

#contributeModal .ui-form {
    overflow-y: auto;
    overflow-x: hidden;
    padding-right: 8px;
    padding-left: 8px;
    scrollbar-gutter: stable;
    scrollbar-width: thin;
    scrollbar-color: #d58ab6 rgba(255, 255, 255, .5);
}

#contributeModal .ui-form::-webkit-scrollbar {
    width: 7px;
}
#contributeModal .ui-form::-webkit-scrollbar-track {
    border-radius: 99px;
    background: rgba(255, 255, 255, .5);
}
#contributeModal .ui-form::-webkit-scrollbar-thumb {
    border: 1px solid rgba(255, 255, 255, .75);
    border-radius: 99px;
    background: linear-gradient(#c58bda, #ee92bd);
}


@media (max-width: 767.98px) {
    #contributeModal .ui-form {
        padding-right: 15px;
    }
    #contributeModal textarea {
        min-height: 86px;
    }

    #contributeImageHelp.ui-note {
        font-size: 9px;
        line-height: 1.4;
    }
    .contribute-ch {
        right: -8%;
        width: 36%;
    }
}

@media (max-width: 575.98px) {
    #contributeModal textarea {
        min-height: 72px;
    }

    #contributeImageHelp.ui-note {
        font-size: 12px;
    }

    #contributeModal .ui-image-btn {
        width: 50%;
        margin-top: .5rem;
    }

    .contribute-ch {
        right: -7%;
        bottom: 2%;
        width: 24%;
    }
}



/* =========================================================
  MODAL / Contribute 我要投稿 / 截圖說明與注意事項
========================================================= */

.contribute-example {
    flex: 0 0 auto;
    overflow: hidden;
    border:1px solid rgb(189 112 161 / 93%);
    border-radius: 8px;
    background: rgba(255, 255, 255, .42);
    margin-top: .5rem;
    margin-bottom: .5rem;
}

.contribute-example-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 8px 11px;
    border: 0;
    background: rgb(164 91 160);
    color: #fff;
    font: inherit;
    font-weight: 500;
    text-align: left;
}
.contribute-example-toggle span{
    filter: drop-shadow(0px 0px 1.5px rgb(87, 16, 83));
}

.contribute-example-toggle:hover {
    background: rgb(164 91 160);
}
.contribute-example-toggle:focus-visible{
    border: none !important;
    outline: none !important;
}

.contribute-example-icon {
    flex: 0 0 auto;
    margin-left: 10px;
    color: #fff;
    font-size: 19px;
    font-weight: 900;
    line-height: 1;
    transition: transform .25s ease;
}

.contribute-example-content {
    display: grid;
    grid-template-rows: 0fr;
    opacity: 0;
    transition: grid-template-rows .28s ease, opacity .22s ease;
}

.contribute-example-inner {
    min-height: 0;
    overflow: hidden;
}

.contribute-example.is-open .contribute-example-content {
    grid-template-rows: 1fr;
    opacity: 1;
}

.contribute-example.is-open .contribute-example-icon {
    transform: rotate(45deg);
}

.contribute-example-lead,
.contribute-example-note {
    margin: 0;
    color: #925e84;
    font-size: 14px;
    line-height: 1.55;
}

.contribute-example-lead {
    padding: 10px 11px 7px;
    /* font-weight: 700; */
}

.contribute-example-image {
    display: block;
    width: calc(100% - 22px);
    height: auto;
    margin: 0 11px;
    border: 2px solid rgba(255, 255, 255, .9);
    border-radius: 6px;
    box-shadow: 0 3px 10px rgba(104, 63, 99, .12);
}

.contribute-example-note {
    padding: 7px 11px 11px;
}

#contributeModal .ui-agree,
#contributeModal .ui-message,
#contributeModal .ui-submit {
    flex: 0 0 auto;
}

@media (max-width: 767.98px) {

    .contribute-example-toggle {
        padding: 7px 9px;
    }

    .contribute-example-lead,
    .contribute-example-note {
        font-size: 12px;
    }
}




/* =========================================================
  MODAL / Work-Detail 作品展示 MORE
========================================================= */

.detail-cont {
    position: absolute;
    z-index: 3;
    top: 8.5%;
    right: 8.5%;
    bottom: 8.5%;
    left: 8.5%;
    display: flex;
    flex-direction: column;
    color: #85547e;
}

/*
   玩家投稿圖片尺寸可能不同：
   固定外框尺寸 + object-fit: contain 可完整顯示圖片、不變形、不超出框。
   圖片比例不同時會保留適量留白，而不是裁切作品。
*/
.work-detail-image-box {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 48%;
    min-height: 0;
    overflow: hidden;
    border-radius: 12px;
    background: rgba(255, 255, 255, .92);
}

.work-detail-image {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
    object-position: center;
}

.detail-info {
    display: flex;
    flex: 1;
    min-height: 0;
    flex-direction: column;
    padding: 26px 20px 4px;
}

.work-detail-heading {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 20px;
}

.work-detail-title {
    margin: 0 0 6px;
    color: #8e5687;
    font-size: 1.45rem;
    font-weight: 900;
}

.detail-author {
    margin: 0;
    color: #9b638d;
    font-size: .95rem;
    font-weight: 800;
}

.detail-votes {
    display: inline-flex;
    flex: 0 0 auto;
    align-items: center;
    gap: 5px;
    color: #d96e99;
    font-size: 1.45rem;
    font-weight: 900;
}

.detail-votes img {
    width: 27px;
}

#workDetailDescription.ui-message {
    overflow-y: auto;
    max-height: 7em;
    margin: 0px 0 10px;
    padding-right: 5px;
    color: #9d8295;
    font-size: .9rem;
    line-height: 1.7;
    scrollbar-width: thin;
    scrollbar-color: #d58ab6 transparent;
    text-align: justify;
}

#workDetailDescription.ui-message::-webkit-scrollbar {
    width: 5px;
}

#workDetailDescription.ui-message::-webkit-scrollbar-thumb {
    border-radius: 99px;
    background: #d58ab6;
}

#workDetailModal .ui-image-btn{
    width: 30%;
    max-width: 110px;
    margin: 3% auto 0;
}

#workDetailModal .ui-image-btn:hover {
    transform: translateY(-2px) scale(1.03);
    filter: brightness(1.04);
}

#workDetailModal .ui-image-btn.is-voted {
    pointer-events: none;
    filter: grayscale(.35);
    opacity: .72;
}

@media (max-width: 767.98px) {
    .detail-cont {
        top: 9%;
        right: 9%;
        bottom: 8%;
        left: 9%;
    }

    .work-detail-image-box {
        height: 46%;
    }

    .detail-info {
        padding: 18px 12px 2px;
    }

    .work-detail-title {
        font-size: 1.2rem;
    }

    .detail-author,
    #workDetailDescription.ui-message {
        font-size: .82rem;
    }

    .detail-votes {
        font-size: 1.2rem;
    }
}

@media (max-width: 575.98px) {

    .detail-cont {
        top: 9.5%;
        right: 8.5%;
        bottom: 13%;
        left: 12%;
    }

    .work-detail-image-box {
        height: 44%;
        border-radius: 8px;
    }

    .detail-info {
        padding: 14px 8px 0;
    }

    .work-detail-heading {
        gap: 10px;
    }

    .work-detail-title {
        font-size: 1.05rem;
    }

    .detail-author,
    #workDetailDescription.ui-message {
        font-size: .74rem;
    }

    #workDetailDescription.ui-message {
        margin-top: 10px;
        line-height: 1.55;
    }

    .detail-votes {
        font-size: 1rem;
    }

    .detail-votes img {
        width: 21px;
    }

    #workDetailModal .ui-image-btn {
        width: 38%;
    }
}

/* =========================================================
  MODAL / vote-verify 我要投票
========================================================= */

.vote-code-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 145px;
    align-items: center;
    gap: 14px;
}

.vote-code-row .ui-image-btn{
    width: 90%;
}

.vote-verify-get-code:disabled {
    cursor: default;
    opacity: .62;
    transform: none;
    filter: none;
}


.vote-item {
    position: absolute;
    z-index: 5;
    right: -6%;
    bottom: -2%;
    width: 29%;
    pointer-events: none;
    transform: scaleX(-1);
}

@media (max-width: 767.98px) {

    .vote-code-row {
        grid-template-columns: minmax(0, 1fr) 125px;
        gap: 9px;
    }
    .vote-item {
        right: -2%;
        width: 27%;
    }
}

@media (max-width: 575.98px) {

    .vote-verify-subtitle {
        top: 4%;
        font-size: 22px;
    }

    .vote-code-row {
        grid-template-columns: minmax(0, 1fr) 110px;
        gap: 7px;
    }

    .vote-item {
        right: 0;
        bottom: -1%;
        width: 24%;
    }
}


/* =========================================================
   投稿／投票結果 Modal：延用原本 modal_bg.webp 外框
========================================================= */
.contest-result-content {
    position: absolute;
    z-index: 3;
    inset: 12% 7% 12% 10%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    gap: 18px;
    overflow-y: auto;
    text-align: center;
    color: #835274;
}
.contest-result-content [hidden],
.contribute-edit-heading[hidden],
.contribute-edit-submit-image[hidden] {
    display: none !important;
}
.contest-result-title,
.contribute-edit-heading {
    margin: 0;
    color: #a05d9a;
    font-size: clamp(22px, 3vw, 3rem);
    font-weight: 800;
    text-align: center;
}
.contribute-edit-heading {
    position: absolute;
    z-index: 4;
    top: 3%;
    left: 15%;
    width: 70%;
}
.contest-result-description,
.contest-result-deadline,
.contest-result-notice,
.contest-result-reason {
    margin: 0;
    line-height: 1.7;
    font-size: clamp(12px, 1.5vw, 14px);
}
.contest-result-deadline { font-weight: 700; }
.contest-result-notice,
.contest-result-reason {
    padding: 10px;
    border-radius: 8px;
    background: rgba(255, 255, 255, .55);
    margin-bottom: 3%;
}
.contest-result-preview {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    width: 100%;
    text-align: left;
    font-size: 14px;
}
.contest-result-preview img {
    width: 90%;
    max-height: 200px;
    object-fit: contain;
    border-radius: 8px;
}
.contest-result-preview p { margin: 5px 0 0; }
.contest-result-status {
    margin: 0;
    padding: 5px 16px;
    border-radius: 30px;
    /* background: #cd5892; */
    font-weight: 800;
    font-size: 1.5rem;
    margin-top: 2%;
    margin-bottom: 2%;
}
#contestResultStatus{color: #ce5c97;}

.contest-result-votes {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: baseline;
    gap: 8px;
    width: 100%;
    margin-top: 5%;
    margin-bottom: 5%;
}
.contest-result-vote-number {
    font-size: clamp(44px, 8vw, 78px);
    line-height: 1.1;
    font-weight: 900;
    font-variant-numeric: tabular-nums;
    color: #b35c9e;
    text-shadow: 0 3px 0 #fff;
}
.contest-result-vote-delta {
    color: #348e65;
    font-size: 22px;
}
.contest-result-actions {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 10px;
    width: 100%;
}
.contest-result-button {
    border: 1px solid #b777ac;
    border-radius: 30px;
    padding: 9px 23px;
    background: #a765a1;
    color: white;
    font-weight: 700;
    cursor: pointer;
    min-width: 150px;
}


@media (max-width: 600px) {
    .contest-result-content { inset: 10% 10% 10%; gap: 8px; }
    .contest-result-preview img { max-height: 120px; }
    .contest-result-button {
        min-width: 130px;
        font-size: 15px;
    }
    .contest-result-button { padding: 7px 16px; }
}
@media (prefers-reduced-motion: reduce) {
    .contest-result-vote-number { transition: none; }
}

/* 投稿／修改成功：標題上方的小型星光裝飾 */
.contest-result-success-icon {
    color: #efba5c;
    font-size: clamp(24px, 3.8vw, 42px);
    line-height: 1;
    text-shadow: 0 2px 0 #fff, 0 3px 8px rgba(179, 92, 158, .25);
}
.contest-result-success-icon span {
    color: #ed93c7;
    font-size: 1.3em;
}
.contest-result-notice p {
    margin: 0;
    line-height: 1.7;
}
.contest-result-notice p + p {
    margin-top: 6px;
}
/* 修改模式保留原有圖片標題，文字副標置於圖下方 */
.contribute-edit-heading {
    position: absolute;
    z-index: 4;
    top: 6%;
    left: 15%;
    width: 70%;
    font-size: clamp(13px, 2vw, 20px);
    color: #a05d9a;
    text-shadow: 0 1px 0 #fff;
}

/* 審核結果標題與投稿表單共用 .ui-modal-title 的位置、寬度及 RWD。 */
#contestResultImageTitle[hidden] {
    display: none !important;
}
.contest-result-content {
    overflow-y: auto;
    overflow-x: hidden;
    padding-right: 8px;
    padding-left: 8px;
    scrollbar-gutter: stable;
    scrollbar-width: thin;
    scrollbar-color: #d58ab6 rgba(255, 255, 255, .5);
}
.contest-result-content::-webkit-scrollbar {
    width: 7px;
}
.contest-result-content::-webkit-scrollbar-track {
    border-radius: 99px;
    background: rgba(255, 255, 255, .5);
}
.contest-result-content::-webkit-scrollbar-thumb {
    border: 1px solid rgba(255, 255, 255, .75);
    border-radius: 99px;
    background: linear-gradient(#c58bda, #ee92bd);
}

/* 圖片上傳：沿用投稿／修改投稿的共用表單與配色。 */
.contribute-upload-row { display: flex; align-items: center; gap: 10px; min-width: 0; }
.contribute-upload-button { flex-shrink: 0; border: 1px solid #df8eb0; border-radius: 5px; padding: 7px 20px; color: #8a5983; background: #fff5fb; font: inherit; cursor: pointer; font-size: x-large;}
.contribute-upload-button:focus-visible,
.contribute-clear-button:focus-visible { outline: 3px solid #d66ba7; outline-offset: 2px; }
.contribute-file-name { min-width: 0; overflow-wrap: anywhere; font-size: 12px; }
#contributeModal .contribute-file-input { position: absolute; width: 1px; height: 1px; padding: 0; opacity: 0; clip-path: inset(50%); }
.contribute-image-preview { margin: 0; padding: 8px; border: 1px solid #df8eb0; border-radius: 5px; background: rgba(255,255,255,.7); text-align: center; transition: border-color 0.2s, background-color 0.2s; }
.contribute-image-preview.has-new-file { border: 2px dashed #10b981; background: rgba(236, 253, 245, 0.9); }
.contribute-image-preview.has-new-file figcaption { color: #047857; font-weight: 600; }
.contribute-image-preview[hidden] { display: none; }
.contribute-image-preview img { display: block; max-width: 100%; max-height: 180px; margin: 0 auto 6px; object-fit: contain; }
.contribute-image-preview figcaption { margin-bottom: 6px; font-size: 12px; overflow-wrap: anywhere; }
#contributeImageError:empty { display: none; }
#contributeModal .ui-form > * { flex-shrink: 0; }
@media (max-height: 760px) { #contributeModal .ui-modal-dialog { max-height: 85dvh; } }

/* 取消選取是預覽區的次要操作，與上傳入口分開設定。 */
.contribute-clear-button {
    display: block;
    width: auto;
    min-height: 32px;
    margin: 4px 0 0 auto;
    padding: 4px 8px;
    border: 0;
    border-radius: 4px;
    background: transparent;
    color: #8a5983;
    font: inherit;
    font-size: 13px;
    line-height: 1.5;
    text-decoration: underline;
    text-underline-offset: 3px;
    cursor: pointer;
}
.contribute-clear-button:hover { background: #f7e3ef; }
.contribute-clear-button[hidden] { display: none; }
.contribute-image-preview figcaption[hidden] { display: none; }

/* 僅能上傳一張：選好後隱藏新增入口，清除後再顯示。 */
#contributeChooseImage[hidden] { display: none; }
#contributeChooseImage.is-replace { padding: 7px 12px; font-size: 13px; line-height: 1.5; }

/* 投稿與修改共用圖片按鈕尺寸，依模式僅顯示其中一張。 */
#contributeSubmitButton img[hidden] { display: none; }
