/* ===== 快乐8 弹窗 (.kl8-*) =====
   每期抽 8 个 1-20 不重复号码。
   7 个 tab:两面 / 第一..五球 / 第六-八球。 */
.kl8-modal {
    position: fixed;
    inset: 0;
    z-index: 98;
    background: #f4f5f7;
    max-width: 480px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.kl8-modal[hidden] { display: none; }

.kl8-topbar {
    height: 54px;
    background: #ff5a4c;
    display: flex;
    align-items: center;
    padding: 0 10px;
    gap: 4px;
    flex: 0 0 auto;
}
.kl8-back, .kl8-history-btn {
    width: 36px; height: 36px;
    background: transparent; border: 0; cursor: pointer; padding: 0;
    display: inline-flex; align-items: center; justify-content: center;
}
.kl8-back svg { width: 22px; height: 22px; stroke: #fff; }
.kl8-history-btn svg { width: 22px; height: 22px; }
.kl8-title {
    flex: 1;
    text-align: center;
    color: #fff;
    font-size: 17px;
    font-weight: 500;
}
.kl8-avatar {
    width: 32px; height: 32px; border-radius: 50%;
    overflow: hidden; margin-left: 4px;
    display: inline-flex; align-items: center; justify-content: center;
}
.kl8-avatar svg { width: 32px; height: 32px; }

.kl8-result {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #fff;
    padding: 10px 14px 12px;
    flex: 0 0 auto;
}
.kl8-period {
    font-size: 13px;
    color: #ff4d4f;
    margin-bottom: 6px;
}
.kl8-balls {
    display: inline-flex;
    gap: 6px;
    flex-wrap: wrap;
    max-width: 360px;
}
.kl8-balance {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    color: #ff4d4f;
    font-weight: 700;
    font-size: 13px;
}
.kl8-balance svg { width: 32px; height: 32px; }
.kl8-balance.warn span { color: #d7261e; }

.kl8-next {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 14px;
    background: #fff;
    border-top: 1px solid #f0e2e0;
    font-size: 13px;
    color: #555;
    flex: 0 0 auto;
}
.kl8-next-period { color: #ff4d4f; }
.kl8-countdown {
    background: #d7261e;
    color: #fff;
    padding: 2px 8px;
    border-radius: 3px;
    font-weight: 700;
    min-width: 40px;
    text-align: center;
    transition: background 0.2s ease;
}
.kl8-countdown.locked {
    background: #fff;
    color: #d7261e;
    border: 1px solid #d7261e;
    animation: kl8CountdownBlink 0.6s ease-in-out infinite alternate;
}
@keyframes kl8CountdownBlink {
    from { opacity: 1; }
    to   { opacity: 0.55; }
}
.kl8-status { flex: 1; color: #666; transition: color 0.2s ease; }
.kl8-status.locked { color: #d7261e; font-weight: 600; }
.kl8-history-link { color: #ff6b48; }
.kl8-history-link b { font-weight: 400; margin-left: 2px; }

.kl8-play {
    flex: 1;
    display: flex;
    min-height: 0;
    overflow: hidden;
}
.kl8-sidebar {
    width: 76px;
    background: #eee;
    display: flex;
    flex-direction: column;
    flex: 0 0 auto;
    border-right: 1px solid #e6e6e6;
    overflow-y: auto;
}
.kl8-side-tab {
    padding: 18px 0;
    text-align: center;
    font-size: 15px;
    color: #666;
    background: #e7e7e7;
    border-bottom: 1px solid #dcdcdc;
    flex: 0 0 auto;
}
.kl8-side-tab.active {
    background: #ff7a1a;
    color: #fff;
    font-weight: 500;
}
.kl8-main {
    flex: 1;
    overflow-y: auto;
    background: #fff;
    position: relative;
}

.kl8-section-title {
    padding: 10px 0;
    text-align: center;
    color: #ff4d4f;
    font-size: 14px;
    font-weight: 600;
    background: #f3f3f3;
    border-bottom: 1px solid #eee;
}

.kl8-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0;
    border-bottom: 1px solid #eee;
}
.kl8-opt {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 22px;
    font-size: 15px;
    color: #333;
    border-right: 1px solid #eee;
    border-bottom: 1px solid #eee;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
    user-select: none;
    background: #fff;
}
.kl8-grid .kl8-opt:nth-child(2n) { border-right: 0; }
.kl8-opt:active { background: #fff4e8; }
.kl8-opt.selected {
    background: #ff7a1a;
    color: #fff;
}
.kl8-opt.selected .n,
.kl8-opt.selected .o { color: #fff; font-weight: 600; }
.kl8-opt .n { color: #333; }
.kl8-opt .o { color: #999; font-weight: 500; font-size: 14px; }

/* 精确号码 1-20 格 */
.kl8-num-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0;
    border-bottom: 1px solid #eee;
}
.kl8-num-opt {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 8px 22px;
    background: #fff;
    border-right: 1px solid #eee;
    border-bottom: 1px solid #eee;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
    user-select: none;
}
.kl8-num-grid .kl8-num-opt:nth-child(2n) { border-right: 0; }
.kl8-num-opt:active { background: #fff4e8; }
.kl8-num-opt.selected { background: #ff7a1a; color: #fff; }
.kl8-num-opt.selected .kl8-num-odds { color: #fff; font-weight: 600; }

/* 1-20 号码方块:按号色系配色,11-20 和 1-10 颜色对应 */
.kl8-num-ball {
    width: 28px;
    height: 28px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-weight: 700;
    font-size: 14px;
    flex: 0 0 auto;
    border-radius: 4px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.2);
}
.kl8-num-ball.c-1,  .kl8-num-ball.c-11 { background: #f5c518; color: #222; }
.kl8-num-ball.c-2,  .kl8-num-ball.c-12 { background: #3a82ff; }
.kl8-num-ball.c-3,  .kl8-num-ball.c-13 { background: #2b2b2b; }
.kl8-num-ball.c-4,  .kl8-num-ball.c-14 { background: #f28c3a; }
.kl8-num-ball.c-5,  .kl8-num-ball.c-15 { background: #26c4a4; }
.kl8-num-ball.c-6,  .kl8-num-ball.c-16 { background: #7258d0; }
.kl8-num-ball.c-7,  .kl8-num-ball.c-17 { background: #98a0a6; }
.kl8-num-ball.c-8,  .kl8-num-ball.c-18 { background: #ef7593; }
.kl8-num-ball.c-9,  .kl8-num-ball.c-19 { background: #d7261e; }
.kl8-num-ball.c-10, .kl8-num-ball.c-20 { background: #3ac24a; }

.kl8-num-odds {
    font-size: 14px;
    color: #999;
    font-weight: 500;
    flex: 1;
    text-align: right;
}

/* 顶部开奖球使用与号码格一致的配色 */
.kl8-head-ball {
    width: 26px;
    height: 26px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-weight: 700;
    font-size: 13px;
    border-radius: 50%;
    box-shadow:
        0 1px 3px rgba(0,0,0,0.3),
        inset -2px -3px 6px rgba(0,0,0,0.22),
        inset 2px 3px 6px rgba(255,255,255,0.3);
    position: relative;
}
.kl8-head-ball::before {
    content: "";
    position: absolute;
    top: 3px;
    left: 6px;
    width: 9px;
    height: 5px;
    background: radial-gradient(ellipse at center, rgba(255,255,255,0.85), rgba(255,255,255,0) 70%);
    border-radius: 50%;
    pointer-events: none;
}
.kl8-head-ball.c-1,  .kl8-head-ball.c-11 { background: #f5c518; color: #222; }
.kl8-head-ball.c-2,  .kl8-head-ball.c-12 { background: #3a82ff; }
.kl8-head-ball.c-3,  .kl8-head-ball.c-13 { background: #2b2b2b; }
.kl8-head-ball.c-4,  .kl8-head-ball.c-14 { background: #f28c3a; }
.kl8-head-ball.c-5,  .kl8-head-ball.c-15 { background: #26c4a4; }
.kl8-head-ball.c-6,  .kl8-head-ball.c-16 { background: #7258d0; }
.kl8-head-ball.c-7,  .kl8-head-ball.c-17 { background: #98a0a6; }
.kl8-head-ball.c-8,  .kl8-head-ball.c-18 { background: #ef7593; }
.kl8-head-ball.c-9,  .kl8-head-ball.c-19 { background: #d7261e; }
.kl8-head-ball.c-10, .kl8-head-ball.c-20 { background: #3ac24a; }

/* 底部快捷下单 */
.kl8-quickbar {
    position: relative;
    background: #ff7a1a;
    color: #fff;
    padding: 20px 12px 14px;
    flex: 0 0 auto;
}
.kl8-tip-pill {
    position: absolute;
    top: -14px;
    left: 50%;
    transform: translateX(-50%);
    background: #d7261e;
    color: #fff;
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 13px;
    white-space: nowrap;
    box-shadow: 0 2px 6px rgba(0,0,0,0.15);
}
.kl8-quick-line {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 10px;
}
.kl8-quick-line:first-of-type { margin-top: 6px; }
.kl8-quick-label {
    font-size: 13px;
    color: #fff;
    white-space: nowrap;
}
.kl8-chips {
    flex: 1;
    display: flex;
    gap: 6px;
    justify-content: space-between;
}
.kl8-chips button {
    flex: 1;
    height: 32px;
    border-radius: 50%;
    background: #a6a112;
    color: #fff;
    border: 0;
    font-size: 13px;
    cursor: pointer;
    min-width: 32px;
    max-width: 48px;
    aspect-ratio: 1;
    padding: 0;
}
.kl8-chips button:active { background: #867f0d; }
#kl8Amount {
    flex: 1;
    height: 32px;
    border: 0;
    border-radius: 4px;
    background: #fff;
    padding: 0 10px;
    font-size: 14px;
    outline: none;
    min-width: 0;
}
.kl8-buy, .kl8-reset {
    height: 32px;
    padding: 0 14px;
    border: 0;
    border-radius: 4px;
    color: #fff;
    font-size: 14px;
    cursor: pointer;
    background: #3a1aa8;
    transition: opacity 0.15s ease;
    font-weight: 500;
}
.kl8-reset { background: #d7261e; }
.kl8-buy:active { background: #2a1278; }
.kl8-reset:active { background: #a8140d; }

.kl8-modal.locked .kl8-buy {
    background: #6a5aa4;
    cursor: not-allowed;
    opacity: 0.7;
}
.kl8-modal.locked .kl8-opt,
.kl8-modal.locked .kl8-num-opt {
    pointer-events: none;
    opacity: 0.8;
}
.kl8-modal.locked .kl8-mask-hint { display: block; }
.kl8-mask-hint {
    display: none;
    position: absolute;
    top: 10px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0,0,0,0.7);
    color: #fff;
    padding: 6px 14px;
    border-radius: 18px;
    font-size: 12px;
    z-index: 2;
    white-space: nowrap;
    pointer-events: none;
}

.kl8-toast {
    position: absolute;
    left: 50%;
    bottom: 80px;
    transform: translateX(-50%) translateY(10px);
    background: rgba(0,0,0,0.8);
    color: #fff;
    padding: 8px 16px;
    border-radius: 18px;
    font-size: 13px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s, transform 0.25s;
    z-index: 10;
    white-space: nowrap;
}
.kl8-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
