/* ===== CSS Variables ===== */
:root {
    --bg-primary: #0b0d15;
    --bg-card: rgba(255, 255, 255, 0.06);
    --bg-card-hover: rgba(255, 255, 255, 0.10);
    --border-glass: rgba(255, 255, 255, 0.10);
    --text-primary: #f0f2f8;
    --text-secondary: rgba(255, 255, 255, 0.55);
    --text-muted: rgba(255, 255, 255, 0.30);
    --banker-color: #ef4444;
    --player-color: #3b82f6;
    --tie-color: #22c55e;
    --radius-card: 20px;
    --radius-btn: 14px;
    --shadow-card: 0 8px 32px rgba(0, 0, 0, 0.45);
    --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

/* ===== Reset & Base ===== */
* { margin: 0; padding: 0; box-sizing: border-box; }
html { font-size: 16px; -webkit-tap-highlight-color: transparent; }
body {
    font-family: var(--font);
    background: var(--bg-primary);
    background-image: radial-gradient(ellipse at 10% 20%, rgba(239, 68, 68, 0.08) 0%, transparent 50%),
                      radial-gradient(ellipse at 90% 80%, rgba(59, 130, 246, 0.06) 0%, transparent 50%);
    color: var(--text-primary);
    min-height: 100vh;
    padding: 16px 12px 40px;
    display: flex;
    justify-content: center;
    line-height: 1.5;
}
.app-container { max-width: 480px; width: 100%; margin: 0 auto; }

/* ===== Glass Card ===== */
.card {
    background: var(--bg-card);
    backdrop-filter: blur(20px) saturate(1.4);
    -webkit-backdrop-filter: blur(20px) saturate(1.4);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-card);
    padding: 18px 16px;
    margin-bottom: 14px;
    box-shadow: var(--shadow-card);
}
.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 14px;
}
.card-title { font-weight: 600; font-size: 0.95rem; }
.badge-status {
    font-size: 0.7rem;
    padding: 4px 12px;
    background: rgba(255,255,255,0.08);
    border-radius: 20px;
    color: var(--text-secondary);
}

