/* 喫茶ふでまめ御得意様之証 — 和風テーマ */

:root {
  --washi: #f7f2e7;
  --washi-deep: #efe6d3;
  --sumi: #3a2f25;
  --sumi-light: #7a6c5a;
  --shu: #b5442c;   /* 朱色 */
  --shu-deep: #8e3421;
  --matcha: #6b7d4f;
  --line: #d9cdb4;
  --card: #fffdf7;
}

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

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: "Hiragino Mincho ProN", "Yu Mincho", "YuMincho", "Noto Serif JP", serif;
  background: var(--washi);
  background-image: radial-gradient(rgba(58, 47, 37, 0.025) 1px, transparent 1px);
  background-size: 14px 14px;
  color: var(--sumi);
  line-height: 1.7;
  min-height: 100vh;
}

.wrap { max-width: 480px; margin: 0 auto; padding: 12px 16px 84px; }

/* ---------- ヘッダー（管理画面用・シンプル） ---------- */

.app-header { text-align: center; padding: 12px 0 4px; }
.app-header .kanban {
  display: inline-block;
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  padding: 6px 18px;
  border-top: 3px double var(--sumi);
  border-bottom: 3px double var(--sumi);
}
.app-header .sub { font-size: 0.72rem; color: var(--sumi-light); letter-spacing: 0.3em; margin-top: 4px; }

/* ---------- 町屋ヘッダー（fal生成: 看板→瓦屋根→のれん。文字はHTMLで重ねる） ---------- */

.machiya { margin: -4px -16px 0; }
.machiya .scene { position: relative; max-width: 300px; margin: 0 auto; }
.machiya .scene img { width: 100%; display: block; }
.machiya .kanban-moji {
  position: absolute;
  left: 50.5%;
  top: 15.5%;
  transform: translate(-50%, -50%);
  font-family: "Yuji Syuku", "Hiragino Mincho ProN", "Yu Mincho", serif;
  font-weight: 700;
  color: #d9b36c;
  font-size: 23px;
  letter-spacing: 0.14em;
  text-indent: 0.14em;
  white-space: nowrap;
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.65), 0 0 6px rgba(0, 0, 0, 0.25);
}
.machiya .noren-moji {
  position: absolute;
  left: 50%;
  top: 70%;
  transform: translate(-50%, -50%);
  font-family: "Yuji Syuku", "Hiragino Mincho ProN", "Yu Mincho", serif;
  color: #f3ecd9;
  font-size: 12.5px;
  letter-spacing: 0.42em;
  text-indent: 0.42em;
  white-space: nowrap;
}

/* ---------- カード共通 ---------- */

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 14px;
  margin-top: 10px;
  box-shadow: 0 2px 6px rgba(58, 47, 37, 0.06);
}
.card h2 {
  font-size: 0.95rem;
  letter-spacing: 0.15em;
  color: var(--shu-deep);
  border-bottom: 1px solid var(--line);
  padding-bottom: 6px;
  margin-bottom: 12px;
}

/* ---------- たぬきちゃん ---------- */

.tanuki-row { display: flex; align-items: center; gap: 14px; }
.tanuki-info { flex: 1; display: flex; flex-direction: column; align-items: flex-start; gap: 4px; }
.tanuki-figure { position: relative; display: inline-block; flex: 0 0 auto; transition: transform 0.6s ease; }
.tanuki-figure img.tanuki { width: 98px; height: auto; display: block; filter: drop-shadow(0 4px 6px rgba(58,47,37,0.18)); }
.tanuki-figure .deco { position: absolute; font-size: 1.5rem; }
.deco-1 { top: -8px; right: -18px; }
.deco-2 { bottom: 6px; left: -26px; }
.deco-3 { top: 30%; right: -34px; }
.deco-4 { top: -14px; left: -14px; transform: rotate(-15deg); }
.deco-5 { bottom: -6px; right: -30px; }

.tanuki-title {
  display: inline-block;
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: var(--card);
  background: var(--sumi);
  border-radius: 4px;
  padding: 2px 14px;
}
.tanuki-nickname { font-size: 0.82rem; color: var(--sumi-light); }

/* ---------- スタンプ帳 ---------- */

.stamp-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; }
.stamp-slot {
  aspect-ratio: 1;
  border: 2px dashed var(--line);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--washi);
  position: relative;
}
.stamp-slot img.ghost { width: 78%; height: 78%; object-fit: contain; opacity: 0.15; }
.stamp-slot .num {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.1rem;
  font-weight: 900;
  color: #fcfaf1;
  text-shadow: 0 1px 2px rgba(58, 47, 37, 0.55), 0 2px 6px rgba(58, 47, 37, 0.35);
}
.stamp-slot.filled { border: 2px solid var(--shu); background: var(--card); }
.stamp-slot.filled img { width: 78%; height: 78%; object-fit: contain; }
.stamp-count { text-align: center; margin-top: 6px; font-size: 0.88rem; }
.stamp-count b { color: var(--shu-deep); font-size: 1.3rem; }

