:root {
    /* 主色 */
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --primary-light: #818cf8;

    /* 功能色 */
    --banker-color: #ef4444;
    --player-color: #3b82f6;
    --tie-color: #10b981;

    /* 中性色 */
    --background: #f9fafb;
    --card-bg: #ffffff;
    --text-primary: #1f2937;
    --text-secondary: #4b5563;
    --border-color: #e5e7eb;

    /* 深色模式 */
    --dark-background: #111827;
    --dark-card-bg: #1f2937;
    --dark-surface: #374151;
    --dark-text-primary: #f9fafb;
    --dark-text-secondary: #9ca3af;
    --dark-border-color: #4b5563;

    /* 尺寸 */
    --sidebar-width: 260px;
    --header-height: 70px;
    --border-radius: 12px;
    --spacing: 24px;

    /* 陰影 */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);

    /* 動畫 */
    --transition: all 0.3s ease;
}

/* 基礎樣式 */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/* 背景層設置 - 將 BF 圖片設為最底層背景 */
body {
    font-family: 'Noto Sans TC', sans-serif;
    /* 設置 BF 圖片為背景，完整顯示 */
    background-image: url('/img/bf.jpg');
    background-size: contain;
    /* 完整顯示圖片 */
    background-position: center center;
    background-repeat: no-repeat;
    background-attachment: fixed;
    /* 添加深色背景色填補空白區域 */
    background-color: var(--dark-background);
    color: var(--dark-text-primary);
    line-height: 1.5;
    overflow-x: hidden;
    position: relative;
}

/* 如果您希望圖片填滿整個螢幕（可能會裁切），可以將上面的 contain 改為以下任一選項：
   - background-size: cover;        // 填滿螢幕，可能裁切圖片
   - background-size: 100% 100%;    // 拉伸圖片填滿螢幕
   - background-size: auto;         // 使用圖片原始大小
*/

/* 為整個頁面添加半透明覆蓋層，確保內容可讀性 */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(17, 24, 39, 0.65);
    /* 降低透明度，讓背景圖更清楚 */
    z-index: -1;
    pointer-events: none;
}

button,
input,
select {
    font-family: inherit;
}

/* 應用容器 */
.app-container {
    display: flex;
    min-height: 100vh;
    position: relative;
    z-index: 1;
}

/* 側邊欄 */
.sidebar {
    width: var(--sidebar-width);
    background-color: rgba(55, 65, 81, 0.95);
    /* 添加透明度 */
    backdrop-filter: blur(10px);
    /* 毛玻璃效果 */
    border-right: 1px solid var(--dark-border-color);
    padding: var(--spacing);
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    z-index: 10;
}

.sidebar-header {
    display: flex;
    align-items: center;
    margin-bottom: 32px;
    gap: 12px;
}

.logo-circle {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    display: flex;
    justify-content: center;
    align-items: center;
    font-weight: 700;
    color: white;
    font-size: 18px;
}

.sidebar-header h2 {
    font-size: 18px;
    font-weight: 600;
    color: var(--dark-text-primary);
}

.sidebar-nav {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.nav-item {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: var(--transition);
    color: var(--dark-text-secondary);
    gap: 12px;
}

.nav-item:hover {
    background-color: rgba(255, 255, 255, 0.05);
}

.nav-item.active {
    background-color: rgba(99, 102, 241, 0.1);
    color: var(--primary-light);
}

.nav-icon {
    font-size: 18px;
}

.nav-text {
    font-size: 15px;
    font-weight: 500;
}

.sidebar-footer {
    margin-top: auto;
    padding-top: var(--spacing);
    border-top: 1px solid var(--dark-border-color);
    display: flex;
    flex-direction: column;
    gap: 12px;
}

#ipTimeInfo {
    font-size: 12px;
    color: var(--dark-text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.status {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: #ef4444;
}

.status.offline .status-dot {
    background-color: #ef4444;
}

.status.online .status-dot {
    background-color: #10b981;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.4);
    }

    70% {
        box-shadow: 0 0 0 6px rgba(16, 185, 129, 0);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(16, 185, 129, 0);
    }
}

/* 主內容區 */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    padding: var(--spacing);
    background-color: transparent;
    /* 改為透明，讓背景圖片顯示 */
    position: relative;
}

