main {
  padding-top: 2.5rem;
}

.roulette-header {
  margin-bottom: 1.75rem;
}

.roulette-stage {
  display: grid;
  justify-items: center;
  gap: 1rem;
  margin-bottom: 1.75rem;
}

.wheel-wrap {
  position: relative;
  width: min(100%, 26rem);
  max-width: 420px;
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  margin-top: 0.75rem;
}

.wheel-pointer {
  position: absolute;
  top: 1.35rem;
  left: 50%;
  z-index: 2;
  width: 0;
  height: 0;
  transform: translateX(-50%);
  border-left: 0.78rem solid transparent;
  border-right: 0.78rem solid transparent;
  border-top: 2.25rem solid var(--wa-ink);
  filter: drop-shadow(0 2px 0 rgba(26, 26, 26, 0.12));
}

#rouletteCanvas {
  width: 100%;
  height: 100%;
  display: block;
}

.spin-button {
  min-width: 9rem;
}

.spin-button:disabled,
.add-button:disabled,
.text-button:disabled,
.item-row input:disabled,
.delete-button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.spin-note {
  min-height: 1.5rem;
  color: var(--wa-gray);
  font-size: 0.85rem;
  text-align: center;
}

.result-area,
.history-area,
.editor-area {
  background: var(--wa-white);
  border: 1px solid var(--wa-gray-light);
  border-radius: 8px;
  padding: 1.1rem;
  margin-bottom: 1rem;
}

.result-area {
  text-align: center;
}

.result-area.is-fresh {
  animation: result-in 0.28s ease-out;
}

.result-kicker {
  margin: 0 0 0.15rem;
  color: var(--wa-gray);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
}

.result-text {
  margin: 0;
  color: var(--wa-ink);
  font-size: 1.2rem;
  font-weight: 700;
  line-height: 1.6;
  overflow-wrap: anywhere;
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.85rem;
}

.section-heading h2 {
  margin: 0;
  font-size: 1rem;
}

.limit-text,
.empty-text {
  color: var(--wa-gray);
  font-size: 0.82rem;
}

.text-button {
  padding: 0.25rem 0.45rem;
  border: 1px solid transparent;
  background: transparent;
  color: var(--wa-orange-dark);
  border-radius: 4px;
  font: inherit;
  font-size: 0.82rem;
  cursor: pointer;
}

.text-button:hover {
  border-color: var(--wa-orange-light);
  background: var(--wa-orange-pale);
}

.history-list {
  display: grid;
  gap: 0.35rem;
  padding-left: 1.4rem;
  color: var(--wa-ink-light);
}

.history-list li {
  overflow-wrap: anywhere;
}

.item-list {
  display: grid;
  gap: 0.55rem;
  margin-bottom: 0.85rem;
}

.item-label-row,
.item-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 5rem 2.4rem 2.25rem;
  gap: 0.45rem;
}

.item-label-row {
  margin-bottom: 0.4rem;
  padding: 0 0.15rem;
  color: var(--wa-gray);
  font-size: 0.75rem;
  font-weight: 700;
}

.item-label-row span:nth-child(2),
.item-label-row span:nth-child(3) {
  text-align: center;
}

.item-row {
  position: relative;
  align-items: center;
}

.item-row input {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--wa-gray-light);
  border-radius: 4px;
  padding: 0.62rem 0.65rem;
  color: var(--wa-ink);
  background: var(--wa-white);
  font: inherit;
  font-size: 0.92rem;
}

.item-row input:focus {
  outline: 2px solid var(--wa-orange-light);
  outline-offset: 1px;
  border-color: var(--wa-orange);
}

.ratio-input {
  text-align: right;
}

.color-button {
  width: 2.4rem;
  height: 2.25rem;
  border: 1px solid var(--wa-gray-light);
  border-radius: 4px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.4), transparent),
    var(--item-color);
  cursor: pointer;
}

.color-button:hover:not(:disabled),
.color-button[aria-expanded="true"] {
  border-color: var(--wa-orange-dark);
}

.color-popover {
  position: absolute;
  top: calc(100% + 0.4rem);
  right: 2.7rem;
  z-index: 4;
  display: flex;
  gap: 0.75rem;
  align-items: center;
  width: max-content;
  max-width: min(24rem, calc(100vw - 3rem));
  padding: 0.65rem;
  border: 1px solid var(--wa-gray-light);
  border-radius: 6px;
  background: var(--wa-white);
  box-shadow: 0 0.5rem 1rem rgba(26, 26, 26, 0.12);
}

.color-grid {
  display: grid;
  grid-template-columns: repeat(6, 1.6rem);
  gap: 0.35rem;
}

.color-swatch {
  width: 1.6rem;
  height: 1.6rem;
  border: 1px solid rgba(26, 26, 26, 0.18);
  border-radius: 4px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.45), transparent),
    var(--swatch-color);
  cursor: pointer;
}

