/* ========== 分边工具样式 ========== */
* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: 'Microsoft YaHei', Arial, sans-serif;
    background: #f5f7fa;
    min-height: 100vh;
    padding: 20px;
    padding-bottom: 60px;
}

.container {
    max-width: 1000px;
    margin: 0 auto;
    background: white;
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.1);
    overflow: hidden;
}

.header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 30px;
    text-align: center;
}
.header h1 { font-size: 2.2em; margin-bottom: 10px; font-weight: 300; }
.header p { font-size: 1.1em; opacity: 0.9; }

/* 赛季专属 Logo（当前：秋季赛） */
.league-logo {
    height: 100px; margin-bottom: 6px;
    filter: drop-shadow(0 4px 12px rgba(0,0,0,0.35));
}

/* 赛事名称修改按钮 */
.league-edit {
    margin-top: 12px; background: rgba(255,255,255,0.18); color: #fff;
    border: 1px solid rgba(255,255,255,0.45); border-radius: 16px;
    padding: 5px 16px; font-size: 13px; cursor: pointer; font-family: inherit;
    transition: background 0.3s ease;
}
.league-edit:hover { background: rgba(255,255,255,0.32); }

/* 进度条 */
.progress-container { background: #f8f9fa; padding: 20px 40px; border-bottom: 1px solid #dee2e6; }
.progress-steps { display: flex; justify-content: space-between; align-items: center; max-width: 600px; margin: 0 auto; }
.progress-step { display: flex; flex-direction: column; align-items: center; position: relative; flex: 1; }
.progress-step:not(:last-child)::after {
    content: ''; position: absolute; top: 15px; right: -50%;
    width: 100%; height: 2px; background: #dee2e6; z-index: 1;
}
.progress-step.active:not(:last-child)::after { background: #667eea; }
.progress-step.completed:not(:last-child)::after { background: #28a745; }
.step-circle {
    width: 30px; height: 30px; border-radius: 50%;
    background: #dee2e6; color: #6c757d;
    display: flex; align-items: center; justify-content: center;
    font-weight: bold; margin-bottom: 8px; position: relative; z-index: 2;
    transition: all 0.3s ease;
}
.progress-step.active .step-circle { background: #667eea; color: white; }
.progress-step.completed .step-circle { background: #28a745; color: white; }
.progress-step.completed .step-circle::after { content: '✓'; position: absolute; font-size: 16px; }
.step-label { font-size: 12px; color: #6c757d; text-align: center; line-height: 1.2; }
.progress-step.active .step-label { color: #667eea; font-weight: bold; }
.progress-step.completed .step-label { color: #28a745; font-weight: bold; }

.content { padding: 40px; }

.section {
    background: #f8f9fa; border-radius: 15px; padding: 30px;
    margin-bottom: 30px; border: 1px solid #e9ecef;
}
.section h3 { color: #667eea; margin-bottom: 25px; font-size: 1.4em; text-align: center; }

/* 规则说明 */
.rules-section { background: #e8f4fd; border: 1px solid #bee5eb; border-radius: 10px; padding: 18px 25px; margin-bottom: 30px; }
.rules-section h3 { color: #0c5460; margin-bottom: 15px; font-size: 1.1em; text-align: center; }
.rules-list { list-style: none; counter-reset: rule-counter; }
.rules-list li {
    background: white; margin-bottom: 10px; padding: 12px 15px 12px 40px;
    border-radius: 6px; border-left: 3px solid #17a2b8;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    position: relative; font-size: 14px; line-height: 1.6;
}
.rules-list li::before {
    content: counter(rule-counter); counter-increment: rule-counter;
    position: absolute; left: 10px; top: 14px;
    background: #17a2b8; color: white; width: 20px; height: 20px;
    border-radius: 50%; display: flex; align-items: center; justify-content: center;
    font-size: 11px; font-weight: bold;
}
.rules-list li b { color: #0c5460; }

/* 队名输入 */
.team-inputs { display: flex; gap: 30px; justify-content: center; }
.team-input-group { flex: 1; max-width: 250px; }
.team-input-group label { display: block; margin-bottom: 8px; font-weight: bold; color: #495057; }
.team-input-group input {
    width: 100%; padding: 12px; border: 2px solid #dee2e6; border-radius: 8px;
    font-size: 16px; text-align: center; transition: all 0.3s ease;
}
.team-input-group input:focus { outline: none; border-color: #667eea; box-shadow: 0 0 10px rgba(102,126,234,0.2); }

.error-message {
    color: #dc3545; background: #f8d7da; border: 1px solid #f5c6cb;
    border-radius: 8px; padding: 10px 15px; margin: 15px auto 0;
    max-width: 400px; font-weight: 500; text-align: center;
}

/* 选面区域 */
.teams-selection { display: flex; gap: 60px; justify-content: center; }
.team-selection { text-align: center; }
.team-name {
    font-size: 1.3em; font-weight: bold; margin-bottom: 20px;
    padding: 12px 25px; border-radius: 8px; color: white;
    min-height: 50px; display: flex; align-items: center; justify-content: center;
}
.team-a .team-name { background: #007bff; }
.team-b .team-name { background: #dc3545; }
.coin-options { display: flex; gap: 20px; justify-content: center; }

.coin-option {
    width: 130px; padding: 14px 10px 12px;
    border: 3px solid #dee2e6; border-radius: 15px; cursor: pointer;
    transition: all 0.3s ease; display: flex; flex-direction: column;
    align-items: center; background: white;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1); font-family: inherit;
}
.coin-option:hover { transform: translateY(-3px); box-shadow: 0 6px 18px rgba(0,0,0,0.15); }
.coin-option:focus-visible { outline: 3px solid #667eea; outline-offset: 2px; }
/* 面图案（选面卡片 & 硬币共用） */
.face-art {
    display: inline-block; background-color: #fff; background-repeat: no-repeat;
    border-radius: 50%;
}
.coin-option .face-art {
    width: 76px; height: 76px; margin-bottom: 8px;
    border: 3px solid #d4af37;
    box-shadow: 0 0 0 2px #f7e7b0, 0 2px 8px rgba(0,0,0,0.18);
}
.art-player {
    background-image: url('face-player.png');
    background-size: 230%; background-position: 50% 26%;
}
.art-ball {
    background-image: url('face-ball.png');
    background-size: cover; background-position: center;
}
.coin-option .coin-label { font-size: 15px; font-weight: bold; color: #495057; }
.coin-option .coin-sub { font-size: 11px; color: #6c757d; margin-top: 2px; }
.coin-option.selected { transform: translateY(-3px); }
.team-a .coin-option.selected { border-color: #007bff; background: #e7f3ff; box-shadow: 0 6px 20px rgba(0,123,255,0.3); }
.team-b .coin-option.selected { border-color: #dc3545; background: #ffe6e6; box-shadow: 0 6px 20px rgba(220,53,69,0.3); }

/* 结果区域 */
.flip-section { text-align: center; }
.result-display {
    background: #d4edda; border: 1px solid #c3e6cb; border-radius: 10px;
    padding: 20px; margin: 0 auto 20px; max-width: 420px;
    animation: resultAppear 0.6s ease;
}
@keyframes resultAppear { from { opacity: 0; transform: scale(0.9); } to { opacity: 1; transform: scale(1); } }
.result-text { font-size: 1.2em; margin-bottom: 10px; color: #155724; }
.winner-display { font-size: 1.4em; font-weight: bold; color: #28a745; margin-bottom: 8px; }
.result-time { font-size: 0.9em; color: #6c757d; margin-bottom: 6px; }
.result-sig { font-size: 0.8em; color: #6c757d; margin-bottom: 14px; font-family: Consolas, monospace; }

.controls { margin-top: 10px; display: flex; justify-content: center; align-items: center; gap: 16px; }
.btn {
    padding: 12px 25px; border: none; border-radius: 25px;
    font-size: 16px; font-weight: 500; cursor: pointer;
    transition: all 0.3s ease; font-family: inherit;
}
.btn-primary { background: linear-gradient(45deg, #667eea, #764ba2); color: white; box-shadow: 0 4px 15px rgba(102,126,234,0.3); }
.btn-primary:hover:not(:disabled) { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(102,126,234,0.4); }
.btn-success { background: #28a745; color: white; box-shadow: 0 4px 15px rgba(40,167,69,0.3); }
.btn-success:hover { background: #218838; transform: translateY(-2px); }
.btn:disabled { opacity: 0.6; cursor: not-allowed; transform: none !important; }

.reset-btn {
    background: #dc3545; color: white; border: none; padding: 10px 20px;
    border-radius: 20px; font-size: 14px; cursor: pointer;
    transition: all 0.3s ease; box-shadow: 0 2px 8px rgba(220,53,69,0.3); font-family: inherit;
}
.reset-btn:hover { background: #c82333; }
.reset-btn.armed, .link-btn.armed { animation: armPulse 0.8s ease infinite; }
@keyframes armPulse { 0%,100% { transform: scale(1); } 50% { transform: scale(1.06); } }

/* 历史记录 */
.history-section h3 .history-count { font-size: 0.7em; color: #6c757d; font-weight: normal; }
.history-list { max-height: 260px; overflow-y: auto; }
.history-empty { text-align: center; color: #adb5bd; padding: 16px 0; font-size: 14px; }
.history-row {
    display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
    background: white; border-radius: 8px; padding: 10px 14px;
    margin-bottom: 8px; font-size: 13px; border: 1px solid #e9ecef;
}
.history-row .h-time { color: #6c757d; font-size: 12px; min-width: 130px; }
.history-row .h-match { flex: 1; min-width: 200px; color: #495057; }
.history-row .h-result { color: #0c5460; font-weight: bold; }
.history-row .h-winner { color: #28a745; font-weight: bold; }
.history-row .h-sig { color: #adb5bd; font-size: 11px; font-family: Consolas, monospace; }
.history-actions { text-align: right; margin-top: 10px; }
.link-btn {
    background: none; border: none; color: #dc3545; font-size: 12px;
    cursor: pointer; text-decoration: underline; font-family: inherit;
}

/* 底部说明 */
.footer-info { background: #f8f9fa; border-top: 1px solid #dee2e6; padding: 25px 40px; }
.footer-info h4 { color: #495057; margin-bottom: 12px; font-size: 1.1em; }
.footer-info p { color: #6c757d; line-height: 1.7; margin-bottom: 8px; font-size: 13px; }
.footer-info b { color: #495057; }

/* 翻转遮罩层 */
.flip-tip {
    position: fixed; inset: 0; z-index: 1000;
    background: rgba(20, 22, 40, 0.72); backdrop-filter: blur(4px);
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    color: white; text-align: center;
}
.flip-tip[hidden] { display: none; }
#flipStatus { font-size: 1.3em; margin-top: 26px; }
.flip-subtext { font-size: 0.95em; margin-top: 10px; opacity: 0.85; }

/* 3D 硬币 */
.coin3d-wrap { width: 170px; height: 170px; perspective: 1000px; position: relative; }
.coin3d {
    width: 100%; height: 100%; position: relative;
    transform-style: preserve-3d; will-change: transform;
}
.face {
    position: absolute; inset: 0; border-radius: 50%;
    backface-visibility: hidden; -webkit-backface-visibility: hidden;
    overflow: hidden;
    box-shadow: 0 6px 24px rgba(212,175,55,0.5);
    display: flex; align-items: center; justify-content: center;
}
/* 硬币金属圈 */
.face::after {
    content: ''; position: absolute; inset: 0; border-radius: 50%;
    box-shadow: inset 0 0 0 6px #d4af37, inset 0 0 0 9px #f7e7b0, inset 0 0 0 12px #b8860b;
    pointer-events: none; z-index: 2;
}
.face-fill {
    position: absolute; inset: 0; border-radius: 50%;
    background-color: #fff; background-repeat: no-repeat;
}
.face-fill.art-ball { background-size: cover; background-position: center; }
.face-front { background: linear-gradient(45deg, #fff, #eef1f6); }
.face-back { background: radial-gradient(circle at 50% 40%, #ffffff 0%, #dfe6f2 100%); transform: rotateY(180deg); }
.coin3d.settled { cursor: pointer; animation: settledPulse 1.2s ease infinite; }
@keyframes settledPulse {
    0%,100% { filter: drop-shadow(0 0 0 rgba(255,215,0,0)); }
    50% { filter: drop-shadow(0 0 18px rgba(255,215,0,0.8)); }
    }

/* 问号封面：落定后遮住硬币两面，点击揭晓时淡出 */
.coin-quest {
    position: absolute; inset: 0; border-radius: 50%; z-index: 5;
    background: radial-gradient(circle at 42% 35%, #ffedb0 0%, #e8c65a 45%, #d4af37 70%, #b8860b 100%);
    display: flex; align-items: center; justify-content: center;
    font-size: 88px; font-weight: 900; color: #8a6a12;
    text-shadow: 0 2px 3px rgba(255,255,255,0.5);
    box-shadow: inset 0 0 0 5px rgba(122,94,18,0.35), 0 6px 24px rgba(212,175,55,0.5);
    transition: opacity 0.3s ease;
    pointer-events: none;   /* 点击穿透到下层的硬币 */
}
.coin-quest[hidden] { display: none; }   /* display:flex 会顶掉 hidden 默认隐藏，必须显式补回 */
.coin-quest.fade { opacity: 0; }

/* Toast */
.toast {
    position: fixed; top: 24px; left: 50%; transform: translateX(-50%) translateY(-80px);
    background: rgba(33, 37, 41, 0.92); color: white; padding: 12px 26px;
    border-radius: 30px; font-size: 14px; z-index: 2000;
    transition: transform 0.35s ease; pointer-events: none; white-space: nowrap;
}
.toast.show { transform: translateX(-50%) translateY(0); }

@media (max-width: 768px) {
    body { padding: 10px; padding-bottom: 30px; }
    .content { padding: 20px; }
    .section { padding: 20px; }
    .progress-container { padding: 15px 20px; }
    .step-circle { width: 25px; height: 25px; }
    .step-label { font-size: 10px; }
    .team-inputs, .teams-selection { flex-direction: column; gap: 20px; align-items: center; }
    .team-input-group { width: 100%; max-width: 320px; }
    .coin3d-wrap { width: 140px; height: 140px; }
    .footer-info { padding: 20px; }
    .history-row .h-time { min-width: 100%; }
}
