/* =========================================================
   いつもありがとうカード / style.css
   淡いピンク・白・クリーム・ベージュのやさしい配色
   ========================================================= */

:root {
  --pink-bg1: #fdeef2;
  --pink-bg2: #fbe0e7;
  --pink: #f0a3b6;
  --pink-deep: #d9788f;
  --pink-soft: #f9d3dc;
  --cream: #fdf7ef;
  --cream-deep: #f7ecdf;
  --beige-line: #e8d6c6;
  --text: #6b5450;
  --text-soft: #9a8580;
  --white: #ffffff;
  --shadow-soft: 0 8px 20px rgba(214, 160, 172, .18);
  --shadow-card: 0 10px 30px rgba(214, 160, 172, .22);
  --radius-lg: 28px;
  --radius-md: 18px;
  --radius-pill: 999px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  overflow-x: hidden;
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  background: linear-gradient(175deg, var(--pink-bg1) 0%, var(--pink-bg2) 55%, #fceff1 100%);
  background-attachment: fixed;
  color: var(--text);
  font-family: "Hiragino Maru Gothic ProN", "ヒラギノ丸ゴ ProN", "Hiragino Sans", "Yu Gothic", "游ゴシック体", system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  line-height: 1.6;
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
  color: inherit;
  -webkit-tap-highlight-color: transparent;
}

/* ===== 背景装飾 ===== */
.bg-deco { position: fixed; inset: 0; pointer-events: none; z-index: 0; overflow: hidden; }
.bd { position: absolute; color: var(--pink-soft); opacity: .75; font-size: 22px; animation: floatSlow 9s ease-in-out infinite; }
.bd1 { top: 8%;  left: 6%;  font-size: 26px; }
.bd2 { top: 16%; right: 7%; animation-delay: 1.4s; }
.bd3 { top: 42%; left: 4%;  animation-delay: 2.6s; color: #f6dfa8; }
.bd4 { top: 62%; right: 5%; animation-delay: .8s; }
.bd5 { top: 82%; left: 8%;  animation-delay: 3.2s; }
.bd6 { top: 92%; right: 12%; animation-delay: 2s; color: #f6dfa8; }
@keyframes floatSlow {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  50%      { transform: translateY(-10px) rotate(8deg); }
}

/* ===== レイアウト ===== */
.app {
  position: relative;
  z-index: 1;
  max-width: 460px;
  margin: 0 auto;
  padding: max(14px, env(safe-area-inset-top)) 16px calc(24px + env(safe-area-inset-bottom));
}

/* ===== ヘッダー ===== */
.hero { text-align: center; padding-top: 6px; }

.title {
  margin: 0;
  font-size: clamp(26px, 8.2vw, 34px);
  font-weight: 800;
  letter-spacing: .01em;
  color: var(--pink);
  text-shadow:
    0 0 0 #fff,
    2px 2px 0 #fff, -2px 2px 0 #fff, 2px -2px 0 #fff, -2px -2px 0 #fff,
    0 3px 0 #fff, 0 -3px 0 #fff, 3px 0 0 #fff, -3px 0 0 #fff,
    0 6px 12px rgba(217, 120, 143, .25);
}

.subtitle {
  margin: 6px 0 0;
  font-size: 15px;
  letter-spacing: .12em;
  color: var(--text-soft);
}
.sub-flower { color: var(--pink); font-size: 13px; }

/* ===== キャラクター ===== */
.characters {
  display: flex;
  justify-content: center;
  align-items: flex-end;
  gap: 0;
  margin: 4px auto -22px;
  max-width: 330px;
}
.chara { width: 46%; max-width: 165px; height: auto; display: block; filter: drop-shadow(0 6px 10px rgba(214, 160, 172, .28)); }
.chara-seal  { width: 51%; max-width: 184px; margin-right: -18px; animation: bob 4s ease-in-out infinite; }
.chara-koala { margin-left: -14px; animation: bob 4s ease-in-out infinite .8s; }
@keyframes bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-5px); } }

.seal-arm { transform-origin: 24px 92px; animation: wave 2.4s ease-in-out infinite; }
@keyframes wave { 0%, 100% { transform: rotate(0deg); } 50% { transform: rotate(-14deg); } }

