:root {
  --bg1: #f6e7c8;
  --bg2: #efcf9d;
  --paper: #fffaf1;
  --ink: #3b2a1a;
  --ink-soft: #7a634c;
  --accent: #d9542b;
  --accent-dark: #b7401c;
  --line: #ead9bd;
  --radius: 22px;
  --shadow: 0 10px 30px rgba(90, 50, 20, 0.12);
}

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

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

body {
  font-family: 'NanumSquareRound', 'Apple SD Gothic Neo', 'Noto Sans KR', sans-serif;
  font-weight: 400;
  color: var(--ink);
  background: linear-gradient(170deg, var(--bg1) 0%, var(--bg2) 60%, #e4b27e 100%);
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
  line-height: 1.6;
}

h1, h2, h3 {
  font-family: inherit;
  font-weight: 800;
  margin: 0;
  line-height: 1.3;
  letter-spacing: -0.01em;
  word-break: keep-all;
}
h3.mt { margin-top: 18px; }

h1 { font-size: 2rem; }
h2 { font-size: 1.4rem; }
h3 { font-size: 1.1rem; margin-bottom: 10px; }

#app {
  position: relative;
  z-index: 1;
  max-width: 480px;
  margin: 0 auto;
  padding: 28px 16px 16px;
  padding-top: calc(28px + env(safe-area-inset-top));
}

.card {
  background: var(--paper);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px 22px;
  margin-bottom: 16px;
  animation: rise .45s ease both;
}

.eyebrow {
  margin: 0 0 8px;
  font-size: .8rem;
  font-weight: 700;
  letter-spacing: .02em;
  color: var(--accent);
  text-transform: uppercase;
}

.lead { color: var(--ink-soft); margin: 14px 0 22px; }
.hint { color: var(--ink-soft); font-size: .9rem; margin: 0 0 12px; }
.desc { margin: 10px 0; }