/* ---------- 豆知識 ---------- */

.tip-category {
  display: inline-block;
  font-size: 0.7rem;
  color: var(--matcha);
  border: 1px solid var(--matcha);
  border-radius: 999px;
  padding: 0 10px;
  margin-bottom: 6px;
}
.tip-title { font-size: 1.02rem; font-weight: 700; margin-bottom: 6px; }
.tip-body { font-size: 0.9rem; }
.tip-date { font-size: 0.72rem; color: var(--sumi-light); margin-top: 8px; text-align: right; }
.tip-item { border-bottom: 1px dashed var(--line); padding: 12px 0; }
.tip-item:last-child { border-bottom: none; }

/* ---------- クーポン（手形） ---------- */

.tegata {
  border: 3px double var(--sumi);
  border-radius: 6px;
  background: linear-gradient(160deg, #fffdf7 0%, #f6eeda 100%);
  padding: 18px 16px;
  margin-top: 14px;
  position: relative;
  overflow: hidden;
}
.tegata::before {
  content: "喫茶ふでまめ";
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%) rotate(-12deg);
  font-size: 1.9rem;
  color: rgba(181, 68, 44, 0.08);
  white-space: nowrap;
  letter-spacing: 0.3em;
  pointer-events: none;
}
.tegata-title { font-size: 1.3rem; font-weight: 700; letter-spacing: 0.22em; text-align: center; color: var(--shu-deep); }
.tegata-desc { font-size: 0.85rem; text-align: center; margin-top: 8px; }
.tegata-meta { font-size: 0.72rem; color: var(--sumi-light); text-align: center; margin-top: 8px; }
.tegata-seal {
  position: absolute;
  right: 10px; bottom: 10px;
  width: 44px; height: 44px;
  border: 2px solid var(--shu);
  border-radius: 50%;
  color: var(--shu);
  font-size: 0.62rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  line-height: 1.2;
  transform: rotate(8deg);
  letter-spacing: 0.05em;
}
.tegata.used { filter: grayscale(1) opacity(0.55); }
.tegata.used::after {
  content: "使用済";
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%) rotate(-18deg);
  border: 3px solid var(--sumi);
  border-radius: 6px;
  padding: 2px 14px;
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--sumi);
  background: rgba(255, 253, 247, 0.75);
}

/* ---------- ボタン ---------- */

.btn {
  display: block;
  width: 100%;
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  padding: 12px;
  margin-top: 12px;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  text-align: center;
  text-decoration: none;
  color: var(--card);
  background: var(--shu);
}
.btn:active { background: var(--shu-deep); }
.btn.secondary { background: var(--card); color: var(--sumi); border: 1px solid var(--sumi-light); }
.btn.insta { background: linear-gradient(45deg, #f09433, #e6683c, #dc2743, #cc2366, #bc1888); }
.btn:disabled { background: var(--line); color: var(--sumi-light); cursor: default; }
.btn.small { display: inline-block; width: auto; padding: 6px 16px; font-size: 0.8rem; margin-top: 8px; }

/* ---------- 下部ナビ ---------- */

.bottom-nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: var(--card);
  border-top: 1px solid var(--line);
  display: flex;
  max-width: 480px;
  margin: 0 auto;
  z-index: 10;
}
.bottom-nav button {
  flex: 1;
  font-family: inherit;
  font-size: 0.7rem;
  letter-spacing: 0.05em;
  padding: 6px 0 8px;
  border: none;
  background: none;
  color: var(--sumi-light);
  cursor: pointer;
}
.bottom-nav button .icon { display: block; font-size: 1.15rem; }
.bottom-nav button.active { color: var(--shu-deep); font-weight: 700; }

.view { display: none; }
.view.active { display: block; }

/* ---------- フォーム ---------- */

input[type="text"], input[type="password"], input[type="date"], textarea, select {
  font-family: inherit;
  font-size: 1rem;
  width: 100%;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--card);
  color: var(--sumi);
  margin-top: 6px;
}
label { font-size: 0.82rem; color: var(--sumi-light); display: block; margin-top: 10px; }

.note { font-size: 0.78rem; color: var(--sumi-light); margin-top: 8px; }
.error-msg { color: var(--shu-deep); font-size: 0.85rem; margin-top: 8px; }

/* ---------- モーダル ---------- */

.modal-bg {
  position: fixed; inset: 0;
  background: rgba(58, 47, 37, 0.5);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 100;
}
.modal-bg.open { display: flex; }
.modal {
  background: var(--card);
  border-radius: 12px;
  padding: 22px;
  width: 100%;
  max-width: 400px;
  max-height: 85vh;
  overflow-y: auto;
}
.modal h3 { font-size: 1rem; letter-spacing: 0.1em; margin-bottom: 8px; color: var(--shu-deep); }

