*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --like:    #4CAF50;
  --dislike: #FF5252;
  --radius:  24px;
  --shadow:  0 12px 48px rgba(0,0,0,0.18);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: #f0f4f8;
  min-height: 100vh;
  display: flex;
  justify-content: center;
}

#app {
  width: 100%;
  max-width: 480px;
  min-height: 100vh;
  background: #fff;
  display: flex;
  flex-direction: column;
  box-shadow: 0 0 80px rgba(0,0,0,0.12);
}

/* ── Header ── */
header {
  background: linear-gradient(135deg, #FF6B6B 0%, #FFE66D 100%);
  padding: 20px 16px 14px;
  text-align: center;
  color: white;
}
header h1 {
  font-size: 2.4rem;
  font-weight: 900;
  text-shadow: 0 2px 6px rgba(0,0,0,0.2);
  margin-bottom: 4px;
}
header p { font-size: 0.82rem; opacity: 0.92; letter-spacing: 0.02em; }

/* ── Progress ── */
#progress-container { padding: 10px 16px 6px; background: #fff; }
#progress-bar {
  height: 8px;
  background: #e8e8e8;
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 4px;
}
#progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #FF6B6B, #4CAF50);
  border-radius: 4px;
  transition: width 0.5s ease;
  width: 0%;
}
#progress-text { text-align: center; font-size: 0.78rem; color: #999; }

/* ── Card Area ── */
#card-area {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px 16px;
  min-height: 420px;
  position: relative;
}

#card-stack {
  position: relative;
  width: 300px;
  height: 390px;
}

/* ── Food Card ── */
.food-card {
  position: absolute;
  inset: 0;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  cursor: grab;
  user-select: none;
  -webkit-user-select: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 28px 24px;
  overflow: hidden;
  will-change: transform;
  touch-action: none;
}
.food-card:active { cursor: grabbing; }

.card-emoji {
  font-size: 88px;
  line-height: 1;
  margin-bottom: 18px;
  pointer-events: none;
  display: block;
  filter: drop-shadow(0 4px 8px rgba(0,0,0,0.15));
}
.card-name {
  font-size: 1.7rem;
  font-weight: 800;
  color: white;
  text-align: center;
  text-shadow: 0 2px 10px rgba(0,0,0,0.25);
  pointer-events: none;
  line-height: 1.2;
}
.card-category {
  margin-top: 10px;
  padding: 4px 14px;
  background: rgba(255,255,255,0.28);
  backdrop-filter: blur(4px);
  border-radius: 20px;
  font-size: 0.78rem;
  color: white;
  font-weight: 600;
  pointer-events: none;
  letter-spacing: 0.03em;
}

/* ── Swipe Overlays ── */
.card-overlay {
  position: absolute;
  top: 22px;
  padding: 7px 16px;
  border-radius: 10px;
  font-size: 1.25rem;
  font-weight: 900;
  border: 3px solid;
  opacity: 0;
  pointer-events: none;
  letter-spacing: 0.04em;
}
.like-overlay {
  left: 18px;
  color: var(--like);
  border-color: var(--like);
  background: rgba(255,255,255,0.92);
  transform: rotate(-16deg);
}
.dislike-overlay {
  right: 18px;
  color: var(--dislike);
  border-color: var(--dislike);
  background: rgba(255,255,255,0.92);
  transform: rotate(16deg);
}

/* ── Done State ── */
#done-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  text-align: center;
  padding: 20px;
}
.done-emoji { font-size: 80px; line-height: 1; margin-bottom: 6px; }
#done-state h2 { font-size: 1.8rem; color: #333; }
#done-state p { color: #777; margin-bottom: 8px; }

/* ── Swipe Buttons ── */
#swipe-buttons {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 20px;
  padding: 10px 20px 12px;
  background: #fff;
}
#swipe-buttons button {
  border: none;
  background: none;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  border-radius: 50%;
  transition: transform 0.1s ease, background 0.2s;
}
#swipe-buttons button:hover:not(:disabled) { background: #f5f5f5; }
#swipe-buttons button:active:not(:disabled) { transform: scale(0.88); }

#btn-dislike {
  width: 66px; height: 66px;
  background: #FFEBEE !important;
  box-shadow: 0 4px 16px rgba(255,82,82,0.2);
}
#btn-dislike span { font-size: 28px; }
#btn-dislike small { font-size: 0.62rem; color: var(--dislike); font-weight: 700; }

#btn-like {
  width: 66px; height: 66px;
  background: #E8F5E9 !important;
  box-shadow: 0 4px 16px rgba(76,175,80,0.2);
}
#btn-like span { font-size: 28px; }
#btn-like small { font-size: 0.62rem; color: var(--like); font-weight: 700; }

#btn-undo { width: 50px; height: 50px; }
#btn-undo span { font-size: 20px; }
#btn-undo small { font-size: 0.58rem; color: #aaa; }
#btn-undo:disabled { opacity: 0.3; cursor: not-allowed; }

