:root {
  --bg-1: #fdf6ec;
  --bg-2: #f6e9d7;
  --ink: #2c2520;
  --panel: #fffdf8;
  --accent: #e06f3f;
  --accent-2: #3c8d7f;
  --danger: #b63d3d;
  --border: #d4c1aa;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: radial-gradient(circle at top right, var(--bg-1), var(--bg-2));
  color: var(--ink);
  font-family: "Trebuchet MS", "Segoe UI", sans-serif;
}

.app {
  max-width: 1100px;
  margin: 24px auto;
  padding: 0 16px;
  display: grid;
  gap: 20px;
  grid-template-columns: 1fr 1fr;
}

.disclaimer {
  max-width: 1100px;
  margin: 8px auto 18px;
  padding: 0 16px;
  color: #5c4f46;
  font-size: 0.85rem;
  line-height: 1.45;
}

.panel {
  background: var(--panel);
  border: 2px solid var(--border);
  border-radius: 18px;
  padding: 18px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.08);
}

h1 {
  margin: 0;
  font-size: 2rem;
}

.logo {
  display: block;
  width: min(100%, 260px);
  height: auto;
  margin: 0 0 12px;
  cursor: default;
}

.subtitle {
  margin-top: 8px;
  color: #544840;
}

.add-form {
  margin-top: 14px;
  display: flex;
  gap: 8px;
}

input,
select,
button {
  font: inherit;
}

input,
select {
  width: 100%;
  border: 2px solid var(--border);
  border-radius: 10px;
  padding: 10px;
}

button {
  border: none;
  border-radius: 10px;
  padding: 10px 14px;
  background: var(--accent);
  color: white;
  font-weight: 700;
  cursor: pointer;
}

button:hover {
  filter: brightness(0.95);
}

.options-list {
  margin: 14px 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 8px;
  max-height: 270px;
  overflow: auto;
}

.option-item {
  background: #fff8ef;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.option-left {
  min-width: 0;
  display: grid;
  gap: 6px;
}

.option-label {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.option-name-input {
  width: 100%;
  border: 1px solid #d7c7b3;
  border-radius: 8px;
  padding: 7px 9px;
  font-size: 1.1rem;
  font-weight: 700;
  color: #2f241c;
  background: #fffaf2;
}

.weight-wrap {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 700;
  color: #5f5148;
  font-size: 0.9rem;
}

.color-wrap {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  color: #5f5148;
  font-size: 0.9rem;
}

.color-input {
  width: 44px;
  min-width: 44px;
  height: 30px;
  padding: 2px;
  border: 2px solid var(--border);
  border-radius: 8px;
  background: #fff;
  cursor: pointer;
}

.weight-input {
  width: 84px;
  padding: 6px 8px;
  -moz-appearance: textfield;
}

.weight-input::-webkit-outer-spin-button,
.weight-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.weight-control {
  display: inline-flex;
  align-items: stretch;
  border: 2px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
}

.weight-control .weight-input {
  border: none;
  border-radius: 0;
  width: 68px;
}

.weight-step-controls {
  display: grid;
  grid-template-rows: 1fr 1fr;
  border-left: 1px solid var(--border);
}

.weight-step {
  width: 28px;
  padding: 0;
  display: grid;
  place-items: center;
  background: #f0dfcb;
  border-radius: 0;
}

.weight-step.up {
  border-bottom: 1px solid var(--border);
}

.weight-step::before {
  content: "";
  width: 0;
  height: 0;
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
}

.weight-step.up::before {
  border-bottom: 8px solid #51453d;
}

.weight-step.down::before {
  border-top: 8px solid #51453d;
}

.option-item button {
  background: var(--danger);
  padding: 6px 10px;
}

.buttons {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.spin-btn {
  background: var(--accent-2);
}

.secondary-btn {
  background: #74695f;
}

.result {
  margin: 12px 0 0;
  font-weight: 700;
  text-align: left;
  transform-origin: left center;
  transition: transform 220ms ease, color 220ms ease;
}

.result.winner-announce {
  color: var(--accent-2);
  transform: scale(1.08);
}

.wheel-panel {
  display: grid;
  place-items: center;
  position: relative;
  background:
    radial-gradient(circle at 20% 18%, rgba(151, 203, 255, 0.35), rgba(151, 203, 255, 0) 38%),
    radial-gradient(circle at 80% 25%, rgba(255, 193, 89, 0.28), rgba(255, 193, 89, 0) 40%),
    linear-gradient(160deg, #f8f6f2, #d6cec1);
  border-color: #b8aa95;
}

.pointer {
  width: 0;
  height: 0;
  border-left: 17px solid transparent;
  border-right: 17px solid transparent;
  border-top: 34px solid #251007;
  position: absolute;
  top: 24px;
  z-index: 5;
  filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.35));
}

.pointer::before {
  content: "";
  position: absolute;
  top: -31px;
  left: -9px;
  width: 0;
  height: 0;
  border-left: 9px solid transparent;
  border-right: 9px solid transparent;
  border-top: 22px solid #ff4638;
  opacity: 0.95;
}

canvas {
  width: min(100%, 580px);
  height: auto;
  cursor: pointer;
  outline: none;
  border-radius: 50%;
  box-shadow:
    0 20px 42px rgba(30, 20, 13, 0.34),
    0 7px 16px rgba(0, 0, 0, 0.2);
}

canvas:focus-visible {
  box-shadow: 0 0 0 4px rgba(60, 141, 127, 0.35);
  border-radius: 50%;
}

.wheel-hint {
  margin: 10px 0 0;
  color: #4f4137;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.confetti {
  position: fixed;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 40;
}

.confetti-piece {
  position: absolute;
  width: 10px;
  height: 16px;
  top: -24px;
  opacity: 0.9;
  transform: translate3d(0, 0, 0) rotate(0deg);
  animation: confetti-fall linear forwards;
}

@keyframes confetti-fall {
  to {
    transform: translate3d(var(--dx), 110vh, 0) rotate(var(--rot));
    opacity: 1;
  }
}

.winner-banner {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  pointer-events: none;
  opacity: 0;
  z-index: 45;
  text-align: center;
  padding: 24px;
}

.winner-banner .winner-text {
  font-size: clamp(2.2rem, 9vw, 6.2rem);
  font-weight: 900;
  letter-spacing: 0.04em;
  color: #ffffff;
  -webkit-text-stroke: 4px rgba(33, 16, 7, 0.88);
  paint-order: stroke fill;
  text-shadow: 0 8px 28px rgba(0, 0, 0, 0.45), 0 2px 4px rgba(0, 0, 0, 0.35);
}

.winner-banner.show {
  animation: winner-banner-fade 3s ease forwards;
}

@keyframes winner-banner-fade {
  0% {
    opacity: 0;
    transform: scale(0.94);
  }
  12% {
    opacity: 1;
    transform: scale(1);
  }
  70% {
    opacity: 1;
    transform: scale(1);
  }
  100% {
    opacity: 0;
    transform: scale(1.04);
  }
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  display: none;
  place-items: center;
  padding: 16px;
}

.modal.is-open {
  display: grid;
}

.modal-card {
  width: min(460px, 100%);
  background: white;
  border-radius: 16px;
  padding: 18px;
  border: 2px solid var(--border);
}

.modal-card h2 {
  margin: 0;
}

.rig-form {
  margin-top: 12px;
  display: grid;
  gap: 10px;
}

@media (max-width: 900px) {
  .app {
    grid-template-columns: 1fr;
  }
}