/* ---------- 押印アニメーション（宙返り→着地） ---------- */

.fly-stage { text-align: center; padding: 16px 0 12px; }
.fly-tanuki {
  width: 140px;
  height: auto;
  will-change: transform;
  filter: drop-shadow(0 5px 8px rgba(58, 47, 37, 0.22));
}
.stamp-burst {
  position: absolute;
  inset: -6px;
  border: 3px solid var(--shu);
  border-radius: 50%;
  pointer-events: none;
  animation: burst-ring 0.6s ease-out forwards;
}
@keyframes burst-ring {
  from { transform: scale(0.6); opacity: 0.9; }
  to { transform: scale(1.7); opacity: 0; }
}
.stamp-after {
  text-align: center;
  margin-top: 16px;
  opacity: 0;
  transition: opacity 0.5s ease;
}
.stamp-after.show { opacity: 1; }
.stamp-after .big { font-size: 1.15rem; font-weight: 700; letter-spacing: 0.12em; }

/* ---------- スタンプ演出 ---------- */

.stamp-anim { text-align: center; padding: 30px 0 10px; }
.stamp-anim img { width: 170px; animation: stamp-pop 0.7s cubic-bezier(0.2, 2.2, 0.4, 1) both; }
@keyframes stamp-pop {
  0% { transform: scale(3) rotate(-10deg); opacity: 0; }
  60% { transform: scale(0.95) rotate(2deg); opacity: 1; }
  100% { transform: scale(1) rotate(0); opacity: 1; }
}
.stamp-anim .big { font-size: 1.2rem; font-weight: 700; letter-spacing: 0.15em; margin-top: 14px; }

/* ---------- 管理画面 ---------- */

.admin-tabs { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 14px; }
.admin-tabs button {
  font-family: inherit;
  font-size: 0.8rem;
  padding: 7px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--card);
  color: var(--sumi);
  cursor: pointer;
}
.admin-tabs button.active { background: var(--sumi); color: var(--card); border-color: var(--sumi); }

.stat-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.stat-box { background: var(--washi-deep); border-radius: 8px; padding: 10px; text-align: center; }
.stat-box .num { font-size: 1.5rem; font-weight: 700; color: var(--shu-deep); }
.stat-box .lbl { font-size: 0.72rem; color: var(--sumi-light); }

.bar-chart { display: flex; align-items: flex-end; gap: 2px; height: 90px; margin-top: 10px; }
.bar-chart .bar { flex: 1; background: var(--matcha); border-radius: 2px 2px 0 0; min-height: 2px; position: relative; }
.bar-chart .bar span {
  position: absolute; top: -16px; left: 50%; transform: translateX(-50%);
  font-size: 0.6rem; color: var(--sumi-light);
}
.chart-labels { display: flex; justify-content: space-between; font-size: 0.65rem; color: var(--sumi-light); }

table.admin-table { width: 100%; border-collapse: collapse; font-size: 0.82rem; margin-top: 10px; }
table.admin-table th, table.admin-table td { border-bottom: 1px solid var(--line); padding: 7px 4px; text-align: left; }
table.admin-table th { color: var(--sumi-light); font-weight: normal; font-size: 0.72rem; }

.tip-admin-item { border: 1px solid var(--line); border-radius: 8px; padding: 10px; margin-top: 10px; background: var(--card); }
.tip-admin-item.inactive { opacity: 0.5; }
.tip-admin-item .head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.tip-admin-item .ttl { font-weight: 700; font-size: 0.9rem; }
.tip-admin-item .bd { font-size: 0.8rem; color: var(--sumi-light); margin-top: 4px; }
.icon-btn { border: 1px solid var(--line); background: var(--card); border-radius: 6px; padding: 4px 8px; cursor: pointer; font-size: 0.8rem; font-family: inherit; }

.qr-box { text-align: center; margin-top: 12px; }
.qr-box img { border: 1px solid var(--line); border-radius: 8px; background: #fff; padding: 8px; }
.url-box {
  font-family: monospace;
  font-size: 0.75rem;
  background: var(--washi-deep);
  border-radius: 6px;
  padding: 8px;
  margin-top: 8px;
  word-break: break-all;
}

.toast {
  position: fixed;
  bottom: 70px; left: 50%; transform: translateX(-50%);
  background: var(--sumi); color: var(--card);
  border-radius: 999px;
  padding: 8px 20px;
  font-size: 0.85rem;
  opacity: 0;
  transition: opacity 0.3s;
  pointer-events: none;
  z-index: 200;
  white-space: nowrap;
}
.toast.show { opacity: 1; }
