/* --- Global & Reset --- */
* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: #f6f7fb;
  color: #333;
  overflow-x: hidden;
}

.container { max-width: 900px; margin: 0 auto; padding: 0 12px; }
.hidden { display: none !important; }

/* --- Authentic Pill Header --- */
#header-container {
  position: fixed;
  top: 16px;
  left: 0;
  width: 100%;
  display: flex;
  justify-content: center;
  z-index: 2000;
}

#main-header {
  background: white;
  width: 90%;
  max-width: 540px;
  height: 52px;
  border-radius: 26px;
  display: flex;
  align-items: center;
  padding: 0 8px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.06);
  border: 1px solid rgba(0,0,0,0.02);
}

.header-icon {
  background: none;
  border: none;
  font-size: 1.3rem;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}

.header-icon:hover { background: #f0f2f5; }

.search-box { flex: 1; position: relative; padding: 0 10px; }
#search-input {
  width: 100%;
  height: 34px;
  border: none;
  background: #f1f3f7;
  border-radius: 17px;
  padding: 0 16px;
  font-size: 0.9rem;
  outline: none;
  text-align: center;
  color: #444;
}

/* --- Search Dropdown --- */
#search-dropdown {
  position: absolute;
  top: 56px;
  left: 50%;
  transform: translateX(-50%);
  width: 110%;
  background: white;
  border-radius: 24px;
  box-shadow: 0 12px 48px rgba(0,0,0,0.15);
  max-height: 400px;
  overflow-y: auto;
  border: 1px solid rgba(0,0,0,0.08);
  z-index: 2500; /* ヘッダーより上に表示 */
}

.search-no-results {
  padding: 20px;
  text-align: center;
  color: #94a3b8;
  font-size: 0.9rem;
}

.search-item {
  display: flex;
  align-items: center;
  padding: 12px 16px;
  cursor: pointer;
  border-bottom: 1px solid #f8fafc;
  transition: 0.2s;
}

.search-item:hover { background: #f1f5f9; }
.search-item img { 
  width: 48px; 
  height: 48px; 
  margin-right: 14px; 
  background: #f8fafc; 
  border-radius: 12px;
  object-fit: contain;
}

/* --- Layout --- */
.main-layout {
  padding-top: 80px;
  display: flex;
  justify-content: center;
  gap: 12px;
  padding-bottom: 40px;
}

#detail-panel {
  width: 500px;
  min-width: 0; /* 防止溢出 */
}

#box-panel {
  width: 340px;
  flex-shrink: 0;
}

/* --- Card Styles --- */
.card {
  background: white;
  border-radius: 24px;
  padding: 16px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.01);
  border: 1px solid rgba(0,0,0,0.03);
}

/* --- Box Panel (Sticky) --- */
#box-panel {
  position: sticky;
  top: 90px;
  max-height: calc(100vh - 110px);
  display: flex;
  flex-direction: column;
}

.box-card {
  display: flex;
  flex-direction: column;
  max-height: 100%;
}

#box-list {
  flex: 1;
  overflow-y: auto;
  margin-bottom: 16px;
  padding-right: 4px; /* スクロールバー用の余白 */
}

/* スクロールバーのカスタマイズ（任意） */
#box-list::-webkit-scrollbar { width: 4px; }
#box-list::-webkit-scrollbar-track { background: transparent; }
#box-list::-webkit-scrollbar-thumb { background: #e2e8f0; border-radius: 2px; }
.detail-header-row {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  margin-bottom: 16px;
}

.sprite-box {
  background: #f8fafc;
  border-radius: 18px;
  padding: 6px;
  border: 1px solid #f0f2f5;
}

#detail-img { width: 64px; height: 64px; }

.name-area h2 { font-size: 1.25rem; font-weight: 600; margin-bottom: 8px; }
.toggle-row { display: flex; gap: 8px; flex-wrap: wrap; }

.tag {
  font-size: 0.7rem;
  padding: 4px 12px;
  border-radius: 10px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  cursor: pointer; /* 追加 */
}

