/* ============================================================
   サブキャス・ボルダー図鑑 スタイル
   世界観：スタンプ帳・図鑑。生成りの紙＋朱色スタンプ。
   ============================================================ */
:root {
  --paper: #f4ecd9;
  --paper-2: #fdf8ec;
  --paper-3: #efe4c8;
  --ink: #37312a;
  --ink-soft: #6f6656;
  --vermillion: #c73e1d;
  --vermillion-dark: #a02f14;
  --line: #d8cba9;
  --grey: #a49a86;
  --grey-dark: #7c7462;
  --ok: #38685c;
  --danger: #b3261e;
  --radius: 14px;
  --shadow: 0 2px 10px rgba(80, 64, 32, .12);
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: "Hiragino Maru Gothic ProN", "Hiragino Sans", "Yu Gothic UI",
    "Yu Gothic", "Noto Sans JP", sans-serif;
  background:
    radial-gradient(circle at 15% 20%, rgba(199,62,29,.05), transparent 40%),
    radial-gradient(circle at 85% 90%, rgba(56,104,92,.06), transparent 40%),
    var(--paper);
  color: var(--ink);
  min-height: 100vh;
}
#app { max-width: 560px; margin: 0 auto; padding: 0 14px 90px; }
.hidden { display: none !important; }
h2 { font-size: 1.25rem; margin: 18px 0 10px; }
h3 { font-size: 1.05rem; margin: 8px 0; }
p { line-height: 1.7; }

/* ---------- header ---------- */
.app-header {
  position: sticky; top: 0; z-index: 20;
  background: linear-gradient(var(--paper) 88%, transparent);
  padding: 14px 0 10px;
}
.header-inner { display: flex; align-items: center; gap: 12px; }
.logo-stamp {
  flex: 0 0 auto; width: 46px; height: 46px;
  background: var(--vermillion); color: #fff;
  font-size: 1.45rem; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  border-radius: 8px; transform: rotate(-6deg);
  box-shadow: var(--shadow);
  border: 2px solid rgba(255,255,255,.55);
  outline: 2px solid var(--vermillion);
}
.header-title h1 { font-size: 1.18rem; margin: 0; letter-spacing: .02em; }
.tagline { margin: 2px 0 0; font-size: .78rem; color: var(--ink-soft); }
.mode-badge {
  margin-left: auto; flex: 0 0 auto;
  font-size: .7rem; font-weight: 700; color: var(--vermillion-dark);
  border: 1.5px solid var(--vermillion); border-radius: 999px;
  padding: 3px 10px; background: var(--paper-2);
}
.mode-badge.live { color: var(--ok); border-color: var(--ok); }