.content-header {
    height: var(--header-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--spacing);
}

.content-header h1 {
    font-size: 24px;
    font-weight: 600;
    color: var(--dark-text-primary);
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
    /* 添加文字陰影提高可讀性 */
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 20px;
}

.connection-info {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

.platform-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--dark-text-primary);
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

.room-name {
    font-size: 12px;
    color: var(--dark-text-secondary);
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

.menu-toggle {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
}

.menu-toggle span {
    display: block;
    width: 22px;
    height: 2px;
    background-color: var(--dark-text-primary);
    margin: 4px 0;
    transition: var(--transition);
}

/* 內容網格 */
.content-grid {
    display: grid;
    grid-template-columns: 2fr 3fr;
    grid-template-rows: auto auto;
    gap: var(--spacing);
    grid-template-areas:
        "config game"
        "stats predict";
}

.config-panel {
    grid-area: config;
}

.game-board {
    grid-area: game;
}

.statistics {
    grid-area: stats;
}

.prediction {
    grid-area: predict;
}

/* 卡片樣式 - 增加透明度和毛玻璃效果 */
.card {
    background-color: rgba(31, 41, 55, 0.9);
    /* 增加透明度 */
    backdrop-filter: blur(10px);
    /* 毛玻璃效果 */
    border: 1px solid rgba(75, 85, 99, 0.5);
    /* 半透明邊框 */
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.card-header {
    padding: 16px 20px;
    border-bottom: 1px solid rgba(75, 85, 99, 0.5);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: rgba(55, 65, 81, 0.3);
}

.card-header h2 {
    font-size: 16px;
    font-weight: 600;
    color: var(--dark-text-primary);
}

.card-actions {
    display: flex;
    gap: 8px;
}

.card-body {
    padding: 20px;
}

/* 表單元素 */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    color: var(--dark-text-secondary);
    margin-bottom: 8px;
}

.form-control {
    width: 100%;
    background-color: rgba(55, 65, 81, 0.8);
    border: 1px solid var(--dark-border-color);
    border-radius: 8px;
    padding: 10px 12px;
    font-size: 14px;
    color: var(--dark-text-primary);
    transition: var(--transition);
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%239ca3af' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.1);
    background-color: rgba(55, 65, 81, 1);
}

/* 按鈕樣式 */
.btn-connect,
.btn-predict {
    width: 100%;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    border: none;
    border-radius: 8px;
    padding: 12px 20px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
}

.btn-connect:hover,
.btn-predict:hover {
    filter: brightness(1.1);
    transform: translateY(-1px);
}

.btn-connect:active,
.btn-predict:active {
    transform: translateY(1px);
}

.btn-connect:disabled {
    background: var(--dark-surface);
    color: var(--dark-text-secondary);
    cursor: not-allowed;
    transform: none;
}

.btn-action {
    background-color: rgba(55, 65, 81, 0.8);
    color: var(--dark-text-secondary);
    border: 1px solid var(--dark-border-color);
    border-radius: 6px;
    padding: 6px 12px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
}

.btn-action:hover {
    background-color: rgba(255, 255, 255, 0.05);
    color: var(--dark-text-primary);
}

.action-buttons {
    display: flex;
    gap: 10px;
    margin-top: 16px;
}

.btn-banker,
.btn-player,
.btn-tie {
    flex: 1;
    padding: 10px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    color: white;
}

.btn-banker {
    background-color: var(--banker-color);
}

.btn-player {
    background-color: var(--player-color);
}

.btn-tie {
    background-color: var(--tie-color);
}

.btn-banker:hover,
.btn-player:hover,
.btn-tie:hover {
    filter: brightness(1.1);
    transform: translateY(-1px);
}

.btn-banker:active,
.btn-player:active,
.btn-tie:active {
    transform: translateY(1px);
}

/* 結果表格 */
.board-container {
    overflow-x: auto;
    margin-bottom: 16px;
}

.result-table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
}

