/* ===== 主题变量：默认深色霓虹 ===== */
:root {
  --bg: #0a0c1a;
  --topbar-bg: linear-gradient(180deg, rgba(13, 15, 32, .72), rgba(13, 15, 32, 0));
  --bg-2: rgba(20, 23, 46, .72);
  --bg-3: rgba(32, 36, 66, .72);
  --bg-2-solid: #14172e;
  --bg-3-solid: #202442;
  --panel: rgba(32, 36, 66, .72);
  --surface: rgba(16, 19, 38, .92);
  --surface-card: rgba(18, 21, 42, .94);
  --fg: #eef1ff;
  --fg-dim: #8e96b8;
  --line: #2a3058;
  --brand: #7c5cff;
  --brand-2: #38bdf8;
  --magenta: #ff4fd8;
  --danger: #ff5d7a;
  --grad: linear-gradient(135deg, #a78bfa 0%, #7c5cff 45%, #38bdf8 100%);
  --glow-p: rgba(124, 92, 255, .5);
  --glow-c: rgba(56, 189, 248, .45);
  --primary-text: #fff;
  --backdrop: rgba(5, 6, 16, .6);
  --toast-bg: rgba(14, 16, 34, .9);
  --aurora-a: rgba(124, 92, 255, .85);
  --aurora-b: rgba(56, 189, 248, .7);
  --aurora-op: .55;
  --shadow-soft: 0 8px 24px rgba(0, 0, 0, .35);
  --warn-bg: rgba(255, 93, 122, .16);
  --warn-line: rgba(255, 93, 122, .3);
  --warn-text: #ffb3c0;
  --radius: 16px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}

/* ===== 明亮主题：奶油暖白、清爽彩色 + 柔和阴影 ===== */
[data-theme="light"] {
  --bg: #f7f2e9;
  --topbar-bg: linear-gradient(180deg, rgba(255, 253, 249, .72), rgba(255, 253, 249, 0));
  --bg-2: rgba(255, 255, 255, .85);
  --bg-3: rgba(255, 255, 255, .92);
  --bg-2-solid: #ffffff;
  --bg-3-solid: #ffffff;
  --panel: #ffffff;
  --surface: #fdfaf4;
  --surface-card: #ffffff;
  --fg: #2a2836;
  --fg-dim: #7d7a86;
  --line: #eae2d1;
  --brand: #6d4ff2;
  --brand-2: #0ea5d3;
  --magenta: #e145b8;
  --danger: #e5484d;
  --grad: linear-gradient(135deg, #7c5cff 0%, #5a4bf0 45%, #0ea5d3 100%);
  --glow-p: rgba(109, 79, 242, .18);
  --glow-c: rgba(14, 165, 211, .16);
  --primary-text: #fff;
  --backdrop: rgba(58, 50, 58, .3);
  --toast-bg: rgba(43, 40, 50, .92);
  --aurora-a: rgba(124, 92, 255, .26);
  --aurora-b: rgba(14, 165, 211, .2);
  --aurora-op: .5;
  --shadow-soft: 0 10px 28px rgba(140, 120, 90, .14);
  --warn-bg: rgba(229, 72, 77, .1);
  --warn-line: rgba(229, 72, 77, .26);
  --warn-text: #b3363b;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
html { background: var(--bg); }
body {
  background: transparent;
  color: var(--fg);
  font: 16px/1.5 system-ui, -apple-system, "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  overscroll-behavior: none;
  user-select: none;
  touch-action: manipulation;
  position: relative;
  isolation: isolate;
}
/* 背景氛围光晕：主题化、缓慢流动 */
body::before, body::after {
  content: "";
  position: fixed;
  z-index: -1;
  pointer-events: none;
  border-radius: 50%;
  filter: blur(70px);
  opacity: var(--aurora-op);
  will-change: transform;
}
body::before {
  width: 62vmax; height: 62vmax;
  left: -20vmax; top: -24vmax;
  background: radial-gradient(circle, var(--aurora-a), transparent 62%);
  animation: drift-a 18s ease-in-out infinite alternate;
}
body::after {
  width: 58vmax; height: 58vmax;
  right: -22vmax; bottom: -20vmax;
  background: radial-gradient(circle, var(--aurora-b), transparent 62%);
  animation: drift-b 22s ease-in-out infinite alternate;
}
@keyframes drift-a { from { transform: translate3d(0, 0, 0) scale(1); } to { transform: translate3d(8vmax, 7vmax, 0) scale(1.15); } }
@keyframes drift-b { from { transform: translate3d(0, 0, 0) scale(1.1); } to { transform: translate3d(-7vmax, -6vmax, 0) scale(.95); } }

/* 顶部栏：玻璃拟态 */
.topbar {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 12px; padding-top: max(10px, env(safe-area-inset-top, 0px));
  position: relative; z-index: 2;
  background: var(--topbar-bg);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
}
.topbar__preset {
  flex: 0 1 auto; max-width: 45%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  background: var(--bg-3); color: var(--fg);
  border: 1px solid var(--line); border-radius: 999px; padding: 8px 14px;
  font-size: 15px; font-weight: 600;
  transition: border-color .2s ease, box-shadow .2s ease;
}
.topbar__preset:active { border-color: var(--brand); box-shadow: 0 0 0 3px var(--glow-p); }
.topbar__remain { margin-left: auto; color: var(--fg-dim); font-size: 14px; font-variant-numeric: tabular-nums; }
.iconbtn {
  background: var(--bg-3); color: var(--fg);
  border: 1px solid var(--line); border-radius: 999px;
  width: 40px; height: 40px; font-size: 18px;
  transition: transform .15s ease, border-color .2s ease, box-shadow .2s ease;
}
.iconbtn:active { transform: scale(.92); border-color: var(--brand); box-shadow: 0 0 14px var(--glow-p); }

/* 舞台与转盘 */
.stage {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 18px; padding: 8px 16px calc(22px + var(--safe-b)); min-height: 0; position: relative; z-index: 1;
}
.brand-title {
  margin: 2px 0 0;
  font-size: clamp(18px, 5.6vw, 23px);
  font-weight: 800;
  letter-spacing: .08em;
  background: var(--grad);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 0 12px var(--glow-p));
}
#wheel {
  width: min(88vw, 46vh, 420px); height: min(88vw, 46vh, 420px); display: block;
  filter: drop-shadow(0 16px 32px rgba(15, 12, 40, .45)) drop-shadow(0 0 18px var(--glow-p));
  transition: filter .3s ease;
}
[data-theme="light"] #wheel { filter: drop-shadow(0 12px 26px rgba(140, 120, 90, .18)); }
.spinbtn {
  width: min(80vw, 360px); padding: 18px; font-size: 20px; font-weight: 800; letter-spacing: .06em;
  color: var(--primary-text); background: var(--grad);
  border: 0; border-radius: 999px; cursor: pointer;
  box-shadow: 0 8px 28px var(--glow-p), inset 0 1px 0 rgba(255, 255, 255, .35);
  animation: spin-glow 3s ease-in-out infinite;
  transition: transform .12s ease, box-shadow .2s ease, filter .2s ease;
}
@keyframes spin-glow {
  0%, 100% { box-shadow: 0 8px 24px var(--glow-p), inset 0 1px 0 rgba(255,255,255,.35); }
  50% { box-shadow: 0 8px 40px var(--glow-c), inset 0 1px 0 rgba(255,255,255,.35); }
}
[data-theme="light"] .spinbtn { animation: none; box-shadow: 0 6px 18px rgba(109, 79, 242, .28), inset 0 1px 0 rgba(255,255,255,.6); }
.spinbtn:active { transform: translateY(1px) scale(.985); }
.spinbtn[disabled] { filter: grayscale(.55) brightness(.65); box-shadow: none; animation: none; }

/* 通用按钮 */
.btn {
  padding: 10px 14px; font-size: 15px; border: 1px solid transparent; border-radius: var(--radius);
  background: var(--bg-3); color: var(--fg); cursor: pointer;
  transition: transform .12s ease, border-color .2s ease, box-shadow .2s ease, filter .2s ease;
}
.btn:active { transform: translateY(1px) scale(.98); }
.btn--primary { background: var(--grad); color: var(--primary-text); font-weight: 700; box-shadow: 0 4px 16px var(--glow-p); }
.btn--ghost { background: transparent; border-color: var(--line); }

/* 布局辅助 */
.row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.hint { color: var(--fg-dim); font-size: 13px; margin: 6px 0 0; }
.check { display: flex; align-items: center; gap: 8px; padding: 6px 0; }
.check input[type="checkbox"] { accent-color: var(--brand); }

/* 横幅 */
.banner { padding: 10px 12px; font-size: 14px; display: flex; align-items: center; gap: 8px; position: relative; z-index: 2; }
.banner--warn { background: var(--warn-bg); color: var(--warn-text); border-bottom: 1px solid var(--warn-line); }
.banner--hint { background: var(--bg-3); color: var(--fg-dim); border-bottom: 1px solid var(--line); }
.banner__close { margin-left: auto; background: transparent; border: 0; color: inherit; font-size: 15px; }

/* Toast */
.toast {
  position: fixed; left: 50%; bottom: calc(30px + var(--safe-b)); transform: translateX(-50%);
  background: var(--toast-bg); color: #fff; padding: 10px 16px; border-radius: 999px; font-size: 14px; z-index: 40;
  display: flex; align-items: center; gap: 10px;
  border: 1px solid var(--line); box-shadow: 0 8px 30px rgba(0, 0, 0, .35), 0 0 16px var(--glow-p);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
}
.toast button { background: transparent; border: 0; color: var(--brand-2); font-size: 14px; font-weight: 700; cursor: pointer; }

/* 遮罩与抽屉 */
.backdrop { position: fixed; inset: 0; background: var(--backdrop); z-index: 20; backdrop-filter: blur(2px); -webkit-backdrop-filter: blur(2px); }
.drawer {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; max-height: 88dvh; display: flex; flex-direction: column;
  background: var(--surface); border-radius: 22px 22px 0 0;
  border: 1px solid var(--line); border-bottom: 0;
  box-shadow: 0 -12px 50px rgba(0, 0, 0, .35), 0 -2px 30px var(--glow-p);
  backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px);
  padding-bottom: var(--safe-b); animation: drawer-in .26s cubic-bezier(.2, .8, .3, 1);
}
@keyframes drawer-in { from { transform: translateY(30px); opacity: .6; } to { transform: none; opacity: 1; } }
.drawer__head {
  display: flex; align-items: center; justify-content: space-between; padding: 16px 16px 12px; font-weight: 700;
  border-bottom: 1px solid var(--line);
}
.drawer__body { overflow-y: auto; padding: 12px 16px 20px; display: flex; flex-direction: column; gap: 14px; }
.panel {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .04);
}
[data-theme="light"] .panel { box-shadow: 0 4px 16px rgba(140, 120, 90, .1); }
.panel__title { margin: 0 0 10px; font-size: 13px; color: var(--fg-dim); font-weight: 600; letter-spacing: .04em; text-transform: uppercase; }

