/* ══════════════════════════════════════
   기도 항아리 — 스타일
   ══════════════════════════════════════ */
:root {
  --bg-top: #eaf4fb;
  --bg-bot: #f6efe3;
  --ink: #2e3a44;
  --ink-soft: #6b7a86;
  --card: rgba(255, 255, 255, 0.72);
  --line: rgba(120, 140, 160, 0.22);
  --accent: #3f8fc4;
  --accent-d: #2c6f9e;
  --water-1: #8fd4f0;
  --water-2: #2f8fc4;
  --sand-1: #f0d99a;
  --sand-2: #c89a4b;
  --radius: 18px;
  --shadow: 0 10px 30px rgba(45, 80, 120, 0.12);
}

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

html, body { height: 100%; }
body {
  font-family: "Gowun Dodum", -apple-system, BlinkMacSystemFont, sans-serif;
  color: var(--ink);
  background: linear-gradient(160deg, var(--bg-top), var(--bg-bot));
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { font-family: "Gowun Batang", serif; }

.screen { display: none; min-height: 100vh; }
.screen.active { display: flex; flex-direction: column; align-items: center; }

button { font-family: inherit; cursor: pointer; border: none; }

/* ── 공통 버튼 ── */
.primary-btn {
  background: linear-gradient(180deg, var(--accent), var(--accent-d));
  color: #fff;
  font-size: 16px;
  font-weight: 700;
  padding: 13px 18px;
  border-radius: 14px;
  box-shadow: 0 6px 16px rgba(47, 111, 158, 0.3);
  transition: transform 0.12s ease, box-shadow 0.2s ease;
}
.primary-btn:active { transform: translateY(1px) scale(0.99); }
.ghost-btn {
  background: rgba(255, 255, 255, 0.6);
  color: var(--accent-d);
  font-size: 16px;
  font-weight: 700;
  padding: 13px 18px;
  border-radius: 14px;
  border: 1.5px solid var(--line);
}
.ghost-btn.wide, .primary-btn { width: 100%; }

/* ══════ 홈 ══════ */
.home-card {
  width: 100%;
  max-width: 440px;
  padding: 32px 20px 48px;
}
.brand { text-align: center; margin-bottom: 26px; }
.brand-jar { font-size: 54px; line-height: 1; }
.brand h1 { font-size: 30px; margin-top: 6px; letter-spacing: -0.5px; }
.brand .sub { color: var(--ink-soft); margin-top: 8px; line-height: 1.5; font-size: 15px; }

.panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px 18px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(6px);
}
.panel h2 { font-size: 18px; margin-bottom: 14px; }

.field { display: block; margin-bottom: 14px; }
.field > span { display: block; font-size: 13px; color: var(--ink-soft); margin-bottom: 6px; }
.field input[type="text"],
.field input[type="number"] {
  width: 100%;
  font-family: inherit;
  font-size: 16px;
  padding: 12px 14px;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  background: #fff;
  color: var(--ink);
}
.field input:focus { outline: none; border-color: var(--accent); }

