:root {
  --bg-1: #ffe4f1;
  --bg-2: #fff4d6;
  --bg-3: #d6f0ff;
  --bg-4: #e8e0ff;
  --primary: #ff7eb3;
  --primary-dark: #ff4d8d;
  --secondary: #ffb86b;
  --accent: #8ad8ff;
  --purple: #b8a4ff;
  --mint: #9be9c7;
  --text: #4a3b52;
  --text-soft: #8b7a93;
  --card: #ffffff;
  --shadow: 0 18px 40px rgba(255, 126, 179, 0.22);
  --shadow-soft: 0 6px 20px rgba(0, 0, 0, 0.06);
  --radius-lg: 32px;
  --radius-md: 20px;
  --radius-sm: 14px;

  --c-thai: #ffb8d0;
  --c-french: #c7baff;
  --c-isan: #ffc99c;
  --c-south: #a5e8c5;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: 'Mali', system-ui, sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at 20% 10%, var(--bg-1) 0%, transparent 45%),
    radial-gradient(circle at 80% 0%, var(--bg-2) 0%, transparent 40%),
    radial-gradient(circle at 90% 80%, var(--bg-3) 0%, transparent 45%),
    radial-gradient(circle at 10% 90%, var(--bg-4) 0%, transparent 45%),
    #fff8fc;
  min-height: 100vh;
  overflow-x: hidden;
}

.bg-deco {
  position: fixed; inset: 0;
  pointer-events: none; z-index: 0; overflow: hidden;
}
.float {
  position: absolute;
  font-size: 38px;
  opacity: 0.4;
  animation: float 9s ease-in-out infinite;
  filter: drop-shadow(0 4px 6px rgba(0,0,0,0.06));
}
.f1 { top: 6%; left: 5%; animation-delay: 0s; }
.f2 { top: 12%; right: 7%; animation-delay: 1.2s; }
.f3 { top: 40%; left: 2%; animation-delay: 2.4s; }
.f4 { top: 58%; right: 4%; animation-delay: 0.6s; }
.f5 { bottom: 6%; left: 10%; animation-delay: 1.8s; }
.f6 { bottom: 12%; right: 12%; animation-delay: 3s; }
.f7 { top: 28%; right: 20%; animation-delay: 2s; font-size: 28px; }
.f8 { bottom: 28%; left: 20%; animation-delay: 1.4s; font-size: 28px; }
.f9 { top: 18%; left: 40%; font-size: 22px; animation-delay: 2.8s; }
.f10 { bottom: 22%; right: 30%; font-size: 22px; animation-delay: 0.9s; }

@keyframes float {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  50% { transform: translateY(-25px) rotate(8deg); }
}

.app {
  position: relative; z-index: 1;
  max-width: 720px;
  margin: 0 auto;
  padding: 24px 16px 60px;
}

