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

body {
    font-family: 'Noto Sans', 'Noto Sans CJK TC', sans-serif;
    background-color: #f5f5f5;
    color: #333;
    line-height: 1.6;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

/* 導航欄 */
.navbar {
    background-color: #2c3e50;
    color: white;
    padding: 0.6rem 0;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.navbar h1 {
    margin: 0;
    font-size: 1.3rem;
}

.navbar-room-info {
    font-size: 0.85rem;
    opacity: 0.9;
    margin-top: 4px;
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
}

.navbar-room-info span {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.navbar-room-info strong {
    color: #ffd700;
    font-weight: 600;
}

/* 排行榜布局 */
.leaderboard-layout {
    display: flex;
    gap: 20px;
    padding: 20px;
    max-width: 1800px;
    margin: 0 auto;
    min-height: calc(100vh - 80px);
    position: relative;
    max-height: calc(100vh - 40px);
    overflow: hidden;
}

/* 主內容區 */
.main-content {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    max-height: calc(100vh - 40px);
    overflow: hidden;
}

.leaderboard-container {
    background: white;
    border-radius: 8px;
    padding: 30px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
    min-height: 0;
}

/* 標籤頁容器 */
.tabs-container {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

/* 標籤頁導航 */
.tabs-nav {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    border-bottom: 2px solid #e0e0e0;
    padding-bottom: 0;
}

.tab-btn {
    padding: 12px 24px;
    background: transparent;
    border: none;
    border-bottom: 3px solid transparent;
    color: #666;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    top: 2px;
}

.tab-btn:hover {
    color: #2c3e50;
    background: #f8f9fa;
}

.tab-btn.active {
    color: #2c3e50;
    border-bottom-color: #3498db;
    font-weight: 600;
    background: transparent;
}

/* 標籤頁內容 */
.tabs-content {
    flex: 1;
    min-height: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.tab-pane {
    display: none !important; /* 強制隱藏非活動標籤頁 */
    flex: 1;
    min-height: 0;
    overflow: hidden;
    flex-direction: column;
    text-align: left !important; /* 確保內容左對齊，使用 !important */
    -webkit-text-align: left !important; /* iOS Safari 特定修復 */
    align-items: stretch; /* 確保子元素拉伸到全寬 */
    -webkit-align-items: stretch; /* iOS Safari 特定修復 */
}

.tab-pane.active {
    display: flex !important; /* 強制顯示活動標籤頁 */
}

/* 排行榜完整視圖（標籤頁中） */
.leaderboard-full {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    overflow: hidden;
    background: #f8f9fa;
    border-radius: 8px;
}

.leaderboard-header {
    padding: 18px 20px;
    border-bottom: 2px solid #e0e0e0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: linear-gradient(135deg, #2c3e50 0%, #34495e 100%);
    color: white;
    border-radius: 8px 8px 0 0;
}

.leaderboard-header h3 {
    margin: 0;
    color: white;
    font-size: 1.3rem;
    font-weight: 600;
    letter-spacing: 0.5px;
}

.leaderboard-header .btn {
    padding: 8px 14px;
    font-size: 1rem;
    background-color: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 6px;
    transition: all 0.3s ease;
    color: white;
}

.leaderboard-header .btn:hover {
    background-color: rgba(255, 255, 255, 0.25);
    transform: scale(1.05);
}

.leaderboard-table-wrapper-full {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    background: white;
    border-radius: 0 0 8px 8px;
}

/* 路線列表完整視圖（標籤頁中） - 已移除 routes-section-full，直接在 tab-pane 中 */
.routes-header {
    padding: 15px 20px;
    border-bottom: 2px solid #e0e0e0;
    background: linear-gradient(135deg, #2c3e50 0%, #34495e 100%);
    border-radius: 8px 8px 0 0;
    flex-shrink: 0;
    text-align: left !important; /* 確保內容左對齊，使用 !important 覆蓋可能的繼承樣式 */
    -webkit-text-align: left !important; /* iOS Safari 特定修復 */
    display: flex;
    flex-direction: column;
    align-items: flex-start; /* 確保子元素左對齊 */
}

.routes-header h3 {
    margin: 0;
    color: white;
    font-size: 1.3rem;
    font-weight: 600;
    letter-spacing: 0.5px;
    text-align: left !important; /* 明確設置標題左對齊，使用 !important */
    -webkit-text-align: left !important; /* iOS Safari 特定修復 */
    align-self: flex-start; /* 強制左對齊 */
    width: 100%; /* 確保佔據全寬以便左對齊生效 */
}

/* 保留舊的樣式以向後兼容（如果其他地方使用） */
.leaderboard-sidebar {
    width: 480px;
    flex-shrink: 0;
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    display: flex;
    flex-direction: column;
    max-height: calc(100vh - 40px);
    position: sticky;
    top: 20px;
    align-self: flex-start;
    overflow: hidden;
}

.leaderboard-sidebar-header {
    padding: 18px 20px;
    border-bottom: 2px solid rgba(255, 255, 255, 0.2);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: linear-gradient(135deg, #2c3e50 0%, #34495e 100%);
    color: white;
}

.leaderboard-sidebar-header h3 {
    margin: 0;
    color: white;
    font-size: 1.3rem;
    font-weight: 600;
    letter-spacing: 0.5px;
}

.room-title-inline {
    font-size: 0.7rem;
    font-weight: 400;
    opacity: 0.8;
    margin-left: 8px;
}

.leaderboard-sidebar-header .btn {
    padding: 8px 14px;
    font-size: 1rem;
    background-color: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 6px;
    transition: all 0.3s ease;
}

.leaderboard-sidebar-header .btn:hover {
    background-color: rgba(255, 255, 255, 0.25);
    transform: scale(1.05);
}

.leaderboard-table-wrapper {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    background: #f8f9fa;
}

.leaderboard-table-wrapper::-webkit-scrollbar {
    width: 6px;
}

.leaderboard-table-wrapper::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.leaderboard-table-wrapper::-webkit-scrollbar-thumb {
    background: #95a5a6;
    border-radius: 3px;
}

.leaderboard-table-wrapper::-webkit-scrollbar-thumb:hover {
    background: #7f8c8d;
}

.leaderboard-table {
    overflow-x: auto;
}

.leaderboard-sidebar .leaderboard-table table {
    margin-top: 0;
    font-size: 0.95rem;
    border-collapse: separate;
    border-spacing: 0;
}

.leaderboard-sidebar .leaderboard-table th,
.leaderboard-sidebar .leaderboard-table td {
    padding: 14px 15px;
    font-size: 0.95rem;
}

.leaderboard-sidebar .leaderboard-table th {
    position: sticky;
    top: 0;
    z-index: 10;
    background: linear-gradient(135deg, #34495e 0%, #2c3e50 100%);
    color: white;
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.5px;
    padding: 12px;
    border-bottom: 2px solid rgba(255, 255, 255, 0.1);
}

.leaderboard-sidebar .leaderboard-table th:nth-child(1) {
    width: 70px;
    text-align: center;
}

.leaderboard-sidebar .leaderboard-table th:nth-child(2) {
    width: 160px;
    text-align: left;
}

.leaderboard-sidebar .leaderboard-table th:nth-child(3) {
    width: 100px;
    text-align: right;
}

.leaderboard-sidebar .leaderboard-table th:nth-child(4) {
    width: 100px;
    text-align: center;
    white-space: nowrap;
}

.leaderboard-sidebar .leaderboard-table th:nth-child(5) {
    width: 80px;
    text-align: center;
}

.leaderboard-sidebar .leaderboard-table tbody tr {
    background: white;
    border-bottom: 1px solid #e8e9ea;
    transition: all 0.2s ease;
}

.leaderboard-sidebar .leaderboard-table tbody tr:hover {
    background: #f0f7ff;
    transform: translateX(2px);
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.leaderboard-sidebar .leaderboard-table tbody tr.rank-1 {
    background: linear-gradient(90deg, #fff9e6 0%, #ffffff 100%);
    border-left: 4px solid #ffd700;
}

.leaderboard-sidebar .leaderboard-table tbody tr.rank-2 {
    background: linear-gradient(90deg, #f5f5f5 0%, #ffffff 100%);
    border-left: 4px solid #c0c0c0;
}

.leaderboard-sidebar .leaderboard-table tbody tr.rank-3 {
    background: linear-gradient(90deg, #ffe8d6 0%, #ffffff 100%);
    border-left: 4px solid #cd7f32;
}

.leaderboard-sidebar .leaderboard-table td:nth-child(1) {
    text-align: center;
    font-weight: 700;
    font-size: 1.05rem;
    color: #2c3e50;
    position: relative;
}

.leaderboard-sidebar .leaderboard-table tbody tr.rank-1 td:nth-child(1) {
    color: #ffd700;
    font-size: 1.1rem;
}

.leaderboard-sidebar .leaderboard-table tbody tr.rank-2 td:nth-child(1) {
    color: #c0c0c0;
    font-size: 1.05rem;
}

.leaderboard-sidebar .leaderboard-table tbody tr.rank-3 td:nth-child(1) {
    color: #cd7f32;
    font-size: 1.05rem;
}

.leaderboard-sidebar .leaderboard-table td:nth-child(2) {
    font-weight: 500;
    color: #2c3e50;
}

.leaderboard-sidebar .leaderboard-table td:nth-child(3) {
    text-align: right;
    font-weight: 600;
}

.leaderboard-sidebar .leaderboard-table td:nth-child(4) {
    text-align: center;
    color: #7f8c8d;
    font-weight: 500;
    white-space: nowrap;
}

.leaderboard-sidebar .leaderboard-table .score {
    font-weight: 700;
    color: #e74c3c;
    font-size: 1.05rem;
}

.leaderboard-sidebar .leaderboard-table .btn-small {
    padding: 6px 12px;
    font-size: 0.8rem;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.leaderboard-sidebar .leaderboard-table .btn-small:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0,0,0,0.15);
}

/* 完成路線連結樣式 */
.completed-routes-link {
    color: #3498db;
    text-decoration: none;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-block;
    padding: 2px 4px;
    border-radius: 4px;
}

.completed-routes-link:hover {
    color: #2980b9;
    background-color: #e8f4f8;
    text-decoration: underline;
}

/* 完成路線列表彈窗樣式 */
.completed-routes-list {
    max-height: 500px;
    overflow-y: auto;
}

.completed-route-item {
    padding: 15px;
    margin-bottom: 15px;
    background: #f8f9fa;
    border-radius: 8px;
    border: 1px solid #e0e0e0;
    transition: all 0.2s ease;
}

.completed-route-item:hover {
    background: #f0f7ff;
    border-color: #3498db;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.completed-route-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.completed-route-info {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
}

.completed-route-info strong {
    color: #2c3e50;
    font-size: 1.1rem;
}

.route-grade-badge {
    color: #e74c3c;
    font-weight: 600;
    font-size: 0.9rem;
    background: #fff;
    padding: 4px 10px;
    border-radius: 4px;
    border: 1px solid #e74c3c;
}

.completed-route-stats {
    color: #7f8c8d;
    font-size: 0.9rem;
    font-weight: 500;
}

.completed-route-photo {
    margin-top: 10px;
}

.completed-route-photo img {
    max-width: 100%;
    height: auto;
    border-radius: 4px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

/* 桌面端隱藏移動端標題 */
.room-header-mobile {
    display: none;
}

.room-header {
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 2px solid #e0e0e0;
    flex-shrink: 0;
}

.room-header h2 {
    color: #2c3e50;
    margin-bottom: 10px;
}

.room-info {
    color: #666;
    font-size: 1rem;
}

.room-info strong {
    color: #e74c3c;
    font-size: 1.2rem;
}


/* 按鈕 */
.actions {
    margin-bottom: 20px;
    display: flex;
    gap: 10px;
    flex-shrink: 0;
}

.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1rem;
    transition: background-color 0.3s;
}

.btn-primary {
    background-color: #3498db;
    color: white;
}

.btn-primary:hover {
    background-color: #2980b9;
}

.btn-secondary {
    background-color: #95a5a6;
    color: white;
}

.btn-secondary:hover {
    background-color: #7f8c8d;
}

/* 表格 */
.leaderboard-table {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 20px;
}

thead {
    background-color: #34495e;
    color: white;
}

th, td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid #ddd;
}

th {
    font-weight: 600;
}

tbody tr:hover {
    background-color: #f8f9fa;
}

/* 主內容區的分數樣式（保持原樣） */
.main-content .score {
    font-weight: bold;
    color: #e74c3c;
    font-size: 1.1rem;
}

.loading, .error, .empty {
    text-align: center;
    padding: 40px;
    color: #666;
}

.error {
    color: #e74c3c;
}

/* 彈窗 */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
    overflow: auto;
}

.modal-content {
    background-color: white;
    margin: 5% auto;
    padding: 0;
    border-radius: 8px;
    width: 90%;
    max-width: 600px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.3);
}

.modal-header {
    background-color: #2c3e50;
    color: white;
    padding: 20px;
    border-radius: 8px 8px 0 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    margin: 0;
}

.close {
    color: white;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    line-height: 20px;
}

.close:hover {
    color: #ecf0f1;
}

.modal-body {
    padding: 30px;
}

/* 表單 */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
    color: #333;
}

.form-group label input[type="checkbox"] {
    margin-right: 8px;
    cursor: pointer;
}

.form-group small {
    display: block;
    color: #666;
    font-size: 0.85rem;
    margin-top: 5px;
    line-height: 1.4;
}

.form-group input[type="text"],
.form-group input[type="url"] {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 1rem;
}

.form-group input:focus {
    outline: none;
    border-color: #3498db;
}

.member-completions {
    max-height: 300px;
    overflow-y: auto;
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 15px;
    background-color: #f9f9f9;
}

.member-checkbox {
    display: block;
    padding: 8px;
    margin-bottom: 5px;
    cursor: pointer;
}

.member-checkbox:hover {
    background-color: #e8e8e8;
}

.member-checkbox input[type="checkbox"] {
    margin-right: 8px;
    cursor: pointer;
}

.form-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 30px;
}

/* 首頁樣式 */
.home-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 30px 20px;
}

.welcome-header {
    text-align: center;
    margin-bottom: 40px;
    padding: 30px 0;
}

.welcome-header h1 {
    color: #2c3e50;
    font-size: 2.5rem;
    margin-bottom: 10px;
}

.subtitle {
    color: #666;
    font-size: 1.1rem;
}

.actions-section {
    text-align: center;
    margin-bottom: 40px;
}

.btn-large {
    padding: 15px 30px;
    font-size: 1.1rem;
    font-weight: 600;
}

.btn-icon {
    margin-right: 8px;
    font-size: 1.2rem;
}

.rooms-section h2 {
    color: #2c3e50;
    margin-bottom: 20px;
    font-size: 1.8rem;
}

.rooms-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
    margin-top: 20px;
}

.room-card {
    background: white;
    border-radius: 8px;
    padding: 20px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    transition: transform 0.2s, box-shadow 0.2s;
    cursor: pointer;
    border: 2px solid transparent;
}

.room-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    border-color: #3498db;
}

.room-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding-bottom: 15px;
    border-bottom: 2px solid #e0e0e0;
}

.room-card-header h3 {
    color: #2c3e50;
    margin: 0;
    font-size: 1.3rem;
}

.room-id {
    color: #95a5a6;
    font-size: 0.9rem;
    background: #ecf0f1;
    padding: 4px 10px;
    border-radius: 4px;
}

.room-card-info {
    margin-bottom: 15px;
}

.info-item {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid #f0f0f0;
}

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

.info-item .label {
    color: #666;
}

.info-item .value {
    color: #2c3e50;
    font-weight: 600;
}

.room-card-actions {
    display: flex;
    gap: 10px;
    margin-top: 15px;
}

.btn-small {
    padding: 6px 12px;
    font-size: 0.9rem;
}

.btn-danger {
    background-color: #e74c3c;
    color: white;
}

.btn-danger:hover {
    background-color: #c0392b;
}

.empty {
    text-align: center;
    padding: 60px 20px;
    color: #95a5a6;
    font-size: 1.1rem;
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.header-top {
    display: flex;
    align-items: center;
    margin-bottom: 10px;
}

/* 路線列表樣式 */
.routes-section {
    background: white;
    border-radius: 8px;
    padding: 20px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

.routes-section h3 {
    flex-shrink: 0;
    margin-bottom: 15px;
    color: #2c3e50;
    font-weight: 600;
}

.routes-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 15px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    background: #fafafa;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.05);
    /* 增加宽度：路线列表现在占据整个标签页宽度 */
    width: 100%;
    box-sizing: border-box;
    /* 优化：一次显示 5 条路线 */
    /* 计算：60px (min-height) * 5 + 10px (gap) * 4 + 30px (padding top+bottom) = 370px */
    height: 370px;
    flex-shrink: 0;
}

/* 自定義滾動條樣式 */
.routes-list::-webkit-scrollbar {
    width: 8px;
}

.routes-list::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

.routes-list::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 4px;
}

.routes-list::-webkit-scrollbar-thumb:hover {
    background: #555;
}

.route-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 15px; /* 优化：减少垂直 padding，使路线更紧凑 */
    background: #f8f9fa;
    border-radius: 6px;
    border: 1px solid #e0e0e0;
    transition: background-color 0.2s;
    min-height: 60px; /* 确保路线项有最小高度，便于计算 */
    box-sizing: border-box;
}

.route-item:hover {
    background: #f0f0f0;
}

.route-info {
    flex: 1;
}

.route-name-grade {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 5px;
    flex-wrap: nowrap; /* 防止內容換行（Safari 修復） */
    -webkit-flex-wrap: nowrap; /* iOS Safari 特定修復 */
}

.route-name-grade strong {
    color: #2c3e50;
    font-size: 1.1rem;
    white-space: nowrap; /* 防止路線名稱換行（Safari 修復） */
    display: inline-block; /* 確保作為內聯塊元素，不會被意外分割 */
    max-width: 100%; /* 允許在必要時收縮，但優先不換行 */
    overflow: hidden; /* 如果內容過長，隱藏溢出部分 */
    text-overflow: ellipsis; /* 如果內容過長，顯示省略號 */
}

.route-grade {
    color: #e74c3c;
    font-weight: 600;
    font-size: 0.9rem;
    background: #fff;
    padding: 2px 8px;
    border-radius: 4px;
    border: 1px solid #e74c3c;
}

.route-photo-thumbnail {
    width: 40px;
    height: 40px;
    object-fit: cover;
    border-radius: 4px;
    border: 2px solid #ddd;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.route-photo-thumbnail:hover {
    transform: scale(1.1);
    border-color: #3498db;
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}

/* 圖片大圖查看彈窗樣式 */
.photo-modal-content {
    max-width: 90%;
    max-height: 90vh;
}

.photo-modal-body {
    text-align: center;
    padding: 20px;
    overflow: auto;
}

.photo-modal-body img {
    max-width: 100%;
    max-height: 80vh;
    object-fit: contain;
}

.route-stats {
    color: #666;
    font-size: 0.9rem;
}

.route-actions {
    display: flex;
    gap: 8px;
}

/* 響應式設計 */
@media (max-width: 1200px) {
    .leaderboard-layout {
        flex-direction: column;
        padding: 15px;
    }

    .leaderboard-sidebar {
        width: 100%;
        position: relative;
        top: 0;
        max-height: 600px;
        order: -1; /* 在移動設備上，排行榜顯示在頂部 */
    }

    .main-content {
        width: 100%;
    }

    .leaderboard-sidebar .leaderboard-table th,
    .leaderboard-sidebar .leaderboard-table td {
        padding: 12px 10px;
        font-size: 0.9rem;
    }
}

/* Toast 通知样式 */
@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slideOut {
    from {
        transform: translateX(0);
        opacity: 1;
    }
    to {
        transform: translateX(100%);
        opacity: 0;
    }
}

.toast {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 15px 25px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    z-index: 10000;
    animation: slideIn 0.3s ease;
    color: white;
    font-weight: 500;
    min-width: 200px;
    max-width: 400px;
}

.toast.success {
    background: #27ae60;
}

.toast.error {
    background: #e74c3c;
}

.toast.info {
    background: #3498db;
}

.toast.warning {
    background: #f39c12;
}

/* 加载动画 */
.spinner {
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: #ffffff;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
    vertical-align: middle;
    margin-right: 8px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* 按钮加载状态 */
.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    pointer-events: none;
}

.btn.loading {
    position: relative;
    color: transparent !important;
}

.btn.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: #ffffff;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

/* 登入界面樣式（桌面版） */
.login-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: calc(100vh - 200px);
    padding: 60px 40px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    position: relative;
    overflow: hidden;
}

