:root {
  color-scheme: light;
  --band: 8px;
  --paper: #f3eadc;
  --card: #fffaf3;
  --ink: #231c16;
  --muted: #6f6256;
  --line: #e6d5c0;
  --red: #d4532b;
  --red-deep: #8e2f24;
  --gold: #e4c98a;
  --shadow: 0 22px 50px rgba(62, 36, 18, 0.12);
}

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

html, body { margin: 0; }
html { overflow-x: clip; }

body {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 12px 10px max(16px, env(safe-area-inset-bottom));
  padding-left: max(10px, env(safe-area-inset-left));
  padding-right: max(10px, env(safe-area-inset-right));
  background:
    radial-gradient(ellipse at 50% -10%, rgba(212, 83, 43, 0.16), transparent 46%),
    radial-gradient(ellipse at 100% 100%, rgba(228, 201, 138, 0.35), transparent 42%),
    var(--paper);
  color: var(--ink);
  font-family: "Noto Sans CJK JP", "Noto Sans JP", "Hiragino Sans", "Yu Gothic", sans-serif;
  font-size: 16px;
  line-height: 1.6;
}

@media (min-height: 920px) {
  body { align-items: center; }
}

.ticket {
  position: relative;
  width: min(460px, 100%);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 22px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.band {
  height: var(--band);
  background: linear-gradient(90deg, var(--red-deep), var(--red) 42%, var(--gold) 72%, var(--red-deep));
}

.head {
  padding: 110px 16px 2px;
  text-align: center;
}

.corner {
  position: absolute;
  top: calc(var(--band) + 12px);
  left: 12px;
  z-index: 4;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
}

.chip,
button.chip:hover,
button.chip:active,
button.chip:focus {
  min-height: 36px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 250, 243, 0.96);
  color: var(--ink);
  -webkit-text-fill-color: var(--ink);
  font-size: 12px;
  font-weight: 700;
}

.mute {
  position: absolute;
  top: calc(var(--band) + 12px);
  right: 12px;
  z-index: 4;
  min-height: 44px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 250, 243, 0.92);
  color: var(--ink);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.06em;
}

.mute[aria-pressed="true"] {
  color: var(--muted);
  background: #f3eadc;
}

.seal {
  width: max-content;
  max-width: calc(100% - 24px);
  height: 34px;
  margin: 0 auto 8px;
  padding: 0 14px;
  display: grid;
  place-items: center;
  border: 2px solid var(--red);
  border-radius: 999px;
  background: #fffaf3;
  color: var(--red);
  font-family: "Noto Serif CJK JP", "Noto Serif JP", "Yu Mincho", serif;
  font-size: 13px;
  font-weight: 700;
  line-height: 1;
  letter-spacing: 0.01em;
  white-space: nowrap;
}

.eyebrow {
  margin: 0;
  color: var(--red-deep);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.22em;
}

h1 {
  margin: 6px 0 8px;
  font-family: "Noto Serif CJK JP", "Noto Serif JP", "Yu Mincho", serif;
  font-size: clamp(28px, 7vw, 36px);
  font-weight: 700;
  letter-spacing: 0.08em;
  line-height: 1.25;
  text-wrap: balance;
}

.lead, .footnote {
  margin: 0 auto;
  max-width: 34em;
  color: var(--muted);
  font-size: 14px;
}

.stage {
  position: relative;
  width: fit-content;
  max-width: 100%;
  margin: 4px auto 0;
  padding-top: 12px;
}

.pointer {
  position: absolute;
  top: 0;
  left: 50%;
  z-index: 3;
  transform: translateX(-50%);
  border-left: 11px solid transparent;
  border-right: 11px solid transparent;
  border-top: 18px solid var(--red);
  filter: drop-shadow(0 1px 0 #231c16);
  pointer-events: none;
}

#wheel {
  margin: 0 auto;
  max-width: 100%;
  overflow: hidden;
}

body.is-spinning #wheel,
body.is-spinning .spin-form {
  pointer-events: none;
}

.status {
  min-height: 1.4em;
  margin: 4px 16px 0;
  text-align: center;
  color: var(--muted);
  font-size: 14px;
}

.legend {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px 12px;
  margin: 8px 16px 4px;
  padding: 0;
  list-style: none;
}

