/* =========================================================
   評分榜
   Modern UI
   ========================================================= */

* {
    box-sizing: border-box;
}

html {
    margin: 0;
    padding: 0;
    background: #f6f7f9;
}

body {
    margin: 0;
    min-height: 100vh;

    background: #f6f7f9;
    color: #171717;

    font-family:
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        "Noto Sans TC",
        "Microsoft JhengHei",
        Arial,
        sans-serif;

    -webkit-font-smoothing: antialiased;
}

button,
input,
textarea {
    font: inherit;
}

button {
    cursor: pointer;
}

a {
    color: inherit;
    text-decoration: none;
}


/* =========================================================
   全站
   ========================================================= */

.container {
    width: min(1120px, calc(100% - 48px));
    margin: 0 auto;
}

.page {
    min-height: 100vh;
}


/* =========================================================
   Header
   ========================================================= */

.site-header {
    height: 72px;

    display: flex;
    align-items: center;

    border-bottom: 1px solid #e9e9e9;

    background: rgba(255, 255, 255, 0.82);

    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);

    position: sticky;
    top: 0;
    z-index: 100;
}

.site-header .container {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.logo {
    font-size: 20px;
    font-weight: 850;
    letter-spacing: -0.5px;
}

.logo a {
    transition: opacity 0.15s ease;
}

.logo a:hover {
    opacity: 0.6;
}


/* =========================================================
   通用按鈕
   ========================================================= */

.primary-button,
.secondary-button,
.danger-button,
.hero-button {
    display: inline-flex;

    align-items: center;
    justify-content: center;

    min-height: 46px;

    padding: 0 20px;

    border: 0;
    border-radius: 11px;

    font-size: 15px;
    font-weight: 700;

    white-space: nowrap;

    transition:
        transform 0.15s ease,
        box-shadow 0.15s ease,
        background 0.15s ease,
        opacity 0.15s ease;
}

.primary-button,
.hero-button {
    background: #171717;
    color: white;

    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.12);
}

.primary-button:hover,
.hero-button:hover {
    background: #303030;

    transform: translateY(-2px);

    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.16);
}

.secondary-button {
    background: white;
    color: #222;

    border: 1px solid #dedede;
}

.secondary-button:hover {
    background: #f3f3f3;

    transform: translateY(-1px);
}

.danger-button {
    background: #ef4444;
    color: white;
}

.danger-button:hover {
    background: #dc2626;

    transform: translateY(-1px);
}

.primary-button:active,
.secondary-button:active,
.danger-button:active,
.hero-button:active {
    transform: translateY(0);
}


/* =========================================================
   首頁
   ========================================================= */

.hero {
    min-height: calc(100vh - 72px);

    display: flex;
    align-items: center;
    justify-content: center;

    padding: 70px 20px 100px;
}

.hero-content {
    width: min(760px, 100%);

    text-align: center;
}

.hero h1 {
    margin: 0;

    font-size: clamp(56px, 8vw, 86px);
    line-height: 1;

    font-weight: 900;

    letter-spacing: -4px;
}

.hero-subtitle {
    max-width: 560px;

    margin: 28px auto 0;

    color: #686868;

    font-size: 18px;
    line-height: 1.8;
}

.hero-button {
    margin-top: 34px;

    min-width: 190px;
    min-height: 50px;

    font-size: 16px;
}

.hero-button::after {
    content: "→";

    margin-left: 10px;

    font-size: 18px;

    transition: transform 0.15s ease;
}

.hero-button:hover::after {
    transform: translateX(3px);
}


/* =========================================================
   建立評分榜
   ========================================================= */

.create-page {
    min-height: calc(100vh - 72px);

    padding: 70px 20px 100px;
}

.create-container {
    width: min(650px, 100%);
    margin: 0 auto;
}

.page-title {
    margin: 0;

    font-size: clamp(36px, 5vw, 52px);
    line-height: 1.15;

    font-weight: 900;

    letter-spacing: -2px;
}

.page-description {
    margin: 14px 0 32px;

    color: #707070;

    font-size: 16px;
    line-height: 1.7;
}


/* =========================================================
   表單卡片
   ========================================================= */

