/* =========================================
   登入組件樣式 - 用於 report.html 和 MemoryMaster.html
   ========================================= */

/* --- 登入按鈕區塊（地球在登入圈左側，名稱在頭像右側） --- */
.user-login-area {
    display: flex;
    align-items: center;
    gap: 15px;
}

.user-login-stack {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 8px;
}

/* --- 登入頭像按鈕 --- */
.user-avatar-btn {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: url('./img/UI/Frame_Main_Login.png') no-repeat center;
    background-size: cover;
    border: 3px solid var(--primary, #FF9F1C);
    cursor: pointer;
    transition: transform 0.3s, box-shadow 0.3s;
    position: relative;
    overflow: hidden;
}

.user-avatar-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 5px 15px rgba(255, 159, 28, 0.5);
}

/* 登入文字（未登入時顯示） */
.user-avatar-btn .login-text {
    position: absolute;
    bottom: -5px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--primary, #FF9F1C);
    color: white;
    font-size: 0.7rem;
    padding: 2px 8px;
    border-radius: 10px;
    white-space: nowrap;
    font-weight: bold;
}

/* 使用者名稱（登入後顯示） */
.user-name-display {
    font-size: 0.95rem;
    color: var(--dark, #1F2421);
    font-weight: 600;
    height: 50px;
    line-height: 50px;
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* --- 登入面板 (Modal) --- */
.login-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    z-index: 9999;
    justify-content: center;
    align-items: center;
    animation: fadeIn 0.3s ease;
}

.login-modal.active {
    display: flex;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

/* 登入面板 - 完全匹配 index.html 的樣式 */
.login-panel {
    width: calc(calc(var(--vh,1vh)*65)*0.82);
    height: calc(var(--vh,1vh)*65);
    background: url('./img/UI/Frame_Login.png') no-repeat;
    background-size: calc(calc(var(--vh,1vh)*65)*0.82) calc(var(--vh,1vh)*65);
    margin: calc(var(--vh,1vh)*20) auto auto auto;
    padding: 0px;
    position: relative;
    animation: slideUp 0.4s ease;
}

@keyframes slideUp {
    from {
        transform: translateY(50px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* 登入面板標題 */
.login-panel-title {
    text-align: center;
    font-size: calc(var(--vh,1vh)*3);
    font-weight: bold;
    color: maroon;
    margin: calc(var(--vh,1vh)*2.5) auto auto auto;
    position: absolute;
    width: calc(var(--vh,1vh)*52);
    font-family: 'PumpkinGames', sans-serif;
}

/* 關閉按鈕 - 保留旋轉效果 */
.login-panel-close {
    width: calc(var(--vh,1vh)*10);
    height: calc(var(--vh,1vh)*10);
    background: url('./img/UI/Button_Close.png') no-repeat;
    background-size: calc(var(--vh,1vh)*10) calc(var(--vh,1vh)*10);
    margin: calc(var(--vh,1vh)*1) auto 0 calc(var(--vh,1vh)*41);
    position: absolute;
    cursor: pointer;
    transition: transform 0.3s ease;
    border: none;
    font-size: 0;
    z-index: 2;
}

.login-panel-close:hover {
    transform: rotate(90deg);
}

/* 登入按鈕群組 - 不使用 flex，改用 absolute 定位 */
.login-buttons {
    position: relative;
    width: 100%;
    height: 100%;
}

/* Facebook 按鈕容器 - 最上方，加寬 10% */
#FacebookButtonDiv {
    position: absolute;
    margin: calc(var(--vh,1vh)*9) auto 0 calc(var(--vh,1vh)*6);
    z-index: 3;
    display: flex !important;
    justify-content: center;
    align-items: center;
    visibility: visible !important;
    opacity: 1 !important;
    max-width: calc(var(--vh,1vh)*42);
    width: 80%;
    height: auto;
    min-height: calc(var(--vh,1vh)*5);
}

.fb-login-button {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    max-width: 100% !important;
    width: 100% !important;
    transform: scale(0.9);
    transform-origin: center;
}

.fb-login-button span {
    max-width: 100% !important;
    width: 100% !important;
    display: block !important;
}

#FacebookButtonDiv iframe {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    max-width: 100% !important;
    width: 100% !important;
}

/* Google 按鈕容器 - 第二位 (LINE 下方)，置中，放大 10% */
#GoogleButtonDiv {
    position: absolute;
    margin: calc(var(--vh,1vh)*18.75) auto 0 0;
    left: 50%;
    transform: translateX(-50%) scale(1.1);
    z-index: 2;
    max-width: calc(var(--vh,1vh)*42);
    display: flex;
    justify-content: center;
}

#GoogleButton {
    display: flex;
    justify-content: center;
}

#GoogleButton > div {
    margin: 0 auto !important;
}

#GoogleButton iframe {
    margin: 0 auto !important;
}

