/* 管理画面（admin.html）。色はゲーム（style.css）と同じ */
:root {
  --bg: #0d1520;
  --panel: #111c29;
  --card: #1c2a3a;
  --line: rgba(160, 210, 255, 0.22);
  --text: #e8f2fb;
  --muted: #93a9bd;
  --accent: #4fc3ff;
  --good: #5be39a;
  --bad: #ff6b7d;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  display: flex; flex-direction: column; background: var(--bg); color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", "Hiragino Sans", "Yu Gothic UI", sans-serif; font-size: 14px;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }

/* 見出しとタブ */
.ad-top { display: flex; align-items: center; gap: 12px; padding: 10px 16px; border-bottom: 1px solid var(--line); background: var(--panel); flex: none; flex-wrap: wrap; }
.ad-top h1 { margin: 0; font-size: 16px; white-space: nowrap; }
.ad-tabs { display: flex; gap: 6px; flex-wrap: wrap; }
.ad-tabs button, .ad-btn { font-size: 13px; padding: 5px 12px; border-radius: 8px; border: 1px solid var(--line); background: none; color: var(--muted); white-space: nowrap; }
.ad-tabs button.on { color: var(--text); border-color: var(--accent); background: rgba(79,195,255,.12); }
.ad-right { margin-left: auto; display: flex; gap: 6px; align-items: center; }
.ad-right a { color: var(--accent); font-size: 13px; text-decoration: none; white-space: nowrap; }
.ad-auth { font-size: 11px; color: var(--muted); white-space: nowrap; }
main { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.ad-view { flex: 1; min-height: 0; display: flex; flex-direction: column; }

/* ログイン */
.ad-login { margin: 15vh auto 0; width: min(360px, calc(100% - 32px)); padding: 20px; border: 1px solid var(--line); border-radius: 14px; background: var(--panel); display: grid; gap: 10px; }
.ad-login h2 { margin: 0; font-size: 16px; }
.ad-login p { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.6; }
.ad-login input { padding: 9px 10px; border-radius: 8px; border: 1px solid var(--line); background: rgba(0,0,0,.25); }
.ad-login button { padding: 9px; border: 0; border-radius: 8px; background: linear-gradient(135deg, #4fc3ff, #3b7cff); color: #fff; font-weight: 700; }
.ad-err { color: var(--bad); font-size: 12px; min-height: 1em; }

/* 状態 */
.ad-status { padding: 16px; overflow-y: auto; display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; align-content: start; }
.ad-card { padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); }
.ad-card h3 { margin: 0 0 8px; font-size: 12px; color: var(--muted); font-weight: 600; letter-spacing: .05em; }
.ad-card dl { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; font-size: 13px; }
.ad-card dt { color: var(--muted); white-space: nowrap; }
.ad-card dd { margin: 0; text-align: right; overflow-wrap: anywhere; }
.ad-card .warn { color: var(--bad); }
.ad-pond-ctl { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.ad-pond-ctl input { flex: 1; min-width: 160px; font-size: 12px; padding: 5px 8px; border-radius: 8px; border: 1px solid var(--line); background: rgba(0,0,0,.25); color: var(--text); }
.ad-pond-ctl button:disabled { opacity: .4; cursor: default; }
.ad-pond-since { width: 100%; font-size: 11px; color: var(--muted); }
.ad-block { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-top: 8px; font-size: 12px; overflow-wrap: anywhere; }

/* AI ログ（ai-log-view.js のパネルを、タブの中いっぱいに広げる） */
#ad-ailog { position: relative; }
#ad-ailog aside.ailog { position: absolute; inset: 0; width: auto; border-left: 0; }
#ad-ailog aside.ailog .ailog-resize, #ad-ailog aside.ailog header button { display: none; }
.ad-empty, .pl-empty { padding: 24px 16px; color: var(--muted); text-align: center; }
.ad-off-note { max-width: 560px; margin: 0 auto; line-height: 1.7; font-size: 13px; }
.ad-off-note p { margin: 0 0 8px; }

/* プレイログ: 左に一覧、右に詳細（狭い画面では詳細を全画面で） */
.pl-split { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(380px, 42%) 1fr; }
.pl-side { display: flex; flex-direction: column; min-height: 0; border-right: 1px solid var(--line); }
.pl-filter { display: flex; gap: 6px; padding: 10px 16px 0; flex-wrap: wrap; flex: none; }
.pl-filter select, .pl-filter input { font-size: 12px; padding: 5px 8px; border-radius: 8px; border: 1px solid var(--line); background: rgba(0,0,0,.25); color: var(--text); }
.pl-filter input { flex: 1; min-width: 140px; }
#pl-note { padding: 8px 16px; font-size: 11px; color: var(--muted); flex: none; }
#pl-body { flex: 1; overflow-y: auto; border-top: 1px solid var(--line); }
#pl-stats { padding: 8px 16px; border-bottom: 1px solid var(--line); font-size: 12px; }
.pl-stats-head { cursor: pointer; color: var(--muted); }
.pl-stats-table { margin-top: 6px; border-collapse: collapse; width: 100%; }
.pl-stats-table th, .pl-stats-table td { padding: 3px 6px; text-align: right; border-top: 1px solid var(--line); white-space: nowrap; }
.pl-stats-table th:first-child, .pl-stats-table td:first-child { text-align: left; }
.pl-stats-table th { color: var(--muted); font-weight: 600; }
.pl-item { border-bottom: 1px solid var(--line); }
.pl-item.live { background: rgba(79,195,255,.06); }
.pl-item.live .pl-stage { color: #7ee2a8; }
.pl-item.sel { background: rgba(79,195,255,.14); box-shadow: inset 3px 0 0 var(--accent); }
.pl-row { display: flex; align-items: center; gap: 10px; padding: 8px 16px; cursor: pointer; }
.pl-row:hover { background: rgba(255,255,255,.04); }
.pl-row canvas { width: 34px; height: 34px; border-radius: 50%; flex: none; }
.pl-who { flex: 1; min-width: 0; }
.pl-who b, .pl-who small { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pl-who small { font-size: 11px; color: var(--muted); }
.pl-stage { font-size: 12px; white-space: nowrap; }
.pl-aff { width: 56px; flex: none; font-size: 12px; }
.pl-aff b { display: block; text-align: right; }
.pl-bar { display: block; height: 4px; border-radius: 2px; background: rgba(255,255,255,.1); overflow: hidden; }
.pl-bar i { display: block; height: 100%; background: var(--accent); }
.pl-aff.danger b { color: #ff6b6b; }
.pl-aff.danger .pl-bar i { background: #ff4d4d; }
.pl-time { width: 9.5em; font-size: 11px; color: var(--muted); text-align: right; flex: none; }
#pl-more { display: block; margin: 12px auto; padding: 8px 24px; font-size: 13px; border-radius: 10px; border: 1px solid var(--line); background: rgba(255,255,255,.05); }

/* 釣り師一覧（プレイログと同じ左右分割。左は表） */
.us-split { grid-template-columns: minmax(560px, 56%) 1fr; }
.pl-note-line { padding: 8px 16px; font-size: 11px; color: var(--muted); flex: none; }
#us-body { flex: 1; overflow: auto; border-top: 1px solid var(--line); }
#us-more { display: block; margin: 12px auto; padding: 8px 24px; font-size: 13px; border-radius: 10px; border: 1px solid var(--line); background: rgba(255,255,255,.05); }
.us-check { display: flex; align-items: center; gap: 4px; font-size: 12px; color: var(--muted); white-space: nowrap; }
.us-check input { flex: none; margin: 0; min-width: 0; width: auto; }
.us-scroll { overflow-x: auto; }
.us-table { border-collapse: collapse; width: 100%; font-size: 12px; }
.us-table th, .us-table td { padding: 6px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; text-align: left; vertical-align: middle; }
.us-table th { color: var(--muted); font-weight: 600; font-size: 11px; position: sticky; top: 0; background: var(--bg); }
.us-table th:first-child, .us-table td:first-child { padding-left: 16px; }
.us-table .r { text-align: right; }
.us-table tr[data-hash] { cursor: pointer; }
.us-table tr[data-hash]:hover { background: rgba(255,255,255,.04); }
.us-table tr.sel { background: rgba(79,195,255,.14); box-shadow: inset 3px 0 0 var(--accent); }
.us-table tr.dim { color: var(--muted); opacity: .6; }
.us-who b, .us-who small { display: block; max-width: 12em; overflow: hidden; text-overflow: ellipsis; }
.us-who small { font-size: 10px; color: var(--muted); }
.us-when span { display: block; font-size: 11px; color: var(--muted); }
.us-live { color: #7ee2a8; }
.us-zukan { margin-top: 4px; }
.us-fish { display: flex; align-items: center; gap: 6px; }
.us-fish canvas { width: 24px; height: 24px; border-radius: 50%; }
.us-plays { display: grid; gap: 4px; }
.us-play { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; padding: 6px 10px; border: 1px solid var(--line); border-radius: 8px; font-size: 12px; cursor: pointer; }
.us-play:hover { background: rgba(255,255,255,.04); }
.us-play.static { cursor: default; }
.us-play.static:hover { background: none; }
.us-play b { font-weight: 700; }
.us-play small { margin-left: auto; color: var(--muted); font-size: 11px; }
.us-play .pl-dbadge { margin: 0; padding: 1px 8px; font-size: 11px; }
.pl-actions button.danger { color: var(--bad); border-color: rgba(255,107,125,.4); }

/* 自由入力の一覧（表だけ。右の詳細は無く、行を押すとプレイログへ） */
.in-body { flex: 1; overflow: auto; border-top: 1px solid var(--line); }
#in-more { display: block; margin: 12px auto; padding: 8px 24px; font-size: 13px; border-radius: 10px; border: 1px solid var(--line); background: rgba(255,255,255,.05); }
.in-table td.in-text { white-space: normal; min-width: 240px; max-width: 520px; overflow-wrap: anywhere; }
.in-table td.in-text small { display: block; color: var(--muted); font-size: 11px; }
.in-table td.in-notes { white-space: normal; max-width: 260px; font-size: 11px; color: var(--muted); }
.in-table tr.link { cursor: pointer; }
.in-table tr.link:hover { background: rgba(255,255,255,.04); }
.in-table tr.neg td.in-text { color: #ffb3bd; }
.in-table tr.guard td.in-text { color: #ffd36b; }
.in-table td.up { color: var(--good); }
.in-table td.down { color: var(--bad); }

/* 詳細 */
.pl-detail { min-height: 0; overflow-y: auto; padding: 16px 20px 32px; }
.pl-back { display: none; margin-bottom: 10px; font-size: 13px; padding: 5px 12px; border-radius: 8px; border: 1px solid var(--line); background: none; }
.pl-dhead { display: flex; gap: 14px; align-items: center; }
.pl-dhead canvas { width: 80px; height: 80px; border-radius: 50%; border: 2px solid var(--line); flex: none; }
.pl-dnames { min-width: 0; display: grid; gap: 3px; }
.pl-dwho { font-size: 18px; font-weight: 800; overflow-wrap: anywhere; }
.pl-dfish { font-size: 12px; color: var(--muted); }
.pl-dbadge { justify-self: start; margin-top: 2px; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; background: rgba(255,255,255,.08); }
.pl-dbadge.live { color: #7ee2a8; background: rgba(126,226,168,.12); }
.pl-dbadge.love { color: #ff9ecb; background: rgba(255,158,203,.14); }
.pl-dbadge.catch { color: #ffd36b; background: rgba(255,211,107,.14); }
.pl-dbadge.fail, .pl-dbadge.escape, .pl-dbadge.timeup { color: #ff8b98; background: rgba(255,107,125,.12); }
.pl-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.pl-chips span { font-size: 12px; padding: 2px 8px; border-radius: 6px; border: 1px solid var(--line); color: var(--muted); }
.pl-h { margin: 18px 0 6px; font-size: 12px; color: var(--muted); font-weight: 600; letter-spacing: .05em; }
.pl-graph { width: 100%; max-width: 640px; height: auto; display: block; }
.pl-graph .ax { fill: var(--muted); font-size: 11px; }
.pl-graph .base { stroke: var(--line); }
.pl-graph .goal { stroke: #ffd36b; stroke-dasharray: 4 4; opacity: .7; }
.pl-graph .goal-t { fill: #ffd36b; font-size: 10px; opacity: .8; }
.pl-graph .danger { stroke: #ff6b6b; stroke-dasharray: 4 4; opacity: .6; }
.pl-graph .danger-t { fill: #ff6b6b; font-size: 10px; opacity: .8; }
.pl-graph .line { fill: none; stroke: var(--accent); stroke-width: 2; }
.pl-graph .pt { fill: var(--panel); stroke: var(--accent); stroke-width: 2; cursor: pointer; }
.pl-graph .pt.up { stroke: var(--good); }
.pl-graph .pt.down { stroke: var(--bad); }
.pl-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.pl-actions button { font-size: 12px; padding: 5px 10px; border-radius: 8px; border: 1px solid var(--line); background: rgba(255,255,255,.04); }
.pl-actions button:disabled { opacity: .4; cursor: default; }

/* 会話（魚は左、プレイヤーは右） */
.pl-chat { display: flex; flex-direction: column; gap: 8px; }
.pl-turn { align-self: center; font-size: 11px; color: var(--muted); padding: 2px 10px; border-radius: 999px; background: rgba(255,255,255,.05); margin-top: 6px; }
.pl-msg { max-width: min(78%, 520px); display: grid; gap: 3px; }
.pl-msg.fish { align-self: flex-start; }
.pl-msg.player { align-self: flex-end; justify-items: end; }
.pl-name { font-size: 11px; color: var(--muted); }
.pl-bubble { padding: 8px 12px; border-radius: 14px; line-height: 1.55; overflow-wrap: anywhere; }
.pl-msg.fish .pl-bubble { background: var(--card); border-top-left-radius: 4px; }
.pl-msg.player .pl-bubble { background: rgba(79,195,255,.18); border-top-right-radius: 4px; }
.pl-msg.ending .pl-bubble { background: rgba(255,211,107,.14); border: 1px solid rgba(255,211,107,.35); }
.pl-msg.hit .pl-bubble { outline: 2px solid var(--accent); outline-offset: 2px; } /* 自由入力の一覧から飛んできた発言 */
.pl-meta { display: flex; flex-wrap: wrap; gap: 4px 8px; font-size: 11px; color: var(--muted); }
.pl-msg.player .pl-meta { justify-content: flex-end; }
.pl-meta b { font-weight: 700; }
.pl-meta b.up { color: var(--good); }
.pl-meta b.down { color: var(--bad); }
.pl-note { padding: 0 6px; border-radius: 4px; background: rgba(255,255,255,.08); }

@media (max-width: 760px) {
  .pl-split, .us-split { grid-template-columns: 1fr; }
  .pl-side { border-right: 0; }
  .pl-detail { display: none; padding: 12px 14px 32px; }
  .pl-split.detail .pl-side { display: none; }
  .pl-split.detail .pl-detail { display: block; }
  .pl-back { display: inline-block; }
  .pl-msg { max-width: 88%; }
}
@media (max-width: 600px) {
  .ad-top { padding: 10px 12px; }
  .ad-right { margin-left: 0; }
  .pl-time { display: none; }
}