/* ===== カード ===== */
.card {
  position: relative;
  background: var(--cream);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: 18px 16px 16px;
  border: 2px dashed #f0d9c9;
}

/* ===== スタンプ枠 ===== */
.stamp-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  margin-top: 4px;
}

.stamp {
  position: relative;
  aspect-ratio: 1 / 1;
  border-radius: 50%;
  border: 2px dashed #e9c9c2;
  background: #fffdfa;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform .18s ease, background .25s ease, border-color .25s ease;
}

.stamp-num {
  position: absolute;
  top: 8%;
  left: 50%;
  transform: translateX(-50%);
  font-size: clamp(11px, 3.4vw, 14px);
  font-weight: 700;
  color: #cbb0a6;
  line-height: 1;
}
.stamp.is-reward .stamp-num { color: var(--pink-deep); }

.stamp-gift {
  position: absolute;
  top: -4px;
  right: -2px;
  font-size: clamp(11px, 3.4vw, 14px);
  line-height: 1;
  filter: drop-shadow(0 1px 1px rgba(0, 0, 0, .08));
}

.stamp-mark {
  font-size: clamp(20px, 6.6vw, 28px);
  line-height: 1;
  color: var(--pink-deep);
  margin-top: 22%;
  opacity: 0;
  transform: scale(.3);
  transition: opacity .25s ease, transform .25s ease;
}

.stamp.is-done {
  background: #fff2f5;
  border-style: solid;
  border-color: var(--pink-soft);
}
.stamp.is-done .stamp-mark { opacity: 1; transform: scale(1); }
.stamp.is-done .stamp-num { color: var(--pink-deep); }

.stamp.just-stamped .stamp-mark { animation: stampPop .55s cubic-bezier(.2, 1.6, .4, 1); }
@keyframes stampPop {
  0%   { opacity: 0; transform: scale(2.2) rotate(-14deg); }
  55%  { opacity: 1; transform: scale(.86) rotate(4deg); }
  100% { opacity: 1; transform: scale(1) rotate(0); }
}
.stamp.just-stamped { animation: stampRing .6s ease-out; }
@keyframes stampRing {
  0%   { box-shadow: 0 0 0 0 rgba(240, 163, 182, .55); }
  100% { box-shadow: 0 0 0 14px rgba(240, 163, 182, 0); }
}