.color-swatch[aria-pressed="true"] {
  outline: 2px solid var(--wa-ink);
  outline-offset: 1px;
}

.color-swatch:disabled {
  cursor: not-allowed;
  opacity: 0.28;
  background:
    linear-gradient(135deg, transparent 46%, rgba(26, 26, 26, 0.45) 47%, rgba(26, 26, 26, 0.45) 53%, transparent 54%),
    var(--swatch-color);
}

.color-wheel {
  position: relative;
  width: 8rem;
  height: 4.7rem;
  padding: 0;
  flex: 0 0 auto;
  overflow: hidden;
  border: 0;
  background: transparent;
  cursor: crosshair;
}

.color-wheel::before {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -3.35rem;
  width: 7.2rem;
  height: 7.2rem;
  transform: translateX(-50%);
  border-radius: 50%;
  background:
    conic-gradient(
      from 258deg,
      #FFD280,
      #FFC857,
      #FFBF69,
      #FFB347,
      #FFAA1A,
      #F5A623,
      #FF9933,
      #E88A00
    );
  border: 1px solid rgba(26, 26, 26, 0.12);
}

.color-wheel:hover::before,
.color-wheel:focus-visible::before {
  filter: saturate(1.08);
}

.color-wheel:focus-visible {
  outline: 2px solid var(--wa-ink);
  outline-offset: 2px;
}

.color-wheel-hole {
  pointer-events: none;
  position: absolute;
  left: 50%;
  bottom: -1.8rem;
  z-index: 1;
  width: 4.1rem;
  height: 4.1rem;
  transform: translateX(-50%);
  border-radius: 50%;
  background: var(--wa-white);
  border: 1px solid rgba(26, 26, 26, 0.08);
}

.color-wheel-marker {
  position: absolute;
  left: calc(50% - 0.39rem);
  bottom: 0.1rem;
  z-index: 2;
  width: 0.78rem;
  height: 0.78rem;
  transform:
    rotate(var(--marker-angle))
    translateX(3.05rem)
    rotate(calc(-1 * var(--marker-angle)));
  border-radius: 50%;
  background: var(--item-color);
  border: 2px solid var(--wa-white);
  box-shadow: 0 0 0 1px rgba(26, 26, 26, 0.35);
  pointer-events: none;
}

.delete-button {
  width: 2.25rem;
  height: 2.25rem;
  border: 1px solid var(--wa-gray-light);
  border-radius: 4px;
  background: var(--wa-bg);
  color: var(--wa-ink-light);
  font: inherit;
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
}

.delete-button:hover:not(:disabled) {
  border-color: var(--wa-orange);
  color: var(--wa-orange-dark);
  background: var(--wa-orange-pale);
}

.add-button {
  width: 100%;
  border: 1px dashed var(--wa-orange);
  border-radius: 6px;
  background: var(--wa-orange-pale);
  color: var(--wa-orange-dark);
  padding: 0.75rem;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.add-button:hover:not(:disabled) {
  background: #ffe5bd;
}

.toast {
  min-height: 1.4rem;
  margin-top: 0.6rem;
  color: var(--wa-orange-dark);
  font-size: 0.82rem;
}

@keyframes result-in {
  from {
    opacity: 0.35;
    transform: translateY(0.35rem);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 768px) {
  .wheel-wrap {
    width: min(100%, 360px);
  }
}

@media (max-width: 420px) {
  main {
    padding-inline: 1rem;
  }

  .result-area,
  .history-area,
  .editor-area {
    padding: 0.95rem;
  }

  .item-row {
    grid-template-columns: minmax(0, 1fr) 3.8rem 2.25rem 2.15rem;
    gap: 0.35rem;
  }

  .item-label-row {
    grid-template-columns: minmax(0, 1fr) 3.8rem 2.25rem 2.15rem;
    gap: 0.35rem;
    font-size: 0.7rem;
  }

  .item-row input {
    padding-inline: 0.5rem;
  }

  .color-popover {
    right: 2.5rem;
    gap: 0.55rem;
    padding: 0.55rem;
  }

  .color-grid {
    grid-template-columns: repeat(6, 1.45rem);
    gap: 0.3rem;
  }

  .color-swatch {
    width: 1.45rem;
    height: 1.45rem;
  }

  .color-wheel {
    width: 6.4rem;
    height: 4rem;
  }

  .color-wheel::before {
    bottom: -2.8rem;
    width: 6rem;
    height: 6rem;
  }

  .color-wheel-hole {
    bottom: -1.45rem;
    width: 3.4rem;
    height: 3.4rem;
  }

  .color-wheel-marker {
    width: 0.68rem;
    height: 0.68rem;
    left: calc(50% - 0.34rem);
    transform:
      rotate(var(--marker-angle))
      translateX(2.55rem)
      rotate(calc(-1 * var(--marker-angle)));
  }
}
