@font-face {
  font-family: "Obcoro Pixel";
  src: url("/assets/fusion-pixel-12px-monospaced-zh_tw.ttf.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
}

:root {
  color-scheme: dark;
  --bg: #030909;
  --panel: #040b09f7;
  --ink: #70f995;
  --bright: #9affb1;
  --muted: #599d72;
  --line: #2a6940;
  --hairline: #203e2b;
  --accent: #fa785c;
  --accent-line: #d45b43;
}

*, *::before, *::after { box-sizing: border-box; border-radius: 0; }
[hidden] { display: none !important; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 16px/1.5 "Obcoro Pixel", monospace;
  font-synthesis: none;
}
input, textarea, button { margin: 0; font: inherit; }
h1, h2, h3, p { margin: 0; }
h1, h2, h3 { font-weight: 400; line-height: 1.25; color: var(--bright); }
:focus-visible { outline: 2px solid var(--bright); outline-offset: 3px; }

.page {
  width: min(100%, 61rem);
  margin-inline: auto;
  padding: max(clamp(36px, 8vh, 80px), env(safe-area-inset-top))
           max(24px, env(safe-area-inset-right))
           max(24px, env(safe-area-inset-bottom))
           max(24px, env(safe-area-inset-left));
}
.page-head, h1, .options, .options label, .field-head, .draw-controls, footer {
  display: flex;
  align-items: center;
}
.page-head { justify-content: space-between; gap: 20px; margin-bottom: 22px; }
h1 { gap: 12px; font-size: clamp(32px, 4vw, 44px); line-height: 1.18; }
.ticket { width: 1em; height: 1em; color: var(--ink); flex: none; }
.options { min-width: 0; }
.options label {
  position: relative;
  flex: 1 1 0;
  min-height: 46px;
  min-width: 44px;
  justify-content: center;
  gap: 9px;
  padding: 8px 15px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: #82b490;
  cursor: var(--ob-cursor-pointer, pointer);
  white-space: nowrap;
  transition: background-color 140ms, color 140ms;
}
.options label + label { margin-left: -1px; }
.options input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: var(--ob-cursor-pointer, pointer); }
.options label span { display: inline-flex; align-items: center; gap: 8px; }
.options label span::before {
  content: "";
  width: 12px;
  height: 12px;
  flex: none;
  border: 1px solid var(--muted);
  background: var(--bg);
}
.options label:has(:checked) { z-index: 1; color: var(--bright); background: #11291b; border-color: var(--ink); }
.options input:checked + span::before { background: var(--ink); border-color: var(--ink); box-shadow: inset 0 0 0 2px #11291b; }
.options label:has(:focus-visible) { z-index: 2; outline: 2px solid var(--bright); outline-offset: 3px; }
.options input:focus-visible { outline: none; }

.panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  border: 1px solid var(--line);
  background: var(--panel);
}
.is-wheel .panel {
  grid-template-columns: minmax(0, 0.9fr) minmax(0, 1fr) auto;
  grid-template-areas: "roster stage stage" "roster result controls";
}
.roster { display: flex; flex-direction: column; min-width: 0; padding: 24px; }
.is-wheel .roster { grid-area: roster; border-right: 1px solid var(--line); }
.field-head { flex-wrap: wrap; justify-content: space-between; gap: 4px 8px; margin-bottom: 12px; }
.field-head label { color: var(--bright); font-size: 20px; }
.field-head label span, #entry-count, #wheel-note { color: var(--muted); font-size: 14px; }
#entry-count { white-space: nowrap; }
textarea, #amount {
  width: 100%;
  min-width: 0;
  min-height: 44px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  background: #080f0c;
  color: var(--bright);
  font-size: 16px;
}
textarea { resize: vertical; line-height: 24px; }
textarea::placeholder { color: var(--muted); opacity: 1; }
.is-wheel textarea {
  flex: 1;
  min-height: 160px;
  background-image: repeating-linear-gradient(to bottom, transparent 0 23px, #14271c 23px 24px);
  background-origin: content-box;
  background-clip: padding-box;
  background-attachment: local;
}
#wheel-note { margin-top: 12px; }
.draw-controls { flex-wrap: wrap; justify-content: flex-end; gap: 10px 20px; padding: 16px 24px; border-top: 1px solid var(--hairline); }
.amount-field { display: flex; align-items: center; gap: 12px; }
#amount { width: 6rem; }
.primary {
  position: relative;
  isolation: isolate;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-width: 142px;
  min-height: 48px;
  padding: 8px 18px;
  border: 0;
  color: var(--accent);
  background: transparent;
  font-size: 18px;
  cursor: var(--ob-cursor-pointer, pointer);
}
.primary::before, .primary::after {
  position: absolute;
  z-index: -1;
  inset: 0;
  content: "";
  clip-path: polygon(7px 0,100% 0,100% calc(100% - 7px),calc(100% - 7px) 100%,0 100%,0 7px);
  background: var(--accent-line);
  transition: background-color 140ms;
}
.primary::after { inset: 1px; background: #26130e; }
.primary svg { width: 20px; height: 20px; flex: none; }
.spin-icon, .is-wheel .draw-icon { display: none; }
.is-wheel .spin-icon { display: initial; }
.is-wheel .draw-controls { grid-area: controls; padding-left: 0; }
.primary:disabled { cursor: wait; opacity: .65; }

#wheel-stage {
  grid-area: stage;
  position: relative;
  display: grid;
  place-items: center;
  min-width: 0;
  padding: 22px 12px;
  background-color: #08130d;
  background-image: radial-gradient(#203927 .75px, transparent .95px);
  background-position: center;
  background-size: 16px 16px;
}
.dial { position: relative; width: min(100%, 364px); aspect-ratio: 1; }
.dial > * { position: absolute; display: block; inset: 0; width: 100%; height: 100%; }
.dial #wheel { inset: 9%; width: 82%; height: 82%; }
.dial-fittings { pointer-events: none; }
#wheel-stage::before, #wheel-stage::after {
  content: "";
  position: absolute;
  top: 50%;
  width: clamp(8px, 4%, 28px);
  height: 1px;
  background: var(--line);
}
#wheel-stage::before { left: 14px; }
#wheel-stage::after { right: 14px; }
#result { min-width: 0; overflow-wrap: anywhere; }
#result:not(:empty) { border-top: 1px solid var(--hairline); padding: 20px 24px; }
#result > p { color: var(--accent); }
#result h2 { margin-bottom: 10px; font-size: 24px; }
#result h3 { font-size: 18px; }
#result section + section { margin-top: 16px; }
#result ul { margin: 6px 0 0; padding-inline-start: 24px; list-style-type: square; }
.is-wheel #result { grid-area: result; display: grid; align-content: center; justify-items: start; min-height: 79px; border-top: 1px solid var(--hairline); padding: 12px 18px; }
.is-wheel #result h2 { font-size: 14px; margin: 0 0 2px; color: #83b792; }
.is-wheel #result:has(.winner) { grid-template-columns: 2px minmax(0, 1fr); column-gap: 10px; }
.is-wheel #result:has(.winner)::before { content: ""; grid-row: span 2; align-self: stretch; width: 2px; background: var(--ink); }
.is-wheel #result .wheel-hint { color: var(--muted); }
.is-wheel #result .winner { font-size: 26px; line-height: 1.2; color: var(--bright); }

footer { justify-content: space-between; gap: 2px 12px; flex-wrap: wrap; margin-top: 12px; color: var(--muted); font-size: 14px; }
@media (hover: hover) {
  .options label:hover { background-color: #173321; color: var(--bright); }
  .primary:enabled:hover::before { background: var(--accent); }
  .primary:enabled:hover::after { background: #402019; }
}
.options label:active { background: #1a3a27; }
.primary:enabled:active::after { background: #51271d; }
@media (max-width: 45rem) {
  .page { padding: max(20px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left)); }
  .page-head { align-items: stretch; flex-direction: column; gap: 14px; margin-bottom: 14px; }
  .options label { padding: 8px 4px; gap: 7px; }
  .is-wheel .panel { grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "roster roster" "stage stage" "result controls"; }
  .roster { padding: 16px; }
  .is-wheel .roster { border-right: 0; border-bottom: 1px solid var(--line); }
  .is-wheel textarea { min-height: 66px; flex: auto; height: calc(18px + var(--visible-lines, 2) * 24px); }
  .field-head { margin-bottom: 7px; }
  #wheel-note { margin-top: 6px; }
  #wheel-stage { padding: 8px; }
  .dial { width: min(100%, clamp(244px, 36svh, 308px)); }
  .draw-controls { padding: 12px 16px; justify-content: space-between; }
  .is-wheel #result { min-height: 76px; padding-inline: 16px 8px; }
  #result:not(:empty) { padding: 14px 16px; }
  footer { margin-top: 6px; }
}
@media (max-width: 22rem) {
  .options label { font-size: 14px; }
  .options label span { gap: 4px; }
  .primary { min-width: 120px; padding-inline: 10px; }
}
@media (forced-colors: active) {
  .options input:checked + span::before { border: 4px solid Highlight; }
  .primary { border: 1px solid ButtonText; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; }
}

.footer-actions {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}