.stamp.is-next { border-color: var(--pink); background: #fff8f9; }

/* ===== 進捗 ===== */
.progress {
  text-align: center;
  margin: 16px 0 2px;
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
}
.progress-now { font-size: 34px; color: var(--pink-deep); font-weight: 800; }
.progress-slash { color: var(--text-soft); margin: 0 1px; }
.progress-unit { margin-left: 6px; }

.thanks {
  text-align: center;
  margin: 2px 0 0;
  font-size: 16px;
  color: var(--text);
}
.mini-heart { color: var(--pink); font-size: 14px; }

.card-note {
  text-align: center;
  margin: 8px 0 0;
  font-size: 13px;
  color: var(--pink-deep);
  background: #fff2f5;
  border-radius: var(--radius-pill);
  padding: 6px 12px;
}

/* ===== ごほうび ===== */
.rewards {
  margin-top: 16px;
  background: #fffdf9;
  border: 1.5px solid #f3e3d3;
  border-radius: var(--radius-md);
  padding: 22px 12px 12px;
  position: relative;
}

.ribbon {
  position: absolute;
  top: -14px;
  left: 50%;
  transform: translateX(-50%);
  margin: 0;
  background: linear-gradient(180deg, #f7a8b8, #ef91a5);
  color: #fff;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: .16em;
  padding: 5px 26px;
  border-radius: 8px;
  box-shadow: 0 4px 8px rgba(217, 120, 143, .25);
  white-space: nowrap;
}
.ribbon::before, .ribbon::after {
  content: "";
  position: absolute;
  top: 50%;
  width: 12px; height: 22px;
  transform: translateY(-50%);
  background: #e8879b;
  z-index: -1;
}
.ribbon::before { left: -9px; clip-path: polygon(0 0, 100% 22%, 100% 78%, 0 100%); }
.ribbon::after  { right: -9px; clip-path: polygon(100% 0, 0 22%, 0 78%, 100% 100%); }

.rewards-body { display: flex; align-items: flex-end; gap: 8px; }

.reward-list { list-style: none; margin: 0; padding: 0; flex: 1 1 auto; min-width: 0; }
.reward-list li {
  display: flex;
  align-items: baseline;
  gap: 5px;
  font-size: clamp(11.5px, 3.25vw, 13.5px);
  padding: 5px 0;
  border-bottom: 1px dashed #f0e0d2;
}
.reward-list .rw-what { flex: 1 1 auto; min-width: 0; }
.reward-list li:last-child { border-bottom: none; }
.reward-list .rw-gift { font-size: 13px; flex: 0 0 auto; }
.reward-list .rw-when { color: var(--text-soft); flex: 0 0 auto; white-space: nowrap; }
.reward-list li.is-earned { color: var(--pink-deep); }
.reward-list li.is-earned .rw-when { color: var(--pink); }
.reward-list li.is-earned .rw-what { text-decoration: none; font-weight: 700; }
.reward-list li.is-earned::after { content: "♡"; color: var(--pink); font-size: 12px; }

.reward-illust { flex: 0 0 74px; text-align: center; padding-bottom: 4px; }
.bubble {
  position: relative;
  background: #fff2f5;
  border: 1.5px solid #f7d7de;
  border-radius: 50% / 42%;
  padding: 10px 8px;
  font-size: 11px;
  line-height: 1.4;
  color: var(--pink-deep);
}
.bubble-heart { display: block; font-size: 10px; }
.bubble::after {
  content: "";
  position: absolute;
  bottom: -7px; left: 30%;
  width: 12px; height: 12px;
  background: #fff2f5;
  border-right: 1.5px solid #f7d7de;
  border-bottom: 1.5px solid #f7d7de;
  transform: rotate(45deg);
}
.sweets { width: 100%; height: auto; margin-top: 6px; }

/* ===== ボタン ===== */
.btn-main {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  min-height: 62px;
  margin-top: 16px;
  border-radius: var(--radius-pill);
  background: linear-gradient(180deg, #ef8fa4, #d9788f);
  color: #fff;
  font-size: 21px;
  font-weight: 800;
  letter-spacing: .06em;
  box-shadow: 0 6px 0 #c2687e, 0 10px 18px rgba(197, 106, 126, .3);
  transition: transform .12s ease, box-shadow .12s ease, filter .2s ease;
}
.btn-main:active { transform: translateY(4px); box-shadow: 0 2px 0 #c2687e, 0 4px 10px rgba(197, 106, 126, .3); }
.btn-main .btn-icon { width: 34px; height: 34px; flex: 0 0 auto; }
.btn-main .btn-icon svg { width: 100%; height: 100%; display: block; }
.btn-main .btn-arrow { font-size: 26px; opacity: .85; }
.btn-main.is-complete { background: linear-gradient(180deg, #f6c177, #e8a955); box-shadow: 0 6px 0 #cf9343, 0 10px 18px rgba(207, 147, 67, .3); }
.btn-main.is-complete:active { box-shadow: 0 2px 0 #cf9343, 0 4px 10px rgba(207, 147, 67, .3); }

.btn-sub {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  min-height: 50px;
  margin-top: 12px;
  border-radius: var(--radius-pill);
  background: #fff;
  border: 2px solid var(--pink-soft);
  color: var(--pink-deep);
  font-size: 17px;
  font-weight: 700;
  letter-spacing: .06em;
  box-shadow: var(--shadow-soft);
  transition: transform .12s ease;
}
.btn-sub:active { transform: scale(.98); }
.btn-icon-sm { font-size: 18px; }

.admin-row { text-align: center; margin-top: 10px; }
.admin-link {
  font-size: 11px;
  color: #cbb8b2;
  letter-spacing: .2em;
  padding: 12px 22px;
  min-height: 42px;
}

.footer-msg {
  text-align: center;
  font-size: 12px;
  color: #c3a9a4;
  margin: 14px 0 0;
}

/* ===== 演出（ハート・花・キラキラ） ===== */
.fx-layer { position: fixed; inset: 0; pointer-events: none; z-index: 55; overflow: hidden; }
.fx {
  position: absolute;
  font-size: 20px;
  will-change: transform, opacity;
  animation: fxFloat 1.5s ease-out forwards;
}
@keyframes fxFloat {
  0%   { opacity: 0; transform: translate(0, 0) scale(.4) rotate(0deg); }
  20%  { opacity: 1; }
  100% { opacity: 0; transform: translate(var(--dx), var(--dy)) scale(1.1) rotate(var(--rot)); }
}

/* ===== オーバーレイ／ポップアップ ===== */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(120, 85, 90, .35);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px 16px calc(20px + env(safe-area-inset-bottom));
  animation: fadeIn .2s ease;
}
.overlay[hidden] { display: none; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.popup {
  width: 100%;
  max-width: 360px;
  max-height: 88vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  background: var(--cream);
  border-radius: var(--radius-lg);
  box-shadow: 0 18px 40px rgba(120, 85, 90, .3);
  padding: 20px 20px 18px;
  text-align: center;
  border: 2px solid #fff;
  animation: popIn .34s cubic-bezier(.2, 1.5, .45, 1);
}
@keyframes popIn { from { opacity: 0; transform: scale(.8) translateY(14px); } to { opacity: 1; transform: none; } }

.popup-chara { width: 96px; margin: -6px auto 4px; }
.popup-chara svg { width: 100%; height: auto; display: block; animation: bob 3s ease-in-out infinite; }

.popup-badge {
  display: inline-block;
  margin: 0 0 8px;
  background: var(--pink-soft);
  color: var(--pink-deep);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .16em;
  padding: 4px 16px;
  border-radius: var(--radius-pill);
}
.popup-title { margin: 0 0 6px; font-size: 21px; font-weight: 800; color: var(--pink-deep); line-height: 1.4; }
.popup-lead { margin: 0; font-size: 14px; color: var(--text-soft); }
.popup-prize {
  margin: 6px 0 10px;
  font-size: 19px;
  font-weight: 800;
  color: var(--text);
  background: #fff;
  border-radius: var(--radius-md);
  padding: 12px 10px;
  border: 1.5px dashed var(--pink-soft);
  line-height: 1.5;
}
.popup-msg { margin: 0 0 14px; font-size: 14px; color: var(--text-soft); line-height: 1.7; }

.popup-close {
  width: 100%;
  min-height: 50px;
  border-radius: var(--radius-pill);
  background: linear-gradient(180deg, #ef8fa4, #d9788f);
  color: #fff;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: .08em;
  box-shadow: 0 4px 0 #c2687e;
  transition: transform .12s ease, box-shadow .12s ease;
}
.popup-close:active { transform: translateY(3px); box-shadow: 0 1px 0 #c2687e; }

/* 5回目：すこし特別 */
.popup.tier-special { background: linear-gradient(180deg, #fff8f1, #fdf0f3); border-color: #fbe3c8; }
.popup.tier-special .popup-badge { background: #fbe6c4; color: #b98134; }
.popup.tier-special .popup-title { color: #d9788f; }
.popup.tier-special::before,
.popup.tier-grand::before {
  content: "";
  display: block;
  height: 4px;
  margin: -6px auto 10px;
  width: 60%;
  border-radius: 4px;
  background: linear-gradient(90deg, transparent, #f6c98f, transparent);
}

/* 10回目：カード1枚ぶんの、いちばんあたたかい演出 */
.popup.tier-grand {
  background: linear-gradient(180deg, #fffaf2 0%, #fdf1f4 60%, #fff6f8 100%);
  border-color: #f7d9a8;
  box-shadow: 0 0 0 4px rgba(247, 217, 168, .4), 0 18px 40px rgba(120, 85, 90, .3);
}
.popup.tier-grand .popup-badge { background: linear-gradient(90deg, #f7d9a8, #f7c0cc); color: #a9714a; }
.popup.tier-grand .popup-title { font-size: 23px; }
.popup.tier-grand .popup-prize { border-color: #f3d3a5; }
.popup.tier-grand .popup-chara { width: 118px; }

/* ===== シート（履歴・管理） ===== */
.sheet-title { margin: 0 0 4px; font-size: 19px; font-weight: 800; color: var(--pink-deep); }
.sheet-sub { margin: 0 0 12px; font-size: 13px; color: var(--text-soft); }

.history-scroll { max-height: 46vh; overflow-y: auto; -webkit-overflow-scrolling: touch; margin-bottom: 14px; }
.history-list { list-style: none; margin: 0; padding: 0; text-align: left; }
.history-list li {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #fff;
  border-radius: 14px;
  padding: 10px 12px;
  margin-bottom: 8px;
  font-size: 14px;
  box-shadow: 0 2px 6px rgba(214, 160, 172, .12);
}
.history-list .h-no {
  flex: 0 0 auto;
  min-width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--pink-soft);
  color: var(--pink-deep);
  font-size: 12px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}
.history-list .h-date { flex: 1 1 auto; color: var(--text); }
.history-list .h-gift { flex: 0 0 auto; font-size: 14px; }
.history-empty { text-align: center; color: var(--text-soft); font-size: 14px; padding: 22px 0; }
.history-list li.history-card-label {
  display: block;
  background: none;
  box-shadow: none;
  padding: 4px 0 2px;
  margin: 6px 0 4px;
  text-align: center;
  font-size: 12px;
  color: var(--text-soft);
  letter-spacing: .08em;
}

.admin-action {
  display: block;
  width: 100%;
  min-height: 50px;
  margin-top: 6px;
  border-radius: var(--radius-md);
  background: #fff;
  border: 2px solid var(--pink-soft);
  color: var(--pink-deep);
  font-size: 16px;
  font-weight: 700;
}
.admin-action:active { transform: scale(.98); }
.admin-action.danger { border-color: #e8b6b6; color: #c56a6a; }
.admin-hint { margin: 6px 0 12px; font-size: 11.5px; color: var(--text-soft); }

.confirm-title { margin: 4px 0 8px; font-size: 19px; font-weight: 800; color: #c56a6a; }
.confirm-text { margin: 0 0 16px; font-size: 14px; color: var(--text); line-height: 1.7; }
.confirm-buttons { display: flex; gap: 10px; }
.btn-cancel, .btn-danger {
  flex: 1 1 0;
  min-height: 50px;
  border-radius: var(--radius-pill);
  font-size: 16px;
  font-weight: 700;
}
.btn-cancel { background: #fff; border: 2px solid var(--pink-soft); color: var(--pink-deep); }
.btn-danger { background: #d98a8a; color: #fff; box-shadow: 0 4px 0 #c07272; }
.btn-danger:active { transform: translateY(3px); box-shadow: 0 1px 0 #c07272; }

/* ===== トースト ===== */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(28px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 60;
  background: rgba(107, 84, 80, .92);
  color: #fff;
  font-size: 14px;
  padding: 10px 20px;
  border-radius: var(--radius-pill);
  box-shadow: 0 6px 16px rgba(0, 0, 0, .2);
  animation: toastIn .25s ease;
  max-width: 88vw;
  text-align: center;
}
.toast[hidden] { display: none; }
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 12px); } to { opacity: 1; transform: translate(-50%, 0); } }

/* ===== 小さい画面の微調整 ===== */
@media (max-width: 359px) {
  .app { padding-left: 12px; padding-right: 12px; }
  .card { padding: 16px 12px 14px; }
  .stamp-grid { gap: 6px; }
  .btn-main { font-size: 19px; }

  /* 幅がせまい端末では、ごほうび一覧を1行ずつ読みやすく */
  .rewards-body { flex-direction: column; align-items: stretch; gap: 4px; }
  .reward-illust {
    flex: none;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 4px 0 0;
  }
  .bubble { font-size: 10.5px; padding: 8px 12px; }
  .sweets { width: 96px; margin-top: 0; }
}

/* ===== アニメーションを減らす設定 ===== */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}