/* 分隔線 - 調整位置 */
.login-divider {
    width: calc(var(--vh,1vh)*40.5);
    height: calc(var(--vh,1vh)*0.75);
    margin: calc(var(--vh,1vh)*39) auto auto calc(var(--vh,1vh)*6);
    position: absolute;
    border: none;
    background: url('./img/UI/Decoration_Line.png') no-repeat;
    background-size: calc(var(--vh,1vh)*40.5) calc(var(--vh,1vh)*0.75);
}

/* 隱藏第一條分隔線（FB 和 Google 之間） */
.login-divider:first-of-type {
    display: none;
}

/* LINE 按鈕 - 調整位置，間距放大 1.5 倍 (9.75vh) */
.login-btn.line {
    width: calc(calc(var(--vh,1vh)*10)*2.93);
    height: calc(var(--vh,1vh)*10);
    background: url('./img/UI/Button_Line.png') no-repeat;
    background-size: calc(calc(var(--vh,1vh)*10)*2.93) calc(var(--vh,1vh)*10);
    margin: calc(var(--vh,1vh)*28.5) auto 0 calc(var(--vh,1vh)*11.5);
    display: block;
    border: none;
    font-size: calc(var(--vh,1vh)*4);
    color: white;
    font-weight: bold;
    position: absolute;
    font-family: 'PumpkinGames', sans-serif;
    cursor: pointer;
    z-index: 2;
}

.login-btn.line:hover {
    transform: scale(1.05);
}

/* 訪客登入警告文字 - 調整位置 */
.guest-warning {
    margin: calc(var(--vh,1vh)*43) auto auto auto;
    text-align: center;
    padding: 0 calc(var(--vh,1vh)*7);
    position: absolute;
    width: calc(var(--vh,1vh)*52);
    font-size: calc(var(--vh,1vh)*2.25);
    color: red;
    font-weight: bold;
    z-index: 2;
}

/* 訪客按鈕 - 調整位置在警告文字下方 */
.login-btn.guest {
    width: calc(calc(var(--vh,1vh)*10)*2.93);
    height: calc(var(--vh,1vh)*10);
    background: url('./img/UI/Button_Visitor.png') no-repeat;
    background-size: calc(calc(var(--vh,1vh)*10)*2.93) calc(var(--vh,1vh)*10);
    margin: calc(var(--vh,1vh)*48) auto 0 calc(var(--vh,1vh)*11.5);
    display: block;
    border: none;
    font-size: calc(var(--vh,1vh)*4);
    color: white;
    font-weight: bold;
    position: absolute;
    font-family: 'PumpkinGames', sans-serif;
    cursor: pointer;
    z-index: 2;
}

.login-btn.guest:hover {
    transform: scale(1.05);
}

/* 顯示按鈕文字 */
.login-btn span {
    pointer-events: none; /* 文字不阻擋點擊 */
}

/* 我的帳戶面板 */
.my-account-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    z-index: 9999;
    justify-content: center;
    align-items: center;
    animation: fadeIn 0.3s ease;
}

.my-account-modal.active {
    display: flex;
}

/* 我的帳戶面板 - 使用 index.html 的樣式 */
.my-account-panel {
    width: min(380px, 90vw);
    min-height: 500px;
    background: url('./img/UI/Frame_Mine.png') no-repeat center;
    background-size: contain;
    position: relative;
    padding: 70px 40px 40px 40px;
    animation: slideUp 0.4s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* 我的帳戶關閉鈕：錨定面板右上角。
   勿沿用 .login-panel-close 的 41vh margin-left（為寬版登入框設計）；
   此面板為 min(380px)，高解析度下 vh 會讓 X 與 Frame_Mine 脫鉤。 */
.my-account-panel .login-panel-close {
    margin: 0;
    top: 0.625rem;
    /* 外側留半顆按鈕寬 + 小間距，避免溢出框線 */
    right: calc(0.625rem + 2.75rem / 2);
    left: auto;
    bottom: auto;
    width: 2.75rem;
    height: 2.75rem;
    min-width: 2.75rem;
    min-height: 2.75rem;
    background-size: 100% 100%;
    transform-origin: center center;
}

.my-account-header {
    text-align: center;
    margin-bottom: 30px;
    margin-top: 20px;
}

.my-account-avatar {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    margin: 0 auto 15px;
    background-size: cover;
    background-position: center;
    border: 4px solid #8B4513;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
}

.my-account-name {
    font-size: 1.5rem;
    font-weight: bold;
    color: saddlebrown;
    font-family: 'PumpkinGames', sans-serif;
}

.my-account-buttons {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 20px;
    width: 100%;
    max-width: 280px;
}

.my-account-btn {
    width: 100%;
    padding: 12px 20px;
    font-size: 1rem;
    font-weight: 600;
    border: 3px solid #FF9F1C;
    background: linear-gradient(180deg, #FFD700 0%, #FFA500 100%);
    border-radius: 12px;
    box-shadow: 0 4px 0 #CC7A00, 0 6px 12px rgba(0, 0, 0, 0.3);
    color: white;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.3);
    cursor: pointer;
    transition: all 0.2s;
    font-family: 'PumpkinGames', 'Microsoft JhengHei', sans-serif;
    min-height: 50px;
}

.my-account-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 0 #CC7A00, 0 8px 15px rgba(0, 0, 0, 0.4);
}

