/* ============================================
   投票系统样式
   ============================================ */

:root {
    --bg-page: #0d1117;
    --bg-card: #161b22;
    --bg-card-hover: #1c2333;
    --text-primary: #e6edf3;
    --text-secondary: rgba(255,255,255,0.55);
    --text-muted: rgba(255,255,255,0.3);
    --accent: #E8A87C;
    --accent2: #F4C2A1;
    --gold: #C9A96E;
    --red: #E94560;
    --green: #4CAF50;
    --gradient-accent: linear-gradient(135deg, #34E4E8, #1FAEE8);
    --border: rgba(255,255,255,0.06);
    --radius: 14px;
    --radius-sm: 10px;
    --nav-height: 100px;
    --header-height: 50px;
    --safe-bottom: env(safe-area-inset-bottom, 20px);
}

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

html, body {
    width: 100%; height: 100%;
    overflow: hidden;
    background: var(--bg-page);
    padding-bottom: env(safe-area-inset-bottom, 20px);
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'PingFang SC', 'Microsoft YaHei', sans-serif;
    color: var(--text-primary);
    -webkit-font-smoothing: antialiased;
    -webkit-tap-highlight-color: transparent;
    display: flex;
    flex-direction: column;
}

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

/* ====== Header ====== */
.page-header {
    flex-shrink: 0;
    height: var(--header-height);
    background: rgba(13,17,23,0.95);
    display: flex; align-items: center; justify-content: space-between;
    padding: 0 12px; z-index: 100;
    border-bottom: 1px solid var(--border);
}
.back-btn {
    width:36px; height:36px; display:flex; align-items:center; justify-content:center;
    background:none; border:none; color:var(--text-primary); cursor:pointer; border-radius:50%;
}
.back-btn:active { background: rgba(255,255,255,0.08); }
.page-title { font-size:17px; font-weight:600; }
.header-space { width:36px; }

/* ====== 主体 ====== */
.main-content {
    flex: 1;
    overflow-y: auto; overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    min-height: 0;
}
.main-content::-webkit-scrollbar { width:0; display:none; }

/* ====== 房间选择页 ====== */
.rooms-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    padding: 20px 16px;
}

.room-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    text-decoration: none;
    color: var(--text-primary);
}

.room-avatar {
    width: 90px; height: 90px;
    border-radius: 14px;
    overflow: hidden;
}

.room-avatar img {
    width:100%; height:100%;
    object-fit: cover; display:block;
}

.room-name {
    font-size: 13px;
    font-weight: 500;
    text-align: center;
}

.room-timer {
    font-size: 13px;
    font-weight: 600;
    color: var(--red);
    font-variant-numeric: tabular-nums;
}

/* ====== 投票房间页 ====== */
/* 公告 */
.marquee-bar {
    flex-shrink: 0;
    height: 32px;
    background: #1c1c2e;
    display: flex;
    align-items: center;
    padding: 0 12px;
    overflow: hidden;
    z-index: 90;
}
.marquee-icon { margin-right: 8px; font-size: 14px; }
.marquee-wrap { flex:1; overflow:hidden; white-space:nowrap; }
.marquee-text {
    display: inline-block;
    font-size: 12px; color: var(--text-secondary);
    animation: marquee 20s linear infinite;
}
@keyframes marquee {
    0% { transform: translateX(100%); }
    100% { transform: translateX(-100%); }
}

/* Tab切换 */
.vote-tabs {
    flex-shrink: 0;
    height: 44px;
    background: var(--bg-page);
    display: flex;
    align-items: center;
    z-index: 90;
    border-bottom: 1px solid var(--border);
}
.vote-tab {
    flex: 1;
    height: 44px;
    display: flex; align-items: center; justify-content: center;
    background: none; border: none;
    color: var(--text-secondary);
    font-size: 14px; font-weight: 500;
    cursor: pointer;
    font-family: inherit;
    position: relative;
    transition: color 0.25s;
}
.vote-tab.active {
    color: var(--red);
    font-weight: 600;
}
.vote-tab.active::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 30%; right: 30%;
    height: 2px;
    border-radius: 1px;
    background: var(--red);
}

/* 投票主内容 */
.vote-main {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    min-height: 0;
}
.vote-main::-webkit-scrollbar { width:0; display:none; }

.tab-panel { display: none; padding: 0 0 20px; }
.tab-panel.active { display: block; }

/* ====== 期号栏 ====== */
.period-bar {
    display: flex;
    padding: 14px 16px;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
}
.period-current {
    flex: 1;
}
.period-num {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
}
.period-countdown {
    font-size: 16px;
    font-weight: 700;
    color: var(--red);
    margin-top: 4px;
    font-variant-numeric: tabular-nums;
}
.period-prev {
    flex: 1;
    text-align: right;
}
.period-prev-num {
    font-size: 13px;
    color: var(--text-secondary);
}
.period-prev-result {
    font-size: 16px;
    font-weight: 700;
    color: var(--gold);
    margin-top: 4px;
}

/* ====== 投票选择 ====== */
.bet-section {
    padding: 16px;
    background: #fff;
}
.bet-label {
    text-align: center;
    font-size: 14px;
    font-weight: 600;
    color: #333;
    margin-bottom: 12px;
}
.bet-choices {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
}
.bet-choice {
    padding: 12px 0;
    border: 2px solid #ddd;
    border-radius: 6px;
    background: #fff;
    color: #333;
    font-size: 18px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
}
.bet-choice:first-child { color: var(--red); }
.bet-choice:nth-child(2) { color: var(--red); }
.bet-choice:nth-child(3) { color: var(--red); }
.bet-choice:nth-child(4) { color: var(--red); }

