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

:root {
    --bg: #f7f7f8;
    --bg-white: #ffffff;
    --bg-hover: #fafafa;
    --border: #e8e8e8;
    --border-light: #f0f0f0;
    --text: #1a1a1a;
    --text-secondary: #555555;
    --text-muted: #999999;
    --accent: #2d2d2d;
    --accent-light: #444444;
    --danger: #d63031;
    --danger-light: #fff5f5;
    --success: #00b894;
    --success-light: #f0fff4;
    --warn: #e17055;
    --warn-light: #fff8f0;
    --radius: 10px;
    --radius-lg: 14px;
    --shadow: 0 1px 3px rgba(0,0,0,0.04), 0 1px 2px rgba(0,0,0,0.06);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.07);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--text); }

/* ── Buttons ── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px 20px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
    background: var(--bg-white);
    color: var(--text);
    line-height: 1.4;
}
.btn:hover { background: var(--bg); border-color: #ccc; }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-primary {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}
.btn-primary:hover { background: var(--accent-light); border-color: var(--accent-light); }
.btn-danger {
    background: var(--bg-white);
    color: var(--danger);
    border-color: var(--danger);
}
.btn-danger:hover { background: var(--danger-light); }
.btn-sm { padding: 4px 12px; font-size: 13px; }
.btn-block { width: 100%; }

/* ── Topbar ── */
.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 28px;
    height: 54px;
    background: var(--bg-white);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
}
.topbar-left .logo {
    font-size: 15px;
    font-weight: 700;
    color: var(--text);
    letter-spacing: 0.3px;
}
.topbar-right { display: flex; align-items: center; gap: 12px; }
.user-info { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.user-avatar {
    width: 28px; height: 28px;
    background: var(--accent);
    color: #fff;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 12px; font-weight: 600;
}
.user-name { color: var(--text-secondary); font-weight: 500; }
.admin-link {
    background: #f0c040;
    color: #333;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.5px;
}
.admin-link:hover { text-decoration: none; color: #333; opacity: 0.9; }

/* ── Cards ── */
.card {
    background: var(--bg-white);
    border-radius: var(--radius-lg);
    padding: 20px 22px;
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
}
.card-header {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* ── Login ── */
.login-body {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg);
}
.login-card {
    background: var(--bg-white);
    padding: 44px 36px;
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 360px;
    border: 1px solid var(--border);
    box-shadow: var(--shadow-md);
}
.login-title {
    text-align: center;
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 4px;
    color: var(--text);
}
.login-subtitle {
    text-align: center;
    color: var(--text-muted);
    margin-bottom: 28px;
    font-size: 13px;
}
.form-group { margin-bottom: 18px; }
.form-group label {
    display: block;
    font-size: 13px;
    margin-bottom: 6px;
    color: var(--text-secondary);
    font-weight: 500;
}
.form-group input {
    width: 100%;
    padding: 10px 14px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-size: 14px;
    outline: none;
    transition: border-color 0.15s;
}
.form-group input:focus { border-color: var(--accent); background: var(--bg-white); }
.form-group input::placeholder { color: var(--text-muted); }
.error-msg {
    background: var(--danger-light);
    color: var(--danger);
    padding: 10px 14px;
    border-radius: var(--radius);
    font-size: 13px;
    margin-bottom: 16px;
    border: 1px solid #fdd;
}

/* ── Dashboard ── */
.dashboard-body { min-height: 100vh; background: var(--bg); }
.dashboard-main { padding: 20px 16px; max-width: 520px; margin: 0 auto; }
.dashboard-grid { display: flex; flex-direction: column; gap: 14px; }

/* ── Top Row: Credit + Notice ── */
.top-row { display: flex; flex-direction: column; gap: 14px; }

.credit-card {
    text-align: center;
    padding: 28px 20px 24px;
    background: linear-gradient(135deg, #fafafa 0%, #f0f0f0 100%);
    border: 1px solid #e0e0e0;
}
.credit-label {
    font-size: 13px;
    color: var(--text-muted);
    font-weight: 500;
    margin-bottom: 8px;
    letter-spacing: 1px;
}
.credit-value {
    font-size: 52px;
    font-weight: 800;
    color: var(--text);
    letter-spacing: -2px;
    line-height: 1;
    font-variant-numeric: tabular-nums;
}
.credit-sub {
    color: var(--text-muted);
    font-size: 12px;
    margin-top: 10px;
}

.notice-card {
    display: flex;
    gap: 12px;
    align-items: flex-start;
    padding: 16px 18px;
    background: #fffef5;
    border: 1px solid #f0e6c0;
}
.notice-icon {
    font-size: 20px;
    line-height: 1;
    flex-shrink: 0;
    margin-top: 2px;
}
.notice-body { flex: 1; min-width: 0; }
.notice-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 6px;
}
.notice-content {
    color: var(--text-secondary);
    font-size: 13px;
    white-space: pre-wrap;
    word-break: break-word;
    line-height: 1.6;
    max-height: 80px;
    overflow-y: auto;
}

/* ── Wheel ── */
.wheel-card {
    text-align: center;
    padding: 20px 18px 18px;
}
.spin-count {
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 400;
    background: var(--bg);
    padding: 3px 10px;
    border-radius: 20px;
}
.spin-count strong { color: var(--text); font-weight: 700; }
.wheel-container {
    display: flex;
    justify-content: center;
    margin: 12px 0 8px;
}
.wheel-wrapper {
    position: relative;
    width: 300px;
    max-width: 100%;
    aspect-ratio: 1;
}
.wheel-wrapper canvas {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    display: block;
}
.wheel-pointer {
    position: absolute;
    top: -10px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 20;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.12));
    pointer-events: none;
}
.pointer-arrow {
    width: 0;
    height: 0;
    border-left: 11px solid transparent;
    border-right: 11px solid transparent;
    border-top: 20px solid var(--accent);
}