.legend li {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.legend li span {
  width: 10px;
  height: 10px;
  flex: none;
  border-radius: 50%;
  box-shadow: inset 0 0 0 1px rgba(35, 28, 22, 0.18);
}

.legend li.is-win {
  color: var(--ink);
  font-weight: 700;
}

.legend li b {
  min-width: 0;
  overflow-wrap: anywhere;
}

.result {
  margin: 12px 16px 0;
  padding: 14px 16px 16px;
  text-align: center;
  background: #fff6e8;
  border: 1px solid var(--gold);
  border-radius: 18px;
}

.result-kicker {
  margin: 2px 0 0;
  color: var(--red);
  font-family: "Noto Serif CJK JP", "Noto Serif JP", serif;
  font-size: 13px;
  letter-spacing: 0.28em;
}

#result-name {
  margin: 4px 0;
  font-family: "Noto Serif CJK JP", "Noto Serif JP", serif;
  font-size: clamp(22px, 6vw, 28px);
  font-weight: 700;
  line-height: 1.35;
}

#result-message,
#result-hint {
  margin: 0;
  color: #4a3f36;
  font-size: 16px;
  line-height: 1.6;
  text-wrap: pretty;
}

#result-hint { margin-top: 4px; }

.spin-form {
  display: grid;
  gap: 10px;
  padding: 14px 16px 8px;
  scroll-margin-top: 12px;
  scroll-margin-bottom: 16px;
}

label {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.08em;
}

input {
  width: 100%;
  min-height: 56px;
  padding: 0 14px;
  border: 1px solid #ddcbb6;
  border-radius: 14px;
  background: #fff;
  color: var(--ink);
  font: 700 16px/1.2 ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  touch-action: manipulation;
}

input::placeholder {
  color: #b3a394;
  font-weight: 500;
  letter-spacing: 0.08em;
}

input:focus {
  outline: 2px solid rgba(212, 83, 43, 0.45);
  outline-offset: 1px;
  border-color: var(--red);
}

button {
  min-height: 56px;
  border: 0;
  border-radius: 999px;
  background: var(--red);
  color: #fffaf3;
  font: 700 17px/1.2 "Noto Sans CJK JP", "Noto Sans JP", sans-serif;
  letter-spacing: 0.08em;
  cursor: pointer;
  touch-action: manipulation;
}

button:hover { background: #c44722; }

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

button:disabled {
  cursor: wait;
  opacity: 0.55;
}

.error {
  margin: 0;
  padding: 12px 14px;
  border-radius: 12px;
  background: #fde8e2;
  color: var(--red-deep);
  font-size: 16px;
  line-height: 1.5;
  text-wrap: pretty;
}

.footnote {
  padding: 4px 16px 18px;
  text-align: center;
}

.noscript {
  margin: 16px;
  text-align: center;
}

@media (min-width: 760px) {
  body { padding: 28px 16px 48px; }
  .ticket { border-radius: 28px; }
  .head { padding: 110px 24px 4px; }
  .seal { height: 36px; font-size: 14px; padding: 0 16px; }
  .legend, .result { margin-left: 22px; margin-right: 22px; }
  .spin-form { padding: 16px 22px 8px; }
  .footnote { padding: 4px 22px 22px; }
}

.voucher {
  display: grid;
  gap: 12px;
  padding: 8px 16px 22px;
  text-align: center;
}

.voucher img {
  width: 100%;
  height: auto;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #fff;
}

.hint {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.6;
}

button.ghost {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--line);
}

body.show-voucher .stage,
body.show-voucher .status,
body.show-voucher .result,
body.show-voucher .spin-form,
body.show-voucher .legend,
body.show-voucher .footnote,
body.show-voucher .head .seal,
body.show-voucher .head h1,
body.show-voucher .head .lead,
body.show-voucher .head .eyebrow {
  display: none;
}

body.show-voucher .head {
  padding-bottom: 0;
}

.sheet-modal {
  width: min(420px, calc(100% - 24px));
  padding: 0;
  border: 0;
  background: transparent;
}

.sheet-modal::backdrop { background: rgba(12, 28, 20, 0.62); }