.form-card {
    padding: 30px;

    background: white;

    border: 1px solid #e7e7e7;
    border-radius: 18px;

    box-shadow:
        0 8px 30px rgba(0, 0, 0, 0.06);
}

.form-group {
    margin-bottom: 24px;
}

.form-group:last-child {
    margin-bottom: 0;
}

.form-group label {
    display: block;

    margin-bottom: 9px;

    font-size: 14px;
    font-weight: 750;
}

.form-group input,
.form-group textarea {
    width: 100%;

    padding: 13px 15px;

    border: 1px solid #dcdcdc;
    border-radius: 10px;

    outline: none;

    background: #fafafa;

    color: #171717;

    transition:
        background 0.15s ease,
        border-color 0.15s ease,
        box-shadow 0.15s ease;
}

.form-group input {
    height: 48px;
}

.form-group textarea {
    min-height: 125px;

    resize: vertical;

    line-height: 1.6;
}

.form-group input:focus,
.form-group textarea:focus {
    background: white;

    border-color: #777;

    box-shadow:
        0 0 0 3px rgba(0, 0, 0, 0.06);
}

.form-actions {
    display: flex;

    gap: 10px;

    margin-top: 28px;
}

.form-actions button,
.form-actions a {
    flex: 1;
}


/* =========================================================
   評分榜頁面
   ========================================================= */

.rank-page {
    width: min(1180px, calc(100% - 48px));

    margin: 0 auto;

    padding: 55px 0 90px;
}

.rank-header {
    margin-bottom: 32px;
}

.rank-header-top {
    display: flex;

    align-items: flex-start;
    justify-content: space-between;

    gap: 30px;
}

#rankTitle,
.rank-title {
    margin: 0;

    font-size: clamp(34px, 5vw, 54px);
    line-height: 1.15;

    font-weight: 900;

    letter-spacing: -2px;

    word-break: break-word;
}

#rankDescription,
.rank-description {
    max-width: 700px;

    margin: 14px 0 0;

    color: #707070;

    font-size: 16px;
    line-height: 1.7;

    white-space: pre-wrap;
}

.rank-actions {
    display: flex;

    flex-wrap: wrap;

    gap: 10px;

    margin-top: 25px;
}


/* =========================================================
   Tier List
   ========================================================= */

#board {
    width: 100%;

    overflow: hidden;

    background: #dcdcdc;

    border: 1px solid #d2d2d2;
    border-radius: 18px;

    box-shadow:
        0 10px 35px rgba(0, 0, 0, 0.08);
}

.tier-row {
    display: grid;

    grid-template-columns: 160px minmax(0, 1fr);

    min-height: 125px;

    border-bottom: 2px solid #f6f6f6;
}

.tier-row:last-child {
    border-bottom: 0;
}

.tier-label {
    display: flex;

    flex-direction: column;

    align-items: center;
    justify-content: center;

    padding: 18px;

    text-align: center;
}

.tier-name {
    font-size: 31px;

    line-height: 1.1;

    font-weight: 900;

    letter-spacing: -1px;

    white-space: nowrap;
}

.tier-range {
    margin-top: 7px;

    font-size: 12px;

    font-weight: 700;

    opacity: 0.62;
}

.tier-items {
    display: flex;

    align-items: center;

    flex-wrap: wrap;

    gap: 10px;

    min-width: 0;

    padding: 16px;

    background: #eeeeee;
}


/* =========================================================
   五個 Tier 顏色
   ========================================================= */

.tier-hot .tier-label {
    background: #ef3028;
    color: white;
}

.tier-top .tier-label {
    background: #f6c63d;
    color: #111;
}

.tier-rich .tier-label {
    background: #fff200;
    color: #111;
}

.tier-npc .tier-label {
    background: #fff0cf;
    color: #111;
}

.tier-done .tier-label {
    background: #d2d2d2;
    color: #111;
}


/* =========================================================
   排行榜項目
   ========================================================= */

.rank-item {
    display: flex;

    flex-direction: column;

    justify-content: center;

    min-width: 135px;

    max-width: 240px;

    min-height: 76px;

    padding: 13px 16px;

    background: white;

    border: 1px solid #e4e4e4;
    border-radius: 12px;

    box-shadow:
        0 3px 9px rgba(0, 0, 0, 0.07);

    cursor: pointer;

    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
    -webkit-tap-highlight-color: transparent;

    transition:
        transform 0.15s ease,
        box-shadow 0.15s ease;
}

