:root {
  --sand: #f4e3c1;
  --sand-deep: #e8cd9a;
  --dune-1: #e6b873;
  --dune-2: #d99f54;
  --dune-3: #c8853a;
  --ink: #4a3214;
  --ink-soft: #7a5a30;
  --card: #fffdf7;
  --accent: #d9772f;
  --accent-deep: #b85a1c;
  --gold: #e0a93b;
  --good: #3f9b5b;
  --bad: #c0573b;
  --shadow: 0 14px 40px rgba(112, 71, 20, 0.18);
  --radius: 20px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

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

body {
  font-family: 'Nunito', system-ui, sans-serif;
  color: var(--ink);
  background: linear-gradient(180deg, #fce9c4 0%, #f7d79e 45%, #ecbf78 100%);
  min-height: 100vh;
  overflow-x: hidden;
}

/* ---- Background dunes ---- */
.dunes { position: fixed; inset: 0; z-index: 0; pointer-events: none; overflow: hidden; }
.sun {
  position: absolute; top: 6%; right: 12%;
  width: 130px; height: 130px; border-radius: 50%;
  background: radial-gradient(circle, #fff3c4 0%, #ffd96b 55%, #ffb43d 100%);
  box-shadow: 0 0 90px 30px rgba(255, 196, 84, 0.55);
}
.dune { position: absolute; left: -10%; right: -10%; border-radius: 50% 50% 0 0 / 100% 100% 0 0; }
.dune-1 { bottom: -28%; height: 60%; background: var(--dune-1); }
.dune-2 { bottom: -36%; height: 58%; background: var(--dune-2); left: -25%; right: 30%; }
.dune-3 { bottom: -44%; height: 60%; background: var(--dune-3); left: 25%; right: -25%; }

/* ---- Layout ---- */
.wrap {
  position: relative; z-index: 1;
  max-width: 760px; margin: 0 auto; padding: 32px 18px 60px;
}

.hero { text-align: center; margin-bottom: 26px; }
.hero-camel { font-size: 64px; line-height: 1; animation: bob 3.5s ease-in-out infinite; }
@keyframes bob { 0%,100% { transform: translateY(0) rotate(-2deg); } 50% { transform: translateY(-10px) rotate(2deg); } }
h1 {
  font-family: 'Baloo 2', cursive; font-weight: 800;
  font-size: clamp(2.1rem, 6vw, 3.2rem);
  margin: 6px 0 4px; color: var(--accent-deep);
  text-shadow: 0 2px 0 #fff6e2;
}
.tagline { max-width: 540px; margin: 0 auto; font-size: 1.05rem; color: var(--ink-soft); }
.tagline em { color: var(--accent); font-style: italic; }

.ai-badge {
  display: inline-block; margin-top: 14px; padding: 6px 14px;
  border-radius: 999px; font-weight: 700; font-size: 0.85rem;
  border: 2px solid transparent;
}
.ai-badge--on { background: #e4f6e9; color: var(--good); border-color: #b6e3c4; }
.ai-badge--unknown { background: #f3e6cd; color: var(--ink-soft); }

/* ---- Cards ---- */
.card {
  background: var(--card); border-radius: var(--radius);
  padding: 22px 22px 24px; margin-bottom: 20px; box-shadow: var(--shadow);
  border: 1px solid #f0e2c4;
}
.card h2 {
  font-family: 'Baloo 2', cursive; font-size: 1.25rem; margin: 0 0 6px;
  display: flex; align-items: center; gap: 10px; color: var(--ink);
}
.step {
  display: inline-grid; place-items: center;
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--accent); color: #fff; font-size: 0.95rem; font-weight: 800;
}
.optional { font-size: 0.8rem; color: var(--ink-soft); font-weight: 600; }
.hint { margin: 0 0 16px; color: var(--ink-soft); font-size: 0.92rem; }

/* ---- Dropzone ---- */
.dropzone {
  display: block; border: 2.5px dashed var(--sand-deep); border-radius: 16px;
  padding: 26px; text-align: center; cursor: pointer; transition: all .2s ease;
  background: #fff9ee;
}
.dropzone:hover, .dropzone.drag { border-color: var(--accent); background: #fff3e0; }
.drop-icon { font-size: 40px; margin-bottom: 8px; }
.drop-sub { font-size: 0.82rem; color: var(--ink-soft); margin-top: 4px; }
.preview-wrap { position: relative; display: inline-block; }
.preview-wrap img {
  max-width: 100%; max-height: 320px; border-radius: 14px;
  box-shadow: 0 8px 20px rgba(112,71,20,.25);
}
.remove-photo {
  position: absolute; top: -10px; right: -10px;
  width: 32px; height: 32px; border-radius: 50%; border: none;
  background: var(--bad); color: #fff; font-size: 15px; cursor: pointer;
  box-shadow: 0 4px 10px rgba(0,0,0,.25);
}

/* ---- Quiz grid ---- */
.quiz-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }
@media (max-width: 560px) { .quiz-grid { grid-template-columns: 1fr; } }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label {
  font-weight: 700; font-size: 0.92rem; display: flex; align-items: center; gap: 7px;
}
.field .q-emoji { font-size: 1.05rem; }
.field select, .field input {
  font-family: inherit; font-size: 0.98rem; padding: 10px 12px;
  border: 2px solid #ecdcbb; border-radius: 12px; background: #fffdf8;
  color: var(--ink); transition: border-color .15s ease;
}
.field select:focus, .field input:focus { outline: none; border-color: var(--accent); }
.field.hidden { display: none; }

/* ---- Actions ---- */
.actions { display: flex; gap: 12px; align-items: center; justify-content: center; margin: 8px 0 4px; flex-wrap: wrap; }
.calc-btn {
  font-family: 'Baloo 2', cursive; font-weight: 800; font-size: 1.2rem;
  color: #fff; border: none; cursor: pointer;
  padding: 15px 30px; border-radius: 999px;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-deep) 100%);
  box-shadow: 0 10px 24px rgba(184,90,28,.4);
  display: inline-flex; align-items: center; gap: 10px;
  transition: transform .12s ease, box-shadow .12s ease;
}
.calc-btn:hover { transform: translateY(-2px); box-shadow: 0 14px 30px rgba(184,90,28,.5); }
.calc-btn:active { transform: translateY(0); }
.calc-btn:disabled { opacity: .65; cursor: progress; }
.calc-btn-camel { font-size: 1.4rem; }
.calc-btn.loading .calc-btn-camel { animation: walk .7s linear infinite; }
@keyframes walk { 0%,100% { transform: translateX(-3px) rotate(-6deg); } 50% { transform: translateX(3px) rotate(6deg); } }
.reset-btn {
  background: none; border: 2px solid #d9c39a; color: var(--ink-soft);
  border-radius: 999px; padding: 12px 20px; font-family: inherit; font-weight: 700;
  cursor: pointer; font-size: 0.95rem;
}
.reset-btn:hover { border-color: var(--accent); color: var(--accent); }

/* ---- Result ---- */
.result {
  margin-top: 22px; background: var(--card); border-radius: var(--radius);
  box-shadow: var(--shadow); border: 1px solid #f0e2c4; overflow: hidden;
  animation: pop .4s cubic-bezier(.2,.9,.3,1.2);
}
@keyframes pop { from { opacity: 0; transform: scale(.9) translateY(20px); } to { opacity: 1; transform: none; } }
.result-top {
  text-align: center; padding: 30px 22px 24px;
  background: linear-gradient(160deg, #fff6e4 0%, #ffe7c0 100%);
}
.result-count {
  font-family: 'Baloo 2', cursive; font-weight: 800;
  font-size: clamp(3rem, 13vw, 5.5rem); line-height: 1; color: var(--accent-deep);
}
.result-unit { font-size: 1.4rem; color: var(--ink-soft); font-weight: 700; margin-top: -4px; }
.result-rating { font-size: 1.5rem; font-weight: 800; margin-top: 14px; font-family: 'Baloo 2', cursive; }
.result-blurb { color: var(--ink-soft); margin-top: 4px; }
.camel-row { font-size: 1.6rem; margin-top: 14px; line-height: 1.5; word-break: break-word; }
.camel-row span { display: inline-block; animation: bob 2.6s ease-in-out infinite; }

.result-body { padding: 22px; }

.ai-verdict {
  background: linear-gradient(135deg, #2a2440 0%, #3a2e57 100%);
  color: #f3edff; border-radius: 16px; padding: 18px 20px; margin-bottom: 20px;
}
.ai-verdict .ai-head { display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: 0.95rem; color: #c9b8ff; margin-bottom: 6px; }
.ai-verdict .ai-title { font-family: 'Baloo 2', cursive; font-size: 1.25rem; margin: 0 0 6px; }
.ai-verdict .ai-comment { font-size: 1rem; line-height: 1.5; }
.ai-verdict .ai-traits { margin-top: 12px; display: flex; flex-wrap: wrap; gap: 7px; }
.ai-verdict .trait { background: rgba(255,255,255,.13); border-radius: 999px; padding: 4px 11px; font-size: 0.82rem; }
.ai-note { background: #fbeede; border: 1px solid #f0d4b4; color: var(--ink-soft); border-radius: 12px; padding: 12px 14px; margin-bottom: 18px; font-size: 0.9rem; }

.breakdown h3 { font-family: 'Baloo 2', cursive; margin: 0 0 12px; font-size: 1.1rem; }
.bd-row { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 8px 12px; margin-bottom: 9px; }
.bd-label { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 0.94rem; }
.bd-label .bd-note { color: var(--ink-soft); font-weight: 400; font-size: 0.85rem; }
.bd-value { font-weight: 800; font-variant-numeric: tabular-nums; white-space: nowrap; }
.bd-value.pos { color: var(--good); }
.bd-value.neg { color: var(--bad); }
.bd-bar { grid-column: 1 / -1; height: 7px; border-radius: 999px; background: #efe2c6; overflow: hidden; }
.bd-bar > i { display: block; height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--gold), var(--accent)); transition: width .6s ease; }
.bd-bar.neg > i { background: linear-gradient(90deg, #e6a08c, var(--bad)); }

.share-row { margin-top: 20px; display: flex; gap: 10px; flex-wrap: wrap; }
.share-btn {
  font-family: inherit; font-weight: 700; cursor: pointer; border-radius: 999px;
  padding: 11px 18px; border: 2px solid var(--accent); background: #fff;
  color: var(--accent-deep); font-size: 0.92rem;
}
.share-btn:hover { background: var(--accent); color: #fff; }
.share-btn.copied { background: var(--good); border-color: var(--good); color: #fff; }

.foot { text-align: center; margin-top: 34px; color: var(--ink-soft); font-size: 0.85rem; }
.foot a { color: var(--accent-deep); }

/* ---- Confetti (camel rain) ---- */
.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 5; overflow: hidden; }
.confetti span { position: absolute; top: -40px; font-size: 26px; animation: fall linear forwards; }
@keyframes fall { to { transform: translateY(110vh) rotate(360deg); opacity: .2; } }