.my-account-btn:active {
    transform: translateY(2px);
    box-shadow: 0 2px 0 #CC7A00, 0 4px 8px rgba(0, 0, 0, 0.3);
}

.my-account-btn.logout {
    background: linear-gradient(180deg, #FF6B6B 0%, #f44336 100%);
    border-color: #d32f2f;
    box-shadow: 0 4px 0 #b71c1c, 0 6px 12px rgba(0, 0, 0, 0.3);
}

.my-account-btn.logout:hover {
    box-shadow: 0 6px 0 #b71c1c, 0 8px 15px rgba(0, 0, 0, 0.4);
}

.my-account-btn.logout:active {
    box-shadow: 0 2px 0 #b71c1c, 0 4px 8px rgba(0, 0, 0, 0.3);
}

nav,
nav .container,
#site-nav-root {
    overflow: visible;
}

/* PC 版 (大於 768px) */
@media (min-width: 769px) {
    /* 導覽列布局 */
    nav .container {
        display: flex;
        justify-content: space-between;
        align-items: center;
    }

    /* 選單連結在中間 */
    .nav-links {
        order: 2;
    }

    /* 登入區域（含地球）在最右邊 */
    .user-login-area {
        order: 3;
        margin-left: auto;
    }

    /* Logo 在左邊 */
    .nav-logo {
        order: 1;
    }
}

/* 手機版 (小於等於 768px) */
@media (max-width: 768px) {
    /* 導覽列布局調整 */
    nav .container {
        display: flex;
        justify-content: space-between;
        align-items: center;
        position: relative;
    }

    /* Logo 在左邊 */
    .nav-logo {
        order: 1;
    }

    /* 登入頭像（地球在圈左側）在右邊，漢堡在最右 */
    .user-login-area {
        order: 3;
        margin-left: auto;
        margin-right: 15px;
    }

    nav,
    nav .container {
        overflow: visible;
    }

    /* 漢堡選單在最右邊 */
    .menu-toggle {
        order: 4;
    }

    /* 縮小登入頭像 */
    .user-avatar-btn {
        width: 40px;
        height: 40px;
    }

    /* 隱藏使用者名稱 */
    .user-name-display {
        display: none;
    }

    /* 登入面板調整 - 放大到 102% */
    .login-panel,
    .login-panel * {
        --vh: 1.02vh;
    }

    /* Facebook 按鈕手機版調整 - 最上方，加寬 10% */
    #FacebookButtonDiv {
        margin-top: calc(var(--vh,1vh)*9) !important;
        margin-left: calc(var(--vh,1vh)*4) !important;
        max-width: calc(var(--vh,1vh)*44) !important;
        width: 83% !important;
    }

    .fb-login-button {
        transform: scale(0.88) !important;
        transform-origin: center !important;
    }

    /* Google 按鈕手機版調整 - FB 下方，置中，放大 10%，間距 1.5 倍 */
    #GoogleButtonDiv {
        margin-top: calc(var(--vh,1vh)*18.75) !important;
        margin-left: 0 !important;
        left: 50% !important;
        transform: translateX(-50%) scale(1.1) !important;
        max-width: calc(var(--vh,1vh)*46) !important;
    }
}

/* 超小螢幕 */
@media (max-width: 480px) {
    .user-avatar-btn {
        width: 35px;
        height: 35px;
    }

    /* 登入面板調整 - 放大到 84% */
    .login-panel,
    .login-panel * {
        --vh: 0.84vh;
    }

    /* Facebook 按鈕超小螢幕調整 - 最上方，加寬 10% */
    #FacebookButtonDiv {
        margin-top: calc(var(--vh,1vh)*9) !important;
        margin-left: calc(var(--vh,1vh)*3) !important;
        max-width: calc(var(--vh,1vh)*46) !important;
        width: 85% !important;
    }

    .fb-login-button {
        transform: scale(0.86) !important;
        transform-origin: center !important;
    }

    /* Google 按鈕超小螢幕調整 - FB 下方，置中，放大 10%，間距 1.5 倍 */
    #GoogleButtonDiv {
        margin-top: calc(var(--vh,1vh)*18.75) !important;
        margin-left: 0 !important;
        left: 50% !important;
        transform: translateX(-50%) scale(1.1) !important;
        max-width: calc(var(--vh,1vh)*48) !important;
    }
}

/* 確保 Facebook XFBML 按鈕可見 */
.fb-login-button {
    display: inline-block !important;
    visibility: visible !important;
    opacity: 1 !important;
    min-width: 200px !important;
    min-height: 40px !important;
}

.fb-login-button > span {
    display: inline-block !important;
    visibility: visible !important;
    opacity: 1 !important;
}

.fb-login-button > span > iframe {
    display: inline-block !important;
    visibility: visible !important;
    opacity: 1 !important;
}

#FacebookButtonDiv iframe {
    display: inline-block !important;
    visibility: visible !important;
    opacity: 1 !important;
}

/* --- 遮罩背景 --- */
.mask-background {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 9998;
}

.mask-background.active {
    display: block;
}