.rank-item:hover {
    transform: translateY(-3px);

    box-shadow:
        0 9px 20px rgba(0, 0, 0, 0.12);
}

.rank-item-name {
    font-size: 16px;

    line-height: 1.4;

    font-weight: 750;

    word-break: break-word;
}

.rank-item-score {
    margin-top: 5px;

    color: #777;

    font-size: 12px;

    font-weight: 650;
}

.empty-tier {
    flex: 1;

    min-height: 50px;
}


/* =========================================================
   尚無評分
   ========================================================= */

.no-score-row .tier-label {
    background: #999;
    color: white;
}

.no-score-row .rank-item {
    opacity: 0.72;
}


/* =========================================================
   Modal
   ========================================================= */

.modal {
    position: fixed;

    inset: 0;

    z-index: 1000;

    display: none;

    align-items: center;
    justify-content: center;

    padding: 24px;

    background: rgba(0, 0, 0, 0.48);

    backdrop-filter: blur(7px);
    -webkit-backdrop-filter: blur(7px);
}

.modal.show {
    display: flex;
}

.modal-content {
    width: min(760px, 100%);

    max-height: 90vh;

    overflow-y: auto;

    padding: 30px;

    background: white;

    border: 1px solid #e6e6e6;

    border-radius: 20px;

    box-shadow:
        0 25px 70px rgba(0, 0, 0, 0.25);

    animation: modal-in 0.18s ease-out;
}

@keyframes modal-in {
    from {
        opacity: 0;

        transform:
            translateY(15px)
            scale(0.98);
    }

    to {
        opacity: 1;

        transform:
            translateY(0)
            scale(1);
    }
}

.modal-header {
    display: flex;

    align-items: flex-start;

    justify-content: space-between;

    gap: 20px;

    margin-bottom: 25px;
}

.modal-header h2 {
    margin: 0;

    font-size: 26px;

    font-weight: 850;
}

.modal-header p {
    margin: 7px 0 0;

    color: #777;

    font-size: 14px;

    line-height: 1.5;
}

.modal-close {
    display: flex;

    align-items: center;
    justify-content: center;

    flex: 0 0 auto;

    width: 38px;
    height: 38px;

    padding: 0;

    border: 0;
    border-radius: 50%;

    background: #f0f0f0;

    color: #444;

    font-size: 25px;

    cursor: pointer;

    transition:
        background 0.15s ease,
        transform 0.15s ease;
}

.modal-close:hover {
    background: #e3e3e3;

    transform: rotate(5deg);
}


/* =========================================================
   投票區
   ========================================================= */

.vote-item {
    padding: 20px 0;

    border-bottom: 1px solid #e8e8e8;
}

.vote-item:first-child {
    padding-top: 0;
}

.vote-item:last-child {
    border-bottom: 0;
}

.vote-item-name {
    margin-bottom: 12px;

    font-size: 17px;

    font-weight: 800;

    line-height: 1.4;

    word-break: break-word;
}

.vote-options {
    display: grid;

    grid-template-columns:
        repeat(5, minmax(0, 1fr));

    gap: 8px;
}


/* =========================================================
   五個投票按鈕
   ========================================================= */

.vote-option {
    display: flex;

    flex-direction: column;

    align-items: center;
    justify-content: center;

    min-height: 72px;

    padding: 8px 5px;

    border: 2px solid #e2e2e2;

    border-radius: 12px;

    background: white;

    color: #222;

    cursor: pointer;

    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
    -webkit-tap-highlight-color: transparent;

    transition:
        transform 0.15s ease,
        border-color 0.15s ease,
        background 0.15s ease,
        box-shadow 0.15s ease;
}

.vote-option:hover {
    transform: translateY(-2px);

    border-color: #aaa;

    box-shadow:
        0 5px 14px rgba(0, 0, 0, 0.08);
}

.vote-option.selected {
    transform: translateY(-2px);

    box-shadow:
        0 7px 17px rgba(0, 0, 0, 0.13);
}

