:root {
  --bg: #F4F2EE;
  --stone-lt: #C9C3B8;
  --stone-dk: #8A857C;
  --ink: #2E2B27;
  --line: #DCD8D0;
  --moss: #6B7257;
}

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

html, body {
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, "Pretendard", "Apple SD Gothic Neo", system-ui, sans-serif;
  height: 100%;
  overscroll-behavior: none;
}

.serif { font-family: "Noto Serif KR", serif; font-weight: 500; letter-spacing: -0.01em; }
.hidden { display: none !important; }

.screen {
  min-height: 100dvh;
  max-width: 560px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom);
}

/* ---- 알프스 배경 + 가독성 처리 (본가 동일 결) ---- */
.main-bg { position: fixed; inset: 0; z-index: 0; overflow: hidden; }
.main-bg img {
  width: 100%; height: 100%; object-fit: cover; object-position: 50% 38%;
  filter: saturate(.9) brightness(1.02) contrast(1.02);
}
.main-bg::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background:
    linear-gradient(180deg, rgba(20,18,15,.42) 0%, rgba(20,18,15,.06) 22%, rgba(244,242,238,0) 46%),
    linear-gradient(180deg, rgba(0,0,0,0) 52%, rgba(244,242,238,.30) 70%, rgba(244,242,238,.66) 88%, rgba(244,242,238,.82) 100%);
}
.screen > *:not(.main-bg) { position: relative; z-index: 1; }