/* 奖项行 */
.tier-row { display: grid; grid-template-columns: 38px 1fr 84px 40px; gap: 8px; align-items: center; padding: 6px 0; }
.tier-row input[type="text"], .tier-row input[type="number"] {
  width: 100%; background: var(--bg-3-solid); color: var(--fg);
  border: 1px solid var(--line); border-radius: 10px; padding: 9px; font-size: 15px;
  transition: border-color .2s ease, box-shadow .2s ease;
}
.tier-row input[type="text"]:focus, .tier-row input[type="number"]:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--glow-p); }
.tier-row input[type="color"] { width: 38px; height: 38px; padding: 0; border: 1px solid var(--line); border-radius: 10px; background: transparent; }
.tier-row__del { background: transparent; border: 0; color: var(--danger); font-size: 18px; cursor: pointer; transition: transform .12s ease; }
.tier-row__del:active { transform: scale(.88); }

/* 预设行 */
.preset-row { display: flex; align-items: center; gap: 8px; padding: 8px 0; }
.preset-row button { flex: 1; text-align: left; transition: border-color .2s ease, box-shadow .2s ease; }
.preset-row.is-active button { border-color: var(--brand); color: var(--brand); box-shadow: 0 0 0 1px var(--brand), 0 0 14px var(--glow-p); }