.btn-spin {
    width: 68px; height: 68px;
    border-radius: 50%;
    background: var(--accent);
    color: #fff;
    font-size: 18px;
    font-weight: 700;
    border: 3px solid var(--bg-white);
    box-shadow: 0 2px 8px rgba(0,0,0,0.15), 0 0 0 2px rgba(0,0,0,0.08);
    cursor: pointer;
    position: absolute;
    top: 50%;
    left: 50%;
    margin-top: -34px;
    margin-left: -34px;
    z-index: 10;
    transition: all 0.15s ease;
    letter-spacing: 2px;
}
.btn-spin:hover:not(:disabled) {
    background: var(--accent-light);
    box-shadow: 0 4px 12px rgba(0,0,0,0.2), 0 0 0 2px rgba(0,0,0,0.12);
}
.btn-spin:active:not(:disabled) { transform: scale(0.95); }
.btn-spin:disabled { opacity: 0.4; cursor: not-allowed; }

.spin-result {
    margin-top: 10px;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
}

/* ── Probability Table ── */
.probability-table {
    margin-top: 16px;
    padding-top: 14px;
    border-top: 1px solid var(--border-light);
}
.prob-title {
    font-size: 11px;
    color: var(--text-muted);
    margin-bottom: 10px;
    text-align: center;
    letter-spacing: 1.5px;
    text-transform: uppercase;
}
.prob-list {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 6px 14px;
}
.prob-item {
    font-size: 12px;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 4px;
}
.prob-pct {
    font-weight: 700;
    color: var(--text);
    font-size: 11px;
    background: var(--bg);
    padding: 1px 6px;
    border-radius: 4px;
}