.login-container::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: 
        radial-gradient(circle at 20% 50%, rgba(255,255,255,0.1) 0%, transparent 50%),
        radial-gradient(circle at 80% 80%, rgba(255,255,255,0.1) 0%, transparent 50%);
    pointer-events: none;
}

.login-card {
    background: white;
    border-radius: 24px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    width: 100%;
    max-width: 1000px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    overflow: hidden;
    position: relative;
    z-index: 1;
}

/* 左側品牌區域（桌面版） */
.login-brand-section {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 60px 50px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    color: white;
    position: relative;
    overflow: hidden;
}

.login-brand-section::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(255,255,255,0.1) 0%, transparent 70%);
    animation: pulse 8s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% {
        transform: scale(1);
        opacity: 0.5;
    }
    50% {
        transform: scale(1.1);
        opacity: 0.8;
    }
}

.login-brand-section h1 {
    font-size: 3rem;
    font-weight: 800;
    margin-bottom: 20px;
    text-shadow: 0 2px 10px rgba(0,0,0,0.2);
    position: relative;
    z-index: 1;
}

.login-brand-section .brand-subtitle {
    font-size: 1.3rem;
    margin-bottom: 40px;
    opacity: 0.95;
    position: relative;
    z-index: 1;
}

.login-brand-section .brand-features {
    list-style: none;
    padding: 0;
    margin: 0;
    text-align: left;
    font-size: 1.1rem;
    line-height: 2;
    position: relative;
    z-index: 1;
}

