:root {
  --bg: #fff6d6;
  --dot: #ffe48a;
  --ink: #4a3426;
  --sub: #8a6d5a;
  --pink: #ff6fa8;
  --pink-d: #e04f8a;
  --yellow: #ffd84d;
  --yellow-d: #e9b800;
  --mint: #5fd3b5;
  --sky: #6cc4ff;
  --card: #ffffff;
  --line: #f1dcae;
  --danger: #e2544a;
  --radius: 22px;
  --font: 'M PLUS Rounded 1c', 'Hiragino Maru Gothic ProN', 'Yu Gothic', sans-serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; }
body {
  font-family: var(--font);
  font-weight: 500;
  color: var(--ink);
  background-color: var(--bg);
  background-image: radial-gradient(var(--dot) 3px, transparent 3.5px);
  background-size: 26px 26px;
  min-height: 100vh;
  overscroll-behavior-y: none;
}
[hidden] { display: none !important; }
button, input, textarea { font: inherit; color: inherit; }

/* ---------- ロゴ ---------- */
.logo-text {
  font-weight: 800;
  margin: 0;
  line-height: 1.15;
  letter-spacing: .02em;
  color: var(--pink);
  text-shadow: 3px 3px 0 #fff, 5px 5px 0 var(--yellow);
}
.logo-text.small { font-size: 20px; text-shadow: 2px 2px 0 #fff, 3px 3px 0 var(--yellow); }

/* ---------- ボタン ---------- */
.btn {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%;
  border: 0; border-radius: 999px;
  font-weight: 800; cursor: pointer;
  transition: transform .08s;
  user-select: none;
}
.btn:active { transform: translateY(3px); }
.btn.big { font-size: 22px; padding: 16px; }
.btn.huge { font-size: 24px; padding: 34px 16px; border-radius: 30px; }
.btn.mid { font-size: 17px; padding: 13px; }
.btn.small { font-size: 14px; padding: 10px; }
.btn.pink { background: var(--pink); color: #fff; box-shadow: 0 5px 0 var(--pink-d); }
.btn.yellow { background: var(--yellow); color: var(--ink); box-shadow: 0 6px 0 var(--yellow-d); }
.btn.ghost { background: #fff; color: var(--ink); box-shadow: 0 4px 0 var(--line); border: 2px solid var(--line); }
.btn.danger { color: var(--danger); }
.btn:disabled { opacity: .55; }

.icon-btn {
  width: 44px; height: 44px; border-radius: 50%;
  background: #fff; border: 2px solid var(--line);
  font-size: 20px; cursor: pointer; flex: none;
}
.chip {
  border: 2px solid var(--line); background: #fff; border-radius: 999px;
  padding: 6px 14px; font-weight: 800; font-size: 15px; cursor: pointer; white-space: nowrap;
}

/* ---------- あいことば ---------- */
#lock { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.lock-card {
  width: 100%; max-width: 380px; text-align: center;
  background: #fff; border-radius: 30px; padding: 30px 22px;
  border: 4px solid var(--yellow); box-shadow: 0 10px 0 var(--yellow-d);
}
.lock-logo { font-size: 64px; animation: bob 2.4s ease-in-out infinite; }
.lock-card h1 { font-size: 34px; margin: 6px 0 14px; }
.lock-card form { display: grid; gap: 14px; }

input, textarea {
  width: 100%;
  border: 3px solid var(--line); border-radius: 16px;
  padding: 13px 14px; font-size: 18px; background: #fffdf6;
  outline: none;
}
input:focus, textarea:focus { border-color: var(--sky); }
textarea { resize: none; }
.msg { min-height: 1.4em; color: var(--danger); font-weight: 800; margin: 10px 0 0; text-align: center; }

/* ---------- ギャラリー ---------- */
#gallery { padding-bottom: 120px; }
.top {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: rgba(255, 246, 214, .92);
  backdrop-filter: blur(6px);
  border-bottom: 3px dashed var(--line);
}
.filters {
  display: flex; gap: 8px; overflow-x: auto; padding: 12px 16px 4px;
  scrollbar-width: none;
}
.filters::-webkit-scrollbar { display: none; }
.filters .chip.on { background: var(--ink); color: #fff; border-color: var(--ink); }
.filters .chip .n { opacity: .7; font-size: 12px; margin-left: 4px; }
.stats { padding: 4px 18px; color: var(--sub); font-size: 14px; }

#grid { padding: 0 12px; }
.month {
  display: inline-block; margin: 18px 4px 10px;
  background: var(--mint); color: #fff; font-weight: 800;
  padding: 4px 14px; border-radius: 999px; font-size: 15px;
  box-shadow: 0 3px 0 #3fb497;
}
.cards { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px 12px; }
@media (min-width: 640px) { .cards { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 960px) { .cards { grid-template-columns: repeat(4, 1fr); } #grid { max-width: 1000px; margin: 0 auto; } }

.card {
  position: relative;
  background: var(--card); border-radius: 18px; padding: 8px 8px 10px;
  box-shadow: 0 5px 0 var(--line);
  border: 0; text-align: left; cursor: pointer; width: 100%;
  transform: rotate(var(--tilt, 0deg));
  animation: pop .35s ease-out both;
}
.card:active { transform: rotate(0) scale(.97); }
.card::before { /* マスキングテープ */
  content: ''; position: absolute; top: -9px; left: 50%;
  width: 54px; height: 18px; transform: translateX(-50%) rotate(-4deg);
  background: var(--tape, rgba(255, 111, 168, .55)); border-radius: 3px;
}
.card img {
  display: block; width: 100%; aspect-ratio: 1; object-fit: cover;
  border-radius: 12px; background: #f6efe0;
}
.card .t {
  font-weight: 800; font-size: 15px; margin-top: 7px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.card .s { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--sub); margin-top: 2px; }
.dotkid {
  display: inline-grid; place-items: center; width: 22px; height: 22px;
  border-radius: 50%; font-size: 13px; flex: none;
}

.empty { text-align: center; padding: 50px 20px; color: var(--sub); font-size: 18px; }
.empty-art { font-size: 80px; animation: bob 2.4s ease-in-out infinite; }

.fab {
  position: fixed; z-index: 6;
  right: 50%; transform: translateX(50%);
  bottom: calc(18px + env(safe-area-inset-bottom));
  display: flex; align-items: center; gap: 8px;
  border: 0; border-radius: 999px; cursor: pointer;
  background: var(--pink); color: #fff;
  font-size: 30px; font-weight: 800; padding: 12px 30px 12px 24px;
  box-shadow: 0 6px 0 var(--pink-d), 0 10px 24px rgba(224, 79, 138, .35);
  animation: wiggle 3.5s ease-in-out infinite;
}
.fab span { font-size: 24px; }
.fab:active { transform: translateX(50%) translateY(4px); }

/* ---------- シート ---------- */
.sheet {
  position: fixed; inset: 0; z-index: 20;
  background: rgba(74, 52, 38, .35);
  display: flex; align-items: flex-end; justify-content: center;
  animation: fade .2s;
}
.sheet-inner {
  width: 100%; max-width: 560px; max-height: 100%;
  overflow-y: auto;
  background: var(--bg); border-radius: 28px 28px 0 0;
  padding: 12px 16px calc(24px + env(safe-area-inset-bottom));
  display: grid; gap: 14px; align-content: start;
  animation: up .25s ease-out;
}
.sheet-top { display: grid; grid-template-columns: 44px 1fr 44px; align-items: center; gap: 8px; }
.sheet-top h2 { margin: 0; text-align: center; font-size: 19px; font-weight: 800; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#pickStep { display: grid; gap: 14px; padding: 10px 0 20px; }
#addForm { display: grid; gap: 10px; }
.q { font-weight: 800; margin: 8px 0 0; font-size: 16px; }

.preview-wrap { position: relative; }
#preview {
  display: block; width: 100%; max-height: 46vh; object-fit: contain;
  background: #fff; border-radius: 20px; border: 4px solid #fff; box-shadow: 0 5px 0 var(--line);
}
#retake { position: absolute; right: 10px; bottom: 10px; }

.kid-pick { display: flex; flex-wrap: wrap; gap: 10px; }
.kid-btn {
  flex: 1 1 120px;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 10px 6px; border-radius: 20px; cursor: pointer;
  background: #fff; border: 4px solid var(--line); font-weight: 800; font-size: 16px;
}
.kid-btn .e { font-size: 36px; line-height: 1.1; }
.kid-btn.on { border-color: var(--kc); background: color-mix(in srgb, var(--kc) 18%, #fff); transform: scale(1.04); }
.kind-pick { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.kind-btn {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 8px 2px; border-radius: 18px; cursor: pointer;
  background: #fff; border: 4px solid var(--line); font-weight: 800; font-size: 13px; white-space: nowrap;
}
.kind-btn .e { font-size: 28px; line-height: 1.15; }
.kind-btn.on { border-color: var(--sky); background: #e6f5ff; transform: scale(1.05); }
.filters.kinds { padding-top: 4px; }
.filters.kinds .chip { font-size: 13px; padding: 4px 12px; }
.filters.kinds .chip.on { background: var(--sky); border-color: var(--sky); }
.kind-tag {
  position: absolute; top: 12px; right: 12px; z-index: 1;
  width: 32px; height: 32px; display: grid; place-items: center;
  background: #fff; border-radius: 50%; font-size: 17px;
  box-shadow: 0 2px 0 var(--line);
}
.badges { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.kind-badge { font-weight: 800; font-size: 15px; padding: 5px 12px; border-radius: 999px; background: #e6f5ff; }
.pw-wrap { position: relative; }
.pw-wrap input { padding-right: 54px; }
.pw-show { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); border: 0; background: none; font-size: 22px; cursor: pointer; padding: 6px; }

/* ---------- しょうさい ---------- */
.frame {
  background: #fff; padding: 10px; border-radius: 22px;
  border: 6px solid var(--yellow); box-shadow: 0 6px 0 var(--yellow-d);
}
.frame img { display: block; width: 100%; max-height: 62vh; object-fit: contain; border-radius: 12px; }
.plate {
  background: #fff; border-radius: 18px; padding: 14px 16px;
  border: 2px dashed var(--line);
}
.kid-badge { display: inline-flex; align-items: center; gap: 6px; font-weight: 800; font-size: 17px; padding: 4px 14px 4px 6px; border-radius: 999px; }
.kid-badge .dotkid { width: 30px; height: 30px; font-size: 18px; background: #fff; }
.d-date { color: var(--sub); margin-top: 6px; font-size: 14px; }
.d-memo { margin: 8px 0 0; font-size: 18px; white-space: pre-wrap; }
.d-memo:empty { display: none; }

/* ---------- せってい ---------- */
#kidList { display: grid; gap: 10px; }
.kid-row {
  display: grid; grid-template-columns: 56px 1fr 44px 40px; gap: 8px; align-items: center;
  background: #fff; padding: 8px; border-radius: 18px; border: 2px solid var(--line);
}
.kid-row .emo {
  width: 56px; height: 52px; font-size: 30px; border-radius: 14px; border: 2px solid var(--line); background: #fffdf6; cursor: pointer;
}
.kid-row input[type=text] { padding: 10px; font-size: 17px; }
.kid-row input[type=color] { padding: 0; width: 44px; height: 44px; border-radius: 12px; border: 2px solid var(--line); }
.kid-row .rm { border: 0; background: none; font-size: 20px; cursor: pointer; }
hr { border: 0; border-top: 3px dashed var(--line); width: 100%; margin: 6px 0; }

/* ---------- トースト・かみふぶき ---------- */
.toast {
  position: fixed; left: 50%; top: 40%; z-index: 40;
  transform: translate(-50%, -50%);
  background: #fff; border: 5px solid var(--pink); border-radius: 26px;
  padding: 18px 28px; font-size: 26px; font-weight: 800; color: var(--pink);
  box-shadow: 0 8px 0 var(--pink-d);
  animation: boing .5s ease-out;
  text-align: center; white-space: nowrap;
}
#confetti { position: fixed; inset: 0; pointer-events: none; z-index: 39; overflow: hidden; }
#confetti i {
  position: absolute; top: -20px; width: 10px; height: 14px; border-radius: 3px;
  animation: fall linear forwards;
}

@keyframes pop { from { opacity: 0; transform: scale(.8) rotate(var(--tilt, 0deg)); } }
@keyframes bob { 50% { transform: translateY(-8px); } }
@keyframes wiggle { 0%, 88%, 100% { rotate: 0deg; } 91% { rotate: -6deg; } 94% { rotate: 6deg; } 97% { rotate: -3deg; } }
@keyframes fade { from { opacity: 0; } }
@keyframes up { from { transform: translateY(40px); opacity: .4; } }
@keyframes boing { 0% { transform: translate(-50%, -50%) scale(.3); } 60% { transform: translate(-50%, -50%) scale(1.12); } 100% { transform: translate(-50%, -50%) scale(1); } }
@keyframes fall { to { transform: translateY(110vh) rotate(720deg); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before { animation: none !important; }
}