/* ---------- cards / forms ---------- */
.card {
  background: var(--paper-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  margin: 12px 0;
}
.intro-card p { margin: 6px 0; font-size: .94rem; }
.intro-card .note { font-size: .8rem; color: var(--ink-soft); }
.stamp-word {
  color: var(--vermillion); font-weight: 700;
  border: 1.5px solid var(--vermillion); border-radius: 6px;
  padding: 0 5px; display: inline-block; transform: rotate(-3deg);
}
.field { display: block; margin: 12px 0; font-size: .9rem; font-weight: 600; }
.field .req {
  color: #fff; background: var(--vermillion); font-size: .68rem;
  border-radius: 4px; padding: 1px 6px; margin-left: 6px; vertical-align: 2px;
}
.field .opt { color: var(--ink-soft); font-size: .72rem; margin-left: 6px; }
input[type="text"], input[type="password"], select, textarea {
  display: block; width: 100%; margin-top: 6px;
  font: inherit; font-weight: 400; color: var(--ink);
  background: #fff; border: 1.5px solid var(--line); border-radius: 10px;
  padding: 11px 12px;
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--vermillion); outline-offset: 0; border-color: transparent;
}
.btn-primary, .btn-secondary, .btn-ghost {
  font: inherit; font-weight: 700; cursor: pointer;
  border-radius: 999px; padding: 12px 20px; width: 100%;
  margin-top: 10px; transition: transform .05s ease, opacity .15s;
}
.btn-primary { background: var(--vermillion); color: #fff; border: none; box-shadow: var(--shadow); }
.btn-primary:active { transform: scale(.98); }
.btn-secondary { background: var(--paper-2); color: var(--vermillion-dark); border: 2px solid var(--vermillion); }
.btn-ghost { background: transparent; color: var(--ink-soft); border: 1.5px solid var(--line); }
.btn-ghost.danger { color: var(--danger); border-color: var(--danger); }
.btn-primary:disabled, .btn-secondary:disabled { opacity: .55; }
.error { color: var(--danger); font-size: .86rem; min-height: 1.2em; margin: 6px 0 0; }
.hint { font-size: .8rem; color: var(--ink-soft); }
.summary { color: var(--ink-soft); font-size: .9rem; margin: 4px 0 10px; }

/* ---------- auth ---------- */
.auth-tabs { display: flex; gap: 8px; margin-top: 14px; }
.auth-tab {
  flex: 1; font: inherit; font-weight: 700; cursor: pointer;
  padding: 11px; border-radius: 12px 12px 0 0;
  border: 1px solid var(--line); border-bottom: none;
  background: var(--paper-3); color: var(--ink-soft);
}
.auth-tab.active { background: var(--paper-2); color: var(--vermillion-dark); }
#form-login, #form-register { margin-top: 0; border-radius: 0 0 var(--radius) var(--radius); }
.done-stamp {
  width: 86px; height: 86px; margin: 4px auto 10px;
  border: 3px double var(--vermillion); border-radius: 50%;
  color: var(--vermillion); font-weight: 700; font-size: 1.05rem;
  display: flex; align-items: center; justify-content: center; text-align: center;
  transform: rotate(-8deg); line-height: 1.3;
}
#register-done { text-align: center; }
.new-code {
  font-size: 1.5rem; font-weight: 700; letter-spacing: .06em;
  background: #fff; border: 2px dashed var(--vermillion);
  border-radius: 10px; padding: 12px; margin: 10px 0;
  user-select: all;
}

/* ---------- icon picker ---------- */
.picker-row { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 6px; }
.emoji-btn {
  font-size: 1.35rem; width: 44px; height: 44px; cursor: pointer;
  background: #fff; border: 2px solid var(--line); border-radius: 12px;
}
.emoji-btn.selected { border-color: var(--vermillion); background: #fdeee8; }
.color-btn {
  width: 34px; height: 34px; border-radius: 50%; cursor: pointer;
  border: 3px solid transparent;
}
.color-btn.selected { border-color: var(--ink); }
.photo-row { display: flex; align-items: center; gap: 12px; margin-top: 6px; }
.photo-preview {
  width: 64px; height: 64px; border-radius: 50%; object-fit: cover;
  border: 2px solid var(--line); background: var(--paper-3);
}
.photo-btns { display: flex; flex-direction: column; gap: 6px; }
.mini-btn {
  font: inherit; font-size: .8rem; font-weight: 700; cursor: pointer;
  border-radius: 999px; padding: 7px 14px;
  background: var(--paper-2); border: 1.5px solid var(--line); color: var(--ink);
}

/* ---------- avatar ---------- */
.avatar {
  border-radius: 50%; display: flex; align-items: center; justify-content: center;
  overflow: hidden; flex: 0 0 auto; font-size: 1.5rem;
  border: 2px solid rgba(255,255,255,.7);
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar-md { width: 58px; height: 58px; }
.avatar-lg { width: 84px; height: 84px; font-size: 2.4rem; margin: 0 auto; }
.avatar-silhouette { background: #cfc6ae !important; }

/* ---------- roster ---------- */
.roster-head h2 { margin-bottom: 2px; }
.roster-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 12px;
}
.member-card {
  position: relative; cursor: pointer; text-align: center;
  background: var(--paper-2); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 16px 10px 12px; overflow: hidden;
}
.member-card .avatar { margin: 0 auto 8px; width: 64px; height: 64px; font-size: 1.8rem; }
.member-name { font-weight: 700; font-size: .98rem; word-break: break-all; }
.member-sub { font-size: .76rem; color: var(--ink-soft); margin-top: 3px; line-height: 1.5; }
.member-card.unmet { background: var(--paper-3); color: var(--grey-dark); }
.member-card.unmet .member-name { letter-spacing: .2em; }
.met-stamp {
  position: absolute; top: 8px; right: 6px;
  color: var(--vermillion); font-weight: 700; font-size: .82rem;
  border: 2.5px double var(--vermillion); border-radius: 8px;
  padding: 2px 7px; transform: rotate(10deg);
  background: rgba(253,248,236,.85);
}
.meet-count {
  display: inline-block; margin-top: 6px; font-size: .74rem; font-weight: 700;
  color: var(--vermillion-dark); background: #fdeee8; border-radius: 999px; padding: 2px 9px;
}
.sample-tag {
  position: absolute; top: 8px; left: 8px; font-size: .64rem; color: var(--ink-soft);
  border: 1px solid var(--line); border-radius: 4px; padding: 1px 5px; background: var(--paper-2);
}

/* ---------- scan ---------- */
.scan-box {
  position: relative; background: #241f18; border-radius: var(--radius);
  overflow: hidden; aspect-ratio: 4 / 3; margin: 10px 0;
  display: flex; align-items: center; justify-content: center;
}
#scan-video { width: 100%; height: 100%; object-fit: cover; }
.scan-placeholder { color: #e8dfc8; text-align: center; padding: 20px; position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center; }
.scan-placeholder p:first-child { font-size: 2.2rem; margin: 0; }
.manual-box h3 { margin-top: 0; }

/* ---------- my QR ---------- */
.qr-card { text-align: center; }
#my-qr { margin: 12px auto; display: block; background: #fff; border-radius: 10px; }
.my-name { font-size: 1.2rem; font-weight: 700; margin-top: 8px; }
.my-meta { color: var(--ink-soft); font-size: .85rem; margin-top: 2px; }
.my-code {
  font-size: 1.25rem; font-weight: 700; letter-spacing: .05em;
  border-top: 2px dashed var(--line); padding-top: 10px; user-select: all;
}

/* ---------- distribution ---------- */
.dist-region {
  background: var(--paper-2); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 14px 16px; margin: 10px 0;
}
.dist-region-head { display: flex; justify-content: space-between; align-items: baseline; }
.dist-region-name { font-weight: 700; }
.dist-nums { font-size: .84rem; color: var(--ink-soft); }
.dist-nums strong { color: var(--vermillion-dark); }
.dist-bar {
  height: 14px; background: var(--paper-3); border-radius: 999px;
  margin: 9px 0 6px; overflow: hidden; border: 1px solid var(--line);
}
.dist-bar-fill {
  height: 100%; background: repeating-linear-gradient(
    -45deg, var(--vermillion), var(--vermillion) 8px, #d6502f 8px, #d6502f 16px);
  border-radius: 999px; transition: width .5s ease;
}
.dist-prefs { font-size: .78rem; color: var(--ink-soft); line-height: 1.9; }
.dist-prefs .pref b { color: var(--ink); }

/* ---------- mypage ---------- */
.profile-view-head { display: flex; gap: 14px; align-items: center; }
.profile-rows { margin-top: 10px; font-size: .9rem; }
.profile-rows div { display: flex; gap: 10px; padding: 6px 0; border-top: 1px dashed var(--line); }
.profile-rows dt { flex: 0 0 92px; color: var(--ink-soft); font-size: .82rem; }
.profile-rows dd { margin: 0; }
.mypage-actions { margin-top: 18px; }

/* ---------- overlays ---------- */
.overlay {
  position: fixed; inset: 0; z-index: 40;
  background: rgba(46, 38, 24, .55);
  display: flex; align-items: flex-end; justify-content: center;
}
.overlay-sheet {
  background: var(--paper-2); width: 100%; max-width: 560px; max-height: 88vh;
  overflow-y: auto; border-radius: 20px 20px 0 0; padding: 20px 18px 30px;
  position: relative; animation: sheet-up .22s ease;
}
@keyframes sheet-up { from { transform: translateY(30px); opacity: .4; } to { transform: none; opacity: 1; } }
.overlay-close {
  position: absolute; top: 10px; right: 12px; z-index: 2;
  width: 38px; height: 38px; border-radius: 50%; border: 1.5px solid var(--line);
  background: var(--paper); font-size: 1.2rem; cursor: pointer; color: var(--ink);
}
.detail-head { text-align: center; padding-top: 6px; }
.detail-head .avatar { margin: 0 auto 8px; width: 84px; height: 84px; font-size: 2.3rem; }
.detail-name { font-size: 1.25rem; font-weight: 700; }
.detail-stamp {
  display: inline-block; margin-top: 8px; color: var(--vermillion); font-weight: 700;
  border: 3px double var(--vermillion); border-radius: 10px; padding: 4px 14px;
  transform: rotate(-5deg); font-size: 1.05rem;
}
.history-list { list-style: none; margin: 10px 0; padding: 0; }
.history-list li {
  display: flex; justify-content: space-between; gap: 10px;
  padding: 9px 2px; border-top: 1px dashed var(--line); font-size: .9rem;
}
.history-list .h-event { color: var(--ink-soft); font-size: .82rem; text-align: right; }

/* ---------- stamp overlay ---------- */
.stamp-overlay {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(253, 248, 236, .88);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
}
.stamp-seal {
  width: 190px; height: 190px; border-radius: 50%;
  border: 6px double var(--vermillion); color: var(--vermillion);
  font-size: 2.6rem; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  transform: rotate(-10deg);
  animation: stamp-in .45s cubic-bezier(.2, 2.2, .4, 1) both;
  background: rgba(255,255,255,.5);
}
@keyframes stamp-in {
  0% { transform: rotate(-10deg) scale(2.6); opacity: 0; }
  60% { opacity: 1; }
  100% { transform: rotate(-10deg) scale(1); opacity: 1; }
}
.stamp-text { font-weight: 700; font-size: 1.05rem; margin-top: 18px; color: var(--ink); text-align: center; padding: 0 20px; }

/* ---------- admin ---------- */
.admin-row {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 2px; border-top: 1px dashed var(--line);
}
.admin-row .grow { flex: 1; min-width: 0; }
.admin-row .a-name { font-weight: 700; }
.admin-row .a-sub { font-size: .76rem; color: var(--ink-soft); }
.del-btn {
  font: inherit; font-size: .8rem; font-weight: 700; cursor: pointer;
  color: #fff; background: var(--danger); border: none;
  border-radius: 999px; padding: 8px 14px; flex: 0 0 auto;
}

/* ---------- tab bar ---------- */
.tab-bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  max-width: 560px; margin: 0 auto;
  display: flex; background: var(--paper-2);
  border-top: 1.5px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tab-btn {
  flex: 1; font: inherit; font-size: .68rem; font-weight: 700; cursor: pointer;
  background: none; border: none; color: var(--ink-soft);
  padding: 8px 2px 10px; display: flex; flex-direction: column; align-items: center; gap: 2px;
}
.tab-btn .tab-ico { font-size: 1.25rem; }
.tab-btn.active { color: var(--vermillion-dark); }

.toast {
  position: fixed; left: 50%; bottom: 92px; transform: translateX(-50%);
  z-index: 70; background: var(--ink); color: #fdf8ec;
  padding: 11px 20px; border-radius: 999px; font-size: .88rem; font-weight: 700;
  box-shadow: var(--shadow); max-width: 88vw; text-align: center;
}
.app-footer { text-align: center; color: var(--ink-soft); font-size: .72rem; margin-top: 26px; }