.result-table td {
    width: 40px;
    height: 40px;
    border: 1px solid var(--dark-border-color);
    text-align: center;
    font-weight: 600;
    font-size: 14px;
    transition: var(--transition);
    background-color: rgba(55, 65, 81, 0.3);
}

.result-table td.red {
    background-color: var(--banker-color);
    color: white;
}

.result-table td.blue {
    background-color: var(--player-color);
    color: white;
}

.result-table td.green {
    background-color: var(--tie-color);
    color: white;
}

.result-table td.highlight {
    animation: highlight 1s ease;
}

@keyframes highlight {

    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.1);
    }
}

/* 統計圓圈 */
.stat-circles {
    display: flex;
    justify-content: space-between;
    margin-bottom: 24px;
}

.stat-circle {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.circle-value {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 20px;
    font-weight: 700;
    color: white;
}

.stat-circle.banker .circle-value {
    background-color: var(--banker-color);
}

.stat-circle.player .circle-value {
    background-color: var(--player-color);
}

.stat-circle.tie .circle-value {
    background-color: var(--tie-color);
}

.circle-label {
    font-size: 14px;
    font-weight: 500;
    color: var(--dark-text-secondary);
}

/* 統計條 */
.stat-bars {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.stat-bar {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.bar-label {
    font-size: 13px;
    color: var(--dark-text-secondary);
}

.bar-container {
    height: 8px;
    background-color: rgba(55, 65, 81, 0.5);
    border-radius: 4px;
    overflow: hidden;
    position: relative;
}

.bar-fill {
    height: 100%;
    width: 0;
    transition: width 1s ease-out;
}

.banker-fill {
    background-color: var(--banker-color);
}

.player-fill {
    background-color: var(--player-color);
}

.tie-fill {
    background-color: var(--tie-color);
}

.bar-value {
    position: absolute;
    right: 0;
    top: -20px;
    font-size: 12px;
    color: var(--dark-text-secondary);
}

/* 預測顯示 */
.prediction-display {
    min-height: 150px;
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 20px;
}

.waiting-prediction {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
}

.pulse-circle {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background-color: rgba(255, 255, 255, 0.1);
    position: relative;
}

.pulse-circle:before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 20px;
    height: 20px;
    background-color: rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    animation: inner-pulse 1.5s ease-in-out infinite;
}

@keyframes inner-pulse {
    0% {
        transform: translate(-50%, -50%) scale(0.5);
        opacity: 0.2;
    }

    50% {
        transform: translate(-50%, -50%) scale(1);
        opacity: 0.6;
    }

    100% {
        transform: translate(-50%, -50%) scale(0.5);
        opacity: 0.2;
    }
}

.waiting-prediction p {
    font-size: 14px;
    color: var(--dark-text-secondary);
    text-align: center;
}

.prediction-result {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.vs-container {
    display: flex;
    width: 100%;
    margin-bottom: 24px;
}

.vs-side {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 16px;
    border-radius: 8px;
}

.vs-side.banker {
    background-color: rgba(239, 68, 68, 0.1);
}

.vs-side.player {
    background-color: rgba(59, 130, 246, 0.1);
}

.vs-percent {
    font-size: 28px;
    font-weight: 700;
}

.vs-side.banker .vs-percent {
    color: var(--banker-color);
}

.vs-side.player .vs-percent {
    color: var(--player-color);
}

.vs-label {
    font-size: 14px;
    font-weight: 500;
    margin-top: 4px;
    color: var(--dark-text-secondary);
}

.vs-divider {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 0 16px;
}

.vs-text {
    font-size: 16px;
    font-weight: 600;
    color: var(--dark-text-secondary);
}

.recommendation {
    padding: 12px 24px;
    border-radius: 30px;
    font-size: 18px;
    font-weight: 700;
    color: white;
    margin-top: 16px;
    animation: pulse-light 2s infinite;
}

.recommendation.banker {
    background-color: var(--banker-color);
}

.recommendation.player {
    background-color: var(--player-color);
}

@keyframes pulse-light {
    0% {
        box-shadow: 0 0 0 0 rgba(255, 255, 255, 0.4);
    }

    70% {
        box-shadow: 0 0 0 10px rgba(255, 255, 255, 0);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(255, 255, 255, 0);
    }
}

/* 模態框 */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal-content {
    background-color: rgba(31, 41, 55, 0.95);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(75, 85, 99, 0.5);
    border-radius: var(--border-radius);
    width: 90%;
    max-width: 400px;
    padding: 32px;
    box-shadow: var(--shadow-lg);
    text-align: center;
}

.logo-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 24px;
}

.logo-container h2 {
    margin-top: 16px;
    font-size: 20px;
    font-weight: 600;
}

.modal p {
    color: var(--dark-text-secondary);
    margin-bottom: 24px;
}

.input-group {
    margin-bottom: 24px;
}

.modal input {
    width: 100%;
    padding: 12px;
    border-radius: 8px;
    border: 1px solid var(--dark-border-color);
    background-color: rgba(55, 65, 81, 0.8);
    color: var(--dark-text-primary);
    font-size: 16px;
    text-align: center;
}

.modal input:focus {
    outline: none;
    border-color: var(--primary);
    background-color: rgba(55, 65, 81, 1);
}

.btn-verify {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    border: none;
    border-radius: 8px;
    padding: 12px 24px;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
}

.btn-verify:hover {
    filter: brightness(1.1);
}

#successMessage {
    margin-top: 16px;
    min-height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
}

#overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    z-index: 999;
}

