/* 돌림판 · 룰렛. 칸 색은 캔버스에서 그리고, 나머지는 공통 변수를 써서 어두운 화면에 맞춘다. */
.rl {
  margin-top: 22px;
  display: grid;
  gap: 14px;
}
@media (min-width: 720px) {
  .rl {
    grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr);
    align-items: start;
  }
  .rl-hist {
    grid-column: 1 / -1;
  }
}
.rl-stage,
.rl-edit,
.rl-hist {
  padding: clamp(16px, 4vw, 22px);
}
.rl-stage {
  text-align: center;
  overflow: hidden; /* 색종이가 화면 밖으로 넘쳐 가로 스크롤이 생기지 않게 */
}

/* 돌림판 */
.rl-wheel {
  position: relative;
  width: min(100%, 420px);
  aspect-ratio: 1;
  margin: 14px auto 0;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.rl-canvas {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 6px 22px rgba(20, 24, 36, 0.16);
}
.rl-wheel.is-spinning .rl-canvas {
  cursor: progress;
}
/* 위쪽 바늘: 아래를 가리키는 삼각형 */
.rl-pointer {
  position: absolute;
  z-index: 2;
  left: 50%;
  top: -12px;
  width: 34px;
  height: 42px;
  transform: translateX(-50%);
  transform-origin: 50% 20%;
  background: var(--ink);
  clip-path: polygon(0 0, 100% 0, 50% 100%);
  filter: drop-shadow(0 2px 2px rgba(0, 0, 0, 0.25));
  pointer-events: none;
}
.rl-pointer::after {
  content: '';
  position: absolute;
  left: 50%;
  top: 7px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--surface);
  transform: translateX(-50%);
}
.rl-hub {
  position: absolute;
  z-index: 2;
  left: 50%;
  top: 50%;
  width: 22%;
  aspect-ratio: 1;
  min-width: 64px;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  border: 4px solid #fff;
  background: var(--ink);
  color: var(--bg);
  font: inherit;
  font-weight: 800;
  font-size: clamp(0.9rem, 3.6vw, 1.1rem);
  cursor: pointer;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.3);
  touch-action: manipulation;
  transition: transform 0.08s ease;
}
.rl-hub:active {
  transform: translate(-50%, -50%) scale(0.94);
}
.rl-hub:disabled {
  cursor: default;
  opacity: 0.85;
}
.rl-status {
  font-weight: 700;
  margin: 16px 0 10px;
  min-height: 1.7em;
}
.rl-spin {
  width: min(100%, 320px);
  min-height: 54px;
  font-size: 1.08rem;
}
.rl-spin:disabled {
  opacity: 0.55;
  cursor: default;
}

/* 결과 */
.rl-result {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}
.rl-big {
  font-size: clamp(2rem, 9vw, 3rem);
  font-weight: 800;
  line-height: 1.15;
  letter-spacing: -0.02em;
  margin: 4px 0 6px;
  overflow-wrap: anywhere;
}
.rl-sub {
  margin: 0;
}
.rl-result.pop .rl-big {
  animation: rl-pop 0.45s cubic-bezier(0.2, 0.9, 0.3, 1.35);
}
@keyframes rl-pop {
  from {
    transform: scale(0.6);
    opacity: 0;
  }
}

/* 색종이 */
.rl-fx {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 3;
}
.rl-fx i {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 9px;
  height: 14px;
  border-radius: 2px;
  opacity: 0;
  animation: rl-confetti 1.2s cubic-bezier(0.15, 0.7, 0.3, 1) forwards;
}
@keyframes rl-confetti {
  0% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(0.4);
  }
  80% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: translate(calc(-50% + var(--x)), calc(-50% + var(--y) + 60px)) rotate(var(--r)) scale(1);
  }
}

/* 항목 넣기 */
.rl-h {
  display: block;
  font-weight: 800;
  font-size: 1.05rem;
}
.rl-h .fine {
  font-weight: 500;
}
.rl-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 12px 0;
}
.rl-presets .chip {
  min-height: 36px;
  font-size: 0.88rem;
}
.rl-text {
  display: block;
  width: 100%;
  min-height: 210px;
  resize: vertical;
  font: inherit;
  font-size: 1rem; /* 16px: 아이폰에서 누를 때 화면이 확대되지 않게 */
  font-weight: 600;
  line-height: 1.6;
  color: var(--ink);
  background: var(--surface-2);
  border: 2px solid transparent;
  border-radius: 14px;
  padding: 10px 12px;
  outline: none;
}
.rl-text:focus {
  border-color: var(--brand);
  background: var(--surface);
}
.rl-text[aria-invalid='true'] {
  border-color: var(--wait);
}
.rl-text[readonly] {
  opacity: 0.7;
}
.rl-count {
  margin: 8px 0 0;
}
.rl-count.is-warn {
  color: var(--wait);
  font-weight: 700;
}
.rl-check {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
  font-weight: 700;
  cursor: pointer;
}
.rl-check input {
  width: 20px;
  height: 20px;
  margin: 0;
  accent-color: var(--brand);
  flex-shrink: 0;
}
.rl-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}
.rl-small {
  min-height: 40px;
  padding: 8px 14px;
  font-size: 0.9rem;
}
.rl-note {
  margin: 12px 0 0;
}

/* 지난 결과 */
.rl-hist h3 {
  margin: 0 0 10px;
  font-size: 1rem;
}
.rl-hist h3 .fine {
  font-weight: 500;
}
.rl-hist-list b {
  min-width: 0;
  overflow-wrap: anywhere;
}
.rl-hist-list time {
  flex-shrink: 0;
  font-size: 0.85rem;
}

@media (prefers-reduced-motion: reduce) {
  .rl-result.pop .rl-big,
  .rl-fx i {
    animation: none;
  }
}