/* ===== Mascot ===== */
.mascot {
  position: relative;
  width: 110px; height: 130px;
  margin: 0 auto 8px;
}
.mascot-body {
  width: 100px; height: 100px;
  margin: 0 auto;
  background: linear-gradient(180deg, #fff 0%, #fff5fa 100%);
  border-radius: 50% 50% 48% 48% / 55% 55% 45% 45%;
  border: 4px solid #4a3b52;
  position: relative;
  animation: bob 2.2s ease-in-out infinite;
  box-shadow: 0 8px 0 -2px rgba(74, 59, 82, 0.15);
}
.mascot-body::before, .mascot-body::after {
  content: '';
  position: absolute;
  width: 10px; height: 16px;
  background: #4a3b52;
  top: 18px;
  border-radius: 50%;
}
.mascot-body::before { left: 0px; transform: rotate(-20deg); }
.mascot-body::after  { right: 0px; transform: rotate(20deg); }

.mascot-face { position: absolute; inset: 0; }
.mascot-face .eye {
  position: absolute;
  width: 10px; height: 14px;
  background: #4a3b52;
  border-radius: 50%;
  top: 38px;
  animation: blink 4s infinite;
}
.eye.left { left: 28px; }
.eye.right { right: 28px; }
@keyframes blink {
  0%, 92%, 100% { transform: scaleY(1); }
  95% { transform: scaleY(0.1); }
}
.cheek {
  position: absolute;
  width: 14px; height: 8px;
  background: #ffb6cf;
  border-radius: 50%;
  top: 55px;
  opacity: 0.8;
}
.cheek.left { left: 16px; }
.cheek.right { right: 16px; }
.mouth {
  position: absolute;
  width: 16px; height: 10px;
  border-bottom: 3px solid #4a3b52;
  border-radius: 0 0 16px 16px;
  left: 50%;
  top: 58px;
  transform: translateX(-50%);
}

.speech {
  position: absolute;
  top: -8px; right: -68px;
  background: white;
  border: 2px solid #4a3b52;
  padding: 6px 12px;
  border-radius: 16px 16px 16px 4px;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  animation: wobble 3s ease-in-out infinite;
  box-shadow: 0 3px 0 rgba(74,59,82,0.12);
}
.speech::before {
  content: '';
  position: absolute;
  left: -10px; bottom: -2px;
  width: 12px; height: 12px;
  background: white;
  border-left: 2px solid #4a3b52;
  border-bottom: 2px solid #4a3b52;
  border-radius: 0 0 0 8px;
}

@keyframes bob {
  0%, 100% { transform: translateY(0) rotate(-2deg); }
  50% { transform: translateY(-6px) rotate(2deg); }
}
@keyframes wobble {
  0%, 100% { transform: rotate(-3deg); }
  50% { transform: rotate(3deg); }
}

/* ===== Hero ===== */
.hero { text-align: center; margin-bottom: 18px; }
.hero h1 {
  font-family: 'Itim', cursive;
  font-size: clamp(30px, 6.5vw, 46px);
  margin: 12px 0 6px;
  background: linear-gradient(90deg, var(--primary-dark) 0%, var(--secondary) 50%, var(--purple) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-shadow: 2px 2px 0 rgba(255, 184, 208, 0.3);
}
.qm {
  display: inline-block;
  color: var(--primary-dark);
  -webkit-text-fill-color: var(--primary-dark);
  animation: jump 1.2s ease-in-out infinite;
}
@keyframes jump {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px) scale(1.2); }
}
.wiggle {
  display: inline-block;
  animation: wiggle 1.4s ease-in-out infinite;
}
@keyframes wiggle {
  0%, 100% { transform: rotate(-12deg); }
  50% { transform: rotate(12deg); }
}
.subtitle { margin: 0; color: var(--text-soft); font-size: 15px; }

/* ===== Filter Chips ===== */
.filters {
  background: var(--card);
  padding: 18px;
  border-radius: var(--radius-lg);
  border: 3px solid #4a3b52;
  box-shadow: 0 6px 0 #4a3b52, var(--shadow-soft);
  margin-bottom: 28px;
}
.filter-title {
  margin: 0 0 12px;
  font-weight: 700;
  font-size: 15px;
  text-align: center;
}
.hint { color: var(--text-soft); font-weight: 400; font-size: 12px; }