.fill-pick { display: flex; gap: 10px; }
.fill-opt { flex: 1; cursor: pointer; }
.fill-opt input { position: absolute; opacity: 0; }
.fill-chip {
  display: flex; align-items: center; justify-content: center;
  padding: 12px; border-radius: 12px; font-weight: 700;
  border: 1.5px solid var(--line); background: #fff; transition: all 0.15s ease;
}
.fill-opt input:checked + .fill-chip.water { border-color: var(--water-2); background: #e8f6fd; color: var(--accent-d); }
.fill-opt input:checked + .fill-chip.sand  { border-color: var(--sand-2);  background: #fbf3df; color: #9a6f24; }

/* 내가 참여한 항아리 목록 — 카드 그리드 */
.my-rooms { margin-bottom: 18px; }
.room-list {
  list-style: none;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(94px, 1fr));
  gap: 10px;
}
.room-item {
  position: relative;
  display: flex; flex-direction: column; align-items: center; text-align: center;
  gap: 5px;
  padding: 14px 8px 12px;
  border: 1px solid var(--line); border-radius: 14px; background: #fff;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.1s ease;
}
.room-item:hover { background: #f1f8fd; }
.room-item:active { transform: scale(0.98); }
.mini-jar {
  position: relative; width: 38px; height: 50px; flex-shrink: 0;
  border: 2px solid rgba(150, 170, 190, 0.5);
  border-radius: 9px 9px 13px 13px / 6px 6px 16px 16px;
  background: rgba(255, 255, 255, 0.55);
  overflow: hidden;
  box-shadow: inset 0 0 6px rgba(255, 255, 255, 0.6);
}
.mini-fill { position: absolute; left: 0; right: 0; bottom: 0; transition: height 0.45s ease; }
.mini-jar[data-fill="water"] .mini-fill { background: linear-gradient(180deg, var(--water-1), var(--water-2)); }
.mini-jar[data-fill="sand"]  .mini-fill { background: linear-gradient(180deg, var(--sand-1), var(--sand-2)); }
.ri-title {
  font-size: 13px; font-weight: 700; max-width: 100%;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.ri-pct { font-size: 16px; font-weight: 700; color: var(--accent-d); font-family: "Gowun Batang", serif; line-height: 1; }
.ri-code { font-size: 11px; color: var(--ink-soft); letter-spacing: 1.5px; }
.ri-del {
  position: absolute; top: 4px; right: 4px;
  width: 22px; height: 22px; border-radius: 7px; background: transparent;
  color: var(--ink-soft); font-size: 16px; line-height: 1;
}
.ri-del:hover { background: #fbeaea; color: #c0392b; }

.divider { display: flex; align-items: center; gap: 12px; margin: 20px 4px; color: var(--ink-soft); font-size: 13px; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }

.form-error { color: #c0392b; font-size: 13px; min-height: 18px; margin: -4px 0 8px; }
.mode-note { text-align: center; color: var(--ink-soft); font-size: 12.5px; margin-top: 22px; line-height: 1.5; }

/* ══════ 항아리 화면 ══════ */
#roomScreen { width: 100%; }
.room-header {
  width: 100%; max-width: 480px;
  display: flex; align-items: center; gap: 10px;
  padding: 16px 16px 8px;
}
.icon-btn {
  width: 40px; height: 40px; border-radius: 12px; flex-shrink: 0;
  background: rgba(255, 255, 255, 0.7); border: 1px solid var(--line);
  font-size: 20px; color: var(--ink);
}
.room-title-wrap { flex: 1; text-align: center; min-width: 0; }
.room-title-wrap h2 { font-size: 18px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hdr-spacer { width: 40px; flex-shrink: 0; }
.code-pill {
  display: inline-flex; align-items: center; gap: 7px;
  margin-top: 4px; padding: 4px 12px; border-radius: 999px;
  background: rgba(255, 255, 255, 0.8); border: 1px solid var(--line);
}
.code-pill .code-label { font-size: 11px; color: var(--ink-soft); }
.code-pill b { font-size: 15px; letter-spacing: 2px; font-family: "Gowun Batang", serif; }
.code-pill .copy-ic { font-size: 13px; color: var(--accent); }

.room-body {
  width: 100%; max-width: 480px;
  padding: 8px 18px 60px;
  display: flex; flex-direction: column; align-items: center;
}

/* ── 항아리 ── */
.jar-stage { position: relative; padding: 18px 0 6px; }
.full-banner {
  position: absolute; top: -2px; left: 50%; transform: translateX(-50%);
  background: linear-gradient(90deg, #f6c453, #e89c2b);
  color: #5a3b00; font-weight: 700; font-size: 13px;
  padding: 6px 14px; border-radius: 999px; white-space: nowrap;
  box-shadow: 0 6px 16px rgba(216, 154, 43, 0.4);
  animation: pop 0.4s ease;
}
.jar {
  position: relative;
  width: 220px; height: 290px;
  margin: 8px auto 0;
}
.jar-lid {
  position: absolute; top: -10px; left: 50%; transform: translateX(-50%);
  width: 120px; height: 22px; border-radius: 8px 8px 6px 6px;
  background: linear-gradient(180deg, #cdb892, #a98f63);
  box-shadow: 0 3px 6px rgba(0, 0, 0, 0.15);
  z-index: 3;
}
.jar-body {
  position: absolute; inset: 0; top: 6px;
  border-radius: 30px 30px 46px 46px / 22px 22px 70px 70px;
  background: rgba(255, 255, 255, 0.28);
  border: 3px solid rgba(255, 255, 255, 0.85);
  box-shadow: inset 0 0 30px rgba(255, 255, 255, 0.5),
              inset 0 -12px 26px rgba(80, 120, 150, 0.12),
              0 16px 34px rgba(60, 100, 140, 0.18);
  overflow: hidden;
  backdrop-filter: blur(1px);
}
.jar-fill {
  position: absolute; left: 0; right: 0; bottom: 0;
  height: 0%;
  transition: height 1.3s cubic-bezier(0.22, 0.61, 0.36, 1);
}

/* 물 */
.jar[data-fill="water"] .jar-fill {
  background: linear-gradient(180deg, var(--water-1), var(--water-2));
}
.jar[data-fill="water"] .jar-fill::before,
.jar[data-fill="water"] .jar-fill::after {
  content: ""; position: absolute; left: 50%; top: -14px;
  width: 260px; height: 260px; margin-left: -130px;
  border-radius: 42%;
  background: rgba(255, 255, 255, 0.18);
}
.jar[data-fill="water"] .jar-fill::before { animation: wave 7s linear infinite; background: rgba(255, 255, 255, 0.22); }
.jar[data-fill="water"] .jar-fill::after  { animation: wave 11s linear infinite reverse; top: -10px; background: rgba(255, 255, 255, 0.14); }

/* 모래 */
.jar[data-fill="sand"] .jar-fill {
  background: linear-gradient(180deg, var(--sand-1), var(--sand-2));
}
.jar[data-fill="sand"] .jar-fill::before {
  content: ""; position: absolute; inset: 0;
  background: repeating-linear-gradient(115deg,
      rgba(255, 255, 255, 0.10) 0 2px,
      rgba(160, 120, 50, 0.06) 2px 5px);
  opacity: 0.5;
}
.jar[data-fill="sand"] .jar-fill::after {
  content: ""; position: absolute; left: 50%; top: -8px;
  width: 240px; height: 30px; margin-left: -120px; border-radius: 50%;
  background: var(--sand-1);
}

.jar-shine {
  position: absolute; top: 14px; left: 16px;
  width: 26px; height: 120px; border-radius: 20px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.7), rgba(255, 255, 255, 0));
  pointer-events: none; z-index: 2;
}
.jar.is-full .jar-body {
  border-color: #ffe6a0;
  box-shadow: inset 0 0 30px rgba(255, 255, 255, 0.5),
              0 0 26px rgba(246, 196, 83, 0.55),
              0 16px 34px rgba(60, 100, 140, 0.18);
}

.jar-pct { text-align: center; margin-top: 12px; }
.jar-pct b { font-size: 24px; font-family: "Gowun Batang", serif; color: var(--accent-d); }

/* 떨어지는 방울 */
.drop {
  position: absolute; top: -6px; width: 12px; height: 12px;
  border-radius: 50% 50% 50% 0; transform: rotate(45deg);
  z-index: 1; animation: drop-fall 0.85s cubic-bezier(0.5, 0, 0.9, 0.5) forwards;
}
.drop.water { background: var(--water-1); }

/* 모래 알갱이 — 위에서 떨어져 내림 */
.grain {
  position: absolute; top: -8px;
  border-radius: 1px;
  z-index: 1;
  animation-name: grain-fall;
  animation-timing-function: cubic-bezier(0.4, 0, 0.85, 0.45);
  animation-fill-mode: forwards;
}

.float-label {
  position: absolute; top: 30px; left: 50%; transform: translateX(-50%);
  font-weight: 700; color: var(--accent-d); font-size: 18px;
  text-shadow: 0 1px 4px rgba(255, 255, 255, 0.9);
  animation: float-up 1.5s ease forwards; pointer-events: none; z-index: 4;
}

/* ── 통계 ── */
.stats {
  display: flex; gap: 10px; width: 100%; margin: 18px 0 6px;
}
.stat {
  flex: 1; text-align: center; background: var(--card);
  border: 1px solid var(--line); border-radius: 14px; padding: 12px 6px;
  box-shadow: var(--shadow);
}
.stat-num { display: block; font-size: 15px; color: var(--ink-soft); }
.stat-num b { font-size: 22px; color: var(--ink); font-family: "Gowun Batang", serif; }
.stat-cap { font-size: 12px; color: var(--ink-soft); }

/* ── 기도 담기 ── */
.pray-form { width: 100%; margin-top: 16px; }
.pray-row { display: flex; gap: 8px; }
.name-input { width: 96px; flex-shrink: 0; }
.min-input { flex: 1; }
.pray-row input {
  font-family: inherit; font-size: 16px; padding: 12px 12px;
  border: 1.5px solid var(--line); border-radius: 12px; background: #fff; color: var(--ink);
  min-width: 0;
}
.pray-row input:focus { outline: none; border-color: var(--accent); }
.pour-btn { width: auto; flex-shrink: 0; padding: 12px 20px; }

.quick-chips { display: flex; gap: 7px; margin-top: 10px; flex-wrap: wrap; }
.quick-chips button {
  background: rgba(255, 255, 255, 0.7); border: 1px solid var(--line);
  border-radius: 999px; padding: 7px 13px; font-size: 13px; color: var(--accent-d); font-weight: 700;
}
.quick-chips button:active { background: #e8f6fd; }

/* ── 최근 기도 ── */
.contrib-wrap { width: 100%; margin-top: 26px; }
.contrib-wrap h3 { font-size: 15px; color: var(--ink-soft); margin-bottom: 8px; }
.contrib-list { list-style: none; }
.contrib-list li {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 14px; background: var(--card); border: 1px solid var(--line);
  border-radius: 12px; margin-bottom: 7px; font-size: 14px;
}
.contrib-list .c-name { font-weight: 700; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.contrib-list .c-min { color: var(--accent-d); font-weight: 700; }
.contrib-list .c-time { color: var(--ink-soft); font-size: 12px; width: 56px; text-align: right; }
.contrib-list .empty { justify-content: center; color: var(--ink-soft); }

/* ── 토스트 ── */
.toast {
  position: fixed; bottom: 28px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: rgba(40, 55, 68, 0.95); color: #fff; padding: 11px 20px;
  border-radius: 999px; font-size: 14px; opacity: 0; pointer-events: none;
  transition: all 0.25s ease; z-index: 100;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ── 애니메이션 ── */
@keyframes wave { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }
@keyframes drop-fall { 0% { top: -6px; opacity: 0; } 20% { opacity: 1; } 100% { top: 85%; opacity: 0; } }
@keyframes grain-fall { 0% { top: -8px; opacity: 0; } 12% { opacity: 1; } 88% { opacity: 1; } 100% { top: 90%; opacity: 0.15; } }
@keyframes float-up { 0% { opacity: 0; transform: translate(-50%, 6px); } 25% { opacity: 1; } 100% { opacity: 0; transform: translate(-50%, -34px); } }
@keyframes pop { 0% { transform: translateX(-50%) scale(0.8); opacity: 0; } 100% { transform: translateX(-50%) scale(1); opacity: 1; } }

@media (max-width: 380px) {
  .name-input { width: 78px; }
  .pour-btn { padding: 12px 14px; }
}
