:root {
  --yellow-bg: #FFE066;
  --yellow-soft: #FFF3B0;
  --orange: #FF7043;
  --orange-deep: #E65100;
  --brown: #5b2c00;
  --coral: #FF5252;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

body {
  margin: 0;
  font-family: 'Vazirmatn', sans-serif;
  color: var(--brown);
  background:
    radial-gradient(circle at 15% 12%, #FFF3B0 0%, transparent 45%),
    radial-gradient(circle at 85% 88%, #FFD54F 0%, transparent 50%),
    repeating-linear-gradient(45deg, #FFE066 0 26px, #FFDB4D 26px 52px);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  overflow-x: hidden;
  padding: 0 16px 40px;
}

/* ---- Header ---- */
header { text-align: center; margin-top: 24px; }
h1 {
  font-family: 'Lalezar', 'Vazirmatn', cursive;
  font-size: clamp(2.4rem, 9vw, 4rem);
  margin: 0;
  color: var(--orange-deep);
  text-shadow: 3px 3px 0 #fff3c4, 5px 5px 0 rgba(230,81,0,0.25);
  letter-spacing: 1px;
}
.subtitle {
  font-weight: 700;
  font-size: clamp(0.9rem, 3.5vw, 1.15rem);
  margin: 6px 0 0;
  color: #7a3b00;
}
.wiggle { display: inline-block; animation: wiggle 1.4s ease-in-out infinite; }
@keyframes wiggle {
  0%,100% { transform: rotate(-8deg) scale(1); }
  50% { transform: rotate(10deg) scale(1.15); }
}

/* ---- Main ---- */
main {
  width: 100%;
  max-width: 560px;
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-top: 18px;
}

/* ---- Wheel ---- */
#wheel-wrap {
  position: relative;
  width: min(90vw, 460px);
  aspect-ratio: 1 / 1;
  filter: drop-shadow(0 14px 24px rgba(120,60,0,0.35));
}
#canvas {
  display: block;
  border-radius: 50%;
  animation: floaty 4s ease-in-out infinite;
}
@keyframes floaty {
  0%,100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}
#pointer {
  position: absolute;
  top: -14px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 46px;
  color: var(--coral);
  z-index: 5;
  filter: drop-shadow(0 3px 2px rgba(0,0,0,0.3));
  line-height: 1;
}
#hub {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: 58px; height: 58px;
  border-radius: 50%;
  background: #fff8e1;
  border: 5px solid var(--orange-deep);
  display: flex; align-items: center; justify-content: center;
  font-size: 28px;
  z-index: 4;
  box-shadow: 0 3px 8px rgba(0,0,0,0.25);
}

/* ---- Spin button ---- */
#spinBtn {
  margin-top: 28px;
  font-family: 'Lalezar', 'Vazirmatn', cursive;
  font-size: clamp(1.3rem, 5.5vw, 1.8rem);
  padding: 16px 40px;
  border: none;
  border-radius: 999px;
  color: #fff;
  background: linear-gradient(135deg, #FF7043, #E65100);
  box-shadow: 0 8px 0 #b23c00, 0 12px 18px rgba(0,0,0,0.25);
  cursor: pointer;
  transition: transform .1s, box-shadow .1s, filter .2s;
  letter-spacing: 1px;
}
#spinBtn:hover:not(:disabled) { filter: brightness(1.08); }
#spinBtn:active:not(:disabled) {
  transform: translateY(6px);
  box-shadow: 0 2px 0 #b23c00, 0 4px 8px rgba(0,0,0,0.25);
}
#spinBtn:disabled { opacity: 0.6; cursor: not-allowed; }
#spinBtn.busy { animation: shake 0.4s infinite; }
@keyframes shake {
  0%,100% { transform: translateX(0); }
  25% { transform: translateX(-2px); }
  75% { transform: translateX(2px); }
}

/* ---- Hint ---- */
.hint {
  margin-top: 14px;
  font-weight: 900;
  font-size: 1.1rem;
  color: #7a3b00;
  animation: bob 1s ease-in-out infinite;
}
@keyframes bob { 0%,100%{transform:translateY(0)} 50%{transform:translateY(6px)} }