.bet-choice.selected {
    border-color: var(--red);
    background: rgba(233,69,96,0.06);
    box-shadow: 0 0 0 1px var(--red);
}
.bet-choice:active { transform: scale(0.95); }

/* ====== 分类图片卡 ====== */
.category-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    padding: 16px;
}
.cat-card {
    border-radius: 12px;
    overflow: hidden;
    aspect-ratio: 5 / 3;
    position: relative;
    display: flex;
    align-items: center;
}
.cat-text {
    position: absolute;
    left: 14px;
    z-index: 2;
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.cat-name {
    font-size: 22px;
    font-weight: 800;
    color: #fff;
    text-shadow: 0 2px 8px rgba(0,0,0,0.3);
}
.cat-en {
    font-size: 10px;
    font-weight: 600;
    color: rgba(255,255,255,0.7);
    text-transform: uppercase;
    letter-spacing: 1px;
}
.cat-img {
    position: absolute;
    right: 0; top: 0;
    height: 100%;
    width: 60%;
    object-fit: cover;
    mask-image: linear-gradient(to left, rgba(0,0,0,1) 40%, rgba(0,0,0,0) 100%);
    -webkit-mask-image: linear-gradient(to left, rgba(0,0,0,1) 40%, rgba(0,0,0,0) 100%);
}

/* ====== 历史表格 ====== */
.history-table-wrap {
    padding: 0;
}
.history-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
.history-table th {
    padding: 10px 8px;
    background: #f5f5f5;
    color: #666;
    font-weight: 500;
    text-align: center;
    border-bottom: 1px solid #eee;
}
.history-table td {
    padding: 10px 8px;
    text-align: center;
    color: #333;
    border-bottom: 1px solid #f5f5f5;
    background: #fff;
}
.empty-cell {
    padding: 50px 20px !important;
    color: #999 !important;
    text-align: center !important;
}
.empty-icon {
    font-size: 48px;
    margin-bottom: 12px;
    opacity: 0.3;
}
.empty-hint {
    font-size: 12px;
    color: #bbb;
    margin-top: 8px;
}
.status-win { color: var(--green); font-weight: 600; }
.status-lose { color: #999; }
.status-pending { color: var(--gold); }

/* ====== 余额卡 ====== */
.balance-card {
    text-align: center;
    padding: 30px 20px;
    background: #fff;
}
.balance-amount {
    font-size: 36px;
    font-weight: 700;
    color: var(--red);
}
.balance-label {
    font-size: 13px;
    color: #999;
    margin-top: 6px;
}
.balance-stats {
    display: flex;
    background: #fff;
    border-top: 1px solid #f0f0f0;
}
.balance-stat {
    flex: 1;
    text-align: center;
    padding: 16px;
}
.bs-num {
    display: block;
    font-size: 18px;
    font-weight: 600;
    color: #333;
}
.bs-label {
    display: block;
    font-size: 12px;
    color: #999;
    margin-top: 4px;
}

/* ====== 底部下注栏 ====== */
.bet-bottom-bar {
    flex-shrink: 0;
    min-height: 56px;
    background: #fff;
    border-top: 1px solid #eee;
    display: flex;
    align-items: center;
    padding: 0 10px;
    padding-bottom: env(safe-area-inset-bottom, 20px);
    z-index: 100;
    gap: 8px;
}
.bet-input-wrap {
    display: flex;
    align-items: center;
    border: 1px solid #ddd;
    border-radius: 4px;
    overflow: hidden;
}
.bet-amount-input {
    width: 60px;
    padding: 8px 6px;
    border: none;
    font-size: 14px;
    outline: none;
    text-align: center;
    color: #333;
    -moz-appearance: textfield;
}
.bet-amount-input::-webkit-outer-spin-button,
.bet-amount-input::-webkit-inner-spin-button { -webkit-appearance: none; }
.bet-unit {
    padding: 6px 8px;
    background: #f5f5f5;
    border-left: 1px solid #ddd;
    font-size: 12px;
    color: #666;
    white-space: nowrap;
}
.btn-clear {
    padding: 8px 14px;
    border: 1px solid #ddd;
    border-radius: 4px;
    background: #fff;
    color: #333;
    font-size: 13px;
    cursor: pointer;
    font-family: inherit;
    white-space: nowrap;
}
.bet-total {
    flex: 1;
    text-align: center;
    font-size: 13px;
    color: #333;
    white-space: nowrap;
}
.bet-total span { color: var(--red); font-weight: 600; }
.btn-submit {
    padding: 8px 18px;
    border: none;
    border-radius: 4px;
    background: var(--bg-page);
    color: #fff;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    white-space: nowrap;
    transition: opacity 0.2s;
}
.btn-submit:active { opacity: 0.7; }

/* ====== Toast ====== */
.toast {
    position: fixed;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%) scale(0.8);
    background: rgba(0,0,0,0.8);
    color: #fff;
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 14px;
    z-index: 9999;
    opacity: 0;
    pointer-events: none;
    transition: all 0.3s cubic-bezier(0.16,1,0.3,1);
}
.toast.show { opacity:1; transform: translate(-50%, -50%) scale(1); }

/* 底部导航样式见 nav.css */
.bottom-spacer { height: 16px; }

/* ====== 响应式 ====== */
@media (min-width: 480px) {
    .main-content, .page-header,
    .marquee-bar, .vote-tabs, .vote-main, .bet-bottom-bar {
        max-width: 480px;
        left: calc(50% - 240px);
        transform: none;
    }
}
