:root {
  font-family: "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans KR", sans-serif;
  color: #24283b;
  background: #f5f6fb;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-optical-sizing: auto;
  font-weight: 400;
}

* { box-sizing: border-box; }

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  padding: 48px 20px;
  background:
    radial-gradient(circle at 8% 12%, #eae8ff 0, transparent 26rem),
    radial-gradient(circle at 95% 85%, #ffe9e5 0, transparent 27rem),
    #f5f6fb;
}

button, input { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }

.app { width: min(100%, 1030px); margin: 0 auto; }
.page-header { position: relative; margin-bottom: 32px; text-align: center; }
.eyebrow { margin: 0 0 8px; color: #8589a2; font-size: 11px; font-weight: 800; letter-spacing: .2em; }
h1 { margin: 0; color: #24283b; font-size: clamp(32px, 6vw, 44px); font-weight: 800; letter-spacing: -.06em; }
.subtitle { margin: 9px 0 0; color: #8589a2; font-size: 15px; }
.theme-toggle {
  position: absolute;
  top: 4px;
  right: 0;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 13px;
  border: 1px solid #e6e7ef;
  border-radius: 999px;
  background: #fff;
  color: #555a70;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: background 150ms ease, border-color 150ms ease, color 150ms ease;
}
.theme-toggle:hover { border-color: #c9c4e7; background: #f8f7ff; }
.theme-toggle:focus-visible { outline: 3px solid #8874ec; outline-offset: 3px; }
.theme-icon { color: #7565cc; font-size: 16px; line-height: 1; }

.game-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(290px, .85fr);
  gap: 24px;
  align-items: stretch;
}

.wheel-panel, .options-panel {
  border: 1px solid #e8e9f1;
  border-radius: 28px;
  background: #fff;
  box-shadow: 0 16px 50px #3336530b;
}

.wheel-panel { display: flex; flex-direction: column; align-items: center; padding: 34px 28px 25px; }
.wheel-wrap { position: relative; width: min(100%, 420px); aspect-ratio: 1; padding: 14px; }
.wheel {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  border: 8px solid #fff;
  border-radius: 50%;
  background: #f0eff5;
  box-shadow: 0 0 0 1px #e8e8f0, 0 10px 24px #292d4618, inset 0 0 0 1px #ffffff80;
  transform: rotate(0deg);
  transition: transform 5.2s cubic-bezier(.12, .72, .12, 1);
}

.wheel::after {
  position: absolute;
  inset: 0;
  border: 1px solid #ffffff55;
  border-radius: inherit;
  content: "";
  pointer-events: none;
}

.pointer {
  position: absolute;
  z-index: 3;
  top: 0;
  left: 50%;
  width: 0;
  height: 0;
  border-top: 28px solid #292d46;
  border-right: 17px solid transparent;
  border-left: 17px solid transparent;
  filter: drop-shadow(0 3px 2px #24283b30);
  transform: translateX(-50%);
}

.wheel-labels { position: absolute; inset: 0; }
.wheel-label {
  position: absolute;
  top: 50%;
  left: 50%;
  width: min(31%, 110px);
  overflow: hidden;
  color: #fff;
  font-size: clamp(10px, 1.5vw, 14px);
  font-weight: 800;
  line-height: 1.25;
  text-align: center;
  text-overflow: ellipsis;
  text-shadow: 0 1px 3px #20243c45;
  white-space: nowrap;
  transform:
    translate(-50%, -50%)
    rotate(var(--label-angle))
    translateY(calc(0px - var(--label-radius)))
    rotate(var(--reverse-angle));
}

.spin-button {
  position: absolute;
  z-index: 2;
  top: 50%;
  left: 50%;
  display: grid;
  width: clamp(76px, 22%, 96px);
  aspect-ratio: 1;
  place-content: center;
  padding: 0;
  border: 5px solid #fff;
  border-radius: 50%;
  background: #292d46;
  box-shadow: 0 4px 12px #292d4638;
  color: #fff;
  cursor: pointer;
  transform: translate(-50%, -50%);
  transition: background 160ms ease, transform 160ms ease, box-shadow 160ms ease;
}

.spin-button span { font-size: 17px; font-weight: 800; }
.spin-button small { margin-top: 1px; color: #c9cbe0; font-size: 9px; font-weight: 700; letter-spacing: .13em; }
.spin-button:not(:disabled):hover { background: #474d70; box-shadow: 0 6px 16px #292d4645; transform: translate(-50%, -50%) scale(1.06); }
.spin-button:focus-visible, .add-button:focus-visible, .delete-button:focus-visible { outline: 3px solid #8874ec; outline-offset: 4px; }
.spin-button:disabled { cursor: not-allowed; opacity: .8; }
.wheel-hint { min-height: 20px; margin: 16px 0 19px; color: #9295a8; font-size: 12px; text-align: center; }

.result {
  width: 100%;
  min-height: 86px;
  display: grid;
  align-content: center;
  padding: 12px 18px;
  border: 1px solid #eeeafd;
  border-radius: 18px;
  background: #f8f7ff;
  text-align: center;
}
.result-label { margin: 0 0 3px; color: #8d89a8; font-size: 11px; font-weight: 700; letter-spacing: .04em; }
.result-value { margin: 0; color: #6654c5; font-size: clamp(20px, 4vw, 28px); font-weight: 800; overflow-wrap: anywhere; }

.options-panel { padding: 30px 28px; }
.panel-heading { display: flex; justify-content: space-between; align-items: center; }
.panel-heading .eyebrow { margin-bottom: 5px; }
h2 { margin: 0; font-size: 23px; font-weight: 800; letter-spacing: -.04em; }
.item-count { padding: 6px 11px; border-radius: 99px; background: #f0effa; color: #7568b7; font-size: 12px; font-weight: 700; }

.add-form { display: flex; gap: 8px; margin-top: 24px; }
.add-form input {
  min-width: 0;
  flex: 1;
  padding: 12px 14px;
  border: 1px solid #e5e6ef;
  border-radius: 12px;
  background: #fbfbfd;
  color: #292d46;
  font-size: 14px;
  outline: none;
  transition: border-color 150ms ease, box-shadow 150ms ease;
}
.add-form input::placeholder { color: #b0b2c0; }
.add-form input:focus { border-color: #9c8beb; box-shadow: 0 0 0 3px #9c8beb24; }
.add-button { padding: 0 18px; border: 0; border-radius: 12px; background: #7765d1; color: #fff; font-size: 14px; font-weight: 700; cursor: pointer; transition: background 150ms ease; }
.add-button:hover { background: #6654c5; }
.list-caption { margin: 19px 0 11px; color: #999bad; font-size: 12px; }

.item-list { display: grid; gap: 9px; max-height: 290px; margin: 0; padding: 0 3px 0 0; overflow-y: auto; list-style: none; }
.item-row { display: flex; min-height: 48px; align-items: center; gap: 10px; padding: 8px 9px 8px 12px; border: 1px solid #eeeff4; border-radius: 13px; background: #fff; }
.item-dot { width: 11px; height: 11px; flex: 0 0 11px; border-radius: 50%; }
.item-name { min-width: 0; flex: 1; overflow: hidden; color: #45495c; font-size: 14px; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.delete-button { display: grid; width: 30px; height: 30px; flex: 0 0 30px; place-items: center; border: 0; border-radius: 9px; background: transparent; color: #a0a2b1; cursor: pointer; font-size: 19px; line-height: 1; }
.delete-button:hover { background: #fff0ef; color: #dd6b67; }
.empty-state { margin: 30px 0; color: #a0a2b1; font-size: 13px; line-height: 1.8; text-align: center; }
.empty-state[hidden] { display: none; }
footer { margin-top: 25px; color: #a1a3b2; font-size: 12px; text-align: center; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

:root[data-theme="dark"] {
  color-scheme: dark;
  color: #e8e9f2;
  background: #171927;
}

:root[data-theme="dark"] body {
  background:
    radial-gradient(circle at 8% 12%, #30294b 0, transparent 26rem),
    radial-gradient(circle at 95% 85%, #442b3c 0, transparent 27rem),
    #171927;
}

:root[data-theme="dark"] h1,
:root[data-theme="dark"] h2 { color: #f0f0f7; }
:root[data-theme="dark"] .eyebrow { color: #a2a4bb; }
:root[data-theme="dark"] .subtitle,
:root[data-theme="dark"] .wheel-hint,
:root[data-theme="dark"] .list-caption,
:root[data-theme="dark"] footer { color: #a2a4bb; }
:root[data-theme="dark"] .wheel-panel,
:root[data-theme="dark"] .options-panel {
  border-color: #34374d;
  background: #222537;
  box-shadow: 0 16px 50px #00000025;
}
:root[data-theme="dark"] .wheel {
  border-color: #303348;
  box-shadow: 0 0 0 1px #41445a, 0 10px 24px #00000035, inset 0 0 0 1px #ffffff20;
}
:root[data-theme="dark"] .wheel::after { border-color: #ffffff25; }
:root[data-theme="dark"] .pointer {
  border-top-color: #f1c75b;
  filter: drop-shadow(0 3px 3px #00000066);
}
:root[data-theme="dark"] .spin-button {
  border-color: #222537;
  background: #7565cc;
}
:root[data-theme="dark"] .spin-button small { color: #e2defb; }
:root[data-theme="dark"] .result {
  border-color: #403b5d;
  background: #2b2940;
}
:root[data-theme="dark"] .result-label { color: #b0aacd; }
:root[data-theme="dark"] .result-value { color: #c7baff; }
:root[data-theme="dark"] .item-count { background: #39344f; color: #c7baff; }
:root[data-theme="dark"] .add-form input {
  border-color: #41445a;
  background: #1c1f30;
  color: #f0f0f7;
}
:root[data-theme="dark"] .add-form input::placeholder { color: #8589a2; }
:root[data-theme="dark"] .item-row {
  border-color: #3a3d52;
  background: #282b3e;
}
:root[data-theme="dark"] .item-name { color: #e0e1ec; }
:root[data-theme="dark"] .delete-button { color: #a2a4bb; }
:root[data-theme="dark"] .delete-button:hover { background: #49313a; color: #ff9a94; }
:root[data-theme="dark"] .empty-state { color: #a2a4bb; }
:root[data-theme="dark"] .theme-toggle {
  border-color: #41445a;
  background: #222537;
  color: #e0e1ec;
}
:root[data-theme="dark"] .theme-toggle:hover { border-color: #70669d; background: #2b2e43; }
:root[data-theme="dark"] .theme-icon { color: #f1c75b; }

@media (max-width: 760px) {
  body { padding: 30px 16px; }
  .page-header { margin-bottom: 24px; }
  .theme-toggle { position: static; display: flex; width: fit-content; margin: 0 auto 15px; }
  .game-layout { grid-template-columns: minmax(0, 1fr); gap: 16px; max-width: 500px; margin: 0 auto; }
  .wheel-panel { padding: 25px 20px 20px; }
  .wheel-wrap { width: min(100%, 380px); }
  .options-panel { padding: 25px 22px; }
  .item-list { max-height: 240px; }
}

@media (max-width: 380px) {
  body { padding: 24px 12px; }
  .wheel-panel { padding: 21px 13px 17px; }
  .wheel-wrap { width: 100%; padding: 12px; }
  .wheel { border-width: 6px; }
  .pointer { border-top-width: 23px; border-right-width: 14px; border-left-width: 14px; }
  .options-panel { padding: 22px 17px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; }
}
