@font-face {
  font-family: "Mochiy Pop One";
  src: url("fonts/mochiy-pop-one-title.woff2") format("woff2");
  font-display: swap;
}

:root {
  color-scheme: only light;
  font-family: system-ui, -apple-system, "Hiragino Sans", "Yu Gothic UI", Meiryo, sans-serif;
  background: var(--stage-background);
  color: var(--stage-text);
  --text: #24252a;
  --stage-text: #f7f7f8;
  --title-text: #ffda75;
  --winner-text: #ff5574;
  --stage-background: #0d4735;
  --accent: #414550;
  --focus: var(--stage-text);
  --panel: #fff;
  --card: #e9eaed;
  --border: #7f828a;
  --selected-card: #d9dbe1;
  --muted: #53565e;
  --drawn-text: #595c65;
  --wheel-text: #fff4df;
  --slot-ink: #3d2630;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
}

button,
input,
select {
  font: inherit;
}

button {
  appearance: none;
  color: inherit;
  cursor: pointer;
  touch-action: manipulation;
}

a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 3px;
}

button:disabled,
button[aria-disabled="true"] {
  cursor: default;
}

.roulette {
  position: relative;
  background: var(--stage-background);
}

.roulette-button {
  display: grid;
  place-items: center;
  width: 100%;
  min-height: 100vh;
  min-height: 100dvh;
  padding: 4.75rem 1.25rem;
  border: 0;
  background: transparent;
  text-align: center;
}

.roulette-button:focus-visible {
  outline-offset: -5px;
}

.roulette-stage {
  position: relative;
  display: grid;
  justify-items: center;
  align-items: center;
  gap: clamp(0.75rem, 3dvh, 1.5rem);
  width: 100%;
  min-width: 0;
}

.roulette-name {
  max-width: 100%;
  font-size: clamp(2.5rem, 10vw, 7rem);
  font-weight: 700;
  line-height: 1.15;
  text-wrap: balance;
  overflow-wrap: anywhere;
}

.roulette-button[data-state="ready"] .roulette-name,
.roulette-button[data-state="empty"] .roulette-name {
  font-size: clamp(1.5rem, 5.2vw, 2.5rem);
  font-weight: 600;
}

.roulette-button[data-state="result"] .roulette-name {
  color: var(--winner-text);
}

.roulette-name.winner {
  animation: reveal-color 250ms steps(1, end), blink 360ms ease-in-out 430ms 3;
}

.wheel-view,
.slot-view {
  display: none;
}

.roulette-button[data-display-mode="wheel"] .wheel-view,
.roulette-button[data-display-mode="slot"] .slot-view {
  display: block;
}

.wheel-view {
  position: relative;
  width: min(100%, 29rem, 60vh);
  width: min(100%, 29rem, max(7rem, calc(100dvh - 14rem)));
  aspect-ratio: 1;
  border-radius: 50%;
  box-shadow: 0 0.75rem 2.5rem #24252a38;
}

.wheel-disc,
.wheel-disc canvas {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: inherit;
}

.wheel-disc {
  position: relative;
  overflow: hidden;
}

.wheel-light {
  position: absolute;
  inset: 0;
  mix-blend-mode: screen;
  opacity: 0;
  pointer-events: none;
}

.wheel-light.is-flashing {
  animation: wheel-flash 520ms ease-in-out 3;
}

.wheel-hub-name:not([hidden]) {
  position: absolute;
  top: 50%;
  left: 50%;
  max-width: 76%;
  padding: 0.25rem 0.65rem;
  border: 1px solid #f1bc57;
  border-radius: 0.75rem;
  background: #61152b;
  color: #fff3ca;
  font-size: clamp(0.9rem, 4vw, 1.5rem);
  font-weight: 700;
  overflow-wrap: anywhere;
  transform: translate(-50%, -50%);
}

.wheel-pointer {
  position: absolute;
  top: -0.4rem;
  left: 50%;
  width: 1.65rem;
  height: 1.75rem;
  background: #ffc455;
  clip-path: polygon(0 0, 100% 0, 50% 100%);
  transform: translateX(-50%);
}

