* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --sea: #0ea5e9;
  --sea-dark: #0369a1;
  --bg: #eaf6fb;
  --card-bg: #ffffff;
  --text: #1f2937;
  --sub: #6b7280;
  --accent: #f59e0b;
  --radius: 14px;
}

body {
  font-family: "Hiragino Maru Gothic ProN", "Yu Gothic", -apple-system, BlinkMacSystemFont, sans-serif;
  background: linear-gradient(180deg, #bde8f7 0%, var(--bg) 220px, var(--bg) 100%);
  color: var(--text);
  min-height: 100vh;
  padding-bottom: 86px;
}

.app-header {
  background: linear-gradient(135deg, var(--sea), var(--sea-dark));
  color: #fff;
  padding: 14px 16px 18px;
  border-radius: 0 0 20px 20px;
  box-shadow: 0 4px 14px rgba(3, 105, 161, 0.35);
}
.app-header h1 { font-size: 1.25rem; margin-bottom: 8px; }

.stat-bar { display: flex; gap: 14px; flex-wrap: wrap; font-size: 0.95rem; font-weight: 600; }
.stat-item { background: rgba(255,255,255,0.18); padding: 4px 10px; border-radius: 999px; }

main { max-width: 560px; margin: 0 auto; padding: 16px; }

.tab-panel { display: none; animation: fadein 0.25s ease; }
.tab-panel.active { display: block; }
@keyframes fadein { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }

h2 { font-size: 1.15rem; margin-bottom: 6px; }
h3 { font-size: 1rem; margin: 18px 0 8px; color: var(--sub); }
.sub-desc { color: var(--sub); font-size: 0.85rem; margin-bottom: 10px; }

/* 海タブ */
.cast-area { text-align: center; margin: 18px 0; }
#cast-btn {
  font-size: 1.15rem; font-weight: 700; color: #fff;
  background: linear-gradient(135deg, var(--sea), var(--sea-dark));
  border: none; border-radius: 999px; padding: 16px 40px;
  box-shadow: 0 6px 0 var(--sea-dark), 0 8px 14px rgba(0,0,0,0.15);
  cursor: pointer; transition: transform 0.1s;
}
#cast-btn:active:not(:disabled) { transform: translateY(4px); box-shadow: 0 2px 0 var(--sea-dark); }
#cast-btn:disabled { opacity: 0.7; cursor: default; }

