:root {
  font-family: "Noto Sans TC", "Microsoft JhengHei", system-ui, sans-serif;
  color: #111827;
  background: #f6f8fc;
  --blue: #2563eb;
  --ink: #111827;
  --muted: #475569;
  --line: #dbe3ef;
}
* { box-sizing: border-box; }
body, h1, h2, h3, p { margin: 0; }
a { color: inherit; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid #d97706; outline-offset: 3px; }
.skip { position: fixed; top: -100px; left: 8px; z-index: 10; background: white; padding: 12px; }
.skip:focus { top: 8px; }
.wrap { max-width: 1250px; margin: auto; padding-inline: 24px; }
.top { background: #111827; color: #fff; border-bottom: 4px solid #3b82f6; }
.top-inner, .brand, nav, .actions, .panel-head { display: flex; align-items: center; gap: 12px; }
.top-inner { min-height: 76px; justify-content: space-between; padding-block: 10px; }
.brand { text-decoration: none; }
.brand strong, .brand small { display: block; }
.brand strong { font-size: 1.15rem; }
.brand small { color: #cbd5e1; font-size: .82rem; }
.mark { display: grid; place-items: center; flex: none; width: 44px; height: 44px; background: var(--blue); border-radius: 7px; font-size: 1.7rem; font-weight: 900; }
.lab { align-self: start; background: #fbbf24; color: #111827; border-radius: 4px; font-size: .75rem; padding: 4px 7px; }
nav { gap: 18px; font-size: .9rem; }
nav a { text-decoration: none; }
.hero { background: #eff6ff; border-bottom: 1px solid #bfd8fb; padding-block: 26px; }
h1 { font-size: clamp(1.8rem, 4.5vw, 2.65rem); letter-spacing: -.035em; margin-bottom: 7px; }
h2 { font-size: 1.18rem; }
h3 { font-size: 1rem; }
p { line-height: 1.65; }
.hero p { color: #334155; }
.main { padding-block: 20px 40px; }
.workspace { display: grid; grid-template-columns: minmax(330px, .8fr) minmax(0, 1.35fr); gap: 18px; align-items: start; }
.panel { border: 1px solid var(--line); border-radius: 10px; background: #fff; min-width: 0; overflow: hidden; }
.panel-head { justify-content: space-between; padding: 13px 16px; border-bottom: 1px solid var(--line); background: #f8fafc; flex-wrap: wrap; }
.panel-body { padding: 16px; }
.stage-link { display: none; color: #1e40af; font-size: .9rem; }
button, input, select, textarea { font: inherit; }
button, select, input:not([type=checkbox],[type=radio]), textarea {
  min-height: 42px; border: 1px solid #c4cfdf; border-radius: 6px; color: var(--ink); padding: 8px 10px;
  font-size: .94rem; background: #fff;
}
button { font-weight: 700; cursor: pointer; }
button:hover:not(:disabled) { background: #eff6ff; }
button:disabled { opacity: .5; cursor: not-allowed; }
.primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.primary:hover:not(:disabled) { background: #1d4ed8; }
fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
legend, label:not(.check) { font-weight: 700; font-size: .9rem; }
legend, .field label:not(.check), dialog label:not(.check) { display: block; margin-bottom: 6px; }
.field, .options { margin-top: 14px; }
.field input:not([type=checkbox]), .field textarea, .field select, dialog textarea, dialog input[type=file] { width: 100%; }
textarea { display: block; resize: vertical; line-height: 1.6; }
.actions { flex-wrap: wrap; }
.field .actions { margin-top: 9px; }
.row { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: end; gap: 8px; }
.mode { display: flex; flex-wrap: wrap; gap: 6px; }
.mode label { position: relative; cursor: pointer; }
.mode input { position: absolute; opacity: 0; }
.mode span { display: grid; min-height: 40px; align-items: center; padding: 6px 10px; border: 1px solid var(--line); border-radius: 6px; }
.mode input:checked + span { color: #1e40af; background: #eff6ff; border-color: #93b4ed; }
.mode input:focus-visible + span { outline: 3px solid #d97706; outline-offset: 2px; }
.mode input:disabled + span { opacity: .55; cursor: not-allowed; }
.check { display: flex; align-items: center; gap: 8px; min-height: 32px; font-size: .9rem; cursor: pointer; }
.check input { width: 17px; height: 17px; accent-color: var(--blue); flex: none; }
.hint { color: var(--muted); font-size: .875rem; margin-top: 5px; }
.privacy { border-top: 1px solid var(--line); padding-top: 10px; margin-top: 14px; }
#event-settings input + label { margin-top: 10px; }
.stage-head { border-bottom-color: #cbdcf4; background: #f2f7ff; }
.stage-body { background: linear-gradient(#f4f8ff, #fff 85%); padding: 18px; text-align: center; }
.stats { display: flex; justify-content: center; flex-wrap: wrap; gap: 6px 18px; color: #475569; font-size: .875rem; margin: 0 auto 14px; }
.stats strong { color: #172554; font-size: 1rem; margin-left: 3px; }
.wheel { width: min(100%, 410px); margin: 0 auto; aspect-ratio: 1; position: relative; border-radius: 50%; box-shadow: 0 10px 28px #1e3a8a27; }
canvas { display: block; width: 100%; height: 100%; }
.pointer { position: absolute; top: -4px; left: 50%; transform: translateX(-50%); width: 29px; height: 36px; background: #fbbf24; clip-path: polygon(0 0,100% 0,50% 100%); }
#wheel-wrap { margin: 20px auto 16px; }
#wheel-note { margin-top: 12px; }
.run { min-width: min(100%, 230px); min-height: 48px; font-size: 1.04rem; }
.stage-message { color: var(--muted); font-size: .925rem; margin-top: 9px; min-height: 1.6em; }
.stage-message.error, #import-error { color: #b91c1c; }
.stage-message:empty { display: none; }
.result { background: #eff6ff; border: 1px solid #bfdbfe; border-radius: 8px; margin: 10px auto 0; padding: 12px; max-width: 760px; overflow-wrap: anywhere; }
.result h3 { color: #1e40af; margin-bottom: 6px; }
.winner-list { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 5px 16px; justify-content: center; font-weight: 800; font-size: clamp(1.12rem, 3.1vw, 1.75rem); }
.winner-list li { max-width: 100%; }
.group-results { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(160px, 100%), 1fr)); gap: 10px; text-align: left; }
.group-card { background: #fff; border: 1px solid var(--line); border-radius: 6px; padding: 10px; }
.group-card ul { padding-inline-start: 1.25em; margin-block: 5px 0; }
.history, .guide { margin-top: 20px; }
.history-list { margin: 0; padding: 0; list-style: none; }
.history-list li + li { border-top: 1px solid var(--line); margin-top: 8px; padding-top: 8px; }
.history-list details { overflow-wrap: anywhere; }
.history-list summary { cursor: pointer; font-weight: 700; }
.history-list details p { margin-top: 5px; }
.guide-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px 24px; }
.guide p { font-size: .94rem; color: var(--muted); margin-top: 5px; }
.foot { border-bottom: 0; border-top: 4px solid #3b82f6; font-size: .875rem; }
dialog { border: 1px solid var(--line); border-radius: 10px; color: var(--ink); max-width: min(540px, calc(100% - 28px)); width: 100%; padding: 18px; }
dialog::backdrop { background: #111827aa; }
dialog label:not(.check), dialog button, #import-error { margin-top: 10px; }
body.projecting { overflow: hidden; }
.stage.projected { position: fixed; inset: 0; z-index: 5; border: 0; border-radius: 0; overflow: auto; width: 100%; height: 100%; background: #f4f8ff; }
.projected .stage-head { position: sticky; top: 0; z-index: 2; }
.projected .wheel { width: min(46dvh, 100%, 640px); }
.projected .winner-list { font-size: clamp(1.25rem, 4.5vw, 2.6rem); }
@media (max-width: 760px) {
  .workspace, .guide-grid { grid-template-columns: 1fr; }
  .wrap { padding-inline: 13px; }
  .hero { padding-block: 18px; }
  .top-inner { flex-wrap: wrap; }
  .brand strong { font-size: .95rem; }
  .mark { height: 36px; width: 36px; font-size: 1.4rem; }
  .stage-body { padding: 15px; }
  .stage-link { display: inline; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; }
}
