/* ===== 全域樣式 ===== */

/* ===== 桌遊名稱中英顯示 ===== */
/* 大卡片：中英分行 */
.gn-zh {
    display: block;
    font-size: 1.5rem;
    font-weight: bold;
    line-height: 1.3;
    color: var(--text-color);
}
.gn-en {
    display: block;
    font-size: 0.95rem;
    color: var(--text-light);
    font-weight: 400;
    margin-top: 0.2rem;
}

/* 排行榜用：中英同行，｜分隔 */
.gn-inline-zh {
    font-weight: 600;
}
.gn-inline-sep {
    margin: 0 0.25em;
    opacity: 0.45;
    font-weight: 400;
}
.gn-inline-en {
    font-size: 0.88em;
    opacity: 0.75;
    font-weight: 400;
}

/* 小標籤：中英兩行 */
.gn-tag-zh {
    display: block;
    font-size: 0.88em;
    font-weight: 600;
    line-height: 1.3;
    text-align: center;
}
.gn-tag-en {
    display: block;
    font-size: 0.75em;
    font-weight: 400;
    opacity: 0.8;
    line-height: 1.2;
    text-align: center;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    /* MBTI 類型顏色 */
    --intj-color: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --intp-color: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    --entj-color: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
    --entp-color: linear-gradient(135deg, #43e97b 0%, #38f9d7 100%);
    --infj-color: linear-gradient(135deg, #fa709a 0%, #fee140 100%);
    --infp-color: linear-gradient(135deg, #a8edea 0%, #fed6e3 100%);
    --enfj-color: linear-gradient(135deg, #ffecd2 0%, #fcb69f 100%);
    --enfp-color: linear-gradient(135deg, #ff9a9e 0%, #fecfef 100%);
    --istj-color: linear-gradient(135deg, #fbc2eb 0%, #a6c1ee 100%);
    --isfj-color: linear-gradient(135deg, #fdcbf1 0%, #e6dee9 100%);
    --estj-color: linear-gradient(135deg, #a1c4fd 0%, #c2e9fb 100%);
    --esfj-color: linear-gradient(135deg, #ffecd2 0%, #fcb69f 100%);
    --istp-color: linear-gradient(135deg, #d299c2 0%, #fef9d7 100%);
    --isfp-color: linear-gradient(135deg, #fbc7d4 0%, #9796f0 100%);
    --estp-color: linear-gradient(135deg, #fad0c4 0%, #ffd1ff 100%);
    --esfp-color: linear-gradient(135deg, #ffeaa7 0%, #fdcb6e 100%);
    
    /* 主色調 - 桌遊風格 */
    --primary-color: #8b6f47;
    --secondary-color: #a0826d;
    --accent-color: #d4956c;
    --text-color: #2d2d2d;
    --text-light: #6b7280;
    --bg-color: #faf8f5;
    --card-bg: #ffffff;
    --border-color: #e8e3dc;
    
    /* 陰影 */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
}

body {
    font-family: 'Segoe UI', 'Microsoft JhengHei', Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji';
    background: var(--bg-color);
    color: var(--text-color);
    line-height: 1.6;
    min-height: 100vh;
}

/* ===== 導覽列 ===== */
.navbar {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    padding: 1rem 0;
    box-shadow: var(--shadow-md);
    position: sticky;
    top: 0;
    z-index: 1000;
}

.navbar-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.navbar-logo {
    color: white;
    font-weight: bold;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 0;
    margin-right: 2rem;
    padding-right: 2rem;
    border-right: 2px solid rgba(255, 255, 255, 0.3);
    line-height: 1.25;
}

.navbar-logo-text {
    display: flex !important;
    flex-direction: column !important;
    align-items: flex-start !important;
    line-height: 1.3;
}

.navbar-logo-text span {
    display: block !important;
    font-size: 1.1rem !important;
    font-weight: 700;
    letter-spacing: 0.02em;
    white-space: nowrap;
}

.navbar-menu {
    display: flex;
    list-style: none;
    gap: 2rem;
}

.navbar-menu a {
    color: white;
    text-decoration: none;
    font-weight: 500;
    transition: opacity 0.3s;
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
}

.navbar-menu a:hover {
    background: rgba(255, 255, 255, 0.2);
}

.navbar-menu a.active {
    background: rgba(255, 255, 255, 0.3);
    font-weight: 600;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

/* ===== 容器 ===== */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
}

/* ===== 頁面標題 ===== */
.page-header {
    text-align: center;
    margin-bottom: 3rem;
}

.page-title {
    font-size: 2.5rem;
    font-weight: bold;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 1rem;
}

.page-subtitle {
    font-size: 1.1rem;
    color: var(--text-light);
}

/* ===== MBTI 卡片網格 ===== */
.mbti-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.mbti-card {
    background: var(--card-bg);
    border-radius: 1rem;
    padding: 1.5rem;
    box-shadow: var(--shadow-md);
    cursor: pointer;
    transition: all 0.3s ease;
    border: 2px solid transparent;
    position: relative;
    overflow: hidden;
}

.mbti-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: var(--mbti-gradient);
}

.mbti-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-xl);
}

.mbti-card.selected {
    border-color: var(--primary-color);
    box-shadow: var(--shadow-lg);
}

.mbti-type {
    font-size: 1.8rem;
    font-weight: bold;
    margin-bottom: 0.5rem;
}

.mbti-name {
    font-size: 1rem;
    color: var(--text-light);
    margin-bottom: 0.5rem;
}

.mbti-description {
    font-size: 0.9rem;
    color: var(--text-light);
    line-height: 1.5;
}

.mbti-count {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
    font-size: 0.9rem;
    color: var(--text-light);
}

/* ===== 表單樣式 ===== */
.form-container {
    background: var(--card-bg);
    border-radius: 1rem;
    padding: 2rem;
    box-shadow: var(--shadow-lg);
    max-width: 600px;
    margin: 0 auto;
}

.form-group {
    margin-bottom: 1.5rem;
}

.form-label {
    display: block;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--text-color);
}

.form-input,
.form-select {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 2px solid var(--border-color);
    border-radius: 0.5rem;
    font-size: 1rem;
    transition: border-color 0.3s;
}

.form-input:focus,
.form-select:focus {
    outline: none;
    border-color: var(--primary-color);
}

.form-textarea {
    min-height: 100px;
    resize: vertical;
}

/* ===== 遊戲標籤 ===== */
.game-tags-container {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.game-tag {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    color: white;
    padding: 0.3rem 0.7rem;
    border-radius: 0.75rem;
    font-size: 0.85rem;
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    gap: 0;
    white-space: normal;
    word-break: keep-all;
    line-height: 1.2;
    text-align: center;
}

.game-tag.disliked {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
}

.game-tag button {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    font-size: 1rem;
    line-height: 1;
    padding: 0;
    opacity: 0.9;
    transition: opacity 0.2s ease;
}

.game-tag button:hover {
    opacity: 1;
}

/* ===== 按鈕 ===== */
.btn {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 0.5rem;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    text-decoration: none;
    display: inline-block;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.btn-secondary {
    background: var(--bg-color);
    color: var(--text-color);
    border: 2px solid var(--border-color);
}

.btn-secondary:hover {
    background: var(--border-color);
}

.btn-block {
    width: 100%;
    display: block;
}

/* ===== 統計卡片 ===== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: var(--card-bg);
    border-radius: 1rem;
    padding: 1.5rem;
    box-shadow: var(--shadow-md);
    text-align: center;
}

.stat-value {
    font-size: 2.5rem;
    font-weight: bold;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.stat-label {
    color: var(--text-light);
    margin-top: 0.5rem;
}

/* ===== 遊戲列表 ===== */
.game-list-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 2rem;
}

.game-list {
    background: var(--card-bg);
    border-radius: 1rem;
    padding: 1.5rem;
    box-shadow: var(--shadow-md);
    display: flex;
    flex-direction: column;
    min-height: 320px;
}

/* 遊戲列表捲軸容器 */
.game-list-scroll {
    flex: 1;
    overflow-y: auto;
    margin-bottom: 1rem;
}

@media (max-width: 768px) {
    /* 手機版：每張卡獨立一行，高度完全由內容決定 */
    .game-list-grid {
        display: block;
    }
    .game-list-grid .game-list {
        display: block !important;   /* 強制取消 flex，子元素不再被撐高 */
        min-height: 0 !important;    /* 完全移除最小高度 */
        height: auto !important;     /* 高度隨內容 */
        margin-bottom: 1rem;
    }
    .game-list-grid .game-list-scroll {
        display: block !important;
        flex: none !important;
        height: auto !important;
        overflow-y: visible !important;
        margin-bottom: 0.5rem;
    }
}

.game-list-title {
    font-size: 1.3rem;
    font-weight: bold;
    margin-bottom: 1rem;
    color: var(--text-color);
}

.game-item {
    padding: 0.75rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.game-item:last-child {
    border-bottom: none;
}

.game-name {
    font-weight: 500;
}

.game-votes {
    color: var(--text-light);
    font-size: 0.9rem;
}

/* ===== 響應式設計 ===== */
@media (max-width: 768px) {
    .navbar {
        padding: 0.75rem 0;
    }
    
    .navbar-container {
        padding: 0 1rem;
    }
    
    .navbar-logo {
        margin-right: 0.8rem;
        padding-right: 0.8rem;
        border-right: 1px solid rgba(255, 255, 255, 0.3);
    }
    
    .navbar-logo-text span {
        font-size: 0.95rem !important;
    }
    
    .navbar-menu {
        gap: 0.3rem;
        font-size: 0.75rem;
        flex-wrap: wrap;
    }
    
    .navbar-menu a {
        padding: 0.4rem 0.5rem;
        white-space: nowrap;
    }
    
    .container {
        padding: 1rem;
    }
    
    .page-title {
        font-size: 2rem;
    }
    
    .mbti-grid {
        grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
        gap: 1rem;
    }
    
    .form-container {
        padding: 1.5rem;
    }
    
    /* 🎯 手機版遊戲標籤優化 */
    .game-tag {
        font-size: 0.8rem;
        padding: 0.2rem 0.55rem;
        line-height: 1.2;
        white-space: normal;
        word-break: keep-all;
    }
}

/* ===== Emoji 顯示優化 ===== */
/* 確保 emoji 在所有瀏覽器正常顯示 */
.page-title,
.game-list-title,
.navbar-logo span,
h1, h2, h3, h4, h5, h6 {
    font-family: 'Segoe UI', 'Microsoft JhengHei', Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji';
}

/* emoji 專用樣式 - 確保顏色和大小正確 */
.emoji {
    font-style: normal;
    font-variant: normal;
    text-rendering: auto;
    -webkit-font-smoothing: antialiased;
    font-family: 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji';
    display: inline-block;
}

/* ===== 載入動畫 ===== */
/* ===== 玩家檔案預覽 Popup ===== */
.player-profile-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(5px);
    z-index: 9999;
    animation: fadeIn 0.3s ease;
}

.player-profile-popup {
    position: relative;
    background: var(--card-bg);
    border-radius: 1.5rem;
    max-width: 500px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
    animation: slideUp 0.4s ease;
}

.player-profile-header {
    position: relative;
    padding: 2rem;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    border-radius: 1.5rem 1.5rem 0 0;
    text-align: center;
    color: white;
}

.player-profile-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    font-size: 1.5rem;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.3s ease;
}

.player-profile-close:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: rotate(90deg);
}

.player-avatar {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    object-fit: cover;
    border: 4px solid rgba(255, 255, 255, 0.3);
    margin-bottom: 1rem;
}

.player-avatar-placeholder {
    font-size: 4rem;
    line-height: 1;
    margin-bottom: 0.5rem;
}

.player-display-name {
    font-size: 1.8rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.player-username {
    font-size: 1rem;
    opacity: 0.9;
    margin-bottom: 1rem;
}

.player-stats {
    display: flex;
    justify-content: center;
    gap: 1.5rem;
    margin-top: 1rem;
}

.player-stat-item {
    text-align: center;
}

.player-stat-value {
    font-size: 1.5rem;
    font-weight: 700;
}

.player-stat-label {
    font-size: 0.9rem;
    opacity: 0.9;
}

.player-profile-body {
    padding: 2rem;
}

.player-section {
    margin-bottom: 2rem;
}

.player-section:last-child {
    margin-bottom: 0;
}

.player-section-title {
    font-size: 1.3rem;
    font-weight: 700;
    margin-bottom: 1rem;
    color: var(--primary-color);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.player-games-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.player-game-tag {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 2rem;
    font-size: 0.9rem;
    font-weight: 500;
}

.player-common-games {
    background: var(--bg-color);
    padding: 1rem;
    border-radius: 0.75rem;
    border-left: 4px solid var(--accent-color);
}

.player-common-game-item {
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border-color);
}

.player-common-game-item:last-child {
    border-bottom: none;
}

.player-empty-state {
    text-align: center;
    padding: 2rem;
    color: var(--text-light);
    font-style: italic;
}

/* 動畫 */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(50px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* 響應式 */
@media (max-width: 768px) {
    .player-profile-popup {
        width: 95%;
        max-height: 85vh;
    }
    
    .player-profile-header {
        padding: 1.5rem;
    }
    
    .player-profile-body {
        padding: 1.5rem;
    }
    
    .player-display-name {
        font-size: 1.5rem;
    }
    
    .player-stats {
        gap: 1rem;
    }
}

.loading {
    text-align: center;
    padding: 2rem;
    color: var(--text-light);
}

.spinner {
    border: 4px solid var(--border-color);
    border-top: 4px solid var(--primary-color);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin: 0 auto;
}

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

/* ===== 提示訊息 ===== */
.alert {
    padding: 1rem;
    border-radius: 0.5rem;
    margin-bottom: 1rem;
}

.alert-success {
    background: #d1fae5;
    color: #065f46;
    border: 1px solid #6ee7b7;
}

.alert-error {
    background: #fee2e2;
    color: #991b1b;
    border: 1px solid #fca5a5;
}

.alert-info {
    background: #dbeafe;
    color: #1e40af;
    border: 1px solid #93c5fd;
}

/* ===== 空狀態 ===== */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-light);
}

.empty-state-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

.empty-state-text {
    font-size: 1.1rem;
    margin-bottom: 1rem;
}

/* ===== 資訊提示圖示 ===== */
.info-tooltip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    font-size: 12px;
    font-weight: bold;
    color: var(--text-light);
    background: var(--border-color);
    border-radius: 50%;
    cursor: help;
    transition: all 0.2s ease;
    user-select: none;
}

.info-tooltip:hover {
    background: var(--primary-color);
    color: white;
    transform: scale(1.1);
}