/* ---------- buttons ---------- */
.btn {
  font-weight: 800;
  display: block;
  width: 100%;
  border: 0;
  border-radius: 999px;
  padding: 15px 20px;
  font: inherit;
  font-size: 1.02rem;
  cursor: pointer;
  margin-top: 10px;
  transition: transform .08s ease, background .2s ease;
}
.btn:active { transform: scale(.98); }
.btn.primary {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 6px 18px rgba(217, 84, 43, .35);
}
.btn.ghost {
  background: #fff;
  color: var(--ink);
  border: 1.5px solid var(--line);
}
.btn.link {
  background: transparent;
  color: var(--ink-soft);
  text-decoration: underline;
  text-underline-offset: 4px;
  padding: 10px;
}
.btn.small { font-size: .9rem; }
.btn.kakao { background: #FEE500; color: #191919; }
.btn.insta { background: linear-gradient(45deg, #f9ce34, #ee2a7b 55%, #6228d7); color: #fff; }
.btn .ic { margin-right: 6px; }
.actions h3 { text-align: center; margin-bottom: 4px; }
.btn[disabled] { opacity: .35; cursor: default; }

/* ---------- intro ---------- */
.intro { text-align: center; }
.intro-trees { display: flex; justify-content: center; gap: 2px; margin: 14px 0 6px; }
.intro-trees .mini { animation: sway 4s ease-in-out infinite; transform-origin: bottom center; }
.intro-trees .mini:nth-child(2) { animation-delay: -1s; }
.intro-trees .mini:nth-child(3) { animation-delay: -2s; }
.intro-trees .mini:nth-child(4) { animation-delay: -3s; }
.notice {
  background: #fff3e4;
  border: 1px dashed #f0b88a;
  border-radius: 14px;
  padding: 12px;
  font-size: .95rem;
  margin: 10px 0 4px;
}

/* ---------- quiz ---------- */
.progress {
  height: 6px;
  background: var(--line);
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 18px;
}
.progress .bar {
  height: 100%;
  background: linear-gradient(90deg, #f2a93b, var(--accent));
  transition: width .35s ease;
}
.question { margin: 4px 0 22px; word-break: keep-all; }
.options { display: grid; gap: 12px; }
.option {
  font-weight: 400;
  text-align: left;
  background: #fff;
  border: 1.5px solid var(--line);
  border-radius: 16px;
  padding: 16px 18px;
  font: inherit;
  font-size: 1rem;
  color: var(--ink);
  cursor: pointer;
  word-break: keep-all;
  animation: rise .4s ease both;
  transition: border-color .15s ease, background .15s ease, transform .08s ease;
}
.option:active { transform: scale(.985); }
.option:focus:not(:focus-visible), .btn:focus:not(:focus-visible), .cell:focus:not(:focus-visible) { outline: none; }

/* ---------- result ---------- */
.result { text-align: center; position: relative; overflow: hidden; }
.result::before {
  content: '';
  position: absolute;
  inset: 0 0 auto 0;
  height: 190px;
  background: radial-gradient(ellipse at 50% 0%, color-mix(in srgb, var(--c1) 35%, transparent), transparent 70%);
  pointer-events: none;
}
.hero { position: relative; display: flex; justify-content: center; animation: sway 5s ease-in-out infinite; transform-origin: bottom center; }
.tree-name { font-size: 2.2rem; margin-top: 2px; }
.tree-title { color: var(--ink-soft); margin: 4px 0 12px; }
.traits { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; }
.traits.small { justify-content: flex-start; }
.chip {
  background: #fff1dd;
  color: #8a4a1c;
  border-radius: 999px;
  padding: 4px 11px;
  font-size: .85rem;
}
.traits.small .chip { font-size: .75rem; padding: 2px 8px; }
.mood { color: var(--ink-soft); margin: 14px 0 10px; font-size: .95rem; }
.lines {
  list-style: none;
  padding: 0;
  margin: 0 auto 14px;
  text-align: left;
  max-width: 320px;
  display: grid;
  gap: 8px;
}
.lines li {
  position: relative;
  padding-left: 22px;
  font-size: 1rem;
  word-break: keep-all;
}
.lines li::before {
  content: '🍂';
  position: absolute;
  left: 0;
  top: 1px;
  font-size: .85rem;
}
.keywords { color: var(--accent); font-size: .95rem; margin-bottom: 18px; font-weight: 700; }

.axes { display: grid; gap: 14px; text-align: left; margin-top: 10px; }
.axis-labels, .axis-pct { display: flex; justify-content: space-between; font-size: .85rem; }
.axis-labels { font-weight: 700; }
.pair-tree { font-weight: 700; }
.axis-pct { color: var(--ink-soft); font-size: .75rem; }
.axis-bar { height: 8px; background: var(--line); border-radius: 999px; overflow: hidden; margin: 4px 0 2px; }
.axis-fill { height: 100%; background: linear-gradient(90deg, var(--c1), var(--c2)); transition: width .6s ease; }

/* ---------- compare ---------- */
.compare { text-align: center; }
.pair { display: flex; align-items: center; justify-content: center; gap: 8px; }
.pair-tree { display: flex; flex-direction: column; align-items: center; font-weight: 700; }
.pair-heart { font-size: 2rem; animation: pulse 1.6s ease-in-out infinite; }
.level { margin: 10px 0 4px; }
.leaves { font-size: 1.3rem; letter-spacing: 2px; }
.level h2 { font-size: 1.6rem; color: var(--accent); }

/* ---------- best list ---------- */
.best-list { display: grid; gap: 10px; }
.best {
  display: flex;
  align-items: center;
  gap: 12px;
  background: #fff;
  border: 1.5px solid var(--line);
  border-radius: 16px;
  padding: 8px 14px;
  font: inherit;
  text-align: left;
  cursor: pointer;
  color: var(--ink);
}
.best div { display: flex; flex-direction: column; }
.best span { font-size: .85rem; color: var(--ink-soft); }
.best.worst { border-color: #d9c7e8; background: #faf6ff; }

/* ---------- grid ---------- */
.grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.cell {
  background: #fff;
  border: 1.5px solid var(--line);
  border-radius: 14px;
  padding: 8px 2px 6px;
  font: inherit;
  font-size: .72rem;
  color: var(--ink);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  transition: border-color .15s ease, background .15s ease;
}
.cell.active { border-color: var(--accent); background: #fff3e4; }

/* ---------- forest ---------- */
.forest { display: grid; gap: 14px; margin: 16px 0 20px; }
.forest-item { display: flex; gap: 12px; align-items: center; border-bottom: 1px solid var(--line); padding-bottom: 12px; }
.forest-item p { margin: 2px 0 6px; font-size: .85rem; color: var(--ink-soft); }

.actions { text-align: center; }
.code-hint { color: #b9a68e; font-size: .75rem; margin: 10px 0 0; }

.foot {
  position: relative; z-index: 1;
  text-align: center;
  color: rgba(59, 42, 26, .55);
  font-size: .75rem;
  padding: 8px 0 28px;
}

/* ---------- tree images ---------- */
.tree-img {
  display: block;
  object-fit: contain;
  user-select: none;
  -webkit-user-drag: none;
}
.hero .tree-img { filter: drop-shadow(0 8px 14px rgba(120, 70, 20, .18)); }

/* ---------- falling leaves ---------- */
.leaves-bg { position: fixed; inset: 0; overflow: hidden; pointer-events: none; z-index: 0; }
.leaves-bg span {
  position: absolute;
  top: -40px;
  font-size: 22px;
  opacity: .7;
  animation: fall linear infinite;
}
.leaves-bg span:nth-child(1) { left: 6%;  animation-duration: 12s; animation-delay: 0s; }
.leaves-bg span:nth-child(2) { left: 18%; animation-duration: 15s; animation-delay: -4s; font-size: 18px; }
.leaves-bg span:nth-child(3) { left: 32%; animation-duration: 11s; animation-delay: -7s; }
.leaves-bg span:nth-child(4) { left: 48%; animation-duration: 17s; animation-delay: -2s; font-size: 16px; }
.leaves-bg span:nth-child(5) { left: 61%; animation-duration: 13s; animation-delay: -9s; }
.leaves-bg span:nth-child(6) { left: 74%; animation-duration: 16s; animation-delay: -5s; font-size: 20px; }
.leaves-bg span:nth-child(7) { left: 86%; animation-duration: 12s; animation-delay: -11s; }
.leaves-bg span:nth-child(8) { left: 94%; animation-duration: 14s; animation-delay: -1s; font-size: 17px; }

@keyframes fall {
  0%   { transform: translateY(0) rotate(0deg) translateX(0); }
  50%  { transform: translateY(55vh) rotate(180deg) translateX(30px); }
  100% { transform: translateY(110vh) rotate(360deg) translateX(-20px); }
}
@keyframes rise {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes sway {
  0%, 100% { transform: rotate(-1.5deg); }
  50%      { transform: rotate(1.5deg); }
}
@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50%      { transform: scale(1.18); }
}

/* 마우스 있는 기기에서만 hover. 터치에선 탭 후 hover가 남아서 다음 문항 버튼이 눌린 것처럼 보임 */
@media (hover: hover) and (pointer: fine) {
  .btn.primary:hover { background: var(--accent-dark); }
  .btn.kakao:hover { background: #f5dc00; }
  .option:hover { border-color: #f2a93b; background: #fff8ee; }
  .cell:hover { border-color: #f2a93b; }
  .best:hover { border-color: #f2a93b; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

@media (min-width: 640px) {
  #app { padding-top: 48px; }
  h1 { font-size: 2.3rem; }
}