.roulette-button[data-display-mode="wheel"] .roulette-name {
  min-height: 1.15em;
  font-size: clamp(1rem, 3.8vw, 1.7rem);
}

.roulette-button[data-display-mode="wheel"][data-state="result"] .roulette-name {
  visibility: hidden;
  white-space: nowrap;
  overflow: hidden;
}

.roulette-button[data-display-mode="wheel"][data-state="stopping"] .roulette-name::after {
  display: inline-block;
  width: 3ch;
  font-family: ui-monospace, monospace;
  text-align: left;
  content: "...";
  animation: stopping-dots 0.95s steps(4, jump-none) infinite alternate;
}

@keyframes stopping-dots {
  from { clip-path: inset(0 100% 0 0); }
  to { clip-path: inset(0); }
}

@keyframes wheel-flash {
  50% { opacity: 0.55; }
}

.roulette-button[data-display-mode="slot"] {
  color: var(--slot-ink);
}

.roulette-button[data-display-mode="slot"] .roulette-stage {
  --slot-row-height: clamp(2.65rem, min(12vw, calc((100dvh - 12rem) / 3)), 6rem);
}

.slot-view {
  position: relative;
  width: min(100%, 39rem);
  padding: clamp(0.45rem, 2.2vw, 0.9rem) clamp(1rem, 3vw, 1.65rem);
  border: 3px solid #bd974e;
  border-radius: 1.5rem;
  background: #8f1b36;
  box-shadow: 0 0.75rem 2rem #24252a29;
}

.slot-view::before,
.slot-view::after {
  position: absolute;
  top: 50%;
  width: 0.55rem;
  height: 0.9rem;
  background: #e4b555;
  clip-path: polygon(0 0, 100% 50%, 0 100%);
  content: "";
}

.slot-view::before {
  left: 0.25rem;
  transform: translateY(-50%);
}

.slot-view::after {
  right: 0.25rem;
  transform: translateY(-50%) rotate(180deg);
}

.slot-window {
  position: relative;
  display: block;
  overflow: hidden;
  height: calc(3 * var(--slot-row-height) + 4px);
  border: 2px solid #bdb8a9;
  border-radius: 0.72rem;
  background: #faf9f5;
}

.slot-window::before,
.slot-window::after {
  position: absolute;
  z-index: 1;
  inset-inline: 0;
  pointer-events: none;
  content: "";
}

.slot-window::before {
  inset-block: 0;
  inset-inline: -4rem;
  box-shadow:
    inset 0 0.26rem 0.55rem -0.13rem #332c2345,
    inset 0 -0.35rem 0.65rem -0.18rem #332c2350,
    inset 0 1.19rem 2rem -0.5rem #4b3a2b56,
    inset 0 -1.28rem 2.15rem -0.54rem #4b3a2b60;
}

.slot-window::after {
  inset-block: var(--slot-row-height);
  border-block: 1px solid #c18a3c9b;
}

.slot-track {
  display: grid;
  grid-auto-rows: var(--slot-row-height);
}

.slot-cell {
  display: block;
  overflow: hidden;
  padding-inline: 0.6rem;
  border-bottom: 1px solid #e2d7be;
  font-size: clamp(1.15rem, 4.8vw, 2.65rem);
  font-weight: 700;
  line-height: var(--slot-row-height);
  white-space: nowrap;
}

.slot-glyph {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
}

.roulette-button[data-display-mode="slot"] .roulette-name {
  position: absolute;
  z-index: 2;
  inset-inline: 0.8rem;
  top: 50%;
  overflow: hidden;
  font-size: clamp(1.15rem, 4.8vw, 2.65rem);
  line-height: 1.3;
  text-overflow: ellipsis;
  white-space: nowrap;
  transform: translateY(-50%);
  --reveal-start: var(--slot-ink);
  --winner-text: #b7193f;
}

.roulette-button[data-display-mode="slot"][data-state="result"] .roulette-name {
  max-height: calc(3 * var(--slot-row-height));
  text-wrap: balance;
  white-space: normal;
}