.login-brand-section .brand-features li {
    padding: 12px 0;
    padding-left: 40px;
    position: relative;
}

.login-brand-section .brand-features li::before {
    content: "✓";
    position: absolute;
    left: 0;
    font-size: 1.5rem;
    font-weight: bold;
    color: #4ade80;
}

.login-brand-icon {
    font-size: 5rem;
    margin-bottom: 30px;
    opacity: 0.9;
    position: relative;
    z-index: 1;
}

/* 右側表單區域（桌面版） */
.login-form-section {
    padding: 60px 50px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

/* 表單區域標題（桌面版，僅在移動版顯示） */
.login-header {
    text-align: center;
    margin-bottom: 40px;
    display: none; /* 桌面版隱藏，移動版顯示 */
}

.login-header h1 {
    color: #2c3e50;
    font-size: 2.2rem;
    margin-bottom: 12px;
    font-weight: 700;
}

.login-header .subtitle {
    color: #7f8c8d;
    font-size: 1.05rem;
}

/* 桌面版表單區域標題 */
.login-form-section .form-section-title {
    text-align: center;
    margin-bottom: 35px;
}

.login-form-section .form-section-title h2 {
    color: #2c3e50;
    font-size: 2rem;
    margin-bottom: 8px;
    font-weight: 700;
}

.login-form-section .form-section-title p {
    color: #7f8c8d;
    font-size: 1rem;
}

.login-tabs {
    display: flex;
    gap: 0;
    margin-bottom: 40px;
    border-bottom: 2px solid #ecf0f1;
    background-color: #f8f9fa;
    border-radius: 10px 10px 0 0;
    padding: 6px;
}

.tab-btn {
    flex: 1;
    padding: 14px 24px;
    background: transparent;
    border: none;
    border-radius: 6px;
    color: #7f8c8d;
    font-size: 1.1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
}

.tab-btn:hover {
    color: #2c3e50;
    background-color: rgba(52, 152, 219, 0.1);
}

.tab-btn.active {
    color: #3498db;
    background-color: white;
    font-weight: 600;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.form-container {
    animation: fadeIn 0.3s;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

.login-form-section .form-group label {
    display: block;
    margin-bottom: 8px;
    color: #2c3e50;
    font-weight: 600;
    font-size: 1rem;
}

.login-card .form-group input[type="email"],
.login-card .form-group input[type="password"],
.login-card .form-group input[type="text"] {
    width: 100%;
    padding: 16px 20px;
    border: 2px solid #e0e0e0;
    border-radius: 10px;
    font-size: 1.05rem;
    transition: all 0.3s ease;
    box-sizing: border-box;
}

.login-card .form-group input[type="email"]:focus,
.login-card .form-group input[type="password"]:focus,
.login-card .form-group input[type="text"]:focus {
    outline: none;
    border-color: #3498db;
    box-shadow: 0 0 0 4px rgba(52, 152, 219, 0.15);
}

/* 登入/註冊按鈕樣式優化（桌面版） */
.login-form-section .btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    border-radius: 12px;
    padding: 20px 40px;
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: 1.2px;
    text-transform: none;
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
    transition: all 0.3s ease;
    cursor: pointer;
    width: 100%;
    margin-top: 15px;
    color: white;
    position: relative;
    overflow: hidden;
}

.login-form-section .btn-primary::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
    transition: left 0.5s;
}

.login-form-section .btn-primary:hover::before {
    left: 100%;
}

.login-form-section .btn-primary:hover {
    background: linear-gradient(135deg, #764ba2 0%, #667eea 100%);
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.5);
    transform: translateY(-3px);
}

.login-form-section .btn-primary:active {
    transform: translateY(-1px);
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
}

.login-form-section .btn-primary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.error-message {
    background-color: #fee;
    color: #c33;
    padding: 14px 16px;
    border-radius: 8px;
    margin-bottom: 20px;
    border: 2px solid #fcc;
    font-size: 0.95rem;
    line-height: 1.5;
}

/* 密碼規則提示（桌面版） */
.login-form-section .password-rules {
    background-color: #f8f9fa;
    border: 2px solid #e9ecef;
    border-radius: 10px;
    padding: 20px;
    margin-top: 12px;
    margin-bottom: 24px;
}

.login-form-section .password-rules-title {
    font-weight: 600;
    color: #2c3e50;
    margin-bottom: 12px;
    font-size: 1rem;
}

.password-rules-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.login-form-section .password-rules-list li {
    padding: 8px 0;
    padding-left: 28px;
    position: relative;
    font-size: 0.95rem;
    color: #555;
    line-height: 1.6;
    transition: color 0.3s ease;
}

.login-form-section .password-rules-list li::before {
    content: "•";
    position: absolute;
    left: 8px;
    color: #3498db;
    font-weight: bold;
    font-size: 1.2rem;
    transition: all 0.3s ease;
}

.login-form-section .password-rules-list li.valid {
    color: #27ae60;
}

.login-form-section .password-rules-list li.valid::before {
    content: "✓";
    color: #27ae60;
    font-size: 1rem;
}

.login-form-section .password-rules-list li.invalid {
    color: #e74c3c;
}

.login-form-section .password-rules-list li.invalid::before {
    content: "✗";
    color: #e74c3c;
    font-size: 1rem;
}

/* 密碼匹配提示 */
#passwordMatchMessage {
    font-weight: 500;
    padding: 8px 12px;
    border-radius: 6px;
    background-color: rgba(39, 174, 96, 0.1);
}