/* ---- Result ---- */
.result {
  margin-top: 22px;
  background: #fffbe9;
  border: 4px dashed var(--orange);
  border-radius: 24px;
  padding: 20px 28px;
  text-align: center;
  width: min(92vw, 400px);
  box-shadow: 0 10px 22px rgba(120,60,0,0.25);
}
.result-emoji { font-size: 64px; line-height: 1; animation: pop-emoji .6s ease; }
@keyframes pop-emoji { 0%{transform:scale(0) rotate(-40deg)} 70%{transform:scale(1.3) rotate(10deg)} 100%{transform:scale(1)} }
.result-label {
  font-family: 'Lalezar', cursive;
  font-size: 1.8rem;
  color: var(--orange-deep);
  margin-top: 6px;
}
.result-quip { font-weight: 700; margin-top: 4px; color: #7a3b00; }
#spinAgain {
  margin-top: 14px;
  background: #FFCA28;
  border: none;
  border-radius: 999px;
  padding: 10px 22px;
  font-family: 'Vazirmatn'; font-weight: 900;
  font-size: 1rem;
  color: var(--brown);
  cursor: pointer;
  box-shadow: 0 4px 0 #d4a017;
  transition: transform .1s;
}
#spinAgain:active { transform: translateY(4px); box-shadow: 0 1px 0 #d4a017; }
.pop { animation: cardpop .5s cubic-bezier(.2,1.4,.4,1); }
@keyframes cardpop { 0%{transform:scale(.6);opacity:0} 100%{transform:scale(1);opacity:1} }

/* ---- Tools ---- */
.tools { margin-top: 18px; display: flex; gap: 10px; }
.tool-btn {
  background: #fffbe9;
  border: 3px solid var(--orange);
  border-radius: 999px;
  padding: 8px 16px;
  font-family: 'Vazirmatn'; font-weight: 700;
  font-size: 1rem;
  color: var(--brown);
  cursor: pointer;
  transition: transform .1s, background .2s;
}
.tool-btn:hover { background: #fff3c4; }
.tool-btn:active { transform: scale(0.94); }

/* ---- History ---- */
.history {
  margin-top: 18px;
  display: flex; flex-wrap: wrap; gap: 8px; justify-content: center;
  align-items: center;
  max-width: 92vw;
}
.hist-title { font-weight: 900; color: #7a3b00; width: 100%; text-align: center; font-size: 0.9rem; }
.hist-chip {
  background: rgba(255,255,255,0.7);
  border: 2px solid var(--orange);
  border-radius: 999px;
  padding: 4px 12px;
  font-weight: 700;
  font-size: 0.9rem;
}

/* ---- Editor ---- */
.editor {
  margin-top: 22px;
  background: #fffbe9;
  border: 4px solid var(--orange-deep);
  border-radius: 20px;
  padding: 18px;
  width: min(92vw, 420px);
  box-shadow: 0 10px 22px rgba(120,60,0,0.2);
}
.editor h3 { margin: 0 0 4px; font-family: 'Lalezar', cursive; font-size: 1.5rem; color: var(--orange-deep); }
.editor-hint { margin: 0 0 12px; font-size: 0.85rem; color: #7a3b00; }
.add-row { display: flex; gap: 8px; }
#newFood {
  flex: 1;
  border: 2px solid var(--orange);
  border-radius: 12px;
  padding: 10px 12px;
  font-family: 'Vazirmatn';
  font-size: 1rem;
  outline: none;
}
#newFood:focus { border-color: var(--orange-deep); }
#addFood {
  background: var(--orange); color: #fff; border: none;
  border-radius: 12px; padding: 0 16px; font-weight: 900;
  font-family: 'Vazirmatn'; cursor: pointer; white-space: nowrap;
}
#foodList { list-style: none; padding: 0; margin: 14px 0; max-height: 220px; overflow-y: auto; }
#foodList li {
  display: flex; justify-content: space-between; align-items: center;
  padding: 8px 12px; margin-bottom: 6px;
  background: rgba(255,202,40,0.25);
  border-radius: 10px; font-weight: 700;
}
#foodList .del {
  background: var(--coral); color: #fff; border: none;
  width: 26px; height: 26px; border-radius: 50%;
  cursor: pointer; font-weight: 900;
}
#foodList .del:disabled { opacity: 0.3; cursor: not-allowed; }
.editor-actions { display: flex; gap: 10px; justify-content: flex-end; }
.editor-actions button {
  border: none; border-radius: 12px; padding: 10px 18px;
  font-family: 'Vazirmatn'; font-weight: 900; cursor: pointer;
}
#closeEditor { background: #66BB6A; color: #fff; }
.ghost { background: transparent; border: 2px solid var(--orange) !important; color: var(--brown); }

/* ---- Footer ---- */
footer {
  margin-top: auto;
  padding-top: 30px;
  display: flex; flex-direction: column; gap: 6px; align-items: center;
  font-weight: 700; font-size: 0.85rem; color: #7a3b00;
}
footer a {
  color: var(--orange-deep);
  font-weight: 900;
  text-decoration: none;
  border-bottom: 2px dotted var(--orange-deep);
}

/* ---- Confetti ---- */
#confetti-layer {
  position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 999;
}
.confetti {
  position: absolute; top: -40px;
  animation: fall linear forwards;
}
@keyframes fall {
  0% { transform: translateY(-40px) rotate(0); opacity: 1; }
  100% { transform: translateY(105vh) rotate(720deg); opacity: 0.9; }
}

.hidden { display: none !important; }