.tag-blue { background: #eff6ff; color: #3b82f6; }
.tag-pink { background: #fdf2f8; color: #db2777; } /* 追加 */

.toggle-btn {
  font-size: 0.75rem;
  padding: 4px 12px;
  background: #f1f5f9;
  border-radius: 10px;
  color: #64748b;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
  font-weight: 500;
  transition: 0.2s;
}

.toggle-btn.active { background: #cbd5e1; color: #334155; }

/* --- Param List --- */
.param-list { margin-top: 10px; border-top: 1px solid #f1f5f9; }
.param-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid #f1f5f9;
  cursor: pointer;
}

.param-item .label { font-size: 0.9rem; color: #64748b; }
.param-item .value { font-size: 0.95rem; color: #1e293b; font-weight: 500; }
.param-item .arrow { color: #cbd5e1; margin-left: 6px; font-size: 1.1rem; }

.move-item { min-height: 48px; }
.move-item .label { color: #94a3b8; }

/* --- Stats Table --- */
.stats-section { margin-top: 16px; background: #f8fafc; border-radius: 16px; padding: 12px; }
.stats-header {
  display: grid;
  grid-template-columns: 1fr 60px 60px;
  padding-bottom: 8px;
  font-size: 0.75rem;
  color: #94a3b8;
  font-weight: 700;
}

.stat-grid { display: flex; flex-direction: column; gap: 8px; }
.stat-row { display: grid; grid-template-columns: 1fr 60px 60px; align-items: center; }
.s-label { font-size: 0.85rem; font-weight: 600; color: #475569; }

.s-input {
  width: 54px;
  height: 28px;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  text-align: center;
  font-size: 0.85rem;
  outline: none;
  background: white;
}

.s-input:focus { border-color: #3b82f6; }

.stats-footer {
  margin-top: 16px;
  font-size: 0.75rem;
  color: #94a3b8;
  text-align: right;
  border-top: 1px solid #e2e8f0;
  padding-top: 10px;
}

/* --- Buttons --- */
.add-action { margin-top: 30px; display: flex; justify-content: center; }
.pill-btn {
  border: none;
  border-radius: 20px;
  height: 40px;
  padding: 0 32px;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  transition: 0.2s;
  box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}

.pill-btn.primary { background: #5c7cb6; color: white; }
.pill-btn.primary:hover { background: #4d6ba3; }

.pill-btn.secondary { background: #e2e8f0; color: #94a3b8; width: 100%; }

/* --- Box Panel --- */
.box-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; border-bottom: 1px solid #f1f5f9; padding-bottom: 12px; }
.box-tabs { display: flex; gap: 16px; font-size: 0.95rem; font-weight: 600; color: #94a3b8; }
.box-tabs .tab { cursor: pointer; }
.box-tabs .active { color: #1e293b; }
.clear-btn { background: none; border: none; font-size: 0.85rem; color: #64748b; cursor: pointer; padding: 0; }
.clear-btn:hover { color: #334155; }

#box-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: #f8fafc;
  padding: 12px;
  border-radius: 12px;
  min-height: 300px;
}

.box-item {
  display: flex;
  align-items: center;
  background: white;
  padding: 8px 12px;
  border-radius: 12px;
  border: 1px solid #f1f5f9;
  cursor: pointer;
  transition: transform 0.1s, box-shadow 0.1s;
  position: relative;
}

.box-item:hover { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(0,0,0,0.03); z-index: 10; }

.box-item img {
  width: 44px;
  height: 44px;
  object-fit: contain;
  margin-right: 12px;
}

.box-item .b-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.box-item .b-name {
  font-size: 0.9rem;
  font-weight: 600;
  color: #1e293b;
  margin-bottom: 2px;
}

.box-item .b-details {
  font-size: 0.75rem;
  color: #64748b;
}

.box-item.editing {
  border: 1px solid #3b82f6;
  background: #eff6ff;
}

.box-quick-delete {
  position: absolute;
  top: 50%;
  right: 12px;
  transform: translateY(-50%);
  width: 24px;
  height: 24px;
  background: #f1f5f9;
  color: #94a3b8;
  border: none;
  border-radius: 50%;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  opacity: 0;
  transition: 0.2s;
  z-index: 20;
}

.box-item:hover .box-quick-delete { opacity: 1; }
.box-quick-delete:hover { background: #ef4444; color: white; }

.box-actions { display: flex; gap: 8px; }
.box-actions button {
  background: #f1f5f9;
  border: none;
  padding: 6px 12px;
  border-radius: 10px;
  font-size: 0.8rem;
  cursor: pointer;
  transition: 0.2s;
  font-weight: 600;
}

.box-actions button:hover {
  background: #e2e8f0;
}

.box-edit-btn { color: #3b82f6; }
.box-delete-btn { color: #ef4444; }

.action-icon { font-size: 1.1rem; cursor: pointer; opacity: 0.5; transition: 0.2s; }
.action-icon:hover { opacity: 1; }

/* --- Picker Overlay --- */
#picker-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  backdrop-filter: blur(4px);
  z-index: 3000;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  transition: opacity 0.3s;
}

#picker-sheet {
  background: white;
  width: 100%;
  max-width: 500px;
  border-radius: 20px 20px 0 0;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  animation: slideUp 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

@keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }

.sheet-header {
  padding: 16px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid #f1f5f9;
}

.sheet-header h3 { font-size: 1.1rem; font-weight: 700; color: #1e293b; }
#close-picker { background: none; border: none; font-size: 1.2rem; cursor: pointer; color: #94a3b8; }

.picker-search-box {
  padding: 12px 20px;
  position: relative;
  background: white;
  border-bottom: 1px solid #f1f5f9;
}

.picker-search-box .search-icon {
  position: absolute;
  left: 35px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.9rem;
  color: #94a3b8;
}

#picker-search-input {
  width: 100%;
  padding: 10px 15px 10px 40px;
  background: #f1f5f9;
  border: none;
  border-radius: 25px;
  font-size: 0.95rem;
  outline: none;
}

#picker-items {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0;
}

.picker-item {
  padding: 14px 24px;
  font-size: 1rem;
  color: #334155;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: background 0.2s;
}

.picker-item:hover { background: #f8fafc; }

.picker-item.active {
  color: #5c7cb6;
  background: #f0f4ff;
  font-weight: 600;
}

.checkmark {
  display: none;
  font-size: 1.1rem;
}

.picker-item.active .checkmark {
  display: block;
}

#picker-items div {
  padding: 16px 20px;
  border-bottom: 1px solid #f1f5f9;
  cursor: pointer;
  font-size: 0.95rem;
}

#picker-items div:active { background: #f8fafc; }

/* --- Mobile --- */
@media (max-width: 600px) {
  .main-layout { grid-template-columns: 1fr; }
  .pill-btn { width: 100%; }
}
/* --- Mobile Optimization --- */
@media (max-width: 860px) {
  .main-layout {
    flex-direction: column;
    align-items: center;
    padding-top: 72px;
  }
  #detail-panel, #box-panel {
    width: 100%;
    max-width: 500px;
  }
  #box-panel {
    position: static;
    max-height: none;
  }
}

.egg-move-text {
  text-decoration: line-through;
  color: #94a3b8;
}

/* --- Share Result UI --- */
#share-result-container {
  margin-top: 16px;
  padding: 16px;
  background: #f8fafc;
  border-radius: 16px;
  border: 1px solid #e2e8f0;
  animation: fadeIn 0.3s ease;
}

@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

.share-box {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
}

#share-url-display {
  flex: 1;
  height: 36px;
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  padding: 0 12px;
  font-size: 0.85rem;
  background: white;
  color: #475569;
  outline: none;
}

.copy-action-btn {
  height: 36px;
  padding: 0 16px;
  background: #3b82f6;
  color: white;
  border: none;
  border-radius: 10px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: 0.2s;
}

.copy-action-btn:hover { background: #2563eb; }
.copy-action-btn.success { background: #10b981; }

.share-hint {
  font-size: 0.75rem;
  color: #64748b;
  text-align: center;
}