/* ---- head ---- */
.gm-head { text-align: center; padding: 28px 28px 0; }
.gm-head h1 { font-size: 28px; line-height: 1.3; color: #fff; text-shadow: 0 2px 14px rgba(20,16,10,.45), 0 1px 2px rgba(0,0,0,.3); }
.gm-sub { margin-top: 6px; font-size: 13px; color: rgba(255,255,255,.82); letter-spacing: .03em; text-shadow: 0 1px 6px rgba(0,0,0,.5); }

/* ---- 이름 목록 ---- */
.gm-names { padding: 18px 24px 0; }
.name-list { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.empty-hint { font-size: 13px; color: rgba(255,255,255,.85); text-shadow: 0 1px 4px rgba(0,0,0,.4); padding: 6px 0; }
.name-chip {
  display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid var(--line); border-radius: 999px;
  background: rgba(255,255,255,.6); color: var(--ink);
  padding: 8px 14px; font-size: 14px; font-family: inherit; cursor: pointer;
  transition: border-color .2s, background .2s, transform .15s;
}
.name-chip:active { transform: scale(.96); }
.name-chip.sel {
  border-color: var(--moss); background: var(--moss); color: #fff; font-weight: 600;
  box-shadow: 0 2px 10px rgba(107,114,87,.45);
}
.chip-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--moss); }
.name-chip.sel .chip-dot { background: #fff; }
.chip-x { color: #b0584e; font-size: 15px; line-height: 1; margin-left: 2px; }

.add-row { display: flex; gap: 8px; margin-top: 12px; }
.add-row .field {
  flex: 1; border: 1px solid var(--line); background: #fff;
  border-radius: 12px; padding: 10px 14px; font-size: 15px; color: var(--ink); font-family: inherit;
}
.add-row .field:focus { outline: none; border-color: var(--stone-dk); }
.add-confirm {
  border: none; border-radius: 12px; background: var(--moss); color: var(--bg);
  padding: 0 18px; font-size: 14px; font-family: inherit; cursor: pointer;
}
.name-actions { display: flex; justify-content: center; gap: 14px; margin-top: 10px; }
.ghost-btn {
  border: none; background: none; color: rgba(255,255,255,.85);
  text-shadow: 0 1px 4px rgba(0,0,0,.45);
  font-size: 13px; font-family: inherit; cursor: pointer; padding: 6px 4px;
  text-underline-offset: 3px;
}
.ghost-btn:hover, .ghost-btn.active { color: #fff; text-decoration: underline; }

/* ---- 기간 선택 ---- */
.gm-period { text-align: center; padding: 16px 28px 0; }
.seg {
  display: inline-flex; border: 1px solid var(--line); border-radius: 999px;
  background: rgba(255,255,255,.6); padding: 3px;
}
.seg-btn {
  border: none; background: none; border-radius: 999px;
  padding: 7px 18px; font-size: 13px; font-family: inherit;
  color: var(--stone-dk); cursor: pointer; transition: background .2s, color .2s;
}
.seg-btn.sel { background: var(--moss); color: var(--bg); }
.count { margin-top: 10px; font-size: 13px; color: rgba(255,255,255,.88); text-shadow: 0 1px 6px rgba(0,0,0,.5); letter-spacing: .04em; min-height: 18px; }

/* ---- cairn stage (알프스 사진이 비치게 — 본가 동일 결) ---- */
.cairn-stage {
  flex: 1; position: relative; min-height: 220px; overflow: hidden;
  margin: 14px 24px 0;
}
.stone {
  position: absolute;
  filter: drop-shadow(0 3px 3px rgba(46,43,39,.28));
  transform: rotate(var(--rot, 0deg));
  transition: none;
  cursor: pointer;
}
.stone.dropping { animation: drop .55s cubic-bezier(.34,1.4,.5,1); }
@keyframes drop {
  0%   { transform: translateY(-220px) rotate(var(--spin)); opacity: 0; }
  60%  { transform: translateY(0) rotate(var(--rot)); opacity: 1; }
  74%  { transform: translateY(-7px) rotate(var(--rot)); }
  100% { transform: translateY(0) rotate(var(--rot)); opacity: 1; }
}

/* ---- 돌 고르기 팔레트 (본가 동일) ---- */
.palette { display: flex; gap: 12px; justify-content: center; align-items: flex-end; margin: 0 0 12px; }
.swatch {
  position: relative; width: 46px; height: 46px; border: 0; background: transparent;
  cursor: pointer; padding: 0; display: grid; place-items: center;
  transition: transform .2s cubic-bezier(.2,.8,.2,1);
}
.swatch svg { filter: drop-shadow(0 3px 5px rgba(0,0,0,.28)); position: static; }
.swatch:active { transform: scale(.9); }
.swatch.sel { transform: translateY(-6px) scale(1.08); }
.swatch.sel::before {
  content: ""; position: absolute; inset: -6px; border-radius: 50%;
  border: 2px solid var(--moss); box-shadow: 0 0 0 4px rgba(107,114,87,.2);
}
/* 직접 고르기 — 컬러 휠 스와치 (네이티브 컬러 피커) */
.swatch.custom {
  width: 38px; height: 38px; border-radius: 50%; overflow: hidden;
  background: conic-gradient(#e66465, #f6e58d, #78e08f, #60a3bc, #a29bfe, #e66465);
  border: 2px solid rgba(255,255,255,.8); box-shadow: 0 2px 6px rgba(0,0,0,.2);
}
.swatch.custom input { opacity: 0; width: 100%; height: 100%; cursor: pointer; border: 0; padding: 0; }

/* ---- foot: 사진 위 반투명 카드 (본가 composer 결) ---- */
.gm-foot {
  padding: 16px 24px calc(20px + env(safe-area-inset-bottom)); text-align: center;
  background: rgba(244,242,238,.55);
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
  border-radius: 22px 22px 0 0;
  box-shadow: 0 -6px 28px rgba(40,36,30,.14);
}
.cta {
  width: 100%; padding: 16px; border: none; border-radius: 12px;
  background: var(--moss); color: var(--bg); font-size: 16px; font-family: inherit;
  letter-spacing: .02em; cursor: pointer; transition: background .3s;
}
.cta:disabled { background: var(--line); color: var(--stone-dk); cursor: default; }
.hint { margin-top: 10px; font-size: 12px; color: var(--stone-dk); opacity: .85; }

/* ---- toast ---- */
.toast {
  position: fixed; left: 50%; bottom: calc(28px + env(safe-area-inset-bottom));
  transform: translateX(-50%); z-index: 100;
  background: var(--ink); color: var(--bg); font-size: 14px;
  padding: 12px 20px; border-radius: 12px; max-width: 82%; text-align: center;
  box-shadow: 0 4px 16px rgba(46, 43, 39, .25);
  animation: toastIn .3s ease;
}
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 8px); } to { opacity: 1; transform: translate(-50%, 0); } }

@media (prefers-reduced-motion: reduce) {
  .stone.dropping { animation: none; }
}