.chips {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
}
@media (max-width: 600px) {
  .chips { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 380px) {
  .chips { grid-template-columns: repeat(2, 1fr); }
}
.chip {
  display: flex; flex-direction: column;
  align-items: center; gap: 4px;
  padding: 10px 4px;
  border: 3px solid #4a3b52;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.15s ease;
  background: #fafafa;
  user-select: none;
  font-weight: 700;
  position: relative;
  text-align: center;
}
.chip:hover {
  transform: translateY(-3px) rotate(-2deg);
}
.chip input { display: none; }
.chip-emoji { font-size: 24px; line-height: 1; }
.chip-text { font-size: 11px; line-height: 1.2; }
.chip:has(input:checked) {
  background: var(--chip-color);
  box-shadow: 0 4px 0 #4a3b52;
}
.chip:has(input:not(:checked)) { opacity: 0.35; }
.chip:has(input:checked)::after {
  content: '✓';
  position: absolute;
  top: -8px; right: -8px;
  width: 22px; height: 22px;
  background: #4a3b52;
  color: white;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px;
}

/* ===== Wheel ===== */
.wheel-section {
  display: flex; justify-content: center;
  margin-bottom: 32px;
}
.wheel-wrap {
  position: relative;
  width: min(420px, 92vw);
  aspect-ratio: 1 / 1;
}

.pointer {
  position: absolute;
  top: -8px; left: 50%;
  transform: translateX(-50%);
  z-index: 5;
  filter: drop-shadow(0 4px 6px rgba(0,0,0,0.25));
}
.pointer-shape {
  width: 40px; height: 50px;
  background: linear-gradient(180deg, #ff4d8d, #ff7eb3);
  border: 3px solid #4a3b52;
  clip-path: polygon(50% 100%, 0% 0%, 100% 0%);
  position: relative;
}
.pointer::after {
  content: '';
  position: absolute;
  top: -8px; left: 50%;
  transform: translateX(-50%);
  width: 20px; height: 20px;
  background: #ff4d8d;
  border: 3px solid #4a3b52;
  border-radius: 50%;
  z-index: -1;
}

.wheel-container {
  position: relative;
  width: 100%; height: 100%;
  border-radius: 50%;
  border: 6px solid #4a3b52;
  box-shadow:
    0 0 0 8px white,
    0 0 0 11px #4a3b52,
    0 12px 30px rgba(255, 77, 141, 0.4),
    inset 0 0 30px rgba(255, 255, 255, 0.3);
  overflow: hidden;
  background: white;
}

#wheel {
  width: 100%; height: 100%;
  display: block;
}

.spin-center {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: 25%; height: 25%;
  border-radius: 50%;
  border: 4px solid #4a3b52;
  background: linear-gradient(135deg, #ff4d8d, #ff7eb3);
  color: white;
  font-family: 'Itim', cursive;
  font-size: clamp(16px, 3vw, 22px);
  font-weight: 700;
  cursor: pointer;
  z-index: 4;
  box-shadow: 0 5px 0 #4a3b52, 0 8px 20px rgba(255, 77, 141, 0.4);
  transition: all 0.1s ease;
  animation: pulse 1.8s ease-in-out infinite;
}
.spin-center:hover {
  transform: translate(-50%, -52%);
  box-shadow: 0 7px 0 #4a3b52, 0 10px 24px rgba(255, 77, 141, 0.5);
}
.spin-center:active {
  transform: translate(-50%, -48%);
  box-shadow: 0 3px 0 #4a3b52;
}
.spin-center:disabled {
  cursor: not-allowed;
  opacity: 0.7;
  animation: none;
}
@keyframes pulse {
  0%, 100% { box-shadow: 0 5px 0 #4a3b52, 0 0 0 0 rgba(255, 77, 141, 0.4); }
  50%      { box-shadow: 0 5px 0 #4a3b52, 0 0 0 12px rgba(255, 77, 141, 0); }
}

.sparkles {
  position: absolute;
  inset: -40px;
  pointer-events: none;
}
.sparkle {
  position: absolute;
  font-size: 24px;
  animation: sparkle-pop 1s ease-out forwards;
}
@keyframes sparkle-pop {
  0% { transform: translate(0, 0) scale(0) rotate(0deg); opacity: 1; }
  100% { transform: translate(var(--dx), var(--dy)) scale(1.4) rotate(360deg); opacity: 0; }
}

/* ===== Result Card ===== */
.result-card {
  background: var(--card);
  border: 4px solid #4a3b52;
  border-radius: var(--radius-lg);
  padding: 24px 22px 22px;
  box-shadow: 0 8px 0 #4a3b52, var(--shadow);
  text-align: center;
  margin-bottom: 28px;
  position: relative;
  animation: popIn 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.result-card.hidden { display: none; }

@keyframes popIn {
  0% { transform: scale(0.5) rotate(-8deg); opacity: 0; }
  100% { transform: scale(1) rotate(0); opacity: 1; }
}

.close-btn {
  position: absolute;
  top: 10px; right: 12px;
  width: 32px; height: 32px;
  border-radius: 50%;
  border: 2px solid #4a3b52;
  background: white;
  font-size: 20px;
  font-weight: 700;
  cursor: pointer;
  line-height: 0;
}
.close-btn:hover { background: #ffe4f1; }

.result-header {
  display: flex; align-items: center; justify-content: center;
  gap: 10px; flex-wrap: wrap;
  margin-bottom: 10px;
}
.result-label {
  font-family: 'Itim', cursive;
  font-size: 18px;
  color: var(--primary-dark);
}
.badge {
  display: inline-block;
  padding: 4px 12px;
  background: #4a3b52;
  color: white;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}
.dish-emoji {
  font-size: 80px;
  margin: 6px 0 10px;
  display: block;
  animation: bouncePop 0.7s ease;
}
@keyframes bouncePop {
  0% { transform: scale(0) rotate(-30deg); }
  60% { transform: scale(1.25) rotate(10deg); }
  100% { transform: scale(1) rotate(0); }
}
.dish-name {
  font-family: 'Itim', cursive;
  font-size: 30px;
  margin: 0 0 2px;
}
.dish-en {
  margin: 0 0 12px;
  color: var(--text-soft);
  font-style: italic;
  font-size: 13px;
}
.dish-desc {
  margin: 0 0 14px;
  font-size: 14px;
  line-height: 1.55;
}
.dish-tagline {
  margin: 0 0 16px;
  font-size: 16px;
  font-weight: 600;
  color: var(--primary-dark);
}
.result-actions {
  display: flex; justify-content: center;
  gap: 10px; flex-wrap: wrap;
}
.meta {
  display: flex; justify-content: center;
  gap: 8px; flex-wrap: wrap;
  margin-bottom: 16px;
}
.meta-item {
  background: #fff5fa;
  border: 2px solid var(--primary);
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  color: var(--primary-dark);
  font-weight: 600;
}

/* ===== Buttons ===== */
.btn {
  display: inline-flex;
  align-items: center; gap: 6px;
  padding: 10px 22px;
  border: 3px solid #4a3b52;
  border-radius: 999px;
  font-family: 'Itim', cursive;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s ease;
}
.btn.ghost {
  background: white;
  color: var(--text);
  box-shadow: 0 4px 0 #4a3b52;
}
.btn.ghost:hover { transform: translateY(-2px); background: #fff5fa; box-shadow: 0 6px 0 #4a3b52; }
.btn.ghost:active { transform: translateY(2px); box-shadow: 0 0 0 #4a3b52; }

/* ===== History ===== */
.history-section {
  background: var(--card);
  padding: 18px 20px;
  border-radius: var(--radius-lg);
  border: 3px solid #4a3b52;
  box-shadow: 0 6px 0 #4a3b52;
}
.history-section h3 {
  margin: 0 0 12px;
  font-family: 'Itim', cursive;
  font-size: 20px;
  text-align: center;
}
.history {
  list-style: none;
  margin: 0; padding: 0;
  display: flex; flex-direction: column;
  gap: 8px;
}
.history li {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px;
  background: #fff8fc;
  border: 2px solid #f3d9e6;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  animation: slideIn 0.3s ease;
}
@keyframes slideIn {
  from { transform: translateX(-10px); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}
.history li .h-emoji { font-size: 22px; }
.history li .h-tag {
  margin-left: auto;
  font-size: 11px;
  background: #4a3b52;
  color: white;
  padding: 3px 8px;
  border-radius: 999px;
  font-weight: 700;
}
.history-empty {
  justify-content: center !important;
  color: var(--text-soft);
  font-style: italic;
  background: transparent !important;
  border: 2px dashed #f3d9e6 !important;
}

.footer {
  text-align: center;
  margin-top: 24px;
  color: var(--text-soft);
  font-size: 13px;
}
