/* --- 字型設定 --- */
@font-face { font-family: 'YuanChuan'; src: url('./500.otf') format('opentype'); font-weight: 500; }
@font-face { font-family: 'YuanChuan'; src: url('./700.otf') format('opentype'); font-weight: 700; }
@font-face { font-family: 'YuanChuan'; src: url('./900.otf') format('opentype'); font-weight: 900; }

:root {
  --primary-color: #4ade80;
  --bg-color: #f8fafc;
  --text-main: #334155;
  --danger-red: #f87171;
  --warning-yellow: #facc15;
  --safe-green: #4ade80;
}

* { box-sizing: border-box; font-family: 'YuanChuan', sans-serif; }

body {
  margin: 0; background-color: var(--bg-color); color: var(--text-main);
  display: flex; flex-direction: column; min-height: 100vh;
}

header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 15px 20px; background: white;
  box-shadow: 0 4px 15px rgba(0,0,0,0.05); border-radius: 0 0 20px 20px;
}
header h1 { margin: 0; font-size: 1.5rem; font-weight: 900; }
#points-display {
  font-weight: 900; color: var(--primary-color); background: #f0fdf4;
  padding: 5px 12px; border-radius: 12px; transition: transform 0.2s; display: inline-block;
}
.btn-icon { background: none; border: none; font-size: 1.5rem; cursor: pointer; padding: 0; transition: transform 0.2s; }
.btn-icon:hover { transform: scale(1.1); }

main { flex: 1; padding: 20px; overflow-y: auto; }

/* 史萊姆資訊面板 */
.slime-info-panel { text-align: center; margin-bottom: 10px; }
#slime-name { margin: 0 0 10px 0; font-size: 1.4rem; color: #334155; display: flex; justify-content: center; align-items: center; gap: 8px; }
.btn-icon-small { background: #f1f5f9; border: none; border-radius: 50%; width: 28px; height: 28px; font-size: 0.8rem; cursor: pointer; transition: transform 0.1s;}
.btn-icon-small:active { transform: scale(0.9); }
.slime-stats { display: flex; justify-content: center; gap: 10px; font-size: 0.85rem; font-weight: 700; }
.stat-badge { background: white; padding: 5px 12px; border-radius: 20px; box-shadow: 0 2px 5px rgba(0,0,0,0.05); }
.health-good { color: #16a34a; } .health-warning { color: #ea580c; } .health-bad { color: #dc2626; }

/* 史萊姆輪播舞台 */
.slime-carousel-container { position: relative; width: 100%; height: 180px; display: flex; align-items: center; justify-content: center; overflow: hidden; margin-bottom: 20px; }
.slime-track { display: flex; align-items: center; justify-content: center; transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275); }
.carousel-item { width: 140px; height: 140px; flex-shrink: 0; transition: all 0.4s ease; opacity: 0.3; transform: scale(0.6); pointer-events: none; }
.carousel-item.active { opacity: 1; transform: scale(1.1); pointer-events: auto; z-index: 2; }
.nav-btn { position: absolute; top: 50%; transform: translateY(-50%); background: rgba(255,255,255,0.8); border: none; border-radius: 50%; width: 35px; height: 35px; font-size: 1.2rem; cursor: pointer; z-index: 10; box-shadow: 0 2px 8px rgba(0,0,0,0.1); }
.prev-btn { left: 10px; } .next-btn { right: 10px; }

#preview-slime-svg { --preview-hue: 160; --preview-sat: 85%; --preview-light: 55%; --preview-color: hsl(var(--preview-hue), var(--preview-sat), var(--preview-light)); --preview-color-light: hsl(var(--preview-hue), var(--preview-sat), calc(var(--preview-light) + 20%)); }

/* 動畫 Keyframes */
#slime-svg.normal .slime-wrapper, .slime-svg-instance.normal .slime-wrapper { animation: floatY 3s ease-in-out infinite; }
#slime-svg.normal .slime-body-group, .slime-svg-instance.normal .slime-body-group { animation: floatScale 3s ease-in-out infinite; }
#slime-svg.normal .shadow, .slime-svg-instance.normal .shadow { animation: shadowFloat 3s ease-in-out infinite; }

.slime-svg-instance.excited .slime-wrapper { animation: jumpY 0.6s cubic-bezier(0.28, 0.84, 0.42, 1) infinite; }
.slime-svg-instance.excited .slime-body-group { animation: jumpScale 0.6s ease-in-out infinite; }
.slime-svg-instance.excited .shadow { animation: shadowJump 0.6s ease-in-out infinite; }

.slime-svg-instance.sick { --slime-sat: 20%; --slime-light: 40%; }
.slime-svg-instance.sick .slime-wrapper, .slime-svg-instance.sick .slime-body-group, .slime-svg-instance.sick .shadow { animation: none; }
.slime-svg-instance.sick .slime-body-group { transform: scaleY(0.6) scaleX(1.1) translateY(10px); }
.slime-svg-instance.sick .mouth { transform: translateY(5px) scaleY(0.5); }

@keyframes floatY { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-12px); } }
@keyframes floatScale { 0%, 100% { transform: scaleY(1) scaleX(1); } 50% { transform: scaleY(1.02) scaleX(0.98); } }
@keyframes shadowFloat { 0%, 100% { transform: scale(1); opacity: 0.1; } 50% { transform: scale(0.85); opacity: 0.05; } }
@keyframes jumpY { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-70px); } }
@keyframes jumpScale { 0%, 100% { transform: scaleY(0.8) scaleX(1.15); } 50% { transform: scaleY(1.1) scaleX(0.9); } }
@keyframes shadowJump { 0%, 100% { transform: scale(1.1); opacity: 0.15; } 50% { transform: scale(0.4); opacity: 0.02; } }

