:root {
  color-scheme: light;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "PingFang SC", "Helvetica Neue", Arial, sans-serif;
  background: #f7f5ef;
  color: #252525;
  --result-color: #252525;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100svh;
  overflow-x: hidden;
  background:
    radial-gradient(circle at 18% 10%, rgba(255, 255, 255, 0.94), rgba(255, 255, 255, 0) 34%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.82), rgba(247, 245, 239, 0.96)),
    #f7f5ef;
}

html {
  overflow-x: hidden;
}

button,
input {
  font: inherit;
}

[hidden] {
  display: none !important;
}

button {
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition:
    transform 180ms ease,
    box-shadow 180ms ease,
    background 180ms ease,
    opacity 180ms ease;
}

.app-shell {
  width: min(100%, 520px);
  min-height: 100svh;
  margin: 0 auto;
  padding: max(18px, env(safe-area-inset-top)) 18px max(22px, env(safe-area-inset-bottom));
  display: grid;
  gap: 16px;
  align-content: start;
}

.wheel-panel,
.records-panel {
  background: rgba(255, 255, 255, 0.76);
  border: 1px solid rgba(36, 36, 36, 0.08);
  border-radius: 8px;
  box-shadow: 0 18px 52px rgba(33, 32, 29, 0.12);
  backdrop-filter: blur(18px);
}

.wheel-panel {
  padding: 18px;
}

.records-panel {
  padding: 16px;
}

.topbar,
.section-head,
.input-row,
.result-card,
.record-item {
  display: flex;
  align-items: center;
}

.topbar,
.section-head {
  justify-content: space-between;
  gap: 12px;
}

.eyebrow {
  margin: 0 0 4px;
  color: #6d6b65;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  max-width: min(100%, 250px);
  font-size: clamp(24px, 7vw, 34px);
  line-height: 1.08;
  white-space: normal;
  overflow-wrap: anywhere;
}

h1 span {
  display: block;
}

h2 {
  font-size: 21px;
  line-height: 1.15;
}

.icon-button,
.text-button,
.input-row button,
.spin-button {
  border: 0;
  color: #fff;
  background: #252525;
}

.icon-button {
  width: 44px;
  height: 44px;
  flex: 0 0 44px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 25px;
  line-height: 1;
}

.icon-button:hover,
.text-button:hover,
.input-row button:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 22px rgba(37, 37, 37, 0.16);
}

.icon-button:active,
.text-button:active,
.input-row button:active,
.spin-button:active {
  transform: scale(0.96);
}

.wheel-stage {
  position: relative;
  width: min(100%, 330px);
  aspect-ratio: 1;
  margin: 22px auto 18px;
  isolation: isolate;
}

canvas {
  position: relative;
  z-index: 1;
  width: 100%;
  height: 100%;
  display: block;
  border-radius: 50%;
  filter: drop-shadow(0 24px 26px rgba(31, 31, 31, 0.2));
  transition: transform 4.2s cubic-bezier(0.12, 0.67, 0.18, 1);
}

.wheel-glow {
  position: absolute;
  z-index: 0;
  inset: 5%;
  border-radius: 50%;
  background: conic-gradient(#ef4444, #f97316, #facc15, #22c55e, #ec4899, #3b82f6, #8b5cf6, #ef4444);
  opacity: 0.22;
  filter: blur(24px);
  transform: scale(0.92);
  transition:
    opacity 260ms ease,
    transform 260ms ease;
}

.pointer {
  position: absolute;
  z-index: 2;
  top: -3px;
  left: 50%;
  width: 30px;
  height: 42px;
  transform: translateX(-50%);
  clip-path: polygon(50% 100%, 0 0, 100% 0);
  background: #242424;
  filter: drop-shadow(0 4px 5px rgba(0, 0, 0, 0.2));
  transform-origin: 50% 8px;
}

.spin-button {
  position: absolute;
  z-index: 3;
  inset: 50% auto auto 50%;
  width: clamp(84px, 24vw, 108px);
  aspect-ratio: 1;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  border: 6px solid rgba(255, 255, 255, 0.92);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.24);
  font-weight: 800;
  font-size: 19px;
}

.spin-button::after {
  content: "";
  position: absolute;
  inset: -13px;
  border: 2px solid rgba(37, 37, 37, 0.12);
  border-radius: 50%;
  animation: buttonPulse 2.1s ease-in-out infinite;
}

.is-spinning .wheel-glow {
  opacity: 0.48;
  transform: scale(1.03);
  animation: glowSpin 1.1s linear infinite;
}

.is-spinning .pointer {
  animation: pointerTick 420ms ease-in-out infinite;
}

.is-spinning .spin-button {
  background: #111111;
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.28);
}

.spin-button:disabled,
.input-row button:disabled {
  opacity: 0.76;
  cursor: wait;
}

.draw-form {
  display: grid;
  gap: 8px;
}

.draw-form label {
  color: #44413b;
  font-size: 14px;
  font-weight: 700;
}

.input-row {
  gap: 10px;
}

input {
  min-width: 0;
  width: 100%;
  height: 52px;
  border: 1px solid rgba(37, 37, 37, 0.16);
  border-radius: 8px;
  padding: 0 14px;
  background: #fff;
  color: #252525;
  outline: none;
  transition:
    border-color 180ms ease,
    box-shadow 180ms ease,
    transform 180ms ease;
}