.roulette-button[data-display-mode="slot"][data-state="result"].has-long-slot-result .roulette-name {
  position: static;
  width: min(100%, 39rem);
  max-height: none;
  padding: 0.55rem 0.8rem;
  border: 1px solid #bdb8a9;
  border-radius: 0.72rem;
  background: #faf9f5;
  transform: none;
}

.roulette-button[data-display-mode="slot"]:is([data-state="ready"], [data-state="result"], [data-state="empty"]) .slot-cell:nth-child(2),
.roulette-button[data-display-mode="slot"]:is([data-state="spinning"], [data-state="stopping"]) .roulette-name {
  visibility: hidden;
}

.roulette-button[data-display-mode="slot"][data-state="result"].has-long-slot-result .slot-cell:nth-child(2) {
  visibility: visible;
  color: var(--slot-ink);
}

@keyframes reveal-color {
  from { color: var(--reveal-start, var(--stage-text)); }
  to { color: var(--winner-text); }
}

@keyframes blink {
  50% { opacity: 0.3; }
}

@media (prefers-reduced-motion: reduce) {
  .roulette-name.winner,
  .wheel-light.is-flashing,
  .roulette-button[data-display-mode="wheel"][data-state="stopping"] .roulette-name::after {
    animation: none;
  }

  .roulette-button[data-display-mode="slot"]:is([data-state="spinning"], [data-state="stopping"]) .roulette-name {
    visibility: visible;
  }

  .roulette-button[data-display-mode="slot"] .slot-cell:nth-child(2) {
    visibility: hidden;
  }
}

.roulette-header {
  position: absolute;
  top: env(safe-area-inset-top);
  right: max(0.75rem, env(safe-area-inset-right));
  left: max(0.75rem, env(safe-area-inset-left));
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.5rem;
  padding-top: clamp(0.5rem, 2.4vw, 1.25rem);
}

.roulette-title {
  display: flex;
  align-items: center;
  margin: 0;
  color: var(--title-text);
  font-family: "Mochiy Pop One", "Hiragino Maru Gothic ProN", "Yu Gothic UI", sans-serif;
  font-size: clamp(1rem, 4.5vw, 1.75rem);
  font-weight: 400;
  line-height: 1.35;
  text-shadow: 0 2px #742640;
}

.title-emoji {
  display: grid;
  flex: 0 0 2.75rem;
  place-items: center;
  width: 2.75rem;
  height: 2.75rem;
  padding: 0;
  border: 0;
  border-radius: 0.65rem;
  background: transparent;
  cursor: default;
  touch-action: none;
  user-select: none;
  -webkit-touch-callout: none;
  --confetti: #75baff;
}

.title-emoji[data-order-enabled="true"] {
  --confetti: #ff4470;
}

.party-popper {
  position: relative;
  display: block;
  width: 2.25rem;
  height: 2.25rem;
  pointer-events: none;
}

.party-cone {
  position: absolute;
  top: 71%;
  left: 10%;
  width: 55%;
  height: 37%;
  transform: rotate(-42deg);
  transform-origin: left center;
}

.party-cone::before,
.party-cone::after,
.party-confetti::before,
.party-confetti::after {
  position: absolute;
  content: "";
}

