/* CardPet — 配色取自阿龍本貓:奶油白毛、海豹棕、藍眼睛、粉紅鼻子 */
:root {
  --bg: #FBF7F0;
  --card: #FFFFFF;
  --ink: #3E2E25;
  --ink-soft: #8A7A6E;
  --point: #5E4636;
  --blue: #4E7FBF;
  --blue-deep: #3A659C;
  --pink: #E8A5AC;
  --gold: #DCA53E;
  --line: #EDE3D4;
  --r-n: #A79B8E;
  --r-r: #4E7FBF;
  --r-sr: #9C6BD1;
  --r-ssr: #DCA53E;
  --radius: 18px;
  --shadow: 0 4px 16px rgba(94, 70, 54, 0.08);
}
* { margin: 0; padding: 0; box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: ui-rounded, -apple-system, "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", sans-serif;
  background: var(--bg);
  color: var(--ink);
  min-height: 100dvh;
}
#app { max-width: 480px; margin: 0 auto; min-height: 100dvh; display: flex; flex-direction: column; }
#view { flex: 1; padding: 20px 18px calc(86px + env(safe-area-inset-bottom)); }
button { font: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, textarea, select { font: inherit; color: var(--ink); }
a { color: var(--blue-deep); }

h1.page-title { font-size: 22px; font-weight: 800; letter-spacing: 0.02em; margin-bottom: 14px; }
.eyebrow { font-size: 12px; font-weight: 700; color: var(--ink-soft); letter-spacing: 0.14em; }

/* ── 首頁:阿龍的窩 ── */
.cat-scene {
  position: relative;
  background: radial-gradient(circle at 50% 42%, #FFF6E6 0%, #FAF1E2 45%, var(--bg) 100%);
  border-radius: 28px;
  padding: 18px 12px 6px;
  text-align: center;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}
.alon { width: min(72vw, 300px); height: auto; display: block; margin: 0 auto; }
.stage-name { font-size: 18px; font-weight: 800; margin-top: 2px; }
.stage-hint { font-size: 12.5px; color: var(--ink-soft); margin-top: 3px; padding-bottom: 12px; }

.alon-tail.swish { animation: swish 0.7s ease-in-out; }
@keyframes swish { 0%,100% { transform: rotate(0deg); } 35% { transform: rotate(-16deg); } 70% { transform: rotate(8deg); } }
.alon-zzz { animation: zzz 2.4s ease-in-out infinite; }
@keyframes zzz { 0%,100% { opacity: 0.25; transform: translateY(0); } 50% { opacity: 1; transform: translateY(-5px); } }
.alon-treat { animation: floaty 3s ease-in-out infinite; }
@keyframes floaty { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-7px); } }
.poke-heart {
  position: absolute; top: 34%; font-size: 26px; pointer-events: none;
  animation: heart-up 1.2s ease-out forwards;
}
@keyframes heart-up { 0% { opacity: 0; transform: translateY(6px) scale(0.6); } 25% { opacity: 1; } 100% { opacity: 0; transform: translateY(-56px) scale(1.15); } }
.treat-drop {
  position: absolute; top: 6%; left: 50%; font-size: 32px; pointer-events: none;
  animation: treat-fall 1.3s cubic-bezier(.5,0,.6,1) forwards;
}
@keyframes treat-fall { 0% { opacity: 0; transform: translate(-50%, 0); } 20% { opacity: 1; } 75% { opacity: 1; transform: translate(-50%, 130px) scale(0.9); } 100% { opacity: 0; transform: translate(-50%, 140px) scale(0.4); } }

/* 統計列 */
.stat-grid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; margin-top: 14px; }
.stat {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 12px 8px; text-align: center;
}
.stat b { font-size: 21px; font-weight: 800; display: block; }
.stat span { font-size: 11.5px; color: var(--ink-soft); }