/* ── Nav Buttons ── */
#nav-buttons {
  display: flex;
  gap: 8px;
  padding: 8px 14px 16px;
  background: #fff;
  border-top: 1px solid #f0f0f0;
}
#nav-buttons button {
  flex: 1;
  padding: 9px 4px;
  border: 1.5px solid #e8e8e8;
  background: white;
  border-radius: 14px;
  cursor: pointer;
  font-size: 0.73rem;
  font-weight: 600;
  color: #555;
  transition: background 0.18s, border-color 0.18s;
}
#nav-buttons button:hover { background: #f9f9f9; border-color: #d0d0d0; }

/* ── Modals ── */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.52);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 200;
}
.modal-content {
  background: white;
  width: 100%;
  max-width: 480px;
  max-height: 88vh;
  border-radius: 24px 24px 0 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.add-modal-content { max-height: 70vh; }

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px 14px;
  border-bottom: 1px solid #f2f2f2;
  flex-shrink: 0;
}
.modal-header h2 { font-size: 1.15rem; color: #222; }
.close-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1.1rem;
  padding: 5px 8px;
  border-radius: 50%;
  color: #999;
  line-height: 1;
}
.close-btn:hover { background: #f2f2f2; color: #555; }

.modal-body {
  overflow-y: auto;
  padding: 16px 20px 28px;
  flex: 1;
  -webkit-overflow-scrolling: touch;
}

/* ── Results ── */
.results-stats {
  display: flex;
  gap: 10px;
  margin-bottom: 20px;
}
.stat-box {
  flex: 1;
  padding: 12px 8px;
  border-radius: 16px;
  text-align: center;
}
.stat-box.likes    { background: #E8F5E9; }
.stat-box.dislikes { background: #FFEBEE; }
.stat-box.pending  { background: #FFF8E1; }
.stat-num { font-size: 2.2rem; font-weight: 900; display: block; line-height: 1; }
.stat-label { font-size: 0.7rem; color: #666; margin-top: 4px; display: block; }

.results-section { margin-bottom: 22px; }
.results-section h3 {
  font-size: 0.95rem;
  font-weight: 700;
  margin-bottom: 10px;
  padding-bottom: 6px;
  border-bottom: 2px solid #f2f2f2;
  color: #333;
}
.food-grid { display: flex; flex-wrap: wrap; gap: 7px; }
.food-pill {
  padding: 5px 12px;
  border-radius: 20px;
  font-size: 0.82rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.food-pill.like    { background: #E8F5E9; color: #2E7D32; }
.food-pill.dislike { background: #FFEBEE; color: #C62828; }
.food-pill.unrated { background: #f4f4f4; color: #777; }
.food-grid em { font-size: 0.85rem; color: #bbb; }

/* ── Add Form ── */
.form-group { margin-bottom: 16px; }
.form-group label {
  display: block;
  font-size: 0.83rem;
  font-weight: 700;
  color: #444;
  margin-bottom: 7px;
}
.label-hint { font-weight: 400; color: #aaa; }
.form-group input {
  width: 100%;
  padding: 12px 14px;
  border: 2px solid #e4e4e4;
  border-radius: 14px;
  font-size: 1rem;
  outline: none;
  transition: border-color 0.2s;
  color: #333;
}
.form-group input:focus { border-color: #FF6B6B; }

.modal-actions { display: flex; gap: 10px; margin-top: 6px; }

.btn-primary, .btn-secondary {
  flex: 1;
  padding: 13px;
  border: none;
  border-radius: 14px;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.1s, opacity 0.18s;
}
.btn-primary {
  background: linear-gradient(135deg, #FF6B6B, #FF8E53);
  color: white;
}
.btn-primary:hover { opacity: 0.92; }
.btn-primary:active { transform: scale(0.97); }
.btn-secondary { background: #f2f2f2; color: #555; }
.btn-secondary:hover { background: #eaeaea; }

.hidden { display: none !important; }

/* ── Unicorn ── */
.unicorn-popup {
  position: fixed;
  z-index: 9999;
  pointer-events: none;
  display: flex;
  align-items: flex-end;
  animation: unicorn-pop 2.8s ease-in-out forwards;
  filter: drop-shadow(0 4px 14px rgba(0,0,0,0.25));
}
.unicorn-body  { font-size: 3.2rem; line-height: 1; }
.unicorn-food  { font-size: 1.9rem; margin-left: -6px; margin-bottom: 2px; animation: unicorn-chew 0.35s ease-in-out infinite alternate; }

@keyframes unicorn-pop {
  0%   { transform: scale(0)   rotate(-25deg); opacity: 0; }
  12%  { transform: scale(1.4) rotate( 8deg);  opacity: 1; }
  22%  { transform: scale(1)   rotate( 0deg);  opacity: 1; }
  72%  { transform: scale(1)   rotate( 0deg);  opacity: 1; }
  88%  { transform: scale(1.15) rotate(-8deg); opacity: 0.7; }
  100% { transform: scale(0)   rotate( 20deg); opacity: 0; }
}
@keyframes unicorn-chew {
  from { transform: translateY(0px) rotate(-5deg); }
  to   { transform: translateY(-4px) rotate(5deg); }
}

/* ── Responsive ── */
@media (max-width: 360px) {
  #card-stack { width: 270px; height: 350px; }
  .card-emoji { font-size: 72px; }
  .card-name { font-size: 1.45rem; }
}
