:root {
  --bg1: #ffd1dc;
  --bg2: #c3b1e1;
  --card: #fffafe;
  --ink: #574f63;
  --muted: #a99fb0;
  --accent: #ff9aa2;
  --accent-dark: #f4757f;
  --chip: #fdeef4;
  --shadow: 0 12px 30px rgba(150, 120, 180, 0.22);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  min-height: 100vh;
  font-family: "Apple SD Gothic Neo", "Malgun Gothic", "Segoe UI", system-ui, sans-serif;
  color: var(--ink);
  background: linear-gradient(160deg, var(--bg1), var(--bg2));
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 24px 16px 48px;
}

.card {
  width: 100%;
  max-width: 460px;
  background: var(--card);
  border-radius: 24px;
  box-shadow: var(--shadow);
  padding: 24px 20px 28px;
}

/* Header */
.app-header {
  text-align: center;
  margin-bottom: 18px;
}
.app-header h1 {
  margin: 0;
  font-size: 26px;
  letter-spacing: -0.5px;
}
.subtitle {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 14px;
}

/* Presets */
.presets {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin-bottom: 16px;
}
.preset-btn {
  border: 1.5px solid #f3d6e4;
  background: #fff;
  color: var(--accent-dark);
  font-weight: 700;
  font-size: 14px;
  padding: 8px 14px;
  border-radius: 999px;
  cursor: pointer;
  transition: transform 0.08s ease, background 0.15s ease;
}
.preset-btn:hover {
  background: var(--chip);
}
.preset-btn:active {
  transform: scale(0.94);
}

/* Menu input */
.menu-input {
  margin-bottom: 18px;
}
#addForm {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
}
#menuInput {
  flex: 1;
  border: 1.5px solid #ecdce8;
  border-radius: 12px;
  padding: 11px 13px;
  font-size: 15px;
  outline: none;
  transition: border-color 0.15s ease;
}
#menuInput:focus {
  border-color: var(--accent);
}
#menuInput.flash {
  border-color: var(--accent-dark);
  background: #fff0f4;
}
#menuInput.flash::placeholder {
  color: var(--accent-dark);
}
.add-btn {
  border: none;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  padding: 0 18px;
  border-radius: 12px;
  cursor: pointer;
  font-size: 15px;
  transition: background 0.15s ease, transform 0.08s ease;
}
.add-btn:hover {
  background: var(--accent-dark);
}
.add-btn:active {
  transform: scale(0.95);
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  min-height: 4px;
}
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--chip);
  color: var(--ink);
  border-radius: 999px;
  padding: 6px 8px 6px 12px;
  font-size: 13.5px;
  font-weight: 600;
}
.chip button {
  border: none;
  background: rgba(0, 0, 0, 0.08);
  color: var(--ink);
  width: 18px;
  height: 18px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 12px;
  line-height: 1;
  display: grid;
  place-items: center;
  padding: 0;
}
.chip button:hover {
  background: var(--accent);
  color: #fff;
}
.chips-empty {
  color: var(--muted);
  font-size: 13px;
}

/* Wheel */
.wheel-area {
  position: relative;
  display: flex;
  justify-content: center;
  margin: 6px 0 18px;
}
.pointer {
  position: absolute;
  top: -6px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 30px;
  color: var(--accent-dark);
  filter: drop-shadow(0 2px 2px rgba(0, 0, 0, 0.25));
  z-index: 2;
}
#wheel {
  width: 320px;
  height: 320px;
  max-width: 86vw;
  max-height: 86vw;
  border-radius: 50%;
  box-shadow: 0 8px 22px rgba(150, 120, 180, 0.25);
  background: #fff;
}

/* Controls */
.controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin-bottom: 18px;
}
.spin-btn {
  border: none;
  background: linear-gradient(135deg, var(--bg1), var(--bg2));
  color: #fff;
  font-weight: 800;
  font-size: 18px;
  padding: 13px 34px;
  border-radius: 14px;
  cursor: pointer;
  box-shadow: 0 6px 16px rgba(195, 177, 225, 0.5);
  transition: transform 0.08s ease, opacity 0.15s ease;
}
.spin-btn:active {
  transform: scale(0.96);
}
.spin-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  box-shadow: none;
}
.sound-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  color: var(--muted);
  cursor: pointer;
  user-select: none;
}
.sound-toggle input {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
}

/* Result */
.result {
  text-align: center;
  background: var(--chip);
  border-radius: 16px;
  padding: 16px;
  margin-bottom: 18px;
  animation: pop 0.4s ease;
}
.result.hidden {
  display: none;
}
.result-label {
  margin: 0;
  font-size: 13px;
  color: var(--muted);
}
.result-menu {
  margin: 4px 0 12px;
  font-size: 28px;
  font-weight: 800;
  color: var(--accent-dark);
  animation: glow 1.4s ease-in-out infinite alternate;
}
.result-actions {
  display: flex;
  gap: 8px;
  justify-content: center;
}
.ghost-btn {
  border: 1.5px solid var(--accent);
  background: #fff;
  color: var(--accent-dark);
  font-weight: 700;
  padding: 9px 14px;
  border-radius: 12px;
  cursor: pointer;
  font-size: 14px;
  transition: background 0.15s ease, transform 0.08s ease;
}
.ghost-btn:hover {
  background: var(--chip);
}
.ghost-btn:active {
  transform: scale(0.95);
}

/* History */
.history-area {
  border-top: 1px solid #f0e4ee;
  padding-top: 14px;
}
.history-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}
.history-head h2 {
  margin: 0;
  font-size: 15px;
}
.link-btn {
  border: none;
  background: none;
  color: var(--muted);
  font-size: 12.5px;
  cursor: pointer;
  text-decoration: underline;
}
.history {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 180px;
  overflow-y: auto;
}
.history li {
  display: flex;
  justify-content: space-between;
  font-size: 13.5px;
  padding: 6px 4px;
  border-radius: 8px;
}
.history li:nth-child(odd) {
  background: #fbf0f6;
}
.history .h-menu {
  font-weight: 700;
}
.history .h-time {
  color: var(--muted);
  font-size: 12px;
}
.history-empty {
  color: var(--muted);
  font-size: 13px;
  padding: 4px;
}

/* Confetti overlay */
.confetti-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 50;
}

@keyframes pop {
  0% {
    transform: scale(0.85);
    opacity: 0;
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}
@keyframes glow {
  from {
    text-shadow: 0 0 0 rgba(244, 117, 127, 0);
  }
  to {
    text-shadow: 0 0 14px rgba(244, 117, 127, 0.5);
  }
}