/* ===== Header ===== */
.header { text-align: center; padding: 8px 0 6px; }
.logo { display: flex; align-items: center; justify-content: center; gap: 10px; }
.logo-icon { font-size: 2rem; }
.logo-text {
    font-size: 1.6rem;
    font-weight: 700;
    background: linear-gradient(135deg, #f0f2f8 0%, #94a3b8 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}
.badge {
    font-size: 0.6rem;
    padding: 2px 10px;
    background: rgba(255,255,255,0.06);
    border-radius: 12px;
    color: var(--text-muted);
    border: 1px solid rgba(255,255,255,0.06);
}
.subtitle { color: var(--text-secondary); font-size: 0.8rem; margin-top: 4px; }

/* ===== Input Buttons ===== */
.btn-group { display: flex; gap: 10px; margin-bottom: 12px; }
.btn-result {
    flex: 1;
    padding: 14px 0;
    font-size: 1.2rem;
    font-weight: 700;
    border: none;
    border-radius: var(--radius-btn);
    cursor: pointer;
    transition: all 0.2s;
    font-family: var(--font);
    letter-spacing: 0.04em;
    background: rgba(255,255,255,0.04);
    color: var(--text-secondary);
    -webkit-tap-highlight-color: transparent;
    outline: none;
}
.btn-result:active { transform: scale(0.94); }
.btn-result.banker { 
    background: rgba(239, 68, 68, 0.55); 
    color: #fff; 
    border: 1px solid rgba(239, 68, 68, 0.50); 
    box-shadow: 0 0 20px rgba(239, 68, 68, 0.20);
}
.btn-result.banker:hover,
.btn-result.banker:active { background: rgba(239, 68, 68, 0.75); box-shadow: 0 0 30px rgba(239, 68, 68, 0.35); }
.btn-result.player { 
    background: rgba(59, 130, 246, 0.50); 
    color: #fff; 
    border: 1px solid rgba(59, 130, 246, 0.50); 
    box-shadow: 0 0 20px rgba(59, 130, 246, 0.20);
}
.btn-result.player:hover,
.btn-result.player:active { background: rgba(59, 130, 246, 0.70); box-shadow: 0 0 30px rgba(59, 130, 246, 0.35); }
.btn-result.tie { 
    background: rgba(34, 197, 94, 0.45); 
    color: #fff; 
    border: 1px solid rgba(34, 197, 94, 0.40); 
    box-shadow: 0 0 20px rgba(34, 197, 94, 0.15);
}
.btn-result.tie:hover,
.btn-result.tie:active { background: rgba(34, 197, 94, 0.65); box-shadow: 0 0 30px rgba(34, 197, 94, 0.30); }

.input-display {
    min-height: 44px;
    padding: 10px 14px;
    background: rgba(0,0,0,0.30);
    border-radius: 12px;
    font-size: 0.85rem;
    color: var(--text-secondary);
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    align-items: center;
    margin-bottom: 10px;
    border: 1px solid rgba(255,255,255,0.04);
}
.input-display .chip {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 6px;
    font-weight: 600;
    font-size: 0.75rem;
}
.chip.banker { background: rgba(239,68,68,0.30); color: #f87171; }
.chip.player { background: rgba(59,130,246,0.28); color: #60a5fa; }
.chip.tie { background: rgba(34,197,94,0.25); color: #4ade80; }
.input-display .placeholder { color: var(--text-muted); font-size: 0.8rem; }

.input-actions { display: flex; gap: 6px; }
.btn-sm {
    padding: 4px 12px;
    font-size: 0.7rem;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    background: rgba(255,255,255,0.06);
    color: var(--text-secondary);
    transition: 0.2s;
    font-family: var(--font);
}
.btn-sm:active { transform: scale(0.92); }
.btn-undo:hover { background: rgba(255,255,255,0.12); }
.btn-clear:hover { background: rgba(239,68,68,0.25); color: #f87171; }

.batch-row {
    display: flex;
    gap: 8px;
}
.batch-input {
    flex: 1;
    padding: 8px 12px;
    border-radius: 10px;
    border: 1px solid rgba(255,255,255,0.08);
    background: rgba(0,0,0,0.25);
    color: var(--text-primary);
    font-size: 0.8rem;
    outline: none;
    font-family: var(--font);
}
.batch-input:focus { border-color: rgba(255,255,255,0.18); }
.batch-input::placeholder { color: var(--text-muted); }
.btn-batch { background: rgba(255,255,255,0.08); padding: 8px 16px; }
.btn-batch:hover { background: rgba(255,255,255,0.14); }

/* ===== Prediction Result ===== */
.prediction-result {
    display: flex;
    align-items: center;
    gap: 20px;
    padding: 4px 0 8px;
}
.result-circle {
    width: 90px;
    height: 90px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.2rem;
    font-weight: 800;
    flex-shrink: 0;
    transition: all 0.4s;
    background: rgba(255,255,255,0.04);
    border: 2px solid rgba(255,255,255,0.08);
    box-shadow: 0 0 40px rgba(255,255,255,0.03);
}
.result-circle.banker { background: var(--banker-color); box-shadow: 0 0 50px rgba(239,68,68,0.35); border-color: var(--banker-color); }
.result-circle.player { background: var(--player-color); box-shadow: 0 0 50px rgba(59,130,246,0.35); border-color: var(--player-color); }
.result-circle.tie { background: var(--tie-color); box-shadow: 0 0 50px rgba(34,197,94,0.30); border-color: var(--tie-color); }
.result-circle .result-text { color: #fff; text-shadow: 0 2px 12px rgba(0,0,0,0.30); }

.result-meta { flex: 1; display: flex; flex-direction: column; gap: 6px; }
.confidence-row {
    display: flex;
    align-items: center;
    gap: 10px;
}
.confidence-row .label { font-size: 0.7rem; color: var(--text-secondary); min-width: 44px; }
.progress-bar {
    flex: 1;
    height: 6px;
    background: rgba(255,255,255,0.08);
    border-radius: 10px;
    overflow: hidden;
}
.progress-fill {
    height: 100%;
    border-radius: 10px;
    background: linear-gradient(90deg, #f59e0b, #22c55e);
    transition: width 0.5s ease;
}
.confidence-row .value { font-weight: 600; font-size: 0.85rem; min-width: 40px; text-align: right; }

.risk-row { display: flex; align-items: center; gap: 10px; }
.risk-row .label { font-size: 0.7rem; color: var(--text-secondary); min-width: 44px; }
.risk-tag {
    font-size: 0.7rem;
    padding: 2px 12px;
    border-radius: 12px;
    font-weight: 500;
}
.risk-tag.high { background: rgba(239,68,68,0.25); color: #f87171; }
.risk-tag.medium { background: rgba(245,158,11,0.25); color: #fbbf24; }
.risk-tag.low { background: rgba(34,197,94,0.20); color: #4ade80; }
.risk-tag.verylow { background: rgba(34,197,94,0.15); color: #6ee7b7; }
.risk-tag.unknown { background: rgba(255,255,255,0.06); color: var(--text-muted); }

.suggestion-text {
    font-size: 0.8rem;
    color: var(--text-secondary);
    background: rgba(255,255,255,0.04);
    padding: 4px 12px;
    border-radius: 8px;
    display: inline-block;
}

/* ===== Prob Details ===== */
.prob-details {
    display: flex;
    gap: 12px;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid rgba(255,255,255,0.05);
}
.prob-item { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; }
.prob-label { font-size: 0.65rem; color: var(--text-muted); text-transform: uppercase; }
.prob-value { font-weight: 700; font-size: 0.95rem; }
.prob-value.banker-c { color: #f87171; }
.prob-value.player-c { color: #60a5fa; }
.prob-value.tie-c { color: #4ade80; }

.accuracy-row {
    display: flex;
    justify-content: space-between;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid rgba(255,255,255,0.05);
    font-size: 0.7rem;
    color: var(--text-secondary);
}
.accuracy-row strong { color: var(--text-primary); }

/* ===== Stats Grid ===== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}
.stat-item {
    background: rgba(255,255,255,0.03);
    border-radius: 12px;
    padding: 10px 6px;
    text-align: center;
}
.stat-label {
    display: block;
    font-size: 0.6rem;
    color: var(--text-muted);
    text-transform: uppercase;
}
.stat-value {
    display: block;
    font-weight: 700;
    font-size: 1.1rem;
    margin-top: 2px;
}
.stat-value.banker-c { color: #f87171; }
.stat-value.player-c { color: #60a5fa; }
.stat-value.tie-c { color: #4ade80; }

/* ===== History ===== */
.history-list {
    max-height: 180px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.history-list::-webkit-scrollbar { width: 3px; }
.history-list::-webkit-scrollbar-track { background: transparent; }
.history-list::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 10px; }

.history-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 10px;
    background: rgba(255,255,255,0.03);
    border-radius: 8px;
    font-size: 0.8rem;
}
.history-item .h-result { font-weight: 600; padding: 0 8px; }
.history-item .h-result.banker { color: #f87171; }
.history-item .h-result.player { color: #60a5fa; }
.history-item .h-result.tie { color: #4ade80; }
.history-item .h-time { color: var(--text-muted); font-size: 0.65rem; }
.history-item .h-del {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 0.8rem;
    padding: 0 4px;
    opacity: 0.4;
    transition: 0.2s;
}
.history-item .h-del:hover { opacity: 1; color: #f87171; }

.empty-state { text-align: center; color: var(--text-muted); font-size: 0.8rem; padding: 20px 0; }

/* ===== Footer ===== */
.footer { text-align: center; padding: 16px 0 4px; }
.footer p { font-size: 0.65rem; color: var(--text-muted); }

/* ===== Responsive ===== */
@media (min-width: 768px) {
    body { padding: 30px 20px 50px; }
    .app-container { max-width: 560px; }
    .card { padding: 24px 24px; border-radius: 24px; }
    .result-circle { width: 110px; height: 110px; font-size: 2.6rem; }
    .btn-result { font-size: 1.4rem; padding: 16px 0; }
    .stats-grid { grid-template-columns: repeat(3, 1fr); gap: 12px; }
    .logo-text { font-size: 1.8rem; }
}

/* ===== Scrollbar ===== */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.12); border-radius: 10px; }

/* ===== 预测依据 ===== */
.predict-reason { margin-top: 14px; padding-top: 14px; border-top: 1px solid rgba(255,255,255,0.06); }
.reason-toggle {
    width: 100%;
    padding: 10px 0;
    background: rgba(255,255,255,0.04);
    border: 1px solid rgba(255,255,255,0.06);
    border-radius: 10px;
    color: var(--text-secondary);
    font-size: 0.8rem;
    cursor: pointer;
    font-family: var(--font);
    transition: 0.2s;
}
.reason-toggle:hover { background: rgba(255,255,255,0.08); }
.reason-content {
    margin-top: 12px;
    padding: 12px 14px;
    background: rgba(0,0,0,0.25);
    border-radius: 10px;
    font-size: 0.78rem;
    color: var(--text-secondary);
    line-height: 1.8;
}
.reason-content .vote-item {
    display: flex;
    justify-content: space-between;
    padding: 2px 0;
    border-bottom: 1px solid rgba(255,255,255,0.03);
}
.reason-content .vote-item:last-child { border-bottom: none; }
.reason-content .vote-label { color: var(--text-muted); }
.reason-content .vote-result { font-weight: 600; }
.reason-content .vote-result.banker { color: #f87171; }
.reason-content .vote-result.player { color: #60a5fa; }
.reason-content .vote-result.tie { color: #4ade80; }
.reason-content .final-result {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid rgba(255,255,255,0.08);
    font-weight: 600;
    color: var(--text-primary);
}
.reason-content .final-result .highlight { color: #fbbf24; }

/* ===== 统计图表 ===== */
.chart-container { width: 100%; overflow-x: auto; }
#chartCanvas {
    width: 100%;
    height: auto;
    aspect-ratio: 16/4;
    background: rgba(0,0,0,0.20);
    border-radius: 10px;
    display: block;
    min-height: 80px;
}
.chart-legend {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-top: 10px;
    font-size: 0.7rem;
    color: var(--text-secondary);
}
.legend-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 4px; vertical-align: middle; }

/* ===== 路纸切换 ===== */
.roadmap-tabs { padding: 14px 16px; }
.roadmap-header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    margin-bottom: 10px;
    flex-wrap: wrap;
    gap: 4px;
}
.roadmap-title { font-size: 0.85rem; font-weight: 600; color: var(--text-primary); }
.roadmap-hint { font-size: 0.65rem; color: var(--text-muted); }
.roadmap-body {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}
.roadmap-body .tabs-scroll {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    padding-bottom: 4px;
    scrollbar-width: none;
    flex: 1;
}
.roadmap-body .tabs-scroll::-webkit-scrollbar { display: none; }
.roadmap-body .tab-btn {
    padding: 6px 16px;
    border-radius: 20px;
    border: 1px solid rgba(255,255,255,0.08);
    background: rgba(255,255,255,0.04);
    color: var(--text-secondary);
    font-size: 0.75rem;
    font-weight: 500;
    cursor: pointer;
    font-family: var(--font);
    white-space: nowrap;
    transition: 0.2s;
    flex-shrink: 0;
    -webkit-tap-highlight-color: transparent;
    outline: none;
}
.roadmap-body .tab-btn:active { transform: scale(0.94); }
.roadmap-body .tab-btn.active {
    background: rgba(239, 68, 68, 0.25);
    border-color: #ef4444;
    color: #f87171;
    box-shadow: 0 0 20px rgba(239, 68, 68, 0.15);
}
.roadmap-body .tab-btn.tab-add {
    background: rgba(255,255,255,0.04);
    border-style: dashed;
    font-size: 0.9rem;
    padding: 6px 12px;
}
.roadmap-body .tab-btn.tab-add:hover { background: rgba(255,255,255,0.08); }
.roadmap-body .tab-actions { display: flex; gap: 4px; flex-shrink: 0; }
.roadmap-body .tab-actions .btn-sm {
    padding: 4px 10px;
    font-size: 0.7rem;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    background: rgba(255,255,255,0.04);
    color: var(--text-muted);
    font-family: var(--font);
    transition: 0.2s;
    -webkit-tap-highlight-color: transparent;
    outline: none;
}
.roadmap-body .tab-actions .btn-sm:hover { background: rgba(255,255,255,0.10); color: var(--text-secondary); }
.roadmap-body .tab-actions .btn-del-table:hover { background: rgba(239,68,68,0.20); color: #f87171; }

/* ===== 模拟器 ===== */
.simulation-section { margin-top: 4px; }
.sim-stats {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
    margin-bottom: 12px;
}
.sim-stat-item {
    background: rgba(255,255,255,0.03);
    border-radius: 8px;
    padding: 6px 4px;
    text-align: center;
}
.sim-stat-label {
    display: block;
    font-size: 0.55rem;
    color: var(--text-muted);
    text-transform: uppercase;
}
.sim-stat-value {
    display: block;
    font-weight: 700;
    font-size: 0.9rem;
    margin-top: 1px;
}
.sim-chart-container { width: 100%; margin-bottom: 10px; }
#simChartCanvas {
    width: 100%;
    height: auto;
    aspect-ratio: 16/3;
    background: rgba(0,0,0,0.20);
    border-radius: 8px;
    display: block;
    min-height: 40px;
}
.sim-detail-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
    flex-wrap: wrap;
}
.sim-bet-history {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
    flex: 1;
}
.sim-bet-history .bet-tag {
    font-size: 0.6rem;
    padding: 1px 8px;
    border-radius: 4px;
    font-weight: 600;
}
.sim-bet-history .bet-tag.win { background: rgba(34,197,94,0.20); color: #4ade80; }
.sim-bet-history .bet-tag.lose { background: rgba(239,68,68,0.20); color: #f87171; }
.sim-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    padding-top: 10px;
    border-top: 1px solid rgba(255,255,255,0.05);
}
@media (max-width: 480px) {
    .sim-stats { grid-template-columns: repeat(4, 1fr); }
}
@media (min-width: 768px) {
    .sim-stats { grid-template-columns: repeat(4, 1fr); gap: 10px; }
}
/* ===== 模拟器表格样式（新增） ===== */
.sim-table-wrapper {
    margin-top: 10px;
    border-radius: 8px;
    overflow: hidden;
    background: rgba(0,0,0,0.15);
}
.sim-table-header {
    display: grid;
    grid-template-columns: 30px 1fr 1fr 40px 1fr 1fr;
    padding: 6px 10px;
    background: rgba(255,255,255,0.05);
    font-size: 0.65rem;
    color: var(--text-muted);
    border-bottom: 1px solid rgba(255,255,255,0.05);
}
.sim-table-body {
    max-height: 120px;
    overflow-y: auto;
    font-size: 0.7rem;
}
.sim-table-body .sim-row {
    display: grid;
    grid-template-columns: 30px 1fr 1fr 40px 1fr 1fr;
    padding: 4px 10px;
    border-bottom: 1px solid rgba(255,255,255,0.03);
    align-items: center;
}
.sim-table-body .sim-row .sim-result { font-weight: 600; }
.sim-table-body .sim-row .sim-result.win { color: #4ade80; }
.sim-table-body .sim-row .sim-result.lose { color: #f87171; }
.sim-table-body .sim-empty {
    padding: 16px;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.7rem;
}
.sim-table-body::-webkit-scrollbar { width: 3px; }
.sim-table-body::-webkit-scrollbar-track { background: transparent; }
.sim-table-body::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 10px; }

/* 模拟器按钮样式补充 */
.sim-mode-selector {
    display: flex;
    gap: 8px;
    margin-bottom: 14px;
}
.sim-mode-btn {
    flex: 1;
    padding: 8px 0;
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 10px;
    background: rgba(255,255,255,0.04);
    color: var(--text-secondary);
    font-size: 0.75rem;
    font-weight: 500;
    cursor: pointer;
    font-family: var(--font);
    transition: 0.2s;
    -webkit-tap-highlight-color: transparent;
    outline: none;
}
.sim-mode-btn:active { transform: scale(0.94); }
.sim-mode-btn.active {
    background: rgba(239, 68, 68, 0.15);
    border-color: #ef4444;
    color: #f87171;
}

.sim-stats {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
    margin-bottom: 12px;
}
.sim-stat-item {
    background: rgba(255,255,255,0.03);
    border-radius: 8px;
    padding: 6px 4px;
    text-align: center;
}
.sim-stat-label {
    display: block;
    font-size: 0.55rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.sim-stat-value {
    display: block;
    font-weight: 700;
    font-size: 0.9rem;
    margin-top: 1px;
}

.sim-chart-container { width: 100%; margin-bottom: 10px; }
#simChartCanvas {
    width: 100%;
    height: auto;
    aspect-ratio: 16/3;
    background: rgba(0,0,0,0.20);
    border-radius: 8px;
    display: block;
    min-height: 40px;
}

.sim-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    padding-top: 10px;
    border-top: 1px solid rgba(255,255,255,0.05);
}

@media (max-width: 480px) {
    .sim-stats { grid-template-columns: repeat(4, 1fr); }
}
@media (min-width: 768px) {
    .sim-stats { grid-template-columns: repeat(4, 1fr); gap: 10px; }
}