/* ── History ── */
.history-card { padding: 18px 20px; }
.history-count {
    font-size: 11px;
    color: var(--text-muted);
    font-weight: 400;
    background: var(--bg);
    padding: 2px 8px;
    border-radius: 10px;
}
.history-list { max-height: 300px; overflow-y: auto; }
.history-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 9px 0;
    border-bottom: 1px solid var(--border-light);
}
.history-row:last-child { border-bottom: none; }
.history-left { display: flex; align-items: center; gap: 10px; }
.history-date { color: var(--text-muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.history-index { color: var(--text-muted); font-size: 11px; background: var(--bg); padding: 1px 6px; border-radius: 4px; }
.history-prize { font-weight: 700; font-size: 14px; font-variant-numeric: tabular-nums; }
.prize-positive { color: var(--success); }
.prize-zero { color: var(--text-muted); font-weight: 400; font-size: 13px; }
.history-empty { text-align: center; color: var(--text-muted); padding: 28px; font-size: 13px; }

/* ── Modal ── */
.modal-overlay {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.25);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}
.modal {
    background: var(--bg-white);
    border-radius: var(--radius-lg);
    padding: 36px 28px;
    width: 90%;
    max-width: 320px;
    border: 1px solid var(--border);
    box-shadow: 0 12px 40px rgba(0,0,0,0.12);
    text-align: center;
}
.modal h3 { margin-bottom: 16px; font-size: 16px; }
.modal input, .modal textarea {
    width: 100%;
    padding: 10px 14px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-size: 14px;
    margin-bottom: 16px;
    outline: none;
}
.modal input:focus, .modal textarea:focus { border-color: var(--accent); background: var(--bg-white); }
.modal-actions { display: flex; gap: 10px; justify-content: center; margin-top: 8px; }
.prize-modal { max-width: 280px; padding: 32px 24px; }
.prize-icon { font-size: 44px; margin-bottom: 10px; }
.prize-text { font-size: 14px; color: var(--text-secondary); margin-bottom: 6px; }
.prize-amount {
    font-size: 30px;
    font-weight: 800;
    color: var(--text);
    margin-bottom: 24px;
    letter-spacing: -1px;
}

/* ── Admin ── */
.admin-body { min-height: 100vh; }
.admin-main { padding: 20px 16px; max-width: 960px; margin: 0 auto; }
.admin-tabs {
    display: flex;
    gap: 0;
    margin-bottom: 20px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-white);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    overflow: hidden;
}
.tab-btn {
    padding: 12px 24px;
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: all 0.15s;
}
.tab-btn.active { color: var(--text); border-bottom-color: var(--accent); background: var(--bg-white); }
.tab-btn:hover { color: var(--text-secondary); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

.panel-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 14px;
    gap: 12px;
    flex-wrap: wrap;
}
.search-input {
    padding: 8px 14px;
    background: var(--bg-white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-size: 14px;
    width: 260px;
    outline: none;
    transition: border-color 0.15s;
}
.search-input:focus { border-color: var(--accent); }
.search-input::placeholder { color: var(--text-muted); }

.table-wrap {
    overflow-x: auto;
    background: var(--bg-white);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
}
.data-table {
    width: 100%;
    border-collapse: collapse;
}
.data-table th, .data-table td {
    padding: 10px 14px;
    text-align: left;
    border-bottom: 1px solid var(--border-light);
    font-size: 14px;
}
.data-table th {
    font-weight: 500;
    color: var(--text-muted);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    background: var(--bg);
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: var(--bg-hover); }
.data-table .actions { display: flex; gap: 6px; }
.loading { text-align: center; color: var(--text-muted); padding: 32px; }

.panel-section {
    background: var(--bg-white);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px;
    margin-bottom: 16px;
    box-shadow: var(--shadow);
}
.panel-section h3 { margin-bottom: 12px; font-size: 14px; font-weight: 600; }
.panel-actions { margin-top: 16px; }
.form-inline { display: flex; align-items: center; gap: 10px; }
.form-inline label { font-size: 14px; color: var(--text-secondary); }
.form-inline input {
    width: 80px;
    padding: 6px 10px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-size: 14px;
    outline: none;
}
.form-inline input:focus { border-color: var(--accent); }
.hint { color: var(--text-muted); font-size: 12px; margin-bottom: 12px; }

.section-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
    flex-wrap: wrap;
}
.section-row input[type="text"],
.section-row input[type="number"] {
    padding: 6px 10px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-size: 13px;
    outline: none;
    transition: border-color 0.15s;
}
.section-row input:focus { border-color: var(--accent); }
.section-row .s-name { width: 110px; }
.section-row .s-prize { width: 90px; }
.section-row .s-weight { width: 70px; }
.section-row .s-color {
    width: 36px; height: 32px;
    padding: 2px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    background: var(--bg-white);
}
.section-row .s-del {
    background: none;
    border: 1px solid transparent;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 16px;
    padding: 4px 8px;
    border-radius: var(--radius);
    transition: all 0.15s;
}
.section-row .s-del:hover { color: var(--danger); background: var(--danger-light); border-color: var(--danger); }

#noticeInput {
    width: 100%;
    padding: 12px 14px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-size: 14px;
    resize: vertical;
    outline: none;
    font-family: inherit;
    line-height: 1.6;
    transition: border-color 0.15s;
}
#noticeInput:focus { border-color: var(--accent); background: var(--bg-white); }

.badge {
    display: inline-block;
    padding: 2px 7px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.3px;
}
.badge-admin { background: #fef3cd; color: #856404; border: 1px solid #f0d080; }
.badge-user { background: var(--bg); color: var(--text-muted); border: 1px solid var(--border); }

/* ── Responsive ── */
@media (max-width: 640px) {
    .topbar { padding: 0 16px; }
    .dashboard-main { padding: 14px 12px; }
    .admin-main { padding: 14px 12px; }
    .wheel-wrapper { width: 260px; }
    .btn-spin { width: 56px; height: 56px; margin-top: -28px; margin-left: -28px; font-size: 16px; }
    .credit-value { font-size: 42px; }
    .search-input { width: 100%; }
    .panel-toolbar { flex-direction: column; align-items: stretch; }
    .login-card { padding: 32px 24px; margin: 16px; }
}