.vote-option-name {
    font-size: 15px;

    font-weight: 850;

    line-height: 1.2;

    white-space: nowrap;
}

.vote-option-score {
    margin-top: 5px;

    color: #777;

    font-size: 11px;

    font-weight: 650;
}


/* 選中後的五種顏色 */

.vote-option:nth-child(1).selected {
    background: #ef3028;

    border-color: #ef3028;

    color: white;
}

.vote-option:nth-child(2).selected {
    background: #f6c63d;

    border-color: #f6c63d;

    color: #111;
}

.vote-option:nth-child(3).selected {
    background: #fff200;

    border-color: #fff200;

    color: #111;
}

.vote-option:nth-child(4).selected {
    background: #fff0cf;

    border-color: #eadbb8;

    color: #111;
}

.vote-option:nth-child(5).selected {
    background: #d2d2d2;

    border-color: #bdbdbd;

    color: #111;
}

.vote-option.selected .vote-option-score {
    color: inherit;

    opacity: 0.6;
}


/* =========================================================
   新增項目
   ========================================================= */

.add-item-box {
    display: flex;

    align-items: center;

    gap: 10px;

    margin-top: 20px;

    padding-top: 20px;

    border-top: 1px solid #e8e8e8;
}

.add-item-box input {
    flex: 1;

    min-width: 0;

    height: 46px;

    padding: 0 14px;

    border: 1px solid #dcdcdc;

    border-radius: 10px;

    outline: none;

    background: #fafafa;

    transition:
        border-color 0.15s ease,
        background 0.15s ease,
        box-shadow 0.15s ease;
}

.add-item-box input:focus {
    background: white;

    border-color: #777;

    box-shadow:
        0 0 0 3px rgba(0, 0, 0, 0.05);
}

.submit-vote-button {
    width: 100%;

    margin-top: 12px;

    min-height: 50px;

    font-size: 16px;
}


/* =========================================================
   詳細資料
   ========================================================= */

.detail-main {
    text-align: center;

    padding: 5px 0 25px;
}

#detailName {
    margin: 0;

    font-size: 28px;

    font-weight: 850;

    word-break: break-word;
}

.detail-average {
    margin-top: 20px;

    font-size: 58px;

    line-height: 1;

    font-weight: 900;

    letter-spacing: -2px;
}

.detail-votes {
    margin-top: 8px;

    color: #777;

    font-size: 14px;
}

.distribution {
    display: flex;

    flex-direction: column;

    gap: 10px;

    margin-top: 20px;
}

.distribution-row {
    display: grid;

    grid-template-columns:
        80px minmax(0, 1fr) 40px;

    align-items: center;

    gap: 10px;

    font-size: 13px;
}

.distribution-label {
    font-weight: 750;
}

.distribution-bar {
    height: 9px;

    overflow: hidden;

    background: #ededed;

    border-radius: 999px;
}

.distribution-bar-fill {
    height: 100%;

    width: 0%;

    border-radius: 999px;

    transition: width 0.25s ease;
}

.distribution-value {
    text-align: right;

    color: #666;

    font-weight: 700;
}

.detail-actions {
    display: flex;

    gap: 10px;

    margin-top: 28px;
}

.detail-actions button {
    flex: 1;
}


/* =========================================================
   空狀態
   ========================================================= */

.empty-vote {
    padding: 50px 20px;

    text-align: center;

    color: #888;

    font-size: 15px;
}

.error-message {
    padding: 0;

    text-align: left;

    color: #dc2626;

    font-size: 13px;

    font-weight: 700;

    min-height: 0;
}

.error-message:not(:empty) {
    margin-bottom: 16px;
}

#board .error-message {
    padding: 50px 20px;

    text-align: center;
    font-size: 15px;
}


/* =========================================================
   Scrollbar
   ========================================================= */

::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: #c9c9c9;

    border-radius: 999px;
}

::-webkit-scrollbar-thumb:hover {
    background: #aaa;
}


/* =========================================================
   Tablet
   ========================================================= */

