@import url('https://fonts.googleapis.com/css2?family=Gowun+Dodum&family=Noto+Sans+KR:wght@400;500;600;700&display=swap');

:root {
  font-family: "Noto Sans KR", sans-serif;
  color: #292b2d;
  background: #f7f4ef;
  font-synthesis: none;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  background: radial-gradient(ellipse at 50% 42%, #fffdfa 0%, #f7f4ef 65%);
}
button, a { -webkit-tap-highlight-color: transparent; }
button { font: inherit; cursor: pointer; border: 0; }
button:disabled { cursor: default; }
button:focus-visible, a:focus-visible, #result-text:focus-visible {
  outline: 3px solid #ba654f;
  outline-offset: 5px;
}
main {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 22px 28px;
  gap: 44px;
}
.change-button {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 24px;
  border: 1px solid #ddd7cf;
  border-radius: 30px;
  background: #fffdf9;
  font-size: 14px;
  font-weight: 600;
  box-shadow: 0 3px 0 #e8e2d9;
  transition: background .2s, transform .2s;
}
.change-button:hover:not(:disabled) { background: #f0e8dd; transform: translateY(-2px); }
.change-button:disabled { opacity: .45; }
.change-button svg { width: 18px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.wheel-stage { width: min(86svh, 720px, 100%); position: relative; }
.wheel-frame {
  position: relative;
  padding: 11px;
  border-radius: 50%;
  background: #27292a;
  border: 2px solid #161819;
  box-shadow: 0 8px 0 #151719, 0 20px 35px #29241c1c, inset 0 2px 1px #ffffff30;
}
#wheel { display: block; width: 100%; height: auto; overflow: visible; transform: rotate(0deg); }
.pin {
  position: absolute;
  z-index: 3;
  left: 50%;
  top: -20px;
  width: 36px;
  height: 48px;
  transform: translateX(-50%);
  background: #d96850;
  clip-path: polygon(0 0, 100% 0, 50% 100%);
  filter: drop-shadow(0 3px 1px #0004);
}
.pin::before { content: ""; display: block; height: 10px; background: #efaa90; }
.pin.tick { animation: tick .09s ease-out; }
@keyframes tick { 50% { transform: translateX(-50%) rotate(-12deg); } }
#spin {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 22%;
  aspect-ratio: 1;
  border-radius: 50%;
  background: #fffdf8;
  border: 6px solid #292b2d;
  box-shadow: 0 4px 0 #151719, 0 8px 12px #0002;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 5px;
  font-weight: 700;
  font-size: clamp(14px, 2.8vw, 22px);
  color: #292b2d;
}
#spin svg { width: 18px; fill: #d96850; }
#spin:hover:not(:disabled) { background: #fff1e5; }
#spin:disabled { color: #8b8881; }
.spinning #spin svg { animation: breathe .8s ease-in-out infinite alternate; }
@keyframes breathe { to { opacity: .25; } }
.wheel-label { font-family: "Gowun Dodum", sans-serif; font-size: 18px; fill: #414344; text-anchor: middle; }
footer { display: flex; justify-content: center; padding: 24px 20px 30px; }
.source-wrapper { position: relative; }
#source { background: transparent; color: #88827a; font-size: 12px; padding: 10px 16px; }
#source span { margin-left: 5px; }
#source-tooltip {
  position: absolute;
  bottom: calc(100% + 10px);
  left: 50%;
  transform: translateX(-50%);
  width: max-content;
  max-width: calc(100vw - 40px);
  border: 1px solid #e3ddd5;
  border-radius: 14px;
  padding: 18px 22px;
  background: #fffefa;
  box-shadow: 0 8px 25px #302a2114;
  z-index: 5;
}
#source-tooltip a { color: #57514a; font-size: 13px; text-decoration: none; }
#source-tooltip a:hover { text-decoration: underline; }
dialog {
  padding: 32px;
  width: min(480px, calc(100vw - 32px));
  border: 1px solid #e9e1d8;
  border-radius: 24px;
  color: #33302e;
  background: #fffdf9;
  box-shadow: 0 24px 100px #0003;
}
dialog::backdrop { background: #24232166; backdrop-filter: blur(6px); }
dialog h2 { font-size: 20px; font-weight: 600; text-align: center; margin: 8px 0 32px; }
.dialog-actions { display: flex; gap: 12px; }
.dialog-actions button { flex: 1; }
.primary, .secondary { border-radius: 12px; padding: 14px 24px; font-weight: 600; font-size: 15px; }
.primary { background: #303333; color: #fffdf7; }
.primary:hover { background: #4c5050; }
.secondary { background: #eee9e2; color: #666057; }
.secondary:hover { background: #e3dcd2; }
#result-dialog { width: min(560px, calc(100vw - 32px)); max-height: 86svh; }
#result-dialog[open] { display: flex; flex-direction: column; }
.winner-highlight {
  fill: #ffe9a51c;
  stroke: #e6b345;
  stroke-width: 6px;
  stroke-linejoin: round;
  pointer-events: none;
  filter: drop-shadow(0 0 6px #ffd477);
  animation: winner-glow .5s ease-out both;
}
@keyframes winner-glow { from { opacity: .25; } to { opacity: 1; } }
#result-dialog.celebrating { animation: result-enter .4s cubic-bezier(.2,.8,.2,1) both; }
@keyframes result-enter {
  from { opacity: 0; transform: translateY(12px) scale(.94); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.result-line { animation: line-enter .55s ease-out both; }
@keyframes line-enter {
  from { opacity: 0; transform: translateY(10px); filter: blur(3px); }
  to { opacity: 1; transform: translateY(0); filter: blur(0); }
}
.result-line { display: block; max-width: 100%; }
#show-all { flex-shrink: 0; margin-top: 12px; }
#confetti { position: absolute; inset: 0; overflow: hidden; pointer-events: none; border-radius: inherit; z-index: 2; }
.confetti-piece {
  position: absolute;
  top: 45%;
  left: var(--origin);
  width: 8px;
  height: 13px;
  background: var(--color);
  animation: confetti-flight 1.5s ease-out both;
}
.confetti-piece.heart { width: auto; height: auto; background: none; color: var(--color); font-size: 18px; }
@keyframes confetti-flight {
  0% { opacity: 0; transform: translate(0, 0) rotate(0); }
  12% { opacity: 1; }
  45% { transform: translate(var(--dx), var(--rise)) rotate(var(--turn)); opacity: 1; }
  100% { transform: translate(var(--dx), 220px) rotate(var(--end-turn)); opacity: 0; }
}
.result-decoration { text-align: center; font-size: 30px; color: #d4846c; margin-bottom: 14px; }
#result-text {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  overflow-y: auto;
  min-height: 0;
  font-family: "Gowun Dodum", sans-serif;
  font-size: 19px;
  line-height: 1.8;
  text-align: center;
  padding: 4px 12px 24px;
  scrollbar-width: thin;
}
#again { flex-shrink: 0; width: 100%; margin-top: 18px; }
#again span { margin-left: 8px; }
#error { max-width: 440px; font-size: 14px; color: #a04435; text-align: center; line-height: 1.8; }
@media (max-width: 480px) {
  main { padding: 32px 18px 20px; gap: 40px; }
  .wheel-frame { padding: 8px; }
  #spin { border-width: 4px; }
  .pin { width: 28px; height: 38px; top: -16px; }
  dialog { padding: 24px; }
}
@media (prefers-reduced-motion: reduce) {
  .winner-highlight, #result-dialog.celebrating, .result-line { animation: none; }
  #confetti { display: none; }
  .pin.tick, .spinning #spin svg { animation: none; }
  .change-button { transition: none; }
}
