/* ToDoDeck - 落ち着いたかわいいベースUI */
:root {
  --main: #C49A70;
  --bg: #F5EFE5;
  --text: #80664F;
  --accent: #82917A;
  --card-paper: #FBF6EC;
  --line: #E4D8C4;
  --danger: #B56A5A;
  --gold1: #E8C878; --gold2: #C9A050; --gold3: #EAD8A0;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; padding: 0; background: var(--bg); color: var(--text);
  font-family: 'Hiragino Maru Gothic ProN', 'Hiragino Sans', 'Yu Gothic UI', sans-serif;
  font-size: 15px; height: 100%; overscroll-behavior-y: none;
}
#app { max-width: 480px; margin: 0 auto; min-height: 100vh; position: relative; background: var(--bg); }
.pad { padding: 16px; }
h1, h2, h3 { font-weight: 700; color: var(--text); }
button { font-family: inherit; }

/* ヘッダー */
.app-header { display: flex; align-items: center; gap: 8px; padding: 14px 16px 8px; }
.logo-mini { display: flex; align-items: center; gap: 6px; font-weight: 800; font-size: 18px; color: var(--main); letter-spacing: 0.5px; }
.logo-mini svg { width: 26px; height: 26px; }

/* 下部ナビ */
.bottom-nav {
  position: fixed; bottom: 0; left: 50%; transform: translateX(-50%);
  width: 100%; max-width: 480px; background: #FFFDF8; border-top: 1px solid var(--line);
  display: flex; z-index: 50; padding-bottom: env(safe-area-inset-bottom);
}
.bottom-nav button {
  flex: 1; background: none; border: none; padding: 8px 0 10px; color: #B3A48E;
  font-size: 10.5px; display: flex; flex-direction: column; align-items: center; gap: 2px; cursor: pointer;
}
.bottom-nav button.active { color: var(--main); font-weight: 700; }
.bottom-nav .nav-ico { width: 24px; height: 24px; display: block; }
.nav-badge { position: absolute; }