#passwordMatchMessage[style*="color: #e74c3c"] {
    background-color: rgba(231, 76, 60, 0.1);
}

/* 訪客登入樣式（桌面版） */
.login-form-section .guest-login-section {
    margin-top: 35px;
    padding-top: 35px;
    border-top: 2px solid #ecf0f1;
}

.guest-divider {
    text-align: center;
    margin-bottom: 20px;
    position: relative;
}

.guest-divider::before,
.guest-divider::after {
    content: '';
    position: absolute;
    top: 50%;
    width: 40%;
    height: 1px;
    background-color: #e0e0e0;
}

.guest-divider::before {
    left: 0;
}

.guest-divider::after {
    right: 0;
}

.guest-divider span {
    background-color: white;
    padding: 0 15px;
    color: #7f8c8d;
    font-size: 0.9rem;
    position: relative;
    z-index: 1;
}

.login-form-section .btn-secondary {
    background: linear-gradient(135deg, #95a5a6 0%, #7f8c8d 100%);
    border: none;
    border-radius: 12px;
    padding: 20px 40px;
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: 1.2px;
    text-transform: none;
    box-shadow: 0 6px 20px rgba(149, 165, 166, 0.3);
    transition: all 0.3s ease;
    cursor: pointer;
    width: 100%;
    color: white;
    position: relative;
    overflow: hidden;
}

.login-form-section .btn-secondary::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
    transition: left 0.5s;
}

