/* ============================================================
   抽奖系统 · 多空间版
   视觉沿用原版：浅灰底、白色卡片、绿/红/橙/蓝按钮
   ============================================================ */

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

:root {
    --green: #4CAF50;
    --green-d: #45a049;
    --red: #f44336;
    --red-d: #da190b;
    --orange: #ff9800;
    --orange-d: #f57c00;
    --blue: #2196F3;
    --blue-d: #0b7dda;
    --purple: #9c27b0;
    --cyan: #00bcd4;
    --line: #e0e0e0;
    --bg: #f5f5f5;
    --panel: #f9f9f9;
    --text: #333;
    --muted: #666;
}

body {
    font-family: 'Microsoft YaHei', 'PingFang SC', Arial, sans-serif;
    background-color: var(--bg);
    color: var(--text);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--blue); }

/* ---------- 顶部空间条 ---------- */
.topbar {
    background: #fff;
    border-bottom: 1px solid var(--line);
    padding: 8px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    font-size: 13px;
    color: var(--muted);
    flex-wrap: wrap;
}
.topbar .tb-left { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.topbar .tb-right { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.topbar a { text-decoration: none; }
.topbar a:hover { text-decoration: underline; }

.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 12px;
    line-height: 18px;
    background: #eee;
    color: #666;
}
.badge.on  { background: #e8f5e9; color: #2e7d32; }
.badge.off { background: #fff3e0; color: #e65100; }

/* ---------- 抽奖页 ---------- */
.lottery-container {
    max-width: 1200px;
    margin: 20px auto;
    padding: 20px;
    background-color: #fff;
    border-radius: 8px;
    box-shadow: 0 0 20px rgba(0, 0, 0, .1);
    transition: max-width .25s ease;
}

.lottery-header {
    text-align: center;
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 2px solid var(--line);
}
.lottery-header h1 { font-size: 28px; color: var(--text); font-weight: bold; }

.lottery-main { display: flex; gap: 30px; }
.lottery-left { flex: 1; min-width: 400px; }
.lottery-right { width: 270px; max-width: 350px; }

.lottery-section {
    background-color: var(--panel);
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, .05);
}
.lottery-section h2 {
    font-size: 18px;
    color: var(--text);
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--line);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.lottery-list { display: flex; flex-wrap: wrap; gap: 10px; }
.lottery-list-item {
    background-color: #fff;
    padding: 8px 12px;
    border-radius: 20px;
    border: 1px solid var(--line);
    font-size: 14px;
    cursor: pointer;
    transition: all .3s ease;
    user-select: none;
}
.lottery-list-item:hover {
    background-color: #f0f0f0;
    transform: translateY(-2px);
    box-shadow: 0 2px 5px rgba(0, 0, 0, .1);
}
.lottery-list-item.active {
    background-color: var(--blue);
    color: #fff;
    border-color: var(--blue);
    transform: scale(1.08);
    box-shadow: 0 4px 12px rgba(33, 150, 243, .45);
}

.empty-tip { text-align: center; color: #999; padding: 20px; font-size: 14px; width: 100%; }

.prize-settings { margin-bottom: 5px; }
.prize-item { margin-bottom: 15px; }
.prize-info { display: flex; align-items: center; gap: 10px; margin-bottom: 5px; cursor: pointer; }
.prize-radio { margin-right: 5px; cursor: pointer; width: 16px; height: 16px; }
.prize-name { font-weight: bold; }
.prize-reward { color: var(--muted); font-size: 14px; }
.prize-progress { font-size: 12px; color: #999; margin-left: auto; white-space: nowrap; }
.prize-item.done .prize-name { color: #bbb; text-decoration: line-through; }
.prize-item.done .prize-progress { color: var(--green); }

.lottery-description { font-size: 14px; line-height: 1.8; color: var(--muted); white-space: pre-wrap; word-break: break-word; }

.winner-list { display: flex; flex-direction: column; gap: 10px; max-height: 60vh; overflow-y: auto; }
.winner-category { margin-bottom: 15px; }
.winner-category h3 { font-size: 16px; color: var(--text); margin-bottom: 10px; font-weight: bold; }
.winner-names { display: flex; flex-wrap: wrap; gap: 10px; }
.winner-item {
    background-color: var(--green);
    color: #fff;
    padding: 8px 12px;
    border-radius: 20px;
    font-size: 14px;
    transition: all .3s ease;
    animation: pop .45s cubic-bezier(.2, 1.4, .5, 1);
}
.winner-item:hover { background-color: var(--green-d); transform: translateY(-2px); box-shadow: 0 2px 5px rgba(0, 0, 0, .2); }
.winner-item.fresh { box-shadow: 0 0 0 3px rgba(76, 175, 80, .35); }

@keyframes pop {
    0%   { transform: scale(.4); opacity: 0; }
    60%  { transform: scale(1.12); opacity: 1; }
    100% { transform: scale(1); }
}

/* ---------- 按钮 ---------- */
.lottery-controls { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 20px; }

.btn {
    padding: 12px;
    border: none;
    border-radius: 4px;
    font-size: 14px;
    font-weight: bold;
    font-family: inherit;
    cursor: pointer;
    transition: all .25s ease;
    flex: 1;
    min-width: 80px;
    max-width: 120px;
    height: 40px;
    text-align: center;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #fff;
}
.btn:hover:not(:disabled) { transform: translateY(-2px); box-shadow: 0 2px 5px rgba(0, 0, 0, .2); }
.btn:disabled { background-color: #ccc !important; cursor: not-allowed; color: #fff; }

.start-btn { background-color: var(--green); }
.start-btn:hover:not(:disabled) { background-color: var(--green-d); }
.stop-btn { background-color: var(--red); }
.stop-btn:hover:not(:disabled) { background-color: var(--red-d); }
.reset-btn { background-color: var(--orange); }
.reset-btn:hover:not(:disabled) { background-color: var(--orange-d); }
.toggle-view-btn { background-color: var(--blue); }
.toggle-view-btn:hover:not(:disabled) { background-color: var(--blue-d); }

.lottery-footer { text-align: center; margin-top: 30px; padding-top: 20px; border-top: 1px solid var(--line); }
.admin-link {
    display: inline-block;
    padding: 10px 20px;
    background-color: var(--blue);
    color: #fff;
    text-decoration: none;
    border-radius: 4px;
    transition: all .3s ease;
}
.admin-link:hover { background-color: var(--blue-d); transform: translateY(-2px); box-shadow: 0 2px 5px rgba(0, 0, 0, .2); }

/* ---------- 中奖弹层 ---------- */
.winner-overlay {
    position: fixed;
    inset: 0;
    background: rgba(8, 10, 20, .78);
    backdrop-filter: blur(3px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    cursor: pointer;
    animation: fadeIn .18s ease;
}
.winner-overlay.show { display: flex; }
.winner-overlay .wo-box { text-align: center; padding: 20px 40px; }
.winner-overlay .wo-label { color: #ffd54f; font-size: 22px; letter-spacing: 4px; margin-bottom: 8px; }
.winner-overlay .wo-name {
    color: #fff;
    font-size: clamp(48px, 11vw, 140px);
    font-weight: 800;
    line-height: 1.15;
    text-shadow: 0 0 40px rgba(255, 213, 79, .8), 0 6px 24px rgba(0, 0, 0, .6);
    animation: zoomIn .38s cubic-bezier(.2, 1.5, .5, 1);
    word-break: break-all;
}
.winner-overlay .wo-prize { color: #b0bec5; font-size: 18px; margin-top: 14px; letter-spacing: 2px; }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes zoomIn { from { transform: scale(.3); opacity: 0; } to { transform: scale(1); opacity: 1; } }

#confetti-canvas {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 9998;
    display: none;
}
#confetti-canvas.show { display: block; }

/* ---------- 竖屏 ---------- */
.lottery-container.vertical-view { max-width: 780px; }
.lottery-container.vertical-view .lottery-main { flex-direction: column; }
.lottery-container.vertical-view .lottery-right { order: 1; width: 260px; max-width: 260px; }

/* ---------- 首页 ---------- */
.page-wrap { max-width: 1000px; margin: 30px auto; padding: 0 16px 60px; }
.page-card {
    background: #fff;
    border-radius: 10px;
    padding: 24px;
    box-shadow: 0 2px 18px rgba(0, 0, 0, .07);
    margin-bottom: 20px;
}
.page-card h1 { font-size: 24px; margin-bottom: 6px; }
.page-card h2 { font-size: 17px; margin-bottom: 16px; padding-bottom: 10px; border-bottom: 1px solid var(--line); }
.page-sub { color: var(--muted); font-size: 14px; }

.space-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; }
.space-card {
    display: block;
    text-decoration: none;
    color: inherit;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 16px;
    background: var(--panel);
    transition: all .2s ease;
    position: relative;
}
.space-card:hover { border-color: var(--blue); background: #f4faff; transform: translateY(-2px); box-shadow: 0 4px 14px rgba(33, 150, 243, .13); }
.space-card .sc-no { font-size: 12px; color: #fff; background: var(--blue); border-radius: 4px; padding: 1px 8px; display: inline-block; margin-bottom: 8px; }
.space-card .sc-title { font-size: 15px; font-weight: bold; line-height: 1.4; margin-bottom: 8px; word-break: break-word; }
.space-card .sc-meta { font-size: 12px; color: #999; }

.form-row { display: flex; gap: 14px; flex-wrap: wrap; }
.form-col { flex: 1; min-width: 180px; }
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 14px; font-weight: bold; margin-bottom: 6px; }
.form-control {
    width: 100%;
    padding: 10px;
    border: 1px solid var(--line);
    border-radius: 4px;
    font-size: 14px;
    font-family: inherit;
    transition: all .2s ease;
    background: #fff;
    color: var(--text);
}
.form-control:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 2px rgba(33, 150, 243, .12); }
.hint { font-size: 12px; color: #999; margin-top: 5px; }

.btn-line { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.btn-solid {
    padding: 11px 22px;
    border: none;
    border-radius: 4px;
    font-size: 15px;
    font-weight: bold;
    font-family: inherit;
    color: #fff;
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: all .2s ease;
}
.btn-solid:hover:not(:disabled) { transform: translateY(-2px); box-shadow: 0 3px 10px rgba(0, 0, 0, .18); }
.btn-solid:disabled { opacity: .55; cursor: not-allowed; }
.btn-solid.green { background: var(--green); }
.btn-solid.blue { background: var(--blue); }
.btn-solid.gray { background: #9e9e9e; }
.btn-solid.red { background: var(--red); }
.btn-solid.purple { background: var(--purple); }
.btn-solid.cyan { background: var(--cyan); }
.btn-ghost {
    padding: 10px 16px;
    border: 1px solid var(--line);
    background: #fff;
    color: var(--text);
    border-radius: 4px;
    font-size: 14px;
    font-family: inherit;
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: all .2s ease;
}
.btn-ghost:hover { border-color: var(--blue); color: var(--blue); }

/* ---------- 管理页 ---------- */
.admin-container {
    max-width: 1100px;
    margin: 20px auto;
    padding: 20px;
    background-color: #fff;
    border-radius: 8px;
    box-shadow: 0 0 20px rgba(0, 0, 0, .1);
}
.admin-header { text-align: center; margin-bottom: 26px; padding-bottom: 18px; border-bottom: 2px solid var(--line); }
.admin-header h1 { font-size: 24px; font-weight: bold; }
.admin-header .ah-sub { font-size: 13px; color: #999; margin-top: 6px; }

.admin-section {
    background-color: var(--panel);
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, .05);
}
.admin-section h2 {
    font-size: 18px;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--line);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}
.admin-content { display: grid; grid-template-columns: repeat(2, 1fr); gap: 20px; }
.admin-content .admin-section { margin-bottom: 0; }

.prizes-container { margin-bottom: 20px; display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; }
.prize-form { background-color: #fff; padding: 15px; border-radius: 8px; border: 1px solid var(--line); position: relative; }
.prize-form h3 { font-size: 15px; margin-bottom: 14px; font-weight: bold; color: var(--muted); }
.prize-actions { position: absolute; top: 10px; right: 10px; display: flex; gap: 5px; }
.mini-btn {
    width: 24px; height: 24px;
    border: none; border-radius: 4px;
    color: #fff; font-size: 13px;
    cursor: pointer; display: inline-flex;
    align-items: center; justify-content: center;
    transition: all .2s ease;
    font-family: inherit;
}
.mini-btn.blue { background: var(--blue); }
.mini-btn.red { background: var(--red); }
.mini-btn:hover:not(:disabled) { transform: scale(1.1); filter: brightness(1.08); }
.mini-btn:disabled { background: #ccc; cursor: not-allowed; }
.prize-form-row { display: flex; flex-direction: column; gap: 10px; margin-bottom: 10px; }
.prize-form-col { flex: 1; }
.prize-form-col.full-width { flex: 1 1 100%; }

.admin-actions { display: flex; gap: 12px; justify-content: center; margin-top: 26px; padding-top: 20px; border-top: 1px solid var(--line); flex-wrap: wrap; }

.toast {
    position: fixed;
    left: 50%;
    bottom: 40px;
    transform: translateX(-50%) translateY(20px);
    background: rgba(33, 33, 33, .92);
    color: #fff;
    padding: 11px 22px;
    border-radius: 24px;
    font-size: 14px;
    opacity: 0;
    pointer-events: none;
    transition: all .25s ease;
    z-index: 10001;
    max-width: 80vw;
    text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.err { background: rgba(211, 47, 47, .95); }
.toast.ok { background: rgba(46, 125, 50, .95); }

/* ---------- 登录 / 提示 ---------- */
.center-box { max-width: 420px; margin: 12vh auto; padding: 30px; background: #fff; border-radius: 10px; box-shadow: 0 4px 26px rgba(0, 0, 0, .1); }
.center-box h1 { font-size: 20px; margin-bottom: 6px; }
.center-box .cb-sub { font-size: 13px; color: #999; margin-bottom: 22px; }
.alert { padding: 10px 14px; border-radius: 4px; font-size: 14px; margin-bottom: 16px; }
.alert.err { background: #ffebee; color: #c62828; }
.alert.info { background: #e3f2fd; color: #1565c0; }

/* ---------- 响应式 ---------- */
@media (max-width: 768px) {
    .lottery-container, .admin-container { padding: 12px; margin: 10px auto; }
    .lottery-header h1 { font-size: 21px; }
    .lottery-main { flex-direction: column; gap: 0; }
    .lottery-left { min-width: 0; }
    .lottery-right { width: 100%; max-width: none; }
    .lottery-section, .admin-section { padding: 15px; }
    .admin-content { grid-template-columns: 1fr; }
    .prizes-container { grid-template-columns: 1fr; }
    .admin-actions { flex-direction: column; align-items: stretch; }
    .btn-solid { width: 100%; }
    .btn { max-width: none; }
    .lottery-container.vertical-view .lottery-right { width: 100%; max-width: none; }
}

@media print {
    .topbar, .lottery-controls, .admin-actions, .lottery-footer { display: none !important; }
    body { background: #fff; }
    .lottery-container { box-shadow: none; }
}