/* 汎用 */
.panel { background: #FFFDF8; border: 1px solid var(--line); border-radius: 16px; padding: 14px; margin-bottom: 12px; }
.panel-title { font-size: 13px; font-weight: 700; margin: 0 0 8px; display: flex; justify-content: space-between; align-items: center; }
.muted { color: #B3A48E; font-size: 12px; }
.btn {
  border: none; border-radius: 999px; padding: 12px 18px; font-size: 15px; font-weight: 700;
  background: var(--main); color: #FFF; cursor: pointer; min-height: 44px;
}
.btn.secondary { background: #EAE0CE; color: var(--text); }
.btn.ghost { background: transparent; color: var(--text); border: 1.5px solid var(--line); }
.btn.danger { background: var(--danger); color: #FFF; }
.btn:disabled { opacity: 0.45; }
.chip {
  border: 1.5px solid var(--line); background: #FFF; color: var(--text);
  border-radius: 999px; padding: 8px 13px; font-size: 13px; cursor: pointer; min-height: 36px;
}
.chip.on { border-color: var(--main); background: #F3E7D6; color: #6B5232; font-weight: 700; }
.row { display: flex; gap: 8px; flex-wrap: wrap; }
.progress-track { height: 10px; background: #EDE4D2; border-radius: 999px; overflow: hidden; }
.progress-fill { height: 100%; background: var(--accent); border-radius: 999px; transition: width .4s; }

/* ===== ホーム ===== */
.home-date { font-size: 13px; color: #B3A48E; }
.home-progress-card { text-align: center; }
.home-progress-card .big { font-size: 30px; font-weight: 800; color: var(--main); margin: 4px 0; }
.genre-progress { display: flex; flex-direction: column; gap: 7px; }
.genre-progress .gp-row { display: flex; align-items: center; gap: 8px; }
.gp-label { width: 106px; font-size: 11px; white-space: nowrap; display: flex; align-items: center; gap: 5px; flex-shrink: 0; }
.gp-dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.gp-track { flex: 1; height: 8px; background: #EDE4D2; border-radius: 999px; overflow: hidden; }
.gp-fill { height: 100%; border-radius: 999px; transition: width .4s; }
.gp-val { width: 76px; font-size: 10.5px; text-align: right; color: #9A886E; flex-shrink: 0; }
.gp-val b { color: var(--main); }
.packs-entry {
  display: flex; align-items: center; justify-content: space-between;
  background: linear-gradient(135deg, #F3E7D6, #EFE3CE); border: 1px solid #E0CDA8;
  border-radius: 16px; padding: 13px 16px; margin-bottom: 12px; cursor: pointer;
}
.packs-entry .pcount { font-size: 22px; font-weight: 800; color: var(--main); }

/* タスクリスト */
.task-item {
  display: flex; align-items: center; gap: 11px; background: #FFFDF8;
  border: 1px solid var(--line); border-left: 6px solid #CCC; border-radius: 13px;
  padding: 12px 13px; margin-bottom: 9px; cursor: pointer; position: relative;
}
.task-item.done { opacity: 0.55; }
.task-item.done .t-name { text-decoration: line-through; }
.task-item.expired { border-left-color: #C9B8A6; background: #F2EDE3; }
.task-item .t-check {
  width: 30px; height: 30px; border-radius: 50%; border: 2px solid #D8CBB4;
  background: #FFF; flex-shrink: 0; display: flex; align-items: center; justify-content: center;
  font-size: 15px; color: transparent; font-weight: 800;
}
.task-item.done .t-check { background: var(--accent); border-color: var(--accent); color: #FFF; }
.t-main { flex: 1; min-width: 0; }
.t-name { font-size: 15.5px; font-weight: 700; color: #6B5232; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.t-sub { font-size: 11.5px; color: #B3A48E; margin-top: 2px; display: flex; gap: 8px; flex-wrap: wrap; }
.t-sub .over { color: var(--danger); font-weight: 700; }
.t-pts { font-size: 12px; font-weight: 800; color: var(--main); flex-shrink: 0; }
.fab {
  position: fixed; right: 18px; bottom: 76px; width: 56px; height: 56px; border-radius: 50%;
  background: var(--main); color: #FFF; font-size: 28px; border: none; z-index: 40;
  box-shadow: 0 4px 12px rgba(128, 102, 79, 0.35); cursor: pointer;
}

/* タスクフォーム */
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12.5px; font-weight: 700; margin-bottom: 5px; }
.field input[type=text], .field input[type=number], .field input[type=date], .field input[type=time], .field textarea, .field select {
  width: 100%; border: 1.5px solid var(--line); border-radius: 12px; padding: 12px;
  font-size: 15px; font-family: inherit; color: var(--text); background: #FFF; min-height: 44px;
}
.field textarea { min-height: 70px; }
.pts-preview { font-size: 13px; color: var(--accent); font-weight: 800; margin-top: 5px; }
.form-actions { display: flex; gap: 10px; padding: 14px 0 30px; }
.form-actions .btn { flex: 1; }

/* ===== カード図鑑 ===== */
.coll-rate { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.coll-rate b { color: var(--main); font-size: 18px; }
.card-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.cgrid-cell { position: relative; cursor: pointer; }
.cgrid-cell img { width: 100%; display: block; border-radius: 10px; box-shadow: 0 2px 6px rgba(107, 82, 50, .18); }
.cgrid-cell.unowned img { filter: grayscale(1) brightness(1.06) opacity(0.45); }
.cgrid-cell.unowned::after {
  content: '?'; position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font-size: 30px; font-weight: 800; color: rgba(107, 82, 50, .5);
}
.dup-badge {
  position: absolute; top: 5px; left: 5px; background: rgba(130, 145, 122, .92); color: #FFF;
  font-size: 10px; font-weight: 700; padding: 2px 7px; border-radius: 999px;
}
.section-label { font-size: 13px; font-weight: 700; margin: 14px 0 8px; color: #9A886E; }

/* カード詳細オーバーレイ */
.overlay {
  position: fixed; inset: 0; background: rgba(80, 62, 45, .62); z-index: 90;
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.overlay-inner { max-width: 480px; width: 100%; text-align: center; }
.flip-scene { perspective: 1200px; width: min(78vw, 315px); margin: 0 auto; aspect-ratio: 63/88; }
.flip-card { position: relative; width: 100%; height: 100%; transform-style: preserve-3d; transition: transform .55s cubic-bezier(.4,.1,.2,1); cursor: pointer; }
.flip-card.flipped { transform: rotateY(180deg); }
.flip-face { position: absolute; inset: 0; backface-visibility: hidden; -webkit-backface-visibility: hidden; border-radius: 22px; overflow: hidden; box-shadow: 0 8px 24px rgba(60,45,28,.4); }
.flip-face img { width: 100%; height: 100%; display: block; }
.flip-face.back { transform: rotateY(180deg); }
.flip-face.back .back-content {
  position: absolute; inset: 0; padding: 34px 26px; display: flex; flex-direction: column;
  align-items: center; text-align: center; color: #6B5232;
}
.back-content .bk-name { font-size: 18px; font-weight: 800; margin-top: 8px; }
.back-content .bk-meta { font-size: 12px; color: #9A886E; margin-top: 4px; display: flex; gap: 10px; align-items: center; }
.back-content .bk-msg { margin-top: 18px; font-size: 13.5px; line-height: 1.8; font-weight: 600; }
.back-content .bk-logo { margin-top: auto; font-weight: 800; color: var(--main); font-size: 12px; letter-spacing: 1px; }
.back-content .bk-logo::before { content: '✔ '; }
.rarity-pill { padding: 1px 8px; border-radius: 999px; color: #FFF; font-weight: 800; font-size: 11px; }
.overlay-hint { color: #F5EFE5; font-size: 12px; margin-top: 14px; }
.overlay-actions { display: flex; gap: 10px; justify-content: center; margin-top: 16px; flex-wrap: wrap; }

/* ===== パック ===== */
.pack-item {
  display: flex; align-items: center; gap: 13px; background: #FFFDF8; border: 1px solid var(--line);
  border-radius: 14px; padding: 12px 14px; margin-bottom: 10px; cursor: pointer;
}
.pack-visual {
  width: 54px; height: 72px; border-radius: 8px; flex-shrink: 0; position: relative;
  display: flex; align-items: center; justify-content: center; color: #FFF; font-weight: 800; font-size: 11px;
  box-shadow: inset 0 0 0 2.5px rgba(232,200,120,.9), 0 2px 6px rgba(107,82,50,.25);
  background: linear-gradient(160deg, var(--pk1), var(--pk2)); writing-mode: vertical-rl; letter-spacing: 2px;
}
.pack-count-col { margin-left: auto; text-align: right; }

/* 開封演出 */
.open-scene { position: fixed; inset: 0; z-index: 100; display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: radial-gradient(circle at 50% 42%, #4A3B2C 0%, #2E2418 70%); overflow: hidden; }
.open-pack {
  width: min(56vw, 230px); aspect-ratio: 63/88; border-radius: 16px; position: relative; z-index: 5; overflow: visible;
  background: linear-gradient(160deg, var(--pk1), var(--pk2));
  box-shadow: inset 0 0 0 4px rgba(232,200,120,.95), 0 10px 40px rgba(0,0,0,.5), 0 0 40px var(--glow, rgba(232,200,120,.4));
  display: flex; flex-direction: column; align-items: center; justify-content: center; color: #FFF;
  transition: transform .2s; touch-action: none; user-select: none; -webkit-user-select: none;
}
.open-pack .pk-label { writing-mode: vertical-rl; letter-spacing: 3px; font-size: 16px; font-weight: 800; text-shadow: 0 1px 4px rgba(0,0,0,.3); }
.open-pack .pk-logo { position: absolute; bottom: 12px; font-size: 10px; opacity: .85; letter-spacing: 1px; }
.open-pack.float { animation: floaty 2.4s ease-in-out infinite; }
@keyframes floaty { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-10px); } }
.pack-body { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.pack-strip {
  position: absolute; top: -3px; left: -3px; right: -3px; height: 26%; z-index: 6;
  background:
    linear-gradient(160deg, rgba(255,255,255,.30), rgba(255,255,255,.05)),
    repeating-linear-gradient(-45deg, rgba(240,215,140,.95) 0 9px, rgba(201,160,80,.95) 9px 18px);
  border-radius: 16px 16px 0 0;
  box-shadow: inset 0 0 0 3px rgba(232,200,120,.95), 0 3px 8px rgba(0,0,0,.28);
  display: flex; align-items: flex-start; justify-content: center; padding-top: 9px;
  color: #FFF; font-weight: 800; font-size: 13px; letter-spacing: 3px; text-shadow: 0 1px 3px rgba(0,0,0,.35);
  clip-path: polygon(0 0, 100% 0, 100% 76%, 97% 100%, 94% 74%, 91% 100%, 88% 74%, 85% 100%, 82% 74%, 79% 100%, 76% 74%, 73% 100%, 70% 74%, 67% 100%, 64% 74%, 61% 100%, 58% 74%, 55% 100%, 52% 74%, 49% 100%, 46% 74%, 43% 100%, 40% 74%, 37% 100%, 34% 74%, 31% 100%, 28% 74%, 25% 100%, 22% 74%, 19% 100%, 16% 74%, 13% 100%, 10% 74%, 7% 100%, 4% 74%, 0 100%);
  transform-origin: left center; touch-action: pan-y; cursor: grab;
}
.pack-strip.torn { transition: transform .5s ease-out, opacity .5s ease-out; transform: translateX(150%) rotate(24deg) !important; opacity: 0; }
.swipe-hint { color: #EADFC8; font-size: 14px; margin-top: 26px; animation: pulse 1.6s ease-in-out infinite; text-align: center; }
@keyframes pulse { 0%,100% { opacity: .55; } 50% { opacity: 1; } }
.particles { position: absolute; inset: 0; pointer-events: none; z-index: 8; }
.pt { position: absolute; border-radius: 50%; background: radial-gradient(circle, #FFF7DF, #E8C878); opacity: 0; }
.reveal-flash { position: absolute; inset: 0; background: radial-gradient(circle at 50% 45%, rgba(255,246,214,.95), rgba(255,246,214,0) 62%); opacity: 0; pointer-events: none; z-index: 6; }
.reveal-flash.on { animation: flash .9s ease-out; }
@keyframes flash { 0% { opacity: 0; } 25% { opacity: 1; } 100% { opacity: 0; } }
.reveal-card { position: relative; z-index: 10; animation: pop .6s cubic-bezier(.3,1.4,.5,1); }
@keyframes pop { 0% { transform: scale(.4); opacity: 0; } 100% { transform: scale(1); opacity: 1; } }
.sr-reveal .reveal-card { animation: pop .6s cubic-bezier(.3,1.4,.5,1), shimmer 2.2s ease-in-out .6s infinite; }
@keyframes shimmer { 0%,100% { filter: drop-shadow(0 0 6px rgba(232,200,120,.6)); } 50% { filter: drop-shadow(0 0 22px rgba(255,230,150,.95)); } }
.open-actions { position: absolute; bottom: 34px; display: flex; gap: 12px; z-index: 20; }

/* ===== ポイント画面 ===== */
.point-row { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px dashed var(--line); }
.point-row:last-child { border-bottom: none; }
.pr-genre { width: 92px; font-size: 12px; display: flex; align-items: center; gap: 5px; flex-shrink: 0; }
.pr-bar { flex: 1; }
.pr-num { width: 92px; text-align: right; font-size: 12px; flex-shrink: 0; }
.pr-num b { color: var(--main); font-size: 15px; }
.deficit-note { color: var(--danger); font-size: 11px; }

/* ===== 記録 ===== */
.record-item { padding: 10px 2px; border-bottom: 1px dashed var(--line); font-size: 13px; }
.record-item .r-head { display: flex; justify-content: space-between; gap: 8px; }
.record-item .r-text { margin-top: 3px; color: #9A886E; font-size: 12px; line-height: 1.5; }
.r-tag { font-size: 10.5px; font-weight: 700; padding: 1px 8px; border-radius: 999px; color: #FFF; flex-shrink: 0; }

/* ===== 設定 ===== */
.set-row { display: flex; align-items: center; justify-content: space-between; padding: 13px 2px; border-bottom: 1px dashed var(--line); }
.switch { position: relative; width: 52px; height: 30px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; background: #D8CBB4; border-radius: 999px; transition: .25s; cursor: pointer; }
.switch span::before { content: ''; position: absolute; width: 24px; height: 24px; left: 3px; top: 3px; background: #FFF; border-radius: 50%; transition: .25s; }
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::before { transform: translateX(22px); }

/* バックアップ案内バナー */
.backup-banner {
  background: #F7EEDA; border: 1px solid #E0CDA8; border-radius: 14px; padding: 12px 14px;
  margin-bottom: 12px; font-size: 12.5px; line-height: 1.6; display: flex; gap: 10px; align-items: flex-start;
}
.backup-banner .bb-actions { margin-top: 8px; display: flex; gap: 8px; }

/* トースト */
#toast {
  position: fixed; left: 50%; bottom: 96px; transform: translateX(-50%); z-index: 120;
  background: rgba(80, 62, 45, .92); color: #FFF; padding: 11px 20px; border-radius: 999px;
  font-size: 13px; opacity: 0; transition: opacity .3s; pointer-events: none; max-width: 86vw; text-align: center;
}
#toast.show { opacity: 1; }

.screen { display: none; padding-bottom: 90px; }
.screen.active { display: block; }
.empty-note { text-align: center; color: #B3A48E; font-size: 13px; padding: 26px 0; }

/* タスクフォーム詳細アコーディオン */
details.panel summary { cursor: pointer; font-weight: 700; font-size: 13px; color: #9A886E; list-style: none; }
details.panel summary::before { content: '▸ '; }
details.panel[open] summary::before { content: '▾ '; }
details.panel[open] summary { margin-bottom: 12px; }

/* オーバーレイ内の間隔調整 */
.overlay-hint { margin-top: 12px; }
.overlay-actions { margin-top: 12px; }