.sheet-card {
  padding: 20px 16px 16px;
  background: var(--card);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 18px;
}

.sheet-card h2 {
  margin: 0 0 10px;
  font-size: 26px;
}

.rules-text p { margin: 0 0 12px; line-height: 1.55; }

.wins-list {
  list-style: none;
  margin: 0 0 12px;
  padding: 0;
  display: grid;
  gap: 8px;
  max-height: 280px;
  overflow: auto;
}

.wins-list li {
  display: grid;
  grid-template-columns: 56px 1fr;
  gap: 10px;
  align-items: center;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
}

.wins-list img {
  width: 56px;
  height: 56px;
  object-fit: cover;
  border-radius: 8px;
}

.wins-list strong, .wins-list span, .wins-list code { display: block; }
.wins-list span, .wins-list code { color: var(--muted); font-size: 13px; }

.sheet-card form { display: grid; gap: 8px; margin-top: 8px; }
.sheet-card .ghost, .sheet-card #rules-close, .sheet-card #wins-close { margin-top: 10px; width: 100%; }

html[data-theme="a"] .chip,
html[data-theme="a"] .sheet-card,
html[data-theme="a"] .wins-list li { border-radius: 0; }
html[data-theme="a"] .chip { background: #fff; border-color: #111; }
html[data-theme="b"] button.chip,
html[data-theme="b"] button.chip:hover,
html[data-theme="b"] button.chip:active,
html[data-theme="b"] button.chip:focus {
  background: #fff6e4;
  border: 2px solid #e7c56b;
  color: #6a2418;
  -webkit-text-fill-color: #6a2418;
  border-radius: 999px;
}
html[data-theme="b"] .sheet-card {
  background: #fff6e4;
  border: 3px solid #e7c56b;
  border-radius: 24px;
}
html[data-theme="b"] .sheet-card h2 { font-family: "Noto Serif", Georgia, serif; color: #6a2418; }

#confetti {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 40;
  pointer-events: none;
}

#result:not([hidden]) {
  position: fixed;
  z-index: 30;
  inset: 0;
  margin: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
  background: rgba(20, 24, 28, 0.55);
  border: 0;
  border-radius: 0;
}

.win-card {
  width: min(100%, 360px);
  padding: 22px 18px 16px;
  text-align: center;
  background: var(--card);
  border: 1px solid var(--gold);
  border-radius: 18px;
  box-shadow: var(--shadow);
}

.win-card #open-voucher {
  width: 100%;
  margin-top: 14px;
}

html[data-theme="a"] {
  --band: 10px;
  --paper: #eceff3;
  --card: #ffffff;
  --ink: #111111;
  --muted: #5c6570;
  --line: #111111;
  --red: #c8102e;
  --red-deep: #111111;
  --gold: #c6a15b;
  --shadow: none;
}

html[data-theme="a"] body {
  font-family: "Noto Sans", "Segoe UI", sans-serif;
  background: #e8ebf0;
}

html[data-theme="a"] .ticket {
  border: 1px solid #111;
  border-radius: 2px;
  box-shadow: none;
}