@media (max-width: 800px) {

    .container {
        width: calc(100% - 32px);
    }

    .rank-page {
        width: calc(100% - 32px);
    }

    .rank-header-top {
        flex-direction: column;
    }

    .rank-actions {
        width: 100%;
    }

    .rank-actions .primary-button,
    .rank-actions .secondary-button {
        flex: 1;
    }

    .tier-row {
        grid-template-columns: 125px minmax(0, 1fr);
    }

    .tier-name {
        font-size: 25px;
    }
}


/* =========================================================
   Mobile
   ========================================================= */

@media (max-width: 600px) {

    .site-header {
        height: 62px;
    }

    .logo {
        font-size: 18px;
    }

    .hero {
        min-height: calc(100vh - 62px);

        padding:
            50px 18px
            70px;
    }

    .hero h1 {
        font-size: 58px;

        letter-spacing: -3px;
    }

    .hero-subtitle {
        margin-top: 22px;

        font-size: 16px;

        line-height: 1.75;
    }

    .hero-button {
        width: 100%;

        margin-top: 28px;
    }


    /* 建立頁 */

    .create-page {
        padding: 40px 16px 70px;
    }

    .form-card {
        padding: 22px;

        border-radius: 16px;
    }

    .form-actions {
        flex-direction: column;
    }

    .form-actions > * {
        width: 100%;
    }


    /* 排行榜 */

    .rank-page {
        width: calc(100% - 20px);

        padding:
            30px 0
            60px;
    }

    #rankTitle,
    .rank-title {
        font-size: 35px;

        letter-spacing: -1.5px;
    }

    #rankDescription,
    .rank-description {
        font-size: 14px;
    }

    .rank-actions {
        display: grid;

        grid-template-columns: 1fr;

        gap: 8px;
    }

    .rank-actions > * {
        width: 100%;
    }


    /* Tier List */

    #board {
        border-radius: 14px;
    }

    .tier-row {
        grid-template-columns: 78px minmax(0, 1fr);

        min-height: 105px;
    }

    .tier-label {
        padding: 8px;
    }

    .tier-name {
        font-size: 19px;

        letter-spacing: -0.5px;
    }

    .tier-range {
        margin-top: 5px;

        font-size: 9px;
    }

    .tier-items {
        min-height: 105px;

        padding: 9px;

        gap: 7px;
    }

    .rank-item {
        min-width: 90px;

        max-width: 170px;

        min-height: 65px;

        padding:
            9px 10px;

        border-radius: 10px;
    }

    .rank-item-name {
        font-size: 13px;
    }

    .rank-item-score {
        font-size: 10px;
    }


    /* Modal */

    .modal {
        align-items: flex-end;

        padding: 0;
    }

    .modal-content {
        width: 100%;

        max-height: 94vh;

        padding: 23px 17px;

        border-radius:
            20px 20px
            0 0;
    }

    .modal-header h2 {
        font-size: 23px;
    }


    /* 投票 */

    .vote-options {
        gap: 5px;
    }

    .vote-option {
        min-height: 60px;

        padding: 5px 2px;

        border-radius: 9px;
    }

    .vote-option-name {
        font-size: 11px;
    }

    .vote-option-score {
        margin-top: 3px;

        font-size: 9px;
    }

    .add-item-box {
        flex-direction: column;
    }

    .add-item-box input,
    .add-item-box button {
        width: 100%;
    }


    /* 詳細 */

    .detail-average {
        font-size: 50px;
    }

    .distribution-row {
        grid-template-columns:
            62px minmax(0, 1fr) 32px;

        gap: 7px;

        font-size: 12px;
    }

    .detail-actions {
        flex-direction: column;
    }

    .detail-actions button {
        width: 100%;
    }
}


/* =========================================================
   超小螢幕
   ========================================================= */

@media (max-width: 380px) {

    .tier-row {
        grid-template-columns: 68px minmax(0, 1fr);
    }

    .tier-name {
        font-size: 17px;
    }

    .tier-items {
        gap: 5px;
        padding: 7px;
    }

    .rank-item {
        min-width: 82px;

        padding: 8px;
    }

    .rank-item-name {
        font-size: 12px;
    }

    .vote-option-name {
        font-size: 10px;
    }

    .vote-option-score {
        display: none;
    }
}