:root {
  color-scheme: light;
  --paper: #f3f2ec;
  --surface: #e9e8e0;
  --ink: #202923;
  --muted: #596359;
  --line: #b4b9ad;
  --accent: #a23c1c;
  --accent-hover: #8d3e27;
  --tint: #eddfcf;
  --danger: #993d32;
  --disabled: #e4e5da;
  --disabled-ink: #686f63;
  --chrome: #202923;
  --chrome-ink: #f3f2ec;
  --switch: #333a30;
  --switch-line: #687360;
  --primary-ink: #fff;
  --log: #272c25;
  --log-ink: #f1f0e5;
  --wheel-one: #d9ded0;
  --wheel-two: #eddfcf;
  --wheel-three: #c8d1c4;
  --wheel-four: #e8e3d4;
  --sans: "Segoe UI", "Microsoft YaHei UI", "PingFang SC", system-ui, sans-serif;
  --mono: Consolas, "IBM Plex Mono", ui-monospace, monospace;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --paper: #171e1b;
  --surface: #232d27;
  --ink: #eceee4;
  --muted: #aeb9aa;
  --line: #647362;
  --accent: #f5a17c;
  --accent-hover: #f4b894;
  --tint: #343e32;
  --danger: #e89f94;
  --disabled: #29332b;
  --disabled-ink: #859280;
  --chrome: #101713;
  --chrome-ink: #e3ebdd;
  --switch: #29382c;
  --switch-line: #6b826b;
  --primary-ink: #171e1b;
  --log: #101713;
  --log-ink: #e3ebdd;
  --wheel-one: #304238;
  --wheel-two: #48372c;
  --wheel-three: #39483c;
  --wheel-four: #3d4133;
}

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

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 1rem/1.5 var(--sans);
  transition: background-color 180ms ease, color 180ms ease;
}

.masthead {
  background: var(--chrome);
  color: var(--chrome-ink);
  border-bottom: 2px solid var(--accent);
}

.masthead-inner {
  max-width: 1240px;
  margin-inline: auto;
  padding: 15px clamp(20px, 4vw, 48px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand {
  display: flex;
  gap: 11px;
  align-items: center;
  font-family: var(--mono);
  font-weight: 700;
}

.brand-mark {
  width: 21px;
  height: 21px;
  border: 1px solid currentColor;
  border-radius: 50%;
  display: grid;
  place-items: center;
  transform: rotate(-35deg);
}

.brand-mark::before {
  content: "";
  width: 25px;
  height: 7px;
  border: 1px solid #f5a17c;
  border-radius: 50%;
}

.workspace {
  display: grid;
  grid-template-columns: 166px minmax(0, 1fr);
  max-width: 1240px;
  margin-inline: auto;
  padding-inline: clamp(20px, 4vw, 48px);
}

.sidebar {
  border-right: 1px solid var(--line);
  padding: 42px 20px 20px 0;
}

nav { display: grid; gap: 6px; }
main { padding: 38px 0 48px clamp(22px, 4vw, 48px); min-width: 0; }

h1 {
  font-size: clamp(1.75rem, 4vw, 2.5rem);
  line-height: 1.2;
  font-weight: 700;
  margin: 0 0 24px;
}

h2 { font-size: 1.25rem; margin: 0 0 14px; }
p { margin: 0; }

button, select, input, textarea, .button {
  font: inherit;
  color: inherit;
  border: 1px solid var(--line);
  background: var(--paper);
  border-radius: 2px;
}

button, .button {
  padding: 8px 16px;
  min-height: 42px;
  text-decoration: none;
  cursor: pointer;
  transition: color 140ms ease, background-color 140ms ease, border-color 140ms ease;
}

button:hover, .button:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--tint);
}

:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

.theme {
  min-height: 36px;
  padding: 5px 12px;
  font-size: .875rem;
  color: var(--chrome-ink);
  border-color: var(--switch-line);
  background: var(--switch);
}

.theme:hover { color: var(--chrome-ink); background: var(--switch); border-color: #f5a17c; }
.theme:focus-visible { outline-color: #f5a17c; }

nav button {
  background: transparent;
  border: 0;
  border-left: 2px solid transparent;
  border-radius: 0;
  padding-inline: 12px;
  text-align: left;
  white-space: nowrap;
}

nav button[aria-current] {
  background: var(--tint);
  border-color: var(--accent);
  color: var(--accent);
  font-weight: 700;
}

.primary { background: var(--accent); color: var(--primary-ink); border-color: var(--accent); font-weight: 700; }
.primary:hover { background: var(--accent-hover); color: var(--primary-ink); }
button:disabled, button:disabled:hover { background: var(--disabled); color: var(--disabled-ink); border-color: var(--line); cursor: default; }
.danger { color: var(--danger); }

.draw-panel, .panel {
  background: var(--surface);
  border: 1px solid var(--line);
  padding: clamp(20px, 3vw, 32px);
}

.draw-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.35fr);
  align-items: center;
  gap: clamp(20px, 4vw, 52px);
}

