:root {
  color-scheme: light;
  --bg: #f4f5f7;
  --panel: #ffffff;
  --panel-soft: #f9fafb;
  --text: #111827;
  --muted: #6b7280;
  --line: #e5e7eb;
  --brand: #111827;
  --brand-text: #ffffff;
  --accent: #4b5563;
  --danger: #b91c1c;
  --ok: #166534;
  --warn: #92400e;
  --shadow: 0 18px 50px rgba(17, 24, 39, 0.08);
}

[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0b0d10;
  --panel: #15181d;
  --panel-soft: #1d2128;
  --text: #f3f4f6;
  --muted: #9ca3af;
  --line: #2c313a;
  --brand: #f3f4f6;
  --brand-text: #0b0d10;
  --accent: #d1d5db;
  --danger: #f87171;
  --ok: #86efac;
  --warn: #fbbf24;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.32);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  background: radial-gradient(circle at top left, rgba(107,114,128,.16), transparent 34rem), var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button, input, textarea, select { font: inherit; }
button { cursor: pointer; }

.shell { width: min(1180px, calc(100% - 32px)); margin: 0 auto; padding: 28px 0 56px; }
.topbar { display: flex; justify-content: space-between; gap: 20px; align-items: center; margin-bottom: 22px; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: clamp(28px, 5vw, 46px); letter-spacing: -0.04em; }
h2 { margin-bottom: 10px; font-size: 24px; letter-spacing: -0.02em; }
h3 { margin-bottom: 8px; }
p { color: var(--muted); line-height: 1.7; }
.eyebrow { margin-bottom: 6px; color: var(--accent); font-size: 12px; font-weight: 800; letter-spacing: .16em; text-transform: uppercase; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; }
.notice { display: none; margin-bottom: 22px; padding: 14px 16px; border: 1px solid var(--line); border-radius: 18px; background: var(--panel); color: var(--muted); box-shadow: var(--shadow); }
.notice.active { display: block; }

.grid { display: grid; gap: 18px; }
.grid.two { grid-template-columns: 1.3fr 1fr; }
.grid.cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.login-wrap { display: grid; min-height: 62vh; place-items: center; }
.login-card { width: min(620px, 100%); }
.reward-page { display: grid; gap: 18px; }
.reward-hero { position: relative; overflow: hidden; }
.reward-hero::after { content: ""; position: absolute; right: -80px; top: -80px; width: 220px; height: 220px; border-radius: 50%; background: color-mix(in srgb, var(--accent) 18%, transparent); pointer-events: none; }
.reward-layout-compact .cards { grid-template-columns: 1fr; }
.reward-layout-compact .rule-card { grid-template-columns: 1fr auto; align-items: center; }
.reward-layout-showcase .cards { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.reward-layout-showcase .rule-card:first-child { grid-column: 1 / -1; }
.reward-anim-soft .rule-card { transition: transform .2s ease, border-color .2s ease; }
.reward-anim-soft .rule-card:hover { transform: translateY(-3px); border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); }
.reward-anim-pulse .rule-card { animation: rewardPulse 3.8s ease-in-out infinite; }
.reward-anim-float .rule-card { animation: rewardFloat 5s ease-in-out infinite; }
.reward-anim-spin .reward-hero::after { animation: wheelSpin 10s linear infinite; }
.card, .table-card { border: 1px solid var(--line); border-radius: 24px; background: color-mix(in srgb, var(--panel) 94%, transparent); box-shadow: var(--shadow); }
.card { padding: 24px; }
.hero-card { min-height: 420px; display: flex; flex-direction: column; justify-content: center; }
.form { display: grid; gap: 14px; margin-top: 22px; }
label { display: grid; gap: 7px; color: var(--muted); font-size: 13px; font-weight: 700; }
input, textarea, select { width: 100%; border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; background: var(--panel-soft); color: var(--text); outline: none; }
textarea { min-height: 96px; resize: vertical; }
input:focus, textarea:focus, select:focus { border-color: var(--accent); }
button { border: 0; border-radius: 14px; padding: 12px 16px; background: var(--brand); color: var(--brand-text); font-weight: 800; }
button.secondary { background: var(--panel-soft); color: var(--text); border: 1px solid var(--line); }
button.ghost { background: transparent; color: var(--text); border: 1px solid var(--line); }
button.danger { background: var(--danger); color: #fff; }
button:disabled { opacity: .55; cursor: not-allowed; }
.hidden { display: none !important; }

.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 20px; }
.stat { padding: 18px; border: 1px solid var(--line); border-radius: 20px; background: var(--panel); }
.stat strong { display: block; margin-top: 6px; font-size: 26px; letter-spacing: -0.03em; }
.section-head { display: flex; justify-content: space-between; gap: 16px; align-items: center; margin: 28px 0 14px; }
.section-head.compact { margin-top: 20px; }
.rule-card { display: grid; gap: 14px; border-color: color-mix(in srgb, var(--rule-accent, var(--line)) 38%, var(--line)); }
.rule-cover { width: 100%; max-height: 180px; object-fit: cover; border-radius: 18px; border: 1px solid var(--line); }
.rule-meta { display: flex; gap: 8px; flex-wrap: wrap; }
.lottery-wheel { position: relative; display: grid; place-items: center; width: min(240px, 100%); aspect-ratio: 1; margin: 0 auto; border-radius: 50%; border: 10px solid color-mix(in srgb, var(--rule-accent, var(--accent)) 35%, var(--line)); background: conic-gradient(from -20deg, color-mix(in srgb, var(--accent) 26%, transparent), var(--panel-soft), color-mix(in srgb, var(--brand) 14%, transparent), var(--panel-soft)); box-shadow: inset 0 0 0 1px var(--line), var(--shadow); overflow: hidden; }
.lottery-wheel::after { content: ""; position: absolute; width: 54px; aspect-ratio: 1; border-radius: 50%; background: var(--panel); border: 1px solid var(--line); box-shadow: var(--shadow); }
.lottery-wheel span { position: absolute; inset: 12px; display: flex; flex-direction: column; align-items: center; justify-content: flex-start; padding-top: 8px; color: var(--text); font-size: 12px; font-weight: 800; text-align: center; transform: rotate(calc(360deg / var(--segments) * var(--i, 0))); }
.lottery-wheel span:nth-child(1) { --i: 0; }
.lottery-wheel span:nth-child(2) { --i: 1; }
.lottery-wheel span:nth-child(3) { --i: 2; }
.lottery-wheel span:nth-child(4) { --i: 3; }
.lottery-wheel span:nth-child(5) { --i: 4; }
.lottery-wheel span:nth-child(6) { --i: 5; }
.lottery-wheel span:nth-child(7) { --i: 6; }
.lottery-wheel span:nth-child(8) { --i: 7; }
.lottery-wheel small { margin-top: 4px; color: var(--muted); font-size: 10px; font-weight: 700; }
.rule-card.is-spinning .lottery-wheel { animation: wheelSpin .9s cubic-bezier(.2,.8,.2,1); }
.badge { display: inline-flex; align-items: center; border: 1px solid var(--line); border-radius: 999px; padding: 5px 9px; background: var(--panel-soft); color: var(--muted); font-size: 12px; font-weight: 700; }
.badge.ok { color: var(--ok); }
.badge.warn { color: var(--warn); }
.badge.danger { color: var(--danger); }
.claim-form { display: none; gap: 10px; }
.claim-form.active { display: grid; }

.table-card { overflow: auto; }
table { width: 100%; border-collapse: collapse; min-width: 720px; }
th, td { padding: 13px 14px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .08em; }
tr:last-child td { border-bottom: 0; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }

.tabs { display: flex; gap: 10px; overflow-x: auto; margin: 20px 0; padding-bottom: 4px; }
.tabs button { white-space: nowrap; background: var(--panel); color: var(--text); border: 1px solid var(--line); }
.tabs button.active { background: var(--brand); color: var(--brand-text); }
.admin-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.toast { position: fixed; right: 18px; bottom: 18px; width: min(420px, calc(100% - 36px)); padding: 14px 16px; border-radius: 16px; background: var(--text); color: var(--bg); box-shadow: var(--shadow); z-index: 20; }
hr { width: 100%; border: 0; border-top: 1px solid var(--line); }
small { color: var(--muted); font-size: 12px; line-height: 1.5; }
@keyframes rewardPulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.012); } }
@keyframes rewardFloat { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }
@keyframes wheelSpin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }

@media (max-width: 860px) {
  .shell { width: min(100% - 22px, 1180px); padding-top: 18px; }
  .topbar { align-items: flex-start; flex-direction: column; }
  .grid.two, .grid.cards, .admin-grid { grid-template-columns: 1fr; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .hero-card { min-height: auto; }
  .card { padding: 18px; border-radius: 20px; }
}

@media (max-width: 520px) {
  .stats { grid-template-columns: 1fr; }
  .section-head { align-items: flex-start; flex-direction: column; }
  button { width: 100%; }
  .actions { width: 100%; }
  .actions button { flex: 1; }
}