.party-cone::before {
  inset: 0;
  background:
    linear-gradient(90deg, transparent 33%, #b53448b8 33% 45%, transparent 45% 59%, #b53448b8 59% 72%, transparent 72%),
    linear-gradient(#ffeda3, #ffd46c 41%, #f6ae50 70%, #d77938);
  clip-path: polygon(0 47%, 100% 0, 100% 100%, 0 53%);
}

.party-cone::after {
  inset: 0 auto 0 100%;
  width: 24%;
  border: 0.075rem solid #ffe08b;
  border-radius: 50%;
  background: #623332;
  transform: translateX(-50%);
}

.party-confetti {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle, var(--confetti) 55%, transparent 65%) 30% 28% / 0.2rem 0.2rem no-repeat,
    radial-gradient(circle, var(--confetti) 55%, transparent 65%) 76% 14% / 0.19rem 0.19rem no-repeat,
    radial-gradient(circle, var(--confetti) 55%, transparent 65%) 90% 53% / 0.16rem 0.16rem no-repeat;
}

.party-confetti::before {
  top: 22%;
  left: 43%;
  width: 18%;
  height: 33%;
  border-top: 0.1rem solid var(--confetti);
  border-right: 0.1rem solid var(--confetti);
  border-radius: 58% 65% 40% 0;
  transform: rotate(18deg);
}

.party-confetti::after {
  top: 39%;
  left: 50%;
  width: 40%;
  height: 19%;
  border-top: 0.1rem solid var(--confetti);
  border-radius: 72% 45% 0 0;
  transform: rotate(-26deg);
}
.public-settings-button,
.reset-button,
.icon-button,
.save-order-button,
.page-button {
  border: 1px solid var(--border);
  border-radius: 0.65rem;
  background: var(--card);
  color: var(--text);
}

.public-settings-button,
.reset-button,
.page-button {
  flex-shrink: 0;
  min-height: 2.75rem;
  padding: 0.375rem clamp(0.625rem, 2.5vw, 1rem);
  font-size: 0.875rem;
  font-weight: 600;
}

.page-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  touch-action: manipulation;
  white-space: nowrap;
}

