:root {
  color-scheme: light;
  --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: 8px;
  background: linear-gradient(90deg, var(--red-deep), var(--red) 42%, var(--gold) 72%, var(--red-deep));
}

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

.mute {
  position: absolute;
  top: 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: 40px;
  height: 40px;
  margin: 0 auto 8px;
  display: grid;
  place-items: center;
  border: 2px solid var(--red);
  border-radius: 50%;
  color: var(--red);
  font-family: "Noto Serif CJK JP", "Noto Serif JP", "Yu Mincho", serif;
  font-size: 20px;
  font-weight: 700;
}

.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 18px/1 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 (max-height: 720px) {
  .seal, .lead { display: none; }
  .head { padding-top: 10px; padding-bottom: 0; }
  h1 { margin: 0 0 4px; font-size: 26px; }
  .stage { margin-top: 0; padding-top: 8px; }
  .result { margin-top: 8px; }
}

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

body.keyboard-open {
  min-height: 0;
  align-items: stretch;
  padding-top: 8px;
  padding-bottom: 8px;
}

body.keyboard-open .seal,
body.keyboard-open .lead,
body.keyboard-open .stage,
body.keyboard-open .legend,
body.keyboard-open .status,
body.keyboard-open .footnote {
  display: none;
}

body.keyboard-open .head {
  padding-top: 8px;
  padding-bottom: 0;
}

body.keyboard-open h1 {
  margin: 0;
  font-size: 22px;
}

body.keyboard-open .ticket {
  box-shadow: none;
}

.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;
}