.progress-track { width: 100%; height: 10px; background: #d7ecf5; border-radius: 999px; margin-top: 14px; overflow: hidden; }
.progress-fill { height: 100%; width: 0%; background: linear-gradient(90deg, var(--accent), #fbbf24); border-radius: 999px; }

.auto-fish-btn {
  display: block; margin: 14px auto 0; border: 2px solid var(--sea);
  background: #fff; color: var(--sea-dark); font-weight: 700;
  border-radius: 999px; padding: 8px 18px; cursor: pointer; font-size: 0.85rem;
}
.auto-fish-btn.active { background: var(--sea); color: #fff; }

.catch-result { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; min-height: 90px; margin: 10px 0; }
.catch-log { display: flex; flex-direction: column; gap: 6px; }
.log-entry { background: var(--card-bg); border-radius: 10px; padding: 8px 12px; font-size: 0.88rem; box-shadow: 0 1px 4px rgba(0,0,0,0.08); }

/* 絵文字カード */
.fish-card {
  --rc: #9ca3af;
  background: var(--card-bg);
  border: 2px solid var(--rc);
  border-radius: 12px;
  padding: 10px 6px;
  width: 84px;
  text-align: center;
  cursor: default;
  box-shadow: 0 2px 6px rgba(0,0,0,0.08);
  animation: pop 0.35s ease;
  position: relative;
}
@keyframes pop { from { transform: scale(0.4); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.fish-emoji { font-size: 2rem; line-height: 1.1; }
.fish-meta { font-size: 0.68rem; color: var(--sub); margin-top: 4px; }
.fish-count-badge {
  position: absolute; top: -6px; right: -6px; background: #1f2937; color: #fff;
  font-size: 0.65rem; font-weight: 700; border-radius: 999px; padding: 2px 6px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}
.place-tag {
  margin-top: 4px; font-size: 0.62rem; font-weight: 700; color: #fff;
  background: var(--rc); border-radius: 999px; padding: 2px 6px; display: inline-block;
}
.autosold-tag { background: #16a34a; }

.show-more-btn {
  display: block; width: 100%; margin-top: 10px; background: #e5f2f8; color: var(--sea-dark);
  box-shadow: none; font-size: 0.85rem;
}

.rarity-filter-bar { display: flex; gap: 6px; flex-wrap: wrap; margin: 8px 0 12px; }
.rarity-filter-btn {
  --rc: #9ca3af;
  border: 2px solid var(--rc); border-radius: 999px; padding: 5px 12px;
  background: #fff; color: var(--rc); font-size: 0.76rem; font-weight: 700; cursor: pointer;
}
.rarity-filter-btn.active { background: var(--rc); color: #fff; }
.fish-grid { display: flex; flex-wrap: wrap; gap: 10px; cursor: pointer; }
.fish-grid .fish-card:active { transform: scale(0.94); }

/* 変異（ミューテーション）演出 */
.fish-card.mutant, .base-slot.mutant {
  box-shadow: 0 0 0 2px var(--rc), 0 0 14px 2px var(--rc);
  animation: pop 0.35s ease, mutant-glow 1.6s ease-in-out infinite;
}
@keyframes mutant-glow {
  0%, 100% { box-shadow: 0 0 0 2px var(--rc), 0 0 8px 1px var(--rc); }
  50% { box-shadow: 0 0 0 2px var(--rc), 0 0 18px 4px var(--rc); }
}
.mutation-rainbow.fish-card, .mutation-rainbow.base-slot {
  background: linear-gradient(135deg, #fca5a5, #fcd34d, #86efac, #93c5fd, #d8b4fe);
}

/* アルティメット専用の特別演出（レアリティ最上位） */
.rarity-ultimate {
  background: linear-gradient(135deg, #fff7cc, #fde68a, #fef3c7, #fde68a);
  background-size: 300% 300%;
  animation: pop 0.35s ease, ultimate-shimmer 2.2s linear infinite;
  box-shadow: 0 0 10px 2px rgba(250, 204, 21, 0.6) !important;
}
@keyframes ultimate-shimmer {
  0% { background-position: 0% 50%; }
  100% { background-position: 200% 50%; }
}

/* オーパーツ専用の特別演出（本当の最上位、虹×黒の特別枠） */
.rarity-oopart {
  background: linear-gradient(135deg, #18181b, #3b0764, #18181b, #7c2d92, #18181b);
  background-size: 300% 300%;
  animation: pop 0.35s ease, oopart-shimmer 3s linear infinite;
  box-shadow: 0 0 16px 4px rgba(250, 204, 21, 0.8) !important;
  color: #fff;
}
.rarity-oopart .fish-meta { color: #e5e7eb; }
@keyframes oopart-shimmer {
  0% { background-position: 0% 50%; box-shadow: 0 0 16px 4px rgba(250, 204, 21, 0.8); }
  50% { background-position: 200% 50%; box-shadow: 0 0 22px 6px rgba(236, 72, 153, 0.8); }
  100% { background-position: 0% 50%; box-shadow: 0 0 16px 4px rgba(250, 204, 21, 0.8); }
}

/* 図鑑 */
.dex-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 10px; }
.dex-cell {
  --rc: #cbd5e1;
  border-radius: 12px; padding: 10px 4px; text-align: center;
  background: var(--card-bg); border: 2px solid #e5e7eb;
}
.dex-cell.found { border-color: var(--rc); box-shadow: 0 2px 6px rgba(0,0,0,0.08); }
.dex-cell.found .fish-emoji { font-size: 1.8rem; }
.dex-cell.locked { opacity: 0.55; }
.dex-cell.locked .fish-emoji { font-size: 1.8rem; color: #cbd5e1; }
.dex-name { font-size: 0.72rem; font-weight: 700; margin-top: 2px; }
.dex-count { font-size: 0.68rem; color: var(--sub); margin-top: 2px; }

/* テーマ選択 */
.theme-list { display: flex; gap: 10px; margin-bottom: 6px; }
.theme-card {
  flex: 1; text-align: center; padding: 14px 6px; border-radius: 12px;
  background: var(--card-bg); border: 2px solid #e5e7eb;
}
.theme-card.unlocked { cursor: pointer; border-color: var(--sea); }
.theme-card.current { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent); }
.theme-card.locked { opacity: 0.5; }
.theme-icon { font-size: 1.6rem; }
.theme-name { font-size: 0.72rem; font-weight: 700; margin-top: 4px; }

/* 実績一覧 */
.achieve-list { display: flex; flex-direction: column; gap: 8px; }
.achieve-row {
  display: flex; align-items: center; gap: 12px;
  background: var(--card-bg); border-radius: 12px; padding: 10px 14px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.06); opacity: 0.55;
}
.achieve-row.unlocked { opacity: 1; border: 2px solid var(--accent); }
.achieve-icon { font-size: 1.5rem; width: 34px; text-align: center; }
.achieve-name { font-weight: 700; font-size: 0.9rem; }
.achieve-desc { font-size: 0.75rem; color: var(--sub); }

/* 更新履歴モーダル */
.version-link { cursor: pointer; text-decoration: underline; }
.modal-overlay {
  display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.45);
  align-items: center; justify-content: center; z-index: 100; padding: 20px;
}
.modal-overlay.show { display: flex; }
.modal-box {
  background: var(--card-bg); border-radius: 16px; max-width: 420px; width: 100%;
  max-height: 80vh; display: flex; flex-direction: column; overflow: hidden;
}
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; border-bottom: 1px solid #eee; }
.modal-close { border: none; background: none; font-size: 1.4rem; cursor: pointer; color: var(--sub); line-height: 1; }
.modal-body { padding: 14px 16px; overflow-y: auto; }
.changelog-entry { margin-bottom: 14px; }
.changelog-version { font-weight: 700; color: var(--sea-dark); }
.changelog-date { font-weight: 400; color: var(--sub); font-size: 0.78rem; }
.changelog-entry ul { margin: 4px 0 0 18px; font-size: 0.85rem; }

/* イベントバナー（管理者ブロードキャスト） */
#event-banner {
  display: none; position: sticky; top: 0; z-index: 40;
  background: linear-gradient(90deg, #f59e0b, #ec4899);
  color: #fff; text-align: center; font-weight: 700; font-size: 0.85rem;
  padding: 8px 12px;
}
#event-banner.show { display: block; }

/* プレイヤー一覧共通（トレードのオンライン表示等） */
.nickname-row { display: flex; gap: 8px; margin: 10px 0; }
.nickname-row input {
  flex: 1; padding: 10px 12px; border-radius: 10px; border: 1px solid #d1d5db; font-size: 0.9rem;
}
.ranking-list { display: flex; flex-direction: column; gap: 6px; }
.rank-row {
  display: flex; align-items: center; gap: 10px; background: var(--card-bg);
  border-radius: 10px; padding: 8px 12px; box-shadow: 0 1px 4px rgba(0,0,0,0.06); font-size: 0.88rem;
}
.rank-row.me { border: 2px solid var(--accent); font-weight: 700; }
.rank-medal { width: 28px; text-align: center; font-weight: 700; }
.rank-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank-value { color: var(--sea-dark); font-weight: 700; }

/* 管理者メニュー */
.admin-gear-btn {
  border: none; background: none; color: var(--sub); font-size: 1rem; cursor: pointer;
  margin-left: 8px; vertical-align: middle;
}
.admin-label { display: block; font-size: 0.78rem; color: var(--sub); margin: 10px 0 4px; font-weight: 700; }
#admin-modal-body input, #admin-modal-body textarea, #admin-modal-body select {
  width: 100%; padding: 10px 12px; border-radius: 10px; border: 1px solid #d1d5db; font-size: 0.9rem; font-family: inherit;
}
.admin-send-btn { width: 100%; margin-top: 14px; }
.admin-logout-btn {
  width: 100%; margin-top: 8px; border: none; background: none; color: var(--sub);
  text-decoration: underline; padding: 6px; cursor: pointer;
}
.admin-error { color: #dc2626; font-size: 0.8rem; margin-top: 8px; }

/* 表示設定（軽量モード） */
.settings-toggle-row { display: flex; align-items: flex-start; gap: 10px; cursor: pointer; margin-bottom: 8px; }
.settings-toggle-row input { width: 20px; height: 20px; flex-shrink: 0; margin-top: 2px; }
.settings-note { font-size: 0.75rem; color: var(--sub); font-weight: 400; margin: 6px 0; }
.autosell-list { display: flex; flex-direction: column; gap: 4px; margin-top: 8px; }
.autosell-row { font-size: 0.85rem; }

/* 手動売却 */
.sell-mini-btn {
  display: block; width: 100%; margin-top: 4px; border: none; border-radius: 999px;
  background: #16a34a; color: #fff; font-size: 0.62rem; font-weight: 700;
  padding: 2px 6px; cursor: pointer;
}
.sell-preview { text-align: center; margin-bottom: 14px; }
.sell-preview .fish-emoji { font-size: 2.2rem; }
.sell-qty-row { display: flex; align-items: center; gap: 8px; justify-content: center; }
.qty-btn {
  width: 40px; height: 40px; border-radius: 10px; border: none; background: var(--sea);
  color: #fff; font-size: 1.2rem; font-weight: 700; cursor: pointer; flex-shrink: 0;
}
#sell-qty-input {
  width: 80px; text-align: center; padding: 10px 4px; border-radius: 10px;
  border: 1px solid #d1d5db; font-size: 1rem;
}
.qty-max-btn {
  border: 1px solid var(--sea); background: #fff; color: var(--sea-dark);
  border-radius: 999px; padding: 8px 12px; font-size: 0.78rem; font-weight: 700; cursor: pointer; flex-shrink: 0;
}
.sell-total { text-align: center; font-weight: 700; margin: 12px 0; font-size: 1rem; }

/* 軽量モード: アニメーション・演出を止めて動作を軽くする */
body.light-mode .fish-card,
body.light-mode .base-slot.filled,
body.light-mode .dex-cell.found,
body.light-mode .theme-card {
  animation: none !important;
}
body.light-mode .rarity-ultimate {
  animation: none !important;
  background: #fef3c7 !important;
  box-shadow: 0 0 0 2px #facc15 !important;
}
body.light-mode .rarity-oopart {
  animation: none !important;
  background: #18181b !important;
  box-shadow: 0 0 0 2px #facc15 !important;
}
body.light-mode .fish-card.mutant,
body.light-mode .base-slot.mutant {
  animation: none !important;
  box-shadow: 0 0 0 2px var(--rc) !important;
}

.admin-divider { border: none; border-top: 1px solid #e5e7eb; margin: 16px 0; }
.admin-section-header {
  display: flex; align-items: center; justify-content: space-between;
  font-weight: 700; font-size: 0.85rem; margin-bottom: 8px;
}
.admin-danger-btn {
  border: 1px solid #dc2626; background: #fff; color: #dc2626; border-radius: 999px;
  padding: 4px 10px; font-size: 0.72rem; font-weight: 700; cursor: pointer;
}
.admin-list { display: flex; flex-direction: column; gap: 6px; max-height: 220px; overflow-y: auto; }
.admin-row {
  display: flex; align-items: center; gap: 8px; background: #f9fafb;
  border-radius: 8px; padding: 6px 10px; font-size: 0.78rem;
}
.admin-row-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.admin-row-value { color: var(--sea-dark); font-weight: 700; flex-shrink: 0; }
.admin-del-btn {
  border: none; background: none; color: #dc2626; text-decoration: underline;
  font-size: 0.75rem; cursor: pointer; flex-shrink: 0;
}
.admin-gift-note { font-size: 0.72rem; color: var(--sub); margin: 6px 0 0; }

/* 拠点グリッド */
.base-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin: 12px 0 20px; }
.base-slot {
  --rc: #cbd5e1;
  aspect-ratio: 1;
  border-radius: 12px;
  border: 2px dashed #b9dcea;
  background: #f4fbfd;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  cursor: pointer;
}
.base-slot.filled { border-style: solid; border-color: var(--rc); background: var(--card-bg); box-shadow: 0 2px 6px rgba(0,0,0,0.08); }
.base-slot .fish-emoji { font-size: 1.7rem; }
.base-slot .fish-meta { font-size: 0.6rem; color: var(--sub); }
.slot-empty { font-size: 1.4rem; color: #b9dcea; }

.empty-msg { color: var(--sub); font-size: 0.85rem; padding: 10px 0; }

/* ショップ */
.shop-list { display: flex; flex-direction: column; gap: 12px; }
.shop-row {
  background: var(--card-bg); border-radius: var(--radius); padding: 14px;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.08);
}
.shop-title { font-weight: 700; }
.shop-lv { color: var(--sea-dark); font-size: 0.85rem; }
.shop-desc { font-size: 0.78rem; color: var(--sub); margin-top: 2px; }
.shop-effect { font-size: 0.75rem; color: var(--accent); margin-top: 4px; font-weight: 600; }
.shop-btns { display: flex; flex-direction: column; gap: 6px; flex-shrink: 0; }
.buy-btn {
  flex-shrink: 0; border: none; border-radius: 999px; padding: 10px 16px;
  background: var(--accent); color: #fff; font-weight: 700; cursor: pointer;
  box-shadow: 0 3px 0 #b45309; white-space: nowrap;
}
.buy-max-btn { background: var(--sea); box-shadow: 0 3px 0 var(--sea-dark); font-size: 0.78rem; padding: 8px 12px; }
.buy-btn:active:not(:disabled) { transform: translateY(3px); box-shadow: none; }
.buy-btn:disabled { background: #d1d5db; box-shadow: none; cursor: default; }

/* リボーン */
.reborn-card {
  background: linear-gradient(135deg, #fdf4ff, #fce7f3);
  border: 2px solid #e9d5ff; border-radius: var(--radius);
  padding: 16px; margin-bottom: 16px;
}
.reborn-title { font-weight: 700; font-size: 1rem; margin-bottom: 4px; }
.reborn-desc { font-size: 0.78rem; color: var(--sub); margin-bottom: 10px; }
.reborn-stats { font-size: 0.82rem; margin-bottom: 8px; display: flex; flex-direction: column; gap: 2px; }
.reborn-reqs { font-size: 0.82rem; margin-bottom: 12px; display: flex; flex-direction: column; gap: 2px; }
.reborn-reqs .ok { color: #16a34a; font-weight: 700; }
.reborn-reqs .ng { color: #dc2626; }
.reborn-btn { width: 100%; }

/* ホーム最適化ボタン */
.optimize-btn { width: 100%; margin: 10px 0 16px; }

/* トレード */
.fish-card.selected { outline: 3px solid var(--accent); transform: scale(1.03); }
.trade-row {
  display: flex; align-items: center; gap: 10px; background: var(--card-bg);
  border-radius: 10px; padding: 8px 12px; box-shadow: 0 1px 4px rgba(0,0,0,0.06); font-size: 0.85rem;
}
.trade-fish { font-size: 1.4rem; width: 32px; text-align: center; }
.trade-info { flex: 1; }
.trade-decline-btn {
  border: none; background: none; color: var(--sub); text-decoration: underline;
  font-size: 0.8rem; cursor: pointer; flex-shrink: 0;
}

/* タブバー */
.tab-bar {
  position: fixed; bottom: 0; left: 0; right: 0;
  display: flex; background: #fff;
  box-shadow: 0 -2px 10px rgba(0,0,0,0.1);
  padding-bottom: env(safe-area-inset-bottom, 0);
}
.tab-btn {
  flex: 1; border: none; background: none; padding: 10px 0 8px;
  font-size: 0.78rem; color: var(--sub); cursor: pointer; line-height: 1.5;
}
.tab-btn.active { color: var(--sea-dark); font-weight: 700; background: #eaf6fb; }

.app-footer { text-align: center; color: var(--sub); font-size: 0.7rem; padding: 10px 0 100px; }

#flash-msg {
  position: fixed; top: 12px; left: 50%; transform: translate(-50%, -20px);
  background: #1f2937; color: #fff; padding: 8px 16px; border-radius: 999px;
  font-size: 0.85rem; opacity: 0; transition: all 0.25s; pointer-events: none; z-index: 50;
}
#flash-msg.show { opacity: 1; transform: translate(-50%, 0); }

@media (min-width: 600px) {
  .base-grid { grid-template-columns: repeat(6, 1fr); }
  .dex-grid { grid-template-columns: repeat(5, 1fr); }
}