.reset-button {
  position: absolute;
  bottom: max(1rem, env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  min-width: 6.5rem;
}

.storage-notice {
  position: absolute;
  z-index: 3;
  bottom: max(4.5rem, calc(env(safe-area-inset-bottom) + 3.5rem));
  left: 50%;
  width: max-content;
  max-width: calc(100% - 2rem);
  margin: 0;
  padding: 0.55rem 0.8rem;
  border: 1px solid var(--border);
  border-radius: 0.65rem;
  background: var(--panel);
  color: var(--text);
  font-size: 0.875rem;
  text-align: center;
  transform: translateX(-50%);
  pointer-events: none;
}

.public-settings-button:disabled {
  opacity: 0.55;
}

dialog {
  --focus: var(--accent);
  width: min(26rem, calc(100% - 2rem));
  max-width: none;
  max-height: calc(100% - 2rem);
  margin: auto;
  padding: 0;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 1.25rem;
  background: var(--panel);
  color: var(--text);
  box-shadow: 0 1.5rem 4rem #24252a30;
}

dialog::backdrop {
  background: #24252a66;
}

.order-dialog {
  color-scheme: only dark;
  --accent: #f28db5;
  --panel: #1c101f;
  --card: #321e38;
  --border: #69445f;
  --selected-card: #51304c;
  --muted: #cfb4cb;
  --text: #f5e4ef;
  --drawn-text: #b29ab0;
  border-color: #8a3554;
  box-shadow: 0 1.25rem 3.5rem #09040dd9, 0 0 1.75rem #a42a594d;
}

.order-dialog::backdrop {
  background: #100617d9;
}

.order-dialog .settings-header h2 {
  color: #ff8d9d;
}

.order-dialog .close-button,
.order-dialog .order-status[data-next] {
  color: var(--accent);
}

@media (prefers-reduced-motion: no-preference) {
  .order-dialog,
  .order-dialog::backdrop {
    opacity: 0;
    transition: opacity 240ms ease, display 240ms, overlay 240ms;
    transition-behavior: allow-discrete;
  }

  .order-dialog[open],
  .order-dialog[open]::backdrop {
    opacity: 1;
  }

  @starting-style {
    .order-dialog[open],
    .order-dialog[open]::backdrop {
      opacity: 0;
    }
  }
}

.settings-panel {
  display: grid;
  gap: 1rem;
  padding: clamp(1rem, 5vw, 1.5rem);
}

.settings-header,
.settings-footer,
.edit-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.settings-header,
.settings-footer {
  justify-content: space-between;
  flex-wrap: wrap;
}

.settings-header h2 {
  margin: 0;
  font-size: 1.375rem;
  line-height: 1.3;
}

.settings-option {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-height: 2.75rem;
  padding-inline: 0.25rem;
}

label.settings-option {
  cursor: pointer;
}

.settings-option input[type="checkbox"] {
  appearance: none;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  width: 1.25rem;
  height: 1.25rem;
  margin: 0;
  border: 1px solid var(--border);
  border-radius: 0.25rem;
  background: var(--card);
  color: var(--panel);
  cursor: inherit;
}

.settings-option input:checked {
  border-color: var(--accent);
  background: var(--accent);
}

.settings-option input:checked::before {
  width: 0.35rem;
  height: 0.65rem;
  border: solid currentColor;
  border-width: 0 2px 2px 0;
  transform: translateY(-1px) rotate(45deg);
  content: "";
}

@media (forced-colors: active) {
  .settings-option input[type="checkbox"] {
    appearance: auto;
  }

  .settings-option input:checked::before {
    content: none;
  }
}

.display-mode-setting {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 0.75rem;
  min-height: 2.75rem;
  padding-inline: 0.25rem;
}

.display-mode-picker {
  position: relative;
}

.display-mode-picker select {
  appearance: none;
  width: 100%;
  min-width: 0;
  min-height: 2.75rem;
  padding: 0.375rem 1.75rem 0.375rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: 0.65rem;
  background: var(--card);
  color: inherit;
  font-size: 0.9375rem;
  cursor: pointer;
}

.name-list {
  display: grid;
  gap: 0.5rem;
  max-height: 48vh;
  max-height: 48dvh;
  overflow: auto;
  margin: 0;
  padding: 0.25rem;
  list-style: none;
}

.name-list:empty {
  display: none;
}

.name-card {
  display: flex;
  align-items: center;
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: 0.65rem;
  background: var(--card);
}

.name-card.is-selected {
  border-color: var(--accent);
  background: var(--selected-card);
}

.name-card input,
.order-picker select {
  width: 100%;
  min-width: 0;
  min-height: 3rem;
  padding: 0.5rem 0.75rem;
  border: 0;
  border-radius: inherit;
  background: transparent;
  color: inherit;
}

.order-position {
  flex: 0 0 2.75rem;
  min-height: 3rem;
  padding: 0.25rem;
  border: 0;
  border-radius: inherit;
  background: transparent;
  color: var(--muted);
  font-size: 0.875rem;
  font-variant-numeric: tabular-nums;
}

.name-card.is-selected .order-position {
  color: var(--text);
}

.order-picker {
  position: relative;
  flex: 1;
  min-width: 0;
}

.order-picker::after,
.display-mode-picker::after {
  position: absolute;
  top: 50%;
  inset-inline-end: 0.75rem;
  width: 0.45rem;
  height: 0.45rem;
  border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted);
  transform: translateY(-70%) rotate(45deg);
  pointer-events: none;
  content: "";
}

.order-picker select {
  appearance: none;
  padding-inline: 0.25rem 1.75rem;
  text-overflow: ellipsis;
  cursor: pointer;
}

.order-picker option,
.display-mode-picker option {
  background: var(--card);
  color: var(--text);
}

.name-card input::placeholder {
  color: var(--muted);
}

.name-card.is-drawn input,
.name-card.is-drawn select {
  color: var(--drawn-text);
}

.order-picker select.has-excluded-name {
  color: transparent;
}

.order-current-name {
  position: absolute;
  top: 50%;
  inset-inline: 0.25rem 1.75rem;
  overflow: hidden;
  transform: translateY(-50%);
  color: var(--muted);
  text-overflow: ellipsis;
  white-space: nowrap;
  pointer-events: none;
}

.name-card.is-drawn .order-current-name {
  color: var(--drawn-text);
}

.name-card input:focus-visible,
.order-position:focus-visible,
.order-picker select:focus-visible {
  outline-offset: -4px;
}

.order-status {
  flex-shrink: 0;
  margin-inline-end: 0.75rem;
  color: var(--muted);
  font-size: 0.875rem;
  white-space: nowrap;
}