.login-form-section .btn-secondary:hover::before {
    left: 100%;
}

.login-form-section .btn-secondary:hover {
    background: linear-gradient(135deg, #7f8c8d 0%, #6c7a7b 100%);
    box-shadow: 0 8px 25px rgba(149, 165, 166, 0.4);
    transform: translateY(-3px);
}

.login-form-section .btn-secondary:active {
    transform: translateY(-1px);
    box-shadow: 0 4px 15px rgba(149, 165, 166, 0.3);
}

.login-form-section .btn-secondary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.login-form-section .guest-note {
    text-align: center;
    color: #7f8c8d;
    font-size: 0.9rem;
    margin-top: 15px;
    line-height: 1.6;
}

/* 桌面版專用樣式 - 確保表單區域正確顯示 */
@media (min-width: 1024px) {
    .login-card {
        display: grid;
        grid-template-columns: 1fr 1fr;
    }
    
    .login-brand-section {
        display: flex;
    }
    
    .login-header {
        display: none;
    }
    
    .login-form-section .form-section-title {
        display: block;
    }
}

/* 平板適配 */
@media (max-width: 1023px) and (min-width: 769px) {
    .login-card {
        grid-template-columns: 1fr 1fr; /* 保持兩欄布局 */
        max-width: 900px;
    }
    
    .login-brand-section {
        padding: 40px 30px;
        display: flex; /* 確保顯示 */
    }
    
    .login-brand-section h1 {
        font-size: 2.5rem;
    }
    
    .login-form-section {
        padding: 40px 30px;
    }
    
    .login-header {
        display: none; /* 平板版也隱藏移動版標題 */
    }
    
    .login-form-section .form-section-title {
        display: block; /* 顯示桌面版標題 */
    }
}

@media (max-width: 768px) {
    .container {
        padding: 10px;
    }

    .navbar {
        padding: 0.5rem 0;
    }

    .navbar .container {
        flex-direction: column;
        gap: 8px;
        padding: 8px 12px;
    }

    .navbar h1 {
        font-size: 1.1rem;
        margin-bottom: 4px;
    }

    .navbar-room-info {
        font-size: 0.75rem;
        gap: 10px;
    }

    .navbar div {
        width: 100%;
        justify-content: center;
        flex-wrap: wrap;
    }

    .navbar a {
        padding: 5px 10px;
        font-size: 0.85rem;
    }

    .leaderboard-layout {
        padding: 10px;
        gap: 15px;
        flex-direction: column;
        max-height: calc(100vh - 60px);
        overflow: hidden;
    }

    .leaderboard-container {
        padding: 15px;
        display: flex;
        flex-direction: column;
        overflow: hidden;
        flex: 1;
        min-height: 0;
    }

    /* 移動端房間標題（顯示在排行榜上方） */
    .room-header-mobile {
        display: block;
        background: white;
        border-radius: 8px;
        padding: 10px 15px;
        box-shadow: 0 2px 8px rgba(0,0,0,0.1);
        order: -2; /* 顯示在排行榜之前 */
        margin-bottom: 15px;
        position: sticky;
        top: 0;
        z-index: 20;
    }

    .room-header-mobile .room-info {
        display: flex;
        flex-direction: row;
        gap: 20px;
        font-size: 0.9rem;
        margin-bottom: 10px;
        color: #666;
        flex-wrap: wrap;
    }

    .room-header-mobile .room-info span {
        margin-left: 0 !important;
    }

    .room-header-mobile .room-info strong {
        color: #e74c3c;
        font-size: 1.1rem;
    }

    .room-header-mobile .header-top {
        margin-bottom: 0;
    }

    .room-header-mobile .header-buttons {
        display: flex;
        gap: 8px;
        justify-content: flex-start;
        flex-wrap: wrap;
    }

    .room-header-mobile .btn-square {
        width: 40px;
        height: 40px;
        padding: 0;
        display: flex;
        align-items: center;
        justify-content: center;
        border-radius: 6px;
        font-size: 1.3rem;
        line-height: 1;
        flex-shrink: 0;
        /* 確保圖標大小一致 */
        font-size: 1.3rem !important;
    }

    .room-header-mobile .btn-primary.btn-square {
        font-size: 1.1rem !important;
    }

    .room-header-mobile .header-top h2 {
        display: none; /* 隱藏房間名稱標題 */
    }

    .room-header {
        display: none; /* 移動端隱藏桌面版標題 */
    }

    .header-top {
        flex-direction: column;
        gap: 10px;
        align-items: stretch;
    }

    .header-top h2 {
        font-size: 1.3rem;
        margin: 10px 0;
    }

    .room-info {
        flex-direction: column;
        gap: 8px;
        font-size: 0.9rem;
    }

    .room-info span {
        margin-left: 0 !important;
    }

    .actions {
        display: none; /* 移動端隱藏，按鈕已移到頭部 */
    }

    .leaderboard-sidebar {
        max-height: calc(100vh - 200px);
        width: 100%;
        position: sticky;
        top: 0;
        order: -1;
        border-radius: 8px;
        z-index: 15;
        display: flex;
        flex-direction: column;
        overflow: hidden;
        min-height: 0;
        flex-shrink: 0;
    }

    .leaderboard-sidebar-header {
        padding: 12px 15px;
        flex-shrink: 0;
    }

    .leaderboard-sidebar-header h3 {
        font-size: 1rem;
    }

    .room-title-inline {
        font-size: 0.6rem;
        font-weight: 400;
        opacity: 0.8;
        margin-left: 6px;
    }

    .leaderboard-table-wrapper {
        flex: 1;
        overflow-y: auto;
        overflow-x: hidden;
        min-height: 0;
    }

    .leaderboard-sidebar .leaderboard-table th,
    .leaderboard-sidebar .leaderboard-table td {
        padding: 8px 6px;
        font-size: 0.8rem;
    }

    .leaderboard-sidebar .leaderboard-table th {
        font-size: 0.7rem;
        padding: 8px 6px;
    }

    .leaderboard-sidebar .leaderboard-table th:nth-child(1) {
        width: 50px;
    }

    .leaderboard-sidebar .leaderboard-table th:nth-child(2) {
        width: 100px;
    }

    .leaderboard-sidebar .leaderboard-table th:nth-child(3) {
        width: 70px;
    }

    .leaderboard-sidebar .leaderboard-table th:nth-child(4) {
        width: 70px;
    }

    .leaderboard-sidebar .leaderboard-table th:nth-child(5) {
        width: 60px;
    }

    .leaderboard-sidebar .leaderboard-table td:nth-child(1) {
        font-size: 0.85rem;
    }

    .leaderboard-sidebar .leaderboard-table .score {
        font-size: 0.9rem;
    }

    .leaderboard-sidebar .leaderboard-table .btn-small {
        padding: 4px 8px;
        font-size: 0.75rem;
    }

    .routes-section {
        padding: 15px;
        flex: 1;
        display: flex;
        flex-direction: column;
        min-height: 0;
        overflow: hidden;
    }

    .routes-section h3 {
        flex-shrink: 0;
        margin-bottom: 10px;
    }


    /* 移動端標籤頁樣式 */
    .tabs-nav {
        gap: 5px;
        margin-bottom: 15px;
    }
    
    .tab-btn {
        padding: 10px 16px;
        font-size: 0.9rem;
        flex: 1;
    }
    
    .leaderboard-header,
    .routes-header {
        padding: 12px 15px;
        text-align: left !important; /* 確保移動端也左對齊，使用 !important */
        -webkit-text-align: left !important; /* iOS Safari 特定修復 */
        display: flex;
        flex-direction: column;
        align-items: flex-start; /* 確保子元素左對齊 */
    }
    
    .leaderboard-header h3,
    .routes-header h3 {
        font-size: 1.1rem;
        text-align: left !important; /* 明確設置標題左對齊，使用 !important */
        -webkit-text-align: left !important; /* iOS Safari 特定修復 */
        align-self: flex-start; /* 強制左對齊 */
        width: 100%; /* 確保佔據全寬以便左對齊生效 */
    }
    
    .routes-list {
        display: flex !important;
        -webkit-display: flex !important;
        flex-direction: column !important;
        -webkit-flex-direction: column !important;
        gap: 10px;
        flex: 1;
        overflow-y: auto;
        overflow-x: hidden;
        padding: 12px;
        border: 2px solid #e0e0e0;
        border-radius: 8px;
        background: #fafafa;
        box-shadow: inset 0 2px 4px rgba(0,0,0,0.05);
        min-height: 0;
        /* 优化：移动端一次显示 5 条路线 */
        /* 移动端路线项是垂直布局，每条约 110px，5条 + 间距 + padding = 约 600px */
        height: 600px; /* 使用固定高度而不是 max-height，确保显示5条 */
        width: 100% !important;
        box-sizing: border-box;
        text-align: left !important;
        -webkit-text-align: left !important;
        direction: ltr !important;
    }
    
    /* 移動端標籤頁中的路線列表 - 已移除 routes-section-full */

    /* 移動端自定義滾動條樣式 */
    .routes-list::-webkit-scrollbar {
        width: 6px;
    }

    .routes-list::-webkit-scrollbar-track {
        background: #f1f1f1;
        border-radius: 3px;
    }

    .routes-list::-webkit-scrollbar-thumb {
        background: #888;
        border-radius: 3px;
    }

    .routes-list::-webkit-scrollbar-thumb:hover {
        background: #555;
    }

    .route-item {
        flex-direction: row !important; /* 改为水平布局，让按钮和内容在同一行 */
        -webkit-flex-direction: row !important;
        align-items: center !important; /* 垂直居中对齐 */
        -webkit-align-items: center !important;
        gap: 10px; /* 内容区域和按钮之间的间距 */
        padding: 10px 12px; /* 减少 padding，使路线更紧凑 */
        min-height: auto; /* 移除固定最小高度，让内容决定高度 */
        box-sizing: border-box;
        text-align: left !important;
        -webkit-text-align: left !important;
        direction: ltr !important;
        display: flex !important;
        -webkit-display: flex !important;
        justify-content: space-between !important;
        -webkit-justify-content: space-between !important;
    }

    .route-info {
        flex: 1; /* 占据剩余空间 */
        min-width: 0; /* 允许内容收缩 */
    }
    
    /* 移动端路线项内容优化 */
    .route-name-grade {
        margin-bottom: 4px; /* 减少底部间距 */
        flex-wrap: nowrap !important; /* 防止路線名稱意外換行（Safari 修復） */
        -webkit-flex-wrap: nowrap !important; /* iOS Safari 特定修復 */
        align-items: center !important;
        -webkit-align-items: center !important;
        text-align: left !important;
        -webkit-text-align: left !important;
        direction: ltr !important;
        display: flex !important;
        -webkit-display: flex !important;
        justify-content: flex-start !important;
        -webkit-justify-content: flex-start !important;
    }
    
    .route-name-grade strong {
        font-size: 0.95rem; /* 稍微减小字体 */
        line-height: 1.3;
        white-space: nowrap !important; /* 防止路線名稱換行（Safari 修復） */
        -webkit-white-space: nowrap !important; /* iOS Safari 特定修復 */
        display: inline-block !important; /* 確保作為內聯塊元素，不會被意外分割 */
        -webkit-display: inline-block !important;
        max-width: 100%; /* 允許在必要時收縮，但優先不換行 */
        overflow: hidden; /* 如果內容過長，隱藏溢出部分 */
        text-overflow: ellipsis; /* 如果內容過長，顯示省略號 */
        text-align: left !important;
        -webkit-text-align: left !important;
        direction: ltr !important;
        flex-shrink: 0 !important;
        -webkit-flex-shrink: 0 !important;
    }
    
    .route-stats {
        font-size: 0.8rem; /* 稍微减小字体 */
        color: #666;
        margin-top: 2px;
    }

    /* 移动端缩略图优化 */
    .route-photo-thumbnail {
        width: 35px;
        height: 35px;
        margin-left: 6px;
    }

    .route-actions {
        flex-shrink: 0; /* 按钮不收缩 */
        width: auto; /* 移除固定宽度 */
    }

    .route-actions .btn {
        padding: 6px 12px; /* 减小按钮 padding */
        font-size: 0.85rem; /* 减小按钮字体 */
        white-space: nowrap; /* 防止按钮文字换行 */
    }

    .home-container {
        padding: 20px 10px;
    }

    .welcome-header {
        padding: 20px 0;
        margin-bottom: 30px;
    }

    .welcome-header h1 {
        font-size: 1.8rem;
    }

    .subtitle {
        font-size: 1rem;
    }

    .rooms-grid {
        grid-template-columns: 1fr;
        gap: 15px;
    }

    .room-card {
        padding: 15px;
    }

    .room-card-header h3 {
        font-size: 1.1rem;
    }

    table {
        font-size: 0.9rem;
    }

    th, td {
        padding: 8px;
    }

    .modal-content {
        width: 95%;
        margin: 5% auto;
        max-width: none;
    }

    .modal-header {
        padding: 15px;
    }

    .modal-header h3 {
        font-size: 1.1rem;
    }

    .modal-body {
        padding: 20px 15px;
    }

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

    .form-group input[type="text"],
    .form-group input[type="url"],
    .form-group select {
        padding: 12px;
        font-size: 16px; /* 防止 iOS 自動縮放 */
    }

    .form-actions {
        flex-direction: column;
        gap: 10px;
    }

    .form-actions .btn {
        width: 100%;
        padding: 12px;
    }

    /* 登入界面樣式（移動版） */
    .login-container {
        padding: 20px 15px;
        background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    }

    .login-card {
        padding: 35px 25px;
        border-radius: 16px;
        display: block;
        max-width: 100%;
        grid-template-columns: 1fr; /* 移動版單欄布局 */
    }
    
    .login-brand-section {
        display: none; /* 移動版隱藏品牌區域 */
    }
    
    .login-form-section {
        padding: 0;
    }
    
    .login-form-section .form-section-title {
        display: none; /* 移動版隱藏表單區域標題 */
    }

    .login-header {
        display: block; /* 移動版顯示標題 */
    }

    .login-header h1 {
        font-size: 1.8rem;
    }
    
    /* 移動版按鈕樣式 */
    .login-form-section .btn-primary,
    .login-form-section .btn-secondary {
        padding: 16px 28px;
        font-size: 1.15rem;
        border-radius: 10px;
    }
    
    /* 移動版輸入框樣式 */
    .login-card .form-group input[type="email"],
    .login-card .form-group input[type="password"],
    .login-card .form-group input[type="text"] {
        padding: 12px 14px;
        font-size: 16px; /* 防止 iOS 自動縮放 */
        border-radius: 8px;
    }

    .login-tabs {
        margin-bottom: 25px;
    }

    .tab-btn {
        padding: 12px 16px;
        font-size: 1rem;
    }

    .login-card .form-group input[type="email"],
    .login-card .form-group input[type="password"],
    .login-card .form-group input[type="text"] {
        padding: 12px 14px;
        font-size: 16px; /* 防止 iOS 自動縮放 */
    }

    /* 登入/註冊按鈕樣式（移動版） */
    .login-card .btn-primary {
        padding: 16px 28px;
        font-size: 1.15rem;
        font-weight: 700;
        letter-spacing: 0.8px;
    }

    .password-rules {
        padding: 12px;
        font-size: 0.85rem;
    }

    .password-rules-list li {
        font-size: 0.85rem;
        padding: 5px 0;
    }

    /* 訪客登入樣式（移動版） */
    .guest-login-section {
        margin-top: 25px;
        padding-top: 25px;
    }

    .login-card .btn-secondary {
        padding: 16px 28px;
        font-size: 1.15rem;
        font-weight: 700;
        letter-spacing: 0.8px;
    }

    .guest-note {
        font-size: 0.8rem;
    }

    .member-completions {
        max-height: 200px;
        padding: 10px;
    }

    .member-checkbox {
        padding: 10px;
        font-size: 0.95rem;
    }
}

/* 超小屏幕優化 */
@media (max-width: 480px) {
    .leaderboard-layout {
        padding: 8px;
        gap: 10px;
    }

    .leaderboard-container {
        padding: 12px;
    }

    .header-top h2 {
        font-size: 1.1rem;
    }

    }

    .room-info {
        font-size: 0.85rem;
    }

    .leaderboard-sidebar {
        max-height: 350px;
    }

    .leaderboard-sidebar-header {
        padding: 10px 12px;
    }

    .leaderboard-sidebar-header h3 {
        font-size: 0.9rem;
    }

    .leaderboard-table-wrapper {
        max-height: 250px;
    }

    .leaderboard-sidebar .leaderboard-table th,
    .leaderboard-sidebar .leaderboard-table td {
        padding: 6px 4px;
        font-size: 0.75rem;
    }

    .leaderboard-sidebar .leaderboard-table th {
        font-size: 0.65rem;
    }

    .modal-content {
        width: 98%;
        margin: 2% auto;
    }

    .modal-body {
        padding: 15px 10px;
    }

    .welcome-header h1 {
        font-size: 1.5rem;
    }
}

