:root {
  color-scheme: dark;
  --page: #111014;
  --panel: #1c191f;
  --raised: #27232a;
  --field: #151317;
  --line: #39323b;
  --line-strong: #584b56;
  --text: #f7ede7;
  --muted: #c1b5be;
  --accent: #f0aa8b;
  --accent-ink: #2b1713;
  --jade: #9ad8b0;
  --lavender: #cdb7e8;
  --amber: #eac58b;
  --blue: #a5d5e2;
  --danger: #ffaea6;
  --backdrop: #0b090ec7;
  font-family: Inter, "Noto Sans CJK SC", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  min-width: 300px;
  min-height: 100vh;
  isolation: isolate;
  background: var(--page);
  color: var(--text);
}

body::before,
body::after {
  content: "";
  position: fixed;
  z-index: -1;
  pointer-events: none;
}

body::before {
  inset: -17% -13%;
  background:
    radial-gradient(ellipse at 18% 25%, #7a413849, transparent 39%),
    radial-gradient(ellipse at 83% 17%, #60456e56, transparent 43%);
  animation: background-light 26s ease-in-out infinite alternate;
}

body::after {
  inset: -6%;
  background:
    radial-gradient(circle at 12% 18%, #ffd1a9ad 0 1px, transparent 2px),
    radial-gradient(circle at 29% 34%, #ffd1a977 0 1px, transparent 2px),
    radial-gradient(circle at 39% 10%, #e6c4f79c 0 1px, transparent 2px),
    radial-gradient(circle at 62% 27%, #e6c4f788 0 1px, transparent 2px),
    radial-gradient(circle at 80% 12%, #ffd1a978 0 1px, transparent 2px),
    radial-gradient(circle at 92% 41%, #e6c4f78b 0 1px, transparent 2px),
    radial-gradient(circle at 8% 64%, #ffd1a977 0 1px, transparent 2px),
    radial-gradient(circle at 88% 70%, #ffd1a968 0 1px, transparent 2px);
  opacity: .47;
  animation: background-points 20s ease-in-out infinite alternate;
}

@keyframes background-light {
  from { transform: translate3d(-2%, -1%, 0); }
  to { transform: translate3d(5%, 4%, 0); }
}

@keyframes background-points {
  from { transform: translate3d(0, 0, 0); }
  to { transform: translate3d(12px, -23px, 0); opacity: .78; }
}

body:has(dialog[open]) { overflow: hidden; }

a { color: inherit; text-decoration: none; }
a:hover { color: var(--accent); }
button, input { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: .56; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }

.topbar { border-bottom: 1px solid #cbb2c41b; background: #151318eb; }
.topbar-inner, .page { width: min(1176px, calc(100% - 64px)); margin: 0 auto; }
.topbar-inner {
  min-height: 68px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: 20px;
}
.topbar-inner .brand { grid-column: 2; justify-self: center; }
.topbar-inner nav { grid-column: 3; justify-self: end; }
.brand { display: inline-flex; align-items: center; gap: 10px; font-size: 16px; font-weight: 780; white-space: nowrap; }
.brand-icon {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border: 1px solid #5a413d;
  border-radius: 8px;
  background: #302223;
}
.brand-icon img { width: 24px; height: 24px; image-rendering: pixelated; }
nav { display: flex; align-items: center; gap: 24px; color: var(--muted); font-size: 13px; white-space: nowrap; }
.nav-action { display: inline-flex; align-items: center; min-height: 36px; color: var(--text); border: 1px solid var(--line); border-radius: 8px; padding: 8px 13px; background: transparent; }
.nav-action:hover { color: var(--accent); }

.page { padding: 28px 0 24px; }
.raffle-page { max-width: 700px; }
.intro { display: flex; align-items: end; justify-content: space-between; gap: 16px; margin-bottom: 24px; }
.intro h1 { margin: 0; font-family: "Noto Serif CJK SC", "Songti SC", SimSun, serif; font-size: clamp(35px, 4.5vw, 56px); font-weight: 900; letter-spacing: -.06em; line-height: 1.18; }
.intro p { margin: 10px 0 0; font-size: 14px; color: var(--muted); }
.draw-rule {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 2px;
  padding: 7px 11px;
  border: 1px solid #345343;
  border-radius: 6px;
  color: var(--jade);
  background: #213129;
  font-size: 12px;
  white-space: nowrap;
}
.draw-rule i { width: 6px; height: 6px; background: var(--jade); border-radius: 50%; }

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; box-shadow: 0 14px 38px #0a070b51; }
.play-panel { overflow: hidden; }
.stage {
  position: relative;
  min-height: 430px;
  padding: 25px 20px 30px;
  display: grid;
  place-items: center;
  isolation: isolate;
  overflow: hidden;
  background: #18151e;
}
.stage::before {
  content: "";
  position: absolute;
  z-index: -2;
  inset: 0;
  background: linear-gradient(#c8afd210 1px, transparent 1px),
    linear-gradient(90deg, #c8afd210 1px, transparent 1px);
  background-size: 29px 29px;
}
.stage::after {
  content: "";
  position: absolute;
  z-index: -1;
  inset: 0;
  background: radial-gradient(ellipse at 50% 46%, #8065924f, transparent 71%);
}
.wheel-frame { position: relative; width: min(100%, 440px); aspect-ratio: 1; }
.wheel {
  display: block;
  width: 100%;
  height: 100%;
  filter: drop-shadow(0 18px 20px #0b07159c);
  transition: transform 4s cubic-bezier(.11,.72,.11,1);
  user-select: none;
  -webkit-user-drag: none;
}
.wheel-hub {
  position: absolute;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  width: 24%;
  height: 24%;
  inset: 38%;
  pointer-events: none;
  color: #432d24;
}
.wheel-hub.has-prize {
  border-radius: 50%;
  box-shadow: 0 0 22px #eac58b67;
  animation: wheel-prize-light 800ms ease-out;
}
@keyframes wheel-prize-light {
  from { box-shadow: 0 0 9px #eac58b30; }
  35% { box-shadow: 0 0 40px #f8d69aaf; }
  to { box-shadow: 0 0 22px #eac58b67; }
}
.wheel-prize-icon { width: 49%; height: 49%; object-fit: contain; image-rendering: pixelated; }
.wheel-prize-name {
  max-width: 90%;
  font-size: clamp(.55rem, 2.65vw, .875rem);
  font-weight: 750;
  line-height: 1.15;
  overflow-wrap: anywhere;
  text-align: center;
}
.pointer {
  position: absolute;
  z-index: 1;
  width: 34px;
  height: 43px;
  top: -11px;
  left: 50%;
  transform: translateX(-50%);
  filter: drop-shadow(0 3px 5px #0c080ccc);
}
.pointer::before, .pointer::after {
  content: "";
  position: absolute;
  inset: 0;
  clip-path: polygon(50% 0, 96% 27%, 50% 100%, 4% 27%);
}
.pointer::before { background: #8b4938; }
.pointer::after { inset: 2px; background: linear-gradient(115deg, #d19376, #c17b5f 49%, #a6513d 51%, #ac5c45); }
.controls { padding: 17px 21px 21px; border-top: 1px solid var(--line); }
label { display: block; color: var(--text); font-size: 13px; font-weight: 700; margin-bottom: 7px; }
.control-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; }
input {
  min-width: 0;
  width: 100%;
  min-height: 46px;
  padding: 0 12px;
  color: var(--text);
  background: var(--field);
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  font-size: 14px;
}
input::placeholder { color: #aaa0a9; }
.primary, .secondary {
  min-height: 40px;
  border-radius: 8px;
  padding: 0 14px;
  font-size: 13px;
  font-weight: 750;
  white-space: nowrap;
}
.primary {
  min-height: 46px;
  border: 1px solid #ffd4bc54;
  color: var(--accent-ink);
  background: var(--accent);
  box-shadow: 0 3px 0 #703f33;
}
.primary span { margin-right: 4px; font-size: 17px; vertical-align: -1px; }
.primary:not(:disabled):hover { background: #ffc2a7; }
.secondary { background: var(--raised); color: var(--text); border: 1px solid var(--line); }
.secondary:not(:disabled):hover { border-color: var(--line-strong); color: var(--accent); }
.status { margin: 10px 0 0; color: var(--muted); font-size: 13px; }
.status.error { color: var(--danger); }
.win {
  display: flex;
  align-items: center;
  gap: 13px;
  margin-top: 14px;
  padding: 12px;
  background: #202e28;
  border: 1px solid #365044;
  border-radius: 10px;
}
.win img { flex: 0 0 38px; width: 38px; height: 38px; }
.win-copy { display: grid; gap: 3px; min-width: 0; margin-right: auto; }
.win-copy > span { font-size: 11px; color: var(--jade); }
.win-copy strong { font-size: 17px; overflow-wrap: anywhere; }
.win-copy small { font-size: 11px; color: var(--muted); }
code { font: .95em ui-monospace, SFMono-Regular, Consolas, monospace; font-variant-numeric: tabular-nums; }

.pool-panel {
  width: min(570px, calc(100% - 24px));
  max-width: none;
  max-height: calc(100vh - 24px);
  max-height: calc(100dvh - 24px);
  padding: 0;
  color: var(--text);
}

.pool-panel[open] { display: flex; flex-direction: column; }
.pool-panel::backdrop { background: var(--backdrop); }
.pool-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
}

.pool-close { font-size: .875rem; }
.pool-scroll { min-height: 0; overflow-y: auto; padding: 13px 20px 16px; }
.pool-count { display: block; margin-top: 3px; color: var(--muted); font-size: .875rem; }
h2 { margin: 0; font-size: 20px; line-height: 1.25; letter-spacing: -.025em; }
.pool-columns, .prize-row { display: grid; grid-template-columns: minmax(0, 1fr) 3rem 4.25rem; gap: 8px; align-items: center; }
.pool-columns { padding-bottom: 7px; border-bottom: 1px solid var(--line); color: var(--muted); font-size: .875rem; }
.pool-columns span:not(:first-child), .prize-quantity, .prize-odds { text-align: right; }
.tier-heading {
  display: flex;
  gap: 9px;
  align-items: center;
  margin: 9px 0 3px;
  color: var(--jade);
  font-size: .875rem;
  font-weight: 740;
  letter-spacing: .06em;
}
.tier-heading::before { content: ""; width: 5px; height: 5px; background: currentColor; transform: rotate(45deg); }
.tier-heading::after { content: ""; height: 1px; margin-left: 3px; background: var(--line); flex: 1; }
.tier-rare { color: var(--lavender); }
.tier-jackpot { color: var(--amber); }
.tier-special { color: var(--blue); }
.prize-row { min-height: 34px; font-size: .9375rem; }
.prize-name { display: flex; gap: 9px; align-items: center; min-width: 0; overflow-wrap: anywhere; }
.prize-name img, .win img { image-rendering: pixelated; }
.prize-name img { flex: 0 0 23px; width: 23px; height: 23px; object-fit: contain; }
.prize-swatch { flex: 0 0 9px; height: 12px; border-radius: 3px; box-shadow: inset 0 0 0 1px #31241b20; }
.prize-quantity { color: var(--muted); }
.prize-odds { font-size: 14px; font-weight: 750; font-variant-numeric: tabular-nums; }
.footer { display: flex; justify-content: space-between; gap: 12px; margin-top: 19px; color: var(--muted); font-size: 12px; }
.footer a { color: var(--accent); }
.footer a:hover { text-decoration: underline; }

.admin-page:has(#login-panel:not([hidden])) {
  display: grid;
  align-content: center;
  justify-items: center;
  min-height: calc(100svh - 69px);
}
.admin-page:has(#login-panel:not([hidden])) .intro {
  justify-content: center;
  text-align: center;
}
.login-panel { width: min(100%, 420px); padding: 24px; }
.login-panel label { margin-top: 18px; }
.login-panel .primary { width: 100%; margin-top: 14px; }
.login-switch { width: 100%; margin-top: 12px; }
.password-field { position: relative; }
.password-field input { padding-inline-end: 48px; }
.password-toggle {
  position: absolute;
  inset: 4px 4px 4px auto;
  display: grid;
  place-items: center;
  width: 40px;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
}
.password-toggle:hover { color: var(--accent); background: var(--raised); }
.password-eye {
  position: relative;
  width: 15px;
  height: 15px;
  border: 1.5px solid currentColor;
  border-radius: 70% 0;
  transform: rotate(45deg);
}
.password-eye::after {
  content: "";
  position: absolute;
  inset: 3px;
  border-radius: 50%;
  background: currentColor;
}
.password-toggle[aria-pressed="true"] .password-eye::before {
  content: "";
  position: absolute;
  top: -4px;
  left: 5px;
  width: 1.5px;
  height: 20px;
  background: currentColor;
  box-shadow: 2px 0 var(--field);
  z-index: 1;
}
.invite-toolbar, .invite-result { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.records-toolbar.invite-toolbar { justify-content: flex-start; }
.invite-result { min-width: 0; }
.invite-result code { overflow-wrap: anywhere; }
#admin-status { margin: 0 0 14px; }
.records-panel { overflow: hidden; }
.records-toolbar, .records-footer { padding: 15px; display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.records-toolbar input { min-height: 40px; }
.records-toolbar form { display: flex; gap: 8px; flex: 0 1 360px; }
.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; white-space: nowrap; }
th, td { text-align: left; padding: 13px 15px; border-top: 1px solid var(--line); font-size: 13px; }
th { background: var(--raised); color: var(--muted); font-size: 12px; font-weight: 680; }
td > small { display: block; margin-top: 4px; color: var(--muted); font-size: 11px; }
td:first-child { white-space: normal; min-width: 116px; overflow-wrap: anywhere; }
.order-lines { min-width: 10rem; margin: 0; padding-left: 18px; white-space: normal; overflow-wrap: anywhere; }
.empty { padding: 36px 12px; color: var(--muted); text-align: center; }
.records-footer { border-top: 1px solid var(--line); color: var(--muted); font-size: 13px; }
.pagination { display: flex; align-items: center; gap: 9px; font-variant-numeric: tabular-nums; }
.pagination button { min-height: 34px; }

@media (min-width: 851px) and (max-height: 800px) {
  .page { padding-top: 22px; }
  .intro { margin-bottom: 18px; }
  .stage { min-height: 0; }
  .wheel-frame { width: min(100%, clamp(300px, calc(100vh - 380px), 440px)); }
}

@media (max-width: 850px) {
  .topbar-inner, .page { width: calc(100% - 32px); }
  .stage { min-height: 0; }
  .wheel-frame { width: min(100%, 425px); }
}

@media (max-width: 680px) {
  .topbar-inner, .page { width: calc(100% - 24px); }
  .panel { border-radius: 11px; }
  .stage { padding: 22px 6px 24px; }
  .controls { padding: 10px; }
  .control-row { grid-template-columns: minmax(0, 1fr); gap: 7px; }
  .control-row input, .control-row .primary { min-height: 41px; }
  .win { flex-wrap: wrap; }
  .win-copy { min-width: 65%; }
  .win-copy strong { font-size: 13px; }
}

@media (max-width: 600px) {
  .topbar-inner { grid-template-columns: 1fr; gap: 7px; padding-block: 8px; }
  .topbar-inner .brand, .topbar-inner nav { grid-column: 1; justify-self: center; }
  .admin-page:has(#login-panel:not([hidden])) { min-height: calc(100svh - 94px); }
}

@media (max-width: 480px) {
  .brand { font-size: 14px; gap: 7px; }
  .brand-icon { width: 29px; height: 29px; }
  nav { gap: 10px; font-size: 12px; }
  .nav-action { padding: 6px 8px; }
  .pool-heading, .pool-scroll { padding-inline: 14px; }
  .pool-columns, .prize-row { grid-template-columns: minmax(0, 1fr) 2.5rem 3.75rem; gap: 6px; }
  .prize-row { font-size: .875rem; }
  .prize-name { gap: 5px; }
  .prize-name img { flex-basis: 19px; width: 19px; height: 19px; }
  .page { padding-top: 22px; }
  .intro { flex-wrap: wrap; align-items: start; gap: 10px; margin-bottom: 15px; }
  .intro h1 { font-size: 38px; }
  .intro p { margin-top: 6px; font-size: 13px; }
  .draw-rule { font-size: 11px; }
  .pointer { width: 19px; height: 24px; top: -5px; }
  .wheel-hub { inset: 37%; width: 26%; height: 26%; }
  .records-toolbar, .records-footer { flex-wrap: wrap; }
  .records-toolbar form { flex: 1 1 100%; }
  .win { gap: 7px; padding: 8px; }
  .win img { flex-basis: 25px; width: 25px; height: 25px; }
  .win .secondary { padding: 0 7px; font-size: 11px; }
}

@media (prefers-reduced-motion: reduce) {
  body::before, body::after, .wheel-hub.has-prize { animation: none; }
  .wheel { transition-duration: .05s; }
}


.wheel { position: relative; }
.wheel-art { position: absolute; inset: 0; width: 100%; height: 100%; }

.entry-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto; align-items: end; gap: 10px; }
.admin-layout { display: grid; gap: 18px; }
.admin-section { overflow: hidden; }
.admin-section h2 { margin: 17px 15px 0; }
.issue-form { padding: 16px 15px 0; }
.issue-form textarea {
  display: block; width: min(100%, 540px); padding: 10px 12px; font: inherit;
  border: 1px solid var(--line-strong); border-radius: 8px; background: var(--field); color: var(--text);
  resize: vertical; min-height: 78px;
}
.issue-actions { display: flex; gap: 10px; align-items: end; margin-top: 9px; }
.issue-actions input { width: 120px; }
.credit-form { display: inline-flex; align-items: center; gap: 7px; }
.credit-form input { width: 66px; min-height: 34px; padding: 0 6px; }
.credit-form .secondary, td > .secondary { min-height: 34px; }
td > code + button { margin-left: 8px; }
.delivered { color: var(--jade); font-weight: 700; }
@media (max-width: 680px) {
  .entry-row { grid-template-columns: 1fr; gap: 8px; }
  .entry-row input, .entry-row button { min-height: 40px; }
  .issue-actions { flex-wrap: wrap; }
}