input:focus {
  border-color: #252525;
  box-shadow: 0 0 0 4px rgba(37, 37, 37, 0.08);
  transform: translateY(-1px);
}

.input-row button,
.text-button {
  height: 52px;
  border-radius: 8px;
  padding: 0 18px;
  font-weight: 800;
  white-space: nowrap;
}

.text-button {
  height: 42px;
  background: #ffffff;
  color: #252525;
  border: 1px solid rgba(37, 37, 37, 0.14);
}

.result-card {
  margin-top: 14px;
  min-height: 72px;
  padding: 12px;
  gap: 12px;
  border-radius: 8px;
  background:
    linear-gradient(90deg, color-mix(in srgb, var(--result-color), white 78%), #ffffff 56%);
  border: 1px solid color-mix(in srgb, var(--result-color), white 58%);
  box-shadow: 0 12px 26px color-mix(in srgb, var(--result-color), transparent 78%);
  animation: resultPop 520ms cubic-bezier(0.17, 0.84, 0.44, 1);
}

.result-dot,
.record-dot {
  display: block;
  border-radius: 50%;
  flex: 0 0 auto;
  border: 2px solid rgba(0, 0, 0, 0.12);
}

.result-dot {
  width: 44px;
  height: 44px;
  box-shadow: 0 0 0 8px color-mix(in srgb, var(--result-color), transparent 84%);
}

.result-card p {
  margin: 0 0 2px;
  color: #6d6b65;
  font-size: 14px;
}

.result-card strong {
  font-size: 22px;
}

.record-list {
  list-style: none;
  display: grid;
  gap: 10px;
  margin: 14px 0 0;
  padding: 0;
}

.record-item {
  min-height: 58px;
  gap: 11px;
  padding: 10px;
  border-radius: 8px;
  background: #fff;
  border: 1px solid rgba(37, 37, 37, 0.08);
  animation: recordIn 320ms ease both;
  transition:
    transform 180ms ease,
    box-shadow 180ms ease;
}

.record-item:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 22px rgba(33, 32, 29, 0.1);
}

.record-dot {
  width: 34px;
  height: 34px;
}

.record-main {
  min-width: 0;
  flex: 1;
}

.record-main strong,
.record-main span {
  display: block;
}

.record-main strong {
  overflow-wrap: anywhere;
}

.record-main span {
  margin-top: 1px;
  color: #6d6b65;
  font-size: 13px;
}

.record-color {
  font-weight: 800;
  white-space: nowrap;
}

.empty-state {
  margin: 16px 0 2px;
  color: #6d6b65;
  font-size: 14px;
}

.celebration-layer {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100svh;
  z-index: 50;
  contain: layout paint;
  pointer-events: none;
  overflow: hidden;
}

.confetti {
  position: absolute;
  top: 46%;
  left: 50%;
  width: var(--piece-width);
  height: var(--piece-height);
  border-radius: var(--piece-radius);
  background: var(--piece-color);
  opacity: 0;
  box-shadow: 0 8px 16px rgba(37, 37, 37, 0.1);
  transform: translate(-50%, -50%) rotate(var(--start-rotate));
  animation: confettiFly var(--duration) cubic-bezier(0.13, 0.74, 0.36, 1) forwards;
}

.confetti.ribbon {
  border-radius: 3px;
  transform-origin: 50% 50%;
}

.confetti.dot {
  border-radius: 999px;
}

.ribbon-burst {
  position: absolute;
  top: 46%;
  left: 50%;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--burst-color);
  box-shadow:
    0 0 24px color-mix(in srgb, var(--burst-color), transparent 18%),
    0 0 76px color-mix(in srgb, var(--burst-color), transparent 40%);
  transform: translate(-50%, -50%) scale(0.1);
  animation: ribbonBurst 760ms ease-out forwards;
}

@keyframes buttonPulse {
  0%,
  100% {
    opacity: 0.58;
    transform: scale(0.96);
  }
  50% {
    opacity: 0.18;
    transform: scale(1.1);
  }
}

@keyframes glowSpin {
  to {
    rotate: 1turn;
  }
}

@keyframes pointerTick {
  0%,
  100% {
    transform: translateX(-50%) rotate(0deg);
  }
  50% {
    transform: translateX(-50%) rotate(7deg);
  }
}

@keyframes resultPop {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.96);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes recordIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes confettiFly {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.42) rotate(var(--start-rotate));
  }
  9% {
    opacity: 1;
  }
  58% {
    opacity: 0.96;
  }
  to {
    opacity: 0;
    transform:
      translate(calc(-50% + var(--x)), calc(-50% + var(--y)))
      scale(var(--end-scale))
      rotate(var(--end-rotate));
  }
}

@keyframes ribbonBurst {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.1);
  }
  18% {
    opacity: 0.74;
    transform: translate(-50%, -50%) scale(3.4);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(8.4);
  }
}

@media (min-width: 860px) {
  .app-shell {
    width: min(100%, 940px);
    grid-template-columns: minmax(0, 1.12fr) minmax(310px, 0.88fr);
    align-items: start;
    padding-top: 42px;
  }

  h1 {
    max-width: none;
    font-size: 38px;
  }

  .wheel-stage {
    width: min(100%, 386px);
  }
}