.controls .field { margin-top: 0; }
.controls .hint { margin: 10px 0 24px; }
.controls .primary { width: 100%; min-height: 48px; }
.hint { color: var(--muted); overflow-wrap: anywhere; }

.field { display: grid; gap: 7px; margin-block: 16px 12px; }
.field > span { font-weight: 600; }
input:not([type="checkbox"]), select, textarea { display: block; width: 100%; min-width: 0; padding: 9px 11px; }
select { cursor: pointer; }
textarea { resize: vertical; }
input[type="checkbox"] { accent-color: var(--accent); width: 1.125rem; height: 1.125rem; margin: 0; }

.wheel-stage { display: grid; place-items: center; padding: 12px 0; }

.frame {
  position: relative;
  width: min(100%, 366px);
  padding: 9px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--paper);
}

.frame canvas {
  width: 100%;
  display: block;
  border: 1px solid var(--line);
  border-radius: 50%;
  transition: transform 1.6s cubic-bezier(.2,.7,.1,1);
}

.pointer {
  position: absolute;
  z-index: 2;
  top: -5px;
  left: 50%;
  width: 16px;
  height: 25px;
  transform: translateX(-50%);
  background: var(--accent);
  clip-path: polygon(0 0, 100% 0, 100% 42%, 50% 100%, 0 42%);
}

.hub {
  position: absolute;
  inset: 43%;
  border: 1px solid var(--line);
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--paper);
}
.hub::after { content: ""; width: 24%; aspect-ratio: 1; background: var(--accent); border-radius: 50%; }

.result, #msg {
  background: var(--log);
  color: var(--log-ink);
  border-left: 2px solid var(--accent);
  padding: 10px 12px;
  margin-top: 14px;
  overflow-wrap: anywhere;
}

.result:empty, #msg:empty { display: none; }
#msg { position: sticky; bottom: 12px; z-index: 3; }

.prize-section { margin-top: 28px; }
.prize-list { border-top: 1px solid var(--line); }
.prize-list article {
  border-bottom: 1px solid var(--line);
  padding: 10px 0;
  overflow-wrap: anywhere;
}

.records { background: var(--log); color: var(--log-ink); }
.records article { padding: 11px 15px; border-bottom: 1px solid var(--line); overflow-wrap: anywhere; }
.panel + .panel { margin-block: 20px; }
.panel { max-width: 660px; }
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.check { display: flex; align-items: center; gap: 8px; margin-block: 14px; }
.guest-setting { margin: 0 0 16px; min-height: 32px; }
.option-editor { min-width: 0; padding: 0; margin: 20px 0; border: 0; }
.option-editor legend { padding: 0; font-weight: 600; }
.option-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(68px, 100px) auto; align-items: end; gap: 8px; }
.option-row .field { margin: 8px 0; font-size: .875rem; }
.option-row button { margin-bottom: 8px; padding-inline: 10px; font-size: .875rem; }
#addOption { margin-top: 4px; }
.registration-table { width: 100%; border-collapse: collapse; table-layout: fixed; margin-top: 12px; }
.registration-table th, .registration-table td { border-bottom: 1px solid var(--line); padding: 8px; text-align: left; overflow-wrap: anywhere; }
#registrationEmpty { margin-top: 12px; }

@media (max-width: 760px) {
  .workspace { display: block; }
  .sidebar { padding: 12px 0 0; border-right: 0; border-bottom: 1px solid var(--line); }
  nav { display: flex; gap: 0 4px; flex-wrap: wrap; }
  nav button { border-left: 0; border-bottom: 2px solid transparent; font-size: .875rem; padding-inline: 8px; }
  main { padding: 24px 0 36px; }
}

@media (max-width: 560px) {
  .draw-panel { grid-template-columns: 1fr; gap: 16px; }
  .wheel-stage { grid-row: 1; }
  .frame { width: min(100%, 264px); }
  .controls .hint { margin-bottom: 16px; }
}

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