/* 记录行 */
.history-row { display: grid; grid-template-columns: 36px 1fr auto; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 15px; }
.history-row .seq { color: var(--fg-dim); font-variant-numeric: tabular-nums; }
.history-row .at { color: var(--fg-dim); font-variant-numeric: tabular-nums; }

textarea {
  width: 100%; background: var(--bg-3-solid); color: var(--fg); border: 1px solid var(--line); border-radius: 10px; padding: 9px;
  font: 12px/1.5 ui-monospace, Consolas, monospace;
}
textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--glow-p); }

/* 指南 */
.guide-lead { color: var(--fg-dim); font-size: 14px; margin: 0 0 2px; }
.guide-title { margin: 0 0 6px; font-size: 16px; font-weight: 700; color: var(--fg); }
.guide-example {
  margin-top: 10px; padding: 10px 12px; background: var(--bg-3); border-left: 3px solid var(--brand);
  border-radius: 8px; font-size: 14px; line-height: 1.55;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.03);
}
.guide-example .guide-example__head { margin: 0 0 4px; font-weight: 700; color: var(--brand-2); font-size: 13px; }
.guide-example p { margin: 0; }
.guide-bye { text-align: center; color: var(--brand-2); font-weight: 700; margin: 6px 0 2px; }

/* 弹窗 */
.modal { position: fixed; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center; background: var(--backdrop); padding: 24px; backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px); }
.modal__card {
  width: min(92vw, 380px); background: var(--surface-card); border-radius: 22px; padding: 26px 24px; text-align: center;
  display: flex; flex-direction: column; gap: 14px; align-items: center;
  border: 1px solid var(--line); box-shadow: 0 20px 60px rgba(0, 0, 0, .3), 0 0 40px var(--glow-p);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  animation: pop-in .3s cubic-bezier(.2, 1.4, .4, 1);
}
@keyframes pop-in { from { transform: translateY(22px) scale(.9); opacity: 0; } to { transform: none; opacity: 1; } }
.modal__label { color: var(--fg-dim); font-size: 14px; letter-spacing: .1em; }
.modal__result {
  font-size: clamp(28px, 9vw, 46px); font-weight: 800; line-height: 1.2; word-break: break-all;
  background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 0 14px var(--glow-p));
}
.modal__text { font-size: 16px; }
.modal__actions { display: flex; gap: 10px; width: 100%; }
.modal__actions .btn { flex: 1; }

/* 撒花画布 */
#fx { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 60; }

#wheel.is-shifting { opacity: .35; transition: opacity .12s linear; }
[hidden] { display: none !important; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  body::before, body::after { animation: none !important; }
}