html[data-theme="a"] .band {
  background: linear-gradient(90deg, #111 0 34%, #c8102e 34% 67%, #c6a15b 67% 100%);
}

html[data-theme="a"] h1,
html[data-theme="a"] .seal,
html[data-theme="a"] .eyebrow,
html[data-theme="a"] .result-kicker,
html[data-theme="a"] #result-name,
html[data-theme="a"] button {
  font-family: "Noto Sans", "Segoe UI", sans-serif;
  letter-spacing: 0.02em;
}

html[data-theme="a"] h1 { color: #111; font-weight: 700; }
html[data-theme="a"] .seal {
  border-radius: 999px;
  border-color: #111;
  color: #111;
  background: #fff;
  font-size: 12px;
  letter-spacing: 0.04em;
}
html[data-theme="a"] .pointer { border-top-color: #c8102e; filter: none; }
html[data-theme="a"] input {
  border-radius: 0;
  border: 1px solid #111;
  background: #fff;
}
html[data-theme="a"] button:not(.chip):not(.mute) {
  border-radius: 0;
  background: #111;
  color: #fff;
}
html[data-theme="a"] button:hover:not(.chip):not(.mute) { background: #c8102e; }
html[data-theme="a"] .win-card {
  border-radius: 0;
  border: 2px solid #111;
  background: #fff;
  box-shadow: 8px 8px 0 #c6a15b;
}
html[data-theme="a"] .win-card #open-voucher { background: #c8102e; color: #fff; }
html[data-theme="a"] .legend li span { border-radius: 0; }

html[data-theme="b"] {
  --band: 18px;
  --paper: #0d2418;
  --card: #fff4dc;
  --ink: #2a1c10;
  --muted: #6d5434;
  --line: #e2c27a;
  --red: #8d1d1d;
  --red-deep: #f0d48a;
  --gold: #e7c56b;
  --shadow: 0 24px 60px rgba(0, 0, 0, 0.35);
}

html[data-theme="b"] body {
  font-family: "Noto Serif", Georgia, serif;
  color: #f6e7c1;
  background:
    radial-gradient(circle at 12% 8%, rgba(240, 212, 138, 0.45), transparent 18%),
    radial-gradient(circle at 86% 18%, rgba(232, 168, 74, 0.35), transparent 16%),
    radial-gradient(circle at 70% 88%, rgba(141, 29, 29, 0.45), transparent 22%),
    #0c2419;
}

html[data-theme="b"] .ticket {
  background: #fff6e4;
  border: 3px solid #e7c56b;
  border-radius: 28px;
  box-shadow: 0 0 0 8px rgba(231, 197, 107, 0.22), 0 0 40px rgba(240, 212, 138, 0.25), var(--shadow);
}

html[data-theme="b"] .band {
  background: repeating-linear-gradient(90deg, #8d1d1d 0 14px, #e7c56b 14px 22px, #fff6e4 22px 28px);
}

html[data-theme="b"] h1,
html[data-theme="b"] .seal,
html[data-theme="b"] .eyebrow,
html[data-theme="b"] #result-name,
html[data-theme="b"] .result-kicker {
  font-family: "Noto Serif", Georgia, serif;
}

html[data-theme="b"] .eyebrow { color: #8d1d1d; letter-spacing: 0.28em; }
html[data-theme="b"] h1 { color: #6a2418; }
html[data-theme="b"] .seal {
  border-radius: 999px;
  border: 2px solid #e7c56b;
  background: #8d1d1d;
  color: #f6e7c1;
  box-shadow: 0 0 0 3px #8d1d1d;
  font-size: 13px;
  letter-spacing: 0.02em;
}
html[data-theme="b"] .pointer {
  border-top-color: #e7c56b;
  filter: drop-shadow(0 0 6px #e7c56b);
}
html[data-theme="b"] .stage::after {
  content: "";
  position: absolute;
  z-index: 2;
  left: 50%;
  top: 10px;
  width: min(100%, 440px);
  aspect-ratio: 1;
  transform: translateX(-50%);
  border-radius: 50%;
  pointer-events: none;
  background: repeating-conic-gradient(from 0deg, #ffe7a3 0 5deg, transparent 5deg 18deg);
  -webkit-mask: radial-gradient(circle, transparent 58%, #000 60%, #000 66%, transparent 68%);
  mask: radial-gradient(circle, transparent 58%, #000 60%, #000 66%, transparent 68%);
  filter: drop-shadow(0 0 6px #e7c56b);
}
html[data-theme="b"] input {
  border-radius: 16px;
  border: 2px solid #e7c56b;
  background: #fffaf0;
}
html[data-theme="b"] button:not(.chip):not(.mute) {
  border-radius: 999px;
  background: #8d1d1d;
  color: #fff6e4;
  border: 2px solid #e7c56b;
  font-family: "Noto Serif", Georgia, serif;
}
html[data-theme="b"] button:hover:not(.chip):not(.mute) { background: #6a2418; }
html[data-theme="b"] .win-card {
  background: #fff6e4;
  border: 3px solid #e7c56b;
  border-radius: 28px;
  box-shadow: 0 0 0 6px rgba(141, 29, 29, 0.35), 0 0 28px rgba(231, 197, 107, 0.45);
}
html[data-theme="b"] .mute {
  background: #fff6e4;
  border-color: #e7c56b;
  color: #6a2418;
}