.order-status[data-next] {
  color: var(--text);
  font-weight: 600;
}

.empty-list {
  margin: 0;
  padding: 0.75rem;
  color: var(--muted);
}

.icon-button {
  min-width: 2.75rem;
  min-height: 2.75rem;
  padding: 0.25rem;
  font-size: 1.25rem;
  line-height: 1;
}

.close-button {
  border-color: transparent;
  background: transparent;
}

.save-order-button {
  min-height: 2.75rem;
  padding-inline: 0.75rem;
  font-size: 0.875rem;
}

.icon-button:disabled {
  opacity: 0.42;
}

@media (hover: hover) {
  .page-button:hover,
  .public-settings-button:not(:disabled):hover,
  .save-order-button:hover,
  .reset-button:hover,
  .icon-button:not(:disabled):hover {
    border-color: var(--accent);
  }
}

.home-page {
  display: grid;
  min-height: 100vh;
  min-height: 100dvh;
  padding: 1rem;
  place-items: center;
}

.home-content,
.home-actions {
  display: grid;
  justify-items: center;
}

.home-content {
  min-width: 0;
  max-width: 100%;
  gap: clamp(1.75rem, 5vh, 2.75rem);
  text-align: center;
}

.home-title {
  justify-content: center;
  gap: 0.55rem;
  font-size: clamp(1.45rem, 6.25vw, 3.3rem);
  text-wrap: balance;
}

#home-cracker {
  cursor: pointer;
  touch-action: manipulation;
  --confetti: #ff4470;
}

.order-guide {
  line-height: 1.6;
  overflow-wrap: anywhere;
}

.order-guide p {
  margin: 0;
}

.order-guide-red {
  color: #ff7885;
}

.order-guide-blue {
  color: #8ebcff;
}

.home-actions {
  gap: 0.85rem;
}

.home-start {
  min-width: min(13rem, calc(100vw - 2rem));
  min-height: 3.75rem;
  border-color: #a85a1b;
  border-radius: 0.875rem;
  background: #ffad55;
  color: #3c2410;
  box-shadow: 0 0.375rem 0.875rem #a8561b24;
  font-size: 1.25rem;
  font-weight: 700;
}

@media (hover: hover) {
  .home-start:hover {
    border-color: #934a14;
    background: #ff992e;
  }
}

.page-link {
  display: inline-flex;
  align-items: center;
  min-height: 2.75rem;
  color: var(--stage-text);
  text-underline-offset: 0.23em;
}

.manual-header,
.manual-page {
  max-width: 45rem;
  margin-inline: auto;
  padding-inline: 1rem;
}

.manual-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  padding-top: max(1rem, env(safe-area-inset-top));
}

.manual-header .roulette-title {
  font-size: clamp(1rem, 4.2vw, 1.45rem);
  text-decoration: none;
}

.manual-page {
  padding-block: clamp(1.75rem, 6vw, 3rem) max(2rem, env(safe-area-inset-bottom));
  line-height: 1.75;
  overflow-wrap: anywhere;
}

.manual-page h1,
.manual-page h2 {
  margin: 0;
  color: var(--title-text);
  line-height: 1.25;
}

.manual-page h1 {
  font-size: clamp(1.8rem, 6vw, 2.5rem);
}

.manual-page h2 {
  font-size: 1.2rem;
}

.manual-page section {
  margin-top: 1.65rem;
  padding-top: 1.25rem;
  border-top: 1px solid #ffffff36;
}

.manual-page :is(p, ol, ul, dl) {
  margin-block: 0.6rem 0;
}

.manual-page :is(ol, ul) {
  padding-inline-start: 1.35rem;
}

.manual-page li + li {
  margin-top: 0.35rem;
}

.manual-modes {
  display: grid;
  gap: 0.6rem;
}

.manual-modes dt {
  font-weight: 700;
}

.manual-modes dd {
  margin: 0;
}

.visually-hidden {
  position: absolute;
  top: 0;
  left: 0;
  width: 1px;
  height: 1px;
  margin: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}