/* 按鈕區 */
.action-bar { display: flex; gap: 10px; margin-bottom: 25px; }
.btn-add { flex: 1; background: white; color: var(--text-main); border: none; cursor: pointer; box-shadow: 0 4px 10px rgba(0,0,0,0.05); border-radius: 16px; font-weight: 700; font-size: 0.95rem; padding: 12px 0; display: flex; flex-direction: column; align-items: center; gap: 5px; }
.btn-add:active { transform: scale(0.95); }

/* 物品清單 */
.list-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 15px; padding-left: 5px; }
.list-header h3 { margin: 0; font-size: 1.2rem; color: #475569; }
.item-list { display: flex; flex-direction: column; gap: 15px; }
.item-card { display: flex; align-items: center; background: white; border-radius: 20px; padding: 15px; box-shadow: 0 4px 12px rgba(0,0,0,0.04); transition: transform 0.2s; }
.card-icon { font-size: 1.8rem; margin-right: 15px; background: rgba(255,255,255,0.5); border-radius: 50%; width: 45px; height: 45px; display: flex; justify-content: center; align-items: center; flex-shrink: 0;}
.card-info { flex: 1; overflow: hidden; }
.card-title { font-weight: 700; font-size: 1.1rem; margin-bottom: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;}
.card-date { font-size: 0.85rem; color: #64748b; }
.card-status { text-align: right; margin-right: 10px; flex-shrink: 0;}
.status-badge { font-size: 0.8rem; font-weight: 900; padding: 4px 8px; border-radius: 10px; }

.card-green { border-left: 6px solid var(--safe-green); }
.card-green .status-badge { background: #dcfce7; color: #166534; }
.card-yellow { border-left: 6px solid var(--warning-yellow); background: #fefce8; }
.card-yellow .status-badge { background: #fef08a; color: #854d0e; }
.card-red { border-left: 6px solid var(--danger-red); background: #fef2f2; }
.card-red .status-badge { background: #fecaca; color: #991b1b; }

.card-actions { display: flex; flex-direction: column; gap: 5px; }
.action-icon { width: 35px; height: 35px; border-radius: 12px; border: none; cursor: pointer; display: flex; justify-content: center; align-items: center; font-size: 1.1rem; background: white; box-shadow: 0 2px 5px rgba(0,0,0,0.05); transition: transform 0.1s; }
.action-icon:active { transform: scale(0.85); }
.btn-consume { color: #16a34a; }
.btn-discard { color: #ef4444; }

.empty-state { text-align: center; color: #94a3b8; padding: 40px 0; font-weight: 700; line-height: 1.6; }
footer { text-align: center; padding: 15px; font-size: 0.85rem; color: #94a3b8; font-weight: 500; }

/* Modal 與表單系統 */
.modal-overlay { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,0.4); backdrop-filter: blur(4px); display: flex; justify-content: center; align-items: center; z-index: 9999; opacity: 1; transition: opacity 0.3s ease; }
.modal-overlay.hidden { opacity: 0; pointer-events: none; }
.modal-content { background: white; padding: 25px; border-radius: 24px; width: 85%; max-width: 350px; text-align: center; box-shadow: 0 15px 30px rgba(0,0,0,0.15); transform: translateY(0) scale(1); transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275); }
.modal-overlay.hidden .modal-content { transform: translateY(30px) scale(0.9); }
.modal-actions { display: flex; gap: 10px; margin-top: 20px; justify-content: center; }
.modal-actions button { border: none; border-radius: 16px; padding: 12px 24px; font-weight: 700; font-size: 1rem; cursor: pointer; transition: transform 0.1s; }
.modal-actions button:active { transform: scale(0.95); }
.btn-primary { background: var(--primary-color); color: white; flex: 1; }
.btn-secondary { background: #e2e8f0; color: var(--text-main); flex: 1; }
.btn-secondary.hidden { display: none; }

.form-group { text-align: left; margin-bottom: 15px; }
.form-group label { display: block; font-size: 0.85rem; font-weight: 700; color: #64748b; margin-bottom: 5px; }
.form-input { width: 100%; padding: 12px 15px; border: 2px solid #e2e8f0; border-radius: 12px; font-size: 1rem; background-color: #f8fafc; transition: all 0.2s; font-family: inherit; }
.form-input:focus { outline: none; border-color: var(--primary-color); background-color: white; box-shadow: 0 0 0 3px rgba(74, 222, 128, 0.2); }
.hint-text { display: block; font-size: 0.75rem; color: var(--primary-color); margin-top: 5px; font-weight: 700; min-height: 1rem; }

/* 語音動畫 */
.voice-content { background: #f0fdf4; border: 4px solid var(--primary-color); }
.pulse-ring { width: 80px; height: 80px; background: var(--primary-color); border-radius: 50%; margin: 20px auto; display: flex; justify-content: center; align-items: center; position: relative; }
.pulse-ring::before { content: ''; position: absolute; width: 100%; height: 100%; border-radius: 50%; background: var(--primary-color); animation: pulse 1.5s infinite; opacity: 0.6; }
@keyframes pulse { 0% { transform: scale(1); opacity: 0.6; } 100% { transform: scale(1.8); opacity: 0; } }
.mic-icon { font-size: 2.5rem; z-index: 1; }
.transcript-preview { color: #86efac; font-style: italic; min-height: 1.5em; margin: 15px 0; font-weight: 700; }

/* 成就徽章畫廊 */
.badge-gallery { display: grid; grid-template-columns: repeat(2, 1fr); gap: 15px; margin-top: 15px; max-height: 50vh; overflow-y: auto; padding: 5px; }
.badge-item { background: #f8fafc; border-radius: 16px; padding: 15px 10px; text-align: center; border: 2px dashed #cbd5e1; opacity: 0.5; filter: grayscale(100%); transition: all 0.4s; }
.badge-item.unlocked { border: 2px solid var(--warning-yellow); background: #fefce8; opacity: 1; filter: grayscale(0%); box-shadow: 0 4px 10px rgba(250, 204, 21, 0.2); }
.badge-icon { font-size: 2.5rem; margin-bottom: 5px; display: block; }
.badge-name { font-weight: 900; font-size: 0.95rem; color: #334155; }
.badge-desc { font-size: 0.75rem; color: #64748b; margin-top: 4px; display: block; }
