:root {
  --bg: #14161c;
  --bg-2: #1d2029;
  --bg-3: #272b36;
  --fg: #f2f4f8;
  --fg-dim: #9aa3b2;
  --brand: #ffcc48;
  --danger: #e5484d;
  --radius: 14px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  background: radial-gradient(120% 80% at 50% 0%, #232838 0%, var(--bg) 60%);
  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;
}
.topbar { display: flex; align-items: center; gap: 8px; padding: 10px 12px; padding-top: max(10px, env(safe-area-inset-top, 0px)); }
.topbar__preset { flex: 0 1 auto; max-width: 45%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  background: var(--bg-2); color: var(--fg); border: 0; border-radius: 999px; padding: 8px 14px; font-size: 15px; font-weight: 600; }
.topbar__remain { margin-left: auto; color: var(--fg-dim); font-size: 14px; font-variant-numeric: tabular-nums; }
.iconbtn { background: var(--bg-2); color: var(--fg); border: 0; border-radius: 999px; width: 40px; height: 40px; font-size: 18px; }
.stage { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px; padding: 8px 16px calc(16px + var(--safe-b)); min-height: 0; }
#wheel { width: min(88vw, 46vh, 420px); height: min(88vw, 46vh, 420px); display: block; }
.spinbtn { width: min(80vw, 360px); padding: 18px; font-size: 20px; font-weight: 700; letter-spacing: .05em;
  color: #26170a; background: linear-gradient(180deg, #ffd970, var(--brand)); border: 0; border-radius: 999px;
  box-shadow: 0 8px 24px rgba(255, 204, 72, .25); }
.spinbtn:active { transform: translateY(1px) scale(.995); }
.spinbtn[disabled] { filter: grayscale(.7) brightness(.7); box-shadow: none; }
.btn { padding: 10px 14px; font-size: 15px; border: 0; border-radius: var(--radius); background: var(--bg-3); color: var(--fg); }
.btn--primary { background: var(--brand); color: #26170a; font-weight: 600; }
.btn--ghost { background: transparent; border: 1px solid var(--bg-3); }
.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; }
.banner { padding: 10px 12px; font-size: 14px; display: flex; align-items: center; gap: 8px; }
.banner--warn { background: #4a2b12; color: #ffd9b0; }
.banner--hint { background: var(--bg-2); color: var(--fg-dim); }
.banner__close { margin-left: auto; background: transparent; border: 0; color: inherit; font-size: 15px; }
.toast { position: fixed; left: 50%; bottom: calc(28px + var(--safe-b)); transform: translateX(-50%);
  background: rgba(0,0,0,.82); color: #fff; padding: 10px 16px; border-radius: 999px; font-size: 14px; z-index: 40;
  display: flex; align-items: center; gap: 10px; }
.toast button { background: transparent; border: 0; color: var(--brand); font-size: 14px; font-weight: 600; }
.backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 20; }
.drawer { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; max-height: 88dvh; display: flex; flex-direction: column;
  background: var(--bg-2); border-radius: 18px 18px 0 0; box-shadow: 0 -12px 40px rgba(0,0,0,.5);
  padding-bottom: var(--safe-b); animation: drawer-in .22s ease-out; }
@keyframes drawer-in { from { transform: translateY(24px); opacity: .6; } to { transform: none; opacity: 1; } }
.drawer__head { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; font-weight: 600; border-bottom: 1px solid var(--bg-3); }
.drawer__body { overflow-y: auto; padding: 12px 16px 20px; display: flex; flex-direction: column; gap: 16px; }
.panel { background: var(--bg); border-radius: var(--radius); padding: 12px; }
.panel__title { margin: 0 0 8px; font-size: 14px; color: var(--fg-dim); font-weight: 600; }
.tier-row { display: grid; grid-template-columns: 34px 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); color: var(--fg); border: 0; border-radius: 8px; padding: 9px; font-size: 15px; }
.tier-row input[type="color"] { width: 34px; height: 34px; padding: 0; border: 0; background: transparent; }
.tier-row__del { background: transparent; border: 0; color: var(--danger); font-size: 18px; }
.preset-row { display: flex; align-items: center; gap: 8px; padding: 8px 0; }
.preset-row button { flex: 1; text-align: left; }
.preset-row.is-active button { border-color: var(--brand); color: var(--brand); }
.history-row { display: grid; grid-template-columns: 36px 1fr auto; gap: 8px; padding: 7px 0; border-bottom: 1px solid var(--bg-3); 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); color: var(--fg); border: 0; border-radius: 8px; padding: 9px; font: 12px/1.5 ui-monospace, Consolas, monospace; }
.modal { position: fixed; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center; background: rgba(0,0,0,.6); padding: 24px; }
.modal__card { width: min(92vw, 380px); background: var(--bg-2); border-radius: 20px; padding: 24px; text-align: center; display: flex; flex-direction: column; gap: 14px; align-items: center; }
.modal__label { color: var(--fg-dim); font-size: 14px; }
.modal__result { font-size: clamp(28px, 9vw, 44px); font-weight: 800; color: var(--brand); line-height: 1.2; word-break: break-all; }
.modal__text { font-size: 16px; }
.modal__actions { display: flex; gap: 10px; width: 100%; }
.modal__actions .btn { flex: 1; }
#wheel.is-shifting { opacity: .35; transition: opacity .12s linear; }
[hidden] { display: none !important; }