/* 連線模態框 */
.connecting-modal {
    display: flex;
    flex-direction: column;
    align-items: center;
    color: white;
}

.connect-icon {
    font-size: 48px;
    margin-bottom: 24px;
    animation: spinning 2s linear infinite;
}

@keyframes spinning {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

.connecting-modal h3 {
    margin-bottom: 24px;
    font-weight: 600;
}

.progress-container {
    width: 100%;
    height: 8px;
    background-color: rgba(55, 65, 81, 0.5);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 16px;
}

.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), var(--primary-light));
    width: 0;
    transition: width 0.3s linear;
}

.connect-status {
    font-size: 14px;
    color: var(--dark-text-secondary);
}

/* 響應式設計 */
@media (max-width: 1024px) {
    .content-grid {
        grid-template-columns: 1fr;
        grid-template-areas:
            "config"
            "game"
            "stats"
            "predict";
    }
}

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s ease;
    }

    .sidebar.active {
        transform: translateX(0);
    }

    .main-content {
        margin-left: 0;
        width: 100%;
    }

    .menu-toggle {
        display: block;
    }

    .menu-toggle.active span:nth-child(1) {
        transform: rotate(45deg) translate(5px, 5px);
    }

    .menu-toggle.active span:nth-child(2) {
        opacity: 0;
    }

    .menu-toggle.active span:nth-child(3) {
        transform: rotate(-45deg) translate(5px, -5px);
    }

    .stat-circles {
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: center;
        gap: 24px;
    }
}

@media (max-width: 480px) {
    :root {
        --spacing: 16px;
    }

    .content-header h1 {
        font-size: 20px;
    }

    .connection-info {
        display: none;
    }

    .card-header {
        padding: 12px 16px;
    }

    .card-body {
        padding: 16px;
    }

    .result-table td {
        width: 32px;
        height: 32px;
        font-size: 12px;
    }

    .circle-value {
        width: 50px;
        height: 50px;
        font-size: 16px;
    }

    .vs-container {
        flex-direction: column;
        gap: 16px;
    }

    .vs-divider {
        padding: 8px 0;
    }

    .modal-content {
        padding: 24px 16px;
    }
}