.exp-panel { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 16px; margin-top: 12px; }
.exp-row { display: flex; justify-content: space-between; align-items: baseline; font-size: 13px; }
.exp-row .lv { font-size: 16px; font-weight: 800; }
.exp-row .nums { color: var(--ink-soft); font-size: 12px; }
.exp-bar { height: 12px; background: #F1E8DA; border-radius: 999px; margin-top: 8px; overflow: hidden; }
.exp-fill { height: 100%; background: linear-gradient(90deg, var(--gold), #E9BE64); border-radius: 999px; transition: width 0.6s ease; }

.scan-cta {
  display: block; width: 100%; margin-top: 16px;
  background: var(--blue); color: #fff;
  font-size: 17px; font-weight: 800; letter-spacing: 0.04em;
  padding: 16px; border-radius: 999px;
  box-shadow: 0 6px 18px rgba(78, 127, 191, 0.35);
  transition: transform 0.1s;
}
.scan-cta:active { transform: scale(0.97); }
.fed-note { text-align: center; font-size: 12.5px; color: var(--ink-soft); margin-top: 10px; }

/* ── 名片列表 ── */
.search-row { display: flex; gap: 8px; margin-bottom: 12px; }
.search-row input {
  flex: 1; border: 1.5px solid var(--line); background: var(--card);
  border-radius: 999px; padding: 10px 16px; outline: none;
}
.search-row input:focus { border-color: var(--blue); }
.chip-row { display: flex; gap: 7px; overflow-x: auto; padding-bottom: 8px; margin-bottom: 10px; scrollbar-width: none; }
.chip-row::-webkit-scrollbar { display: none; }
.chip {
  flex: 0 0 auto; font-size: 13px; padding: 6px 13px; border-radius: 999px;
  background: var(--card); border: 1.5px solid var(--line); color: var(--ink-soft);
}
.chip.on { background: var(--point); border-color: var(--point); color: #fff; font-weight: 700; }

.card-item {
  display: flex; align-items: center; gap: 12px;
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 13px 15px; margin-bottom: 10px; text-decoration: none; color: inherit;
  position: relative;
}
.card-item .avatar {
  width: 44px; height: 44px; border-radius: 12px; flex: 0 0 auto;
  background: #F1E8DA; color: var(--point);
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; font-weight: 800;
}
.card-item .info { flex: 1; min-width: 0; }
.card-item .nm { font-weight: 800; font-size: 15.5px; }
.card-item .co { font-size: 12.5px; color: var(--ink-soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rarity-tag {
  flex: 0 0 auto; font-size: 11px; font-weight: 800; color: #fff;
  padding: 3px 9px; border-radius: 999px; letter-spacing: 0.06em;
}
.rarity-N { background: var(--r-n); } .rarity-R { background: var(--r-r); }
.rarity-SR { background: var(--r-sr); } .rarity-SSR { background: var(--r-ssr); }

.empty-note { text-align: center; color: var(--ink-soft); padding: 48px 20px; font-size: 14px; line-height: 1.9; }

/* ── 掃描/表單 ── */
.photo-drop {
  border: 2px dashed #D8C9B4; border-radius: var(--radius); background: var(--card);
  padding: 40px 20px; text-align: center; color: var(--ink-soft); font-size: 14px; line-height: 1.9;
}
.photo-drop b { color: var(--ink); font-size: 16px; }
.preview-img { width: 100%; border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 12px; }
.ocr-status { text-align: center; padding: 18px; color: var(--ink-soft); font-size: 14px; }
.ocr-status .spin { display: inline-block; animation: spin 1.1s linear infinite; font-size: 22px; }
@keyframes spin { to { transform: rotate(360deg); } }

.form-grid { display: grid; gap: 10px; }
.field label { display: block; font-size: 12px; font-weight: 700; color: var(--ink-soft); margin-bottom: 4px; }
.field input, .field textarea, .field select {
  width: 100%; border: 1.5px solid var(--line); background: var(--card);
  border-radius: 12px; padding: 10px 12px; outline: none;
}
.field input:focus, .field textarea:focus, .field select:focus { border-color: var(--blue); }
.field textarea { min-height: 70px; resize: vertical; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.btn-primary {
  background: var(--blue); color: #fff; font-weight: 800; font-size: 16px;
  padding: 14px; border-radius: 999px; width: 100%; margin-top: 14px;
}
.btn-primary:disabled { opacity: 0.5; }
.btn-ghost {
  width: 100%; padding: 12px; margin-top: 8px; border-radius: 999px;
  border: 1.5px solid var(--line); background: var(--card); color: var(--ink-soft); font-weight: 700;
}
.btn-danger { color: #C0554F; border-color: #EAD2D0; }

/* ── 詳情 ── */
.detail-head { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px 18px; margin-bottom: 12px; }
.detail-head .nm { font-size: 22px; font-weight: 800; }
.detail-head .ti { color: var(--ink-soft); margin-top: 3px; font-size: 14px; }
.detail-rows { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; margin-bottom: 12px; }
.d-row { display: flex; padding: 13px 16px; border-bottom: 1px solid #F5EEE2; font-size: 14px; gap: 12px; }
.d-row:last-child { border-bottom: none; }
.d-row .k { flex: 0 0 62px; color: var(--ink-soft); font-size: 12.5px; padding-top: 1px; }
.d-row .v { flex: 1; word-break: break-all; }
.quick-acts { display: flex; gap: 10px; margin-bottom: 12px; }
.quick-acts a {
  flex: 1; text-align: center; background: var(--card); box-shadow: var(--shadow);
  border-radius: var(--radius); padding: 12px 6px; text-decoration: none;
  font-size: 13px; font-weight: 700; color: var(--ink);
}

/* ── 圖鑑與成就 ── */
.dex-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 9px; margin-bottom: 22px; }
.dex-cell {
  aspect-ratio: 1; border-radius: 14px; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 3px;
  background: var(--card); box-shadow: var(--shadow); font-size: 12px; font-weight: 700;
}
.dex-cell .cnt { font-size: 10.5px; color: var(--ink-soft); font-weight: 400; }
.dex-cell.off { background: #F2ECE1; box-shadow: none; color: #C4B8A6; }
.dex-cell.lit { border: 2px solid var(--gold); }
.ach-item {
  display: flex; align-items: center; gap: 13px; background: var(--card);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 13px 15px; margin-bottom: 9px;
}
.ach-item.locked { opacity: 0.45; filter: grayscale(1); box-shadow: none; }
.ach-item .ic { font-size: 26px; }
.ach-item .t { font-weight: 800; font-size: 14.5px; }
.ach-item .d { font-size: 12px; color: var(--ink-soft); }

/* ── Tab bar ── */
#tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 50;
  background: rgba(255, 255, 255, 0.94); backdrop-filter: blur(10px);
  border-top: 1px solid var(--line);
  padding: 6px 0 calc(6px + env(safe-area-inset-bottom));
}
.tab-inner { max-width: 480px; margin: 0 auto; display: flex; align-items: center; }
.tab {
  flex: 1; text-align: center; font-size: 10.5px; color: var(--ink-soft);
  text-decoration: none; padding: 4px 0; font-weight: 700;
}
.tab .ic { font-size: 21px; display: block; margin-bottom: 1px; }
.tab.on { color: var(--blue-deep); }
.tab-scan {
  flex: 0 0 74px; height: 58px; margin-top: -26px;
  background: var(--blue); border-radius: 50% / 46%;
  box-shadow: 0 5px 14px rgba(78, 127, 191, 0.4);
  color: #fff; font-size: 25px;
  display: flex; align-items: center; justify-content: center; text-decoration: none;
}

/* ── 開卡動畫 ── */
#overlay {
  position: fixed; inset: 0; z-index: 100; display: none;
  background: rgba(46, 34, 26, 0.86); backdrop-filter: blur(4px);
  align-items: center; justify-content: center; padding: 24px;
}
#overlay.show { display: flex; }
.reveal-card {
  width: min(88vw, 340px); background: var(--card); border-radius: 22px;
  padding: 26px 22px; text-align: center;
  animation: card-in 0.55s cubic-bezier(0.2, 1.4, 0.5, 1);
}
@keyframes card-in { 0% { transform: rotateY(90deg) scale(0.7); opacity: 0; } 100% { transform: rotateY(0) scale(1); opacity: 1; } }
.reveal-card.glow-SSR { box-shadow: 0 0 60px 12px rgba(220, 165, 62, 0.75); }
.reveal-card.glow-SR { box-shadow: 0 0 50px 10px rgba(156, 107, 209, 0.65); }
.reveal-card.glow-R { box-shadow: 0 0 40px 8px rgba(78, 127, 191, 0.5); }
.reveal-rarity { font-size: 34px; font-weight: 900; letter-spacing: 0.12em; }
.reveal-rarity.c-N { color: var(--r-n); } .reveal-rarity.c-R { color: var(--r-r); }
.reveal-rarity.c-SR { color: var(--r-sr); } .reveal-rarity.c-SSR { color: var(--r-ssr); }
.reveal-name { font-size: 19px; font-weight: 800; margin-top: 8px; }
.reveal-co { font-size: 13px; color: var(--ink-soft); }
.reward-lines { margin-top: 14px; display: grid; gap: 6px; }
.reward-lines div {
  font-size: 13.5px; background: #FBF6EC; border-radius: 10px; padding: 8px;
  animation: pop-in 0.4s ease backwards;
}
.reward-lines div:nth-child(2) { animation-delay: 0.15s; }
.reward-lines div:nth-child(3) { animation-delay: 0.3s; }
.reward-lines div:nth-child(4) { animation-delay: 0.45s; }
.reward-lines div:nth-child(5) { animation-delay: 0.6s; }
@keyframes pop-in { 0% { transform: scale(0.7); opacity: 0; } 100% { transform: scale(1); opacity: 1; } }
.churu-banner {
  margin-top: 14px; background: linear-gradient(120deg, #FDEFF1, #FCE3E7);
  border-radius: 14px; padding: 12px; font-weight: 800; color: #B3565E; font-size: 15px;
}
.churu-banner .tube { display: inline-block; animation: lick 0.8s ease-in-out infinite; }
@keyframes lick { 0%,100% { transform: rotate(-8deg); } 50% { transform: rotate(10deg) translateY(-2px); } }

.confetti { position: fixed; top: -10px; font-size: 18px; z-index: 101; pointer-events: none; animation: conf-fall linear forwards; }
@keyframes conf-fall { to { transform: translateY(105vh) rotate(540deg); } }

/* ── 登入 ── */
#login-view { min-height: 100dvh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 32px; text-align: center; }
#login-view .alon { width: 200px; }
#login-view h1 { font-size: 24px; font-weight: 900; margin: 10px 0 4px; }
#login-view p { color: var(--ink-soft); font-size: 13.5px; margin-bottom: 22px; }
#login-view input {
  width: 100%; max-width: 300px; text-align: center;
  border: 1.5px solid var(--line); background: var(--card);
  border-radius: 999px; padding: 12px 16px; outline: none; margin-bottom: 12px;
}
#login-view button { width: 100%; max-width: 300px; }
.login-err { color: #C0554F; font-size: 13px; margin-top: 10px; min-height: 18px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
