/* Shared base. The admin page (/admin) uses these cream colours; the customer page
   overrides them under body.wheel-page further down. */
:root {
  --bg: #f7efe1;
  --surface: #fffaf1;
  --text: #2b2926;
  --muted: #5f584f;
  --accent: #8e1b1b;
  --accent-text: #ffffff;
  --border: #e2d3b8;
  color-scheme: light;
}

* { box-sizing: border-box; }

html, body { margin: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", sans-serif;
  line-height: 1.6;
  -webkit-text-size-adjust: 100%;
}

main {
  max-width: 420px;
  margin: 0 auto;
  padding: 24px 16px calc(32px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
}

h1 { margin: 0; font-size: 1.375rem; line-height: 1.4; text-align: center; }

.btn {
  appearance: none;
  border: 0;
  border-radius: 999px;
  font: inherit;
  font-weight: 700;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.btn:focus-visible { outline: 3px solid var(--text); outline-offset: 3px; }
.btn-small {
  padding: 6px 14px;
  font-size: 0.9375rem;
  background: var(--accent);
  color: var(--accent-text);
  white-space: nowrap;
}

/* ===================== Customer wheel page ===================== */

body.wheel-page {
  position: relative;
  min-height: 100vh;
  min-height: 100dvh;
  background: #09090b radial-gradient(circle at 50% 40%, #5a1c0b 0%, #2a0d07 38%, #0c0706 72%, #09090b 100%) no-repeat fixed;
  color: #f6efe3;
  color-scheme: dark;
}

.wheel-page .defs { position: absolute; width: 0; height: 0; overflow: hidden; }

.wheel-page .sr-only {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.wheel-page .page {
  max-width: 420px;
  margin: 0 auto;
  padding: 18px 20px calc(32px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}
.wheel-page .page.is-result { gap: 12px; }

.wheel-page .logo { display: block; width: 104px; height: auto; margin: 0 auto; }

/* Ribbon title */
.wheel-page .ribbon { display: block; width: min(330px, 100%); height: auto; overflow: visible; }
.wheel-page .ribbon-text {
  font-size: 25px;
  font-weight: 900;
  letter-spacing: 4px;
  fill: #fff1c9;
  filter: drop-shadow(0 2px 0 #6e1607);
}
.wheel-page .is-result .ribbon-text { font-size: 26px; letter-spacing: 6px; }

/* Start view */
.wheel-page .start-view, .wheel-page .result-view {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}
.wheel-page .result-view { gap: 12px; }
.wheel-page .start-view[hidden], .wheel-page .result-view[hidden] { display: none; }

.wheel-page .wheel {
  display: block;
  width: min(350px, calc(100vw - 40px));
  height: auto;
  overflow: visible;
}
.wheel-page .wheel-rot {
  transform-box: view-box;
  transform-origin: 0 0;
  transform: rotate(0deg);
  will-change: transform;
}
.wheel-page .wheel-rot.spinning { transition: transform 5.5s cubic-bezier(.17, .85, .25, 1); }
.wheel-page .slice-label { font-weight: 900; letter-spacing: .5px; }
.wheel-page .divider { stroke: #e8be5c; stroke-width: 2.5; }
.wheel-page .peg { fill: url(#bw-gold); stroke: #8a5a14; stroke-width: .8; }
.wheel-page .bulb .halo { fill: rgba(255, 210, 90, .35); }
.wheel-page .bulb .lamp { fill: url(#bw-bulb); }
.wheel-page .bulb .off { fill: #a4782e; }
.wheel-page .bulb:not(.on) .halo, .wheel-page .bulb:not(.on) .lamp, .wheel-page .bulb.on .off { display: none; }
.wheel-page .hub-text { font-size: 30px; font-weight: 900; fill: #ffe6a3; }
.wheel-page .pin { transform-box: view-box; transform-origin: 0 -184px; }

/* Spin button */
.wheel-page .btn-spin {
  appearance: none;
  display: block;
  width: 100%;
  height: 60px;
  border: 0;
  border-radius: 30px;
  background: linear-gradient(180deg, #f26a45 0%, #c2371d 58%, #a82a12 100%);
  box-shadow: 0 6px 0 #6e1607, 0 16px 30px rgba(0, 0, 0, .55), inset 0 2px 0 rgba(255, 255, 255, .35);
  color: #fff6e8;
  font: inherit;
  font-size: 21px;
  font-weight: 900;
  letter-spacing: .16em;
  text-shadow: 0 2px 0 rgba(110, 22, 7, .7);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.wheel-page .btn-spin:active:not(:disabled) {
  transform: translateY(4px);
  box-shadow: 0 2px 0 #6e1607, 0 10px 22px rgba(0, 0, 0, .55), inset 0 2px 0 rgba(255, 255, 255, .35);
}
.wheel-page .btn-spin:disabled { opacity: .6; cursor: default; }

.wheel-page .btn-spin:focus-visible,
.wheel-page .btn-shop:focus-visible,
.wheel-page .btn-copy:focus-visible,
.wheel-page .sound-toggle:focus-visible { outline: 3px solid #ffe6a3; outline-offset: 3px; }

/* Odds and rules panel */
.wheel-page .odds-panel {
  width: 100%;
  padding: 12px 16px;
  border-radius: 14px;
  background: rgba(255, 230, 180, .06);
  border: 1px solid rgba(232, 192, 106, .28);
}
.wheel-page .odds-heading {
  margin: 0 0 8px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .22em;
  color: #e8c06a;
}
.wheel-page .odds-grid { display: grid; grid-template-columns: 1fr auto; column-gap: 16px; row-gap: 2px; }
.wheel-page .odds-grid .odds { display: contents; }
.wheel-page .odds-name { font-size: 13px; color: #d9cbb4; }
.wheel-page .odds-pct { font-size: 13px; font-weight: 700; color: #ffe6a3; text-align: right; font-variant-numeric: tabular-nums; }
.wheel-page .rules-text { margin: 10px 0 0; padding-left: 1.2em; font-size: 11px; line-height: 1.6; color: #a8967c; }

.wheel-page .error {
  width: 100%;
  margin: 0;
  padding: 14px 16px;
  border-radius: 14px;
  background: rgba(194, 55, 29, .18);
  border: 1px solid rgba(242, 106, 69, .55);
  color: #ffe6a3;
  font-weight: 700;
  text-align: center;
}
.wheel-page .error[hidden] { display: none; }

/* Result view */
.wheel-page .showcase { display: block; width: min(300px, 100%); height: auto; overflow: visible; }
.wheel-page .rays { transform-box: view-box; transform-origin: 0 0; animation: bw-turn 60s linear infinite; }
.wheel-page .medallion { transform-box: view-box; transform-origin: 0 0; }
.wheel-page .medallion.pop { animation: bw-pop 450ms cubic-bezier(.34, 1.56, .64, 1) both; }

.wheel-page .prize-intro { margin: 0; font-size: 13px; letter-spacing: .2em; color: #e8c06a; }
/* Same look as the intro line. The negative top margin cancels the column gap, so adding this
   line moves the ticket and buttons down by exactly its own height. */
.wheel-page .prize-value { margin: -12px 0 0; font-size: 13px; line-height: 1.6; letter-spacing: .2em; color: #e8c06a; text-align: center; white-space: nowrap; }
.wheel-page .prize-name {
  margin: -6px 0 4px;
  font-size: 40px;
  line-height: 1.2;
  font-weight: 900;
  color: #fff1c9;
  text-align: center;
  text-shadow: 0 3px 0 #7a1606, 0 0 24px rgba(255, 170, 60, .45);
}

.wheel-page .ticket {
  position: relative;
  width: 100%;
  padding: 16px 18px;
  border-radius: 16px;
  background: linear-gradient(180deg, #fffaf0, #fbeed6);
  box-shadow: 0 18px 40px rgba(0, 0, 0, .5), inset 0 0 0 1px rgba(185, 134, 46, .5);
  color: #3a1a10;
}
.wheel-page .ticket[hidden] { display: none; }
.wheel-page .ticket::before, .wheel-page .ticket::after {
  content: "";
  position: absolute;
  top: 50%;
  width: 24px;
  height: 24px;
  margin-top: -12px;
  border-radius: 50%;
  background: #1d0a06;
}
.wheel-page .ticket::before { left: -12px; }
.wheel-page .ticket::after { right: -12px; }
.wheel-page .ticket-inner { border: 1.5px dashed rgba(194, 55, 29, .45); border-radius: 10px; padding: 12px 14px; }
.wheel-page .ticket-top { display: flex; align-items: center; gap: 12px; }
.wheel-page .ticket-code { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.wheel-page .code-label { font-size: 12px; letter-spacing: .12em; color: #8a6a4a; }
.wheel-page .code {
  font-size: 28px;
  line-height: 1.25;
  font-weight: 700;
  letter-spacing: .14em;
  color: #8c1d0c;
  font-variant-numeric: tabular-nums;
  /* Every character the same width, so any 16-character code fits at 18px or more next to the button. */
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Roboto Mono", "Droid Sans Mono", "Liberation Mono", monospace;
  white-space: nowrap; /* one line always; app.js shrinks the size to fit */
  user-select: all;
  -webkit-user-select: all;
}
.wheel-page .btn-copy {
  appearance: none;
  flex: none;
  height: 40px;
  min-width: 5.6em; /* fits 已複製 too, so the button never changes width after a tap */
  padding: 0 18px;
  border: 0;
  border-radius: 20px;
  background: linear-gradient(180deg, #f26a45, #c2371d);
  box-shadow: 0 3px 0 #6e1607;
  color: #fff6e8;
  font: inherit;
  font-size: 14px;
  font-weight: 700;
  white-space: nowrap;
  cursor: pointer;
}
.wheel-page .btn-copy:active { transform: translateY(2px); box-shadow: 0 1px 0 #6e1607; }

.wheel-page .how-to { margin: 2px 0 0; font-size: 13px; line-height: 1.6; color: #d9cbb4; text-align: center; }
.wheel-page .how-to[hidden] { display: none; }

.wheel-page .btn-shop {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 58px;
  border-radius: 29px;
  background: linear-gradient(180deg, #fff1b8 0%, #f2c95b 45%, #c8962f 100%);
  box-shadow: 0 6px 0 #7a4e14, 0 16px 30px rgba(0, 0, 0, .55), inset 0 2px 0 rgba(255, 255, 255, .6);
  color: #5a1206;
  font-size: 19px;
  font-weight: 900;
  letter-spacing: .16em;
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
}
.wheel-page .btn-shop:active { transform: translateY(4px); box-shadow: 0 2px 0 #7a4e14, 0 10px 22px rgba(0, 0, 0, .55), inset 0 2px 0 rgba(255, 255, 255, .6); }

.wheel-page .fine-print { margin: 0; font-size: 11px; color: #a8967c; text-align: center; }

/* Sound toggle */
.wheel-page .sound-toggle {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: rgba(0, 0, 0, .35);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.wheel-page .sound-toggle .sound-x { display: none; }
.wheel-page .sound-toggle[aria-pressed="true"] .sound-x { display: inline; }
.wheel-page .sound-toggle[aria-pressed="true"] .sound-waves { display: none; }

.wheel-page .confetti { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 3; }

/* Narrow phones: a little more room so a 16-character code stays on one line at 18px or more. */
@media (max-width: 374px) {
  .wheel-page .ticket-top { gap: 8px; }
  .wheel-page .btn-copy { padding: 0 14px; min-width: 5em; }
}

@keyframes bw-turn { to { transform: rotate(360deg); } }
@keyframes bw-pop { from { transform: scale(.6); } to { transform: scale(1); } }

@media (prefers-reduced-motion: reduce) {
  .wheel-page .wheel-rot.spinning { transition-duration: 1.2s; }
  .wheel-page .rays { animation: none; }
  .wheel-page .medallion.pop { animation: none; }
}

/* Wheel page: spin 2 */
.wheel-page .first-gift { width: 100%; display: flex; flex-direction: column; gap: 8px; }
.wheel-page .first-gift[hidden], .wheel-page .btn-spin[hidden] { display: none; }
.wheel-page .first-gift-name { margin: 6px 0 0; font-size: 13px; letter-spacing: .12em; color: #e8c06a; text-align: center; }
.wheel-page .ticket-small { padding: 10px 14px; }
.wheel-page .ticket-small .ticket-inner { padding: 8px 12px; }

/* ===================== Survey page (/survey) ===================== */
.survey-page [hidden] { display: none !important; }
.survey-page .survey, .survey-page .thanks { width: 100%; display: flex; flex-direction: column; gap: 16px; }
.survey-page .survey-head { text-align: center; }
.survey-page .survey-title {
  margin: 0;
  font-size: 24px;
  line-height: 1.35;
  font-weight: 900;
  color: #fff1c9;
  text-shadow: 0 2px 0 #7a1606;
}
.survey-page .survey-subtitle { margin: 8px 0 0; font-size: 14px; line-height: 1.7; color: #d9cbb4; }
.survey-page .q {
  min-width: 0;
  margin: 0;
  padding: 14px;
  border-radius: 14px;
  background: rgba(255, 230, 180, .06);
  border: 1px solid rgba(232, 192, 106, .28);
}
.survey-page .q-label { display: block; padding: 0; font-size: 16px; font-weight: 700; color: #ffe6a3; }
/* A floated legend sits inside the box like the other questions' labels, not on its border. */
.survey-page legend.q-label { float: left; width: 100%; }
.survey-page legend.q-label + * { clear: both; }
.survey-page .q-help { margin: 2px 0 0; font-size: 13px; color: #a8967c; }
.survey-page .q-error { margin: 8px 0 0; font-size: 14px; font-weight: 700; color: #ff9b7d; }
.survey-page .q-input {
  display: block;
  width: 100%;
  margin-top: 8px;
  padding: 10px 12px;
  border: 1px solid rgba(185, 134, 46, .6);
  border-radius: 10px;
  background: #fffaf0;
  color: #2b2926;
  font: inherit;
  font-size: 16px; /* 16px or more stops iPhones zooming in on focus */
  line-height: 1.5;
  resize: vertical;
}
.survey-page .q-input:focus { outline: 3px solid #ffe6a3; outline-offset: 1px; }

/* One product per row: name, 5 stars, clear. 5 x 36px stars fit next to a 6-character name at 360px. */
.survey-page .products { margin-top: 8px; display: flex; flex-direction: column; }
.survey-page .product { display: flex; align-items: center; gap: 4px; min-height: 44px; border-top: 1px solid rgba(232, 192, 106, .15); }
.survey-page .product:first-child { border-top: 0; }
.survey-page .product-name { flex: 1; min-width: 0; font-size: 15px; color: #f6efe3; overflow-wrap: anywhere; }
.survey-page .stars { display: flex; flex: none; }
.survey-page .star, .survey-page .star-clear {
  appearance: none;
  flex: none;
  width: 36px;
  height: 40px;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.survey-page .star svg { display: block; width: 28px; height: 28px; margin: 0 auto; fill: rgba(255, 230, 180, .16); stroke: #b98a3a; stroke-width: 1.2; }
.survey-page .star.on svg { fill: #f2c95b; stroke: #f2c95b; }
.survey-page .star-clear { width: 24px; font-size: 20px; line-height: 1; color: #a8967c; }
.survey-page .star-clear[hidden] { display: block !important; visibility: hidden; } /* keeps every row the same width */
.survey-page .star:focus-visible, .survey-page .star-clear:focus-visible,
.survey-page .btn-spin:focus-visible { outline: 3px solid #ffe6a3; outline-offset: 1px; border-radius: 6px; }

.survey-page .choices { margin-top: 8px; display: flex; flex-direction: column; gap: 6px; }
.survey-page .choice {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding: 8px 12px;
  border-radius: 10px;
  border: 1px solid rgba(232, 192, 106, .28);
  font-size: 15px;
  cursor: pointer;
}
.survey-page .choice:has(input:checked) { border-color: #f2c95b; background: rgba(242, 201, 91, .12); }
.survey-page .choice input { flex: none; width: 20px; height: 20px; margin: 0; accent-color: #c2371d; }

.survey-page .btn-link { display: flex; align-items: center; justify-content: center; text-decoration: none; }
.survey-page .thanks { align-items: center; text-align: center; gap: 18px; padding-top: 8px; }
.survey-page .thanks-note { margin: 0; font-size: 14px; line-height: 1.7; color: #d9cbb4; overflow-wrap: anywhere; }
.survey-page .thanks-note a { display: block; color: #ffe6a3; }

/* ===================== Admin page (/admin) ===================== */
.admin { max-width: 640px; align-items: stretch; }
.admin h1 { text-align: left; }
.admin-status { margin: 0; overflow-wrap: anywhere; }
.admin-status.error { color: var(--accent); font-weight: 700; }
.admin-status[hidden], .admin-prizes[hidden] { display: none; }
.admin-prizes { display: flex; flex-direction: column; gap: 16px; }
.admin-card { padding: 16px; border-radius: 14px; background: var(--surface); border: 1px solid var(--border); }
.admin-card h2 { margin: 0 0 8px; font-size: 1.125rem; }
.admin-id { font-weight: 400; font-size: 0.875rem; color: var(--muted); }
.admin-counts { display: flex; gap: 24px; margin: 0 0 8px; }
.admin-counts dt { font-size: 0.8125rem; color: var(--muted); }
.admin-counts dd { margin: 0; font-size: 1.25rem; font-weight: 700; }
.admin-warning { margin: 0 0 8px; padding: 8px 10px; border-radius: 8px; background: var(--accent); color: var(--accent-text); font-weight: 700; }
.admin-form label { display: block; font-size: 0.875rem; color: var(--muted); }
.admin-form textarea { display: block; width: 100%; margin: 4px 0 8px; padding: 8px; font: 0.9375rem ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; border: 1px solid var(--border); border-radius: 8px; background: #fff; color: var(--text); }
.admin-result { margin: 8px 0 0; font-size: 0.875rem; }
.admin-table { width: 100%; border-collapse: collapse; margin: 0 0 12px; font-size: 0.9375rem; }
.admin-table th, .admin-table td { padding: 4px 8px 4px 0; text-align: left; border-bottom: 1px solid var(--border); }
.admin-table td.num, .admin-table th.num { text-align: right; font-variant-numeric: tabular-nums; }
