/* ===== Poker HUD ダークテーマ（PPPoker風） ===== */
:root {
  --bg: #0b0d0b;
  --bg2: #12161300;
  --card: #171b17;
  --card2: #1d221d;
  --line: #2a312a;
  --txt: #e8ede8;
  --txt-dim: #8a938a;
  --green: #2f9e5f;
  --green-br: #3ddc84;
  --gold: #e7b34a;
  --red: #e5675f;
  --d0: #3ddc84; /* 好カモ */
  --d1: #7fd08a;
  --d2: #e7b34a; /* 注意 */
  --d3: #e5675f; /* 強者 */
  --good: #3ddc84;
  --warn: #e5675f;
  --info: #7aa7c7;
  --radius: 14px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--txt); }
body {
  font-family: -apple-system, "Hiragino Sans", "Noto Sans JP", system-ui, sans-serif;
  font-size: 15px; line-height: 1.5;
  padding-bottom: calc(64px + env(safe-area-inset-bottom));
  overscroll-behavior-y: contain;
}
h1 { font-size: 19px; margin: 0; font-weight: 700; }
button { font-family: inherit; cursor: pointer; }
select, input { font-family: inherit; font-size: 15px; }
.hidden { display: none !important; }

/* ヘッダー */
.app-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px 8px; position: sticky; top: 0; z-index: 5;
  background: linear-gradient(180deg, var(--bg) 70%, transparent);
}

/* ボタン */
.btn-primary {
  background: var(--green); color: #04210f; border: none; font-weight: 700;
  padding: 10px 14px; border-radius: 10px; font-size: 14px;
}
.btn-primary.block { width: 100%; margin-top: 10px; padding: 13px; }
.btn-ghost { background: transparent; color: var(--txt-dim); border: 1px solid var(--line); padding: 6px 12px; border-radius: 8px; font-size: 13px; }

/* セットアップ行 */
.setup-row { display: flex; gap: 8px; padding: 4px 16px 10px; align-items: flex-end; flex-wrap: wrap; }
.field { display: flex; flex-direction: column; gap: 4px; }
.field span { font-size: 11px; color: var(--txt-dim); padding-left: 2px; }
.field select {
  background: var(--card); color: var(--txt); border: 1px solid var(--line);
  border-radius: 10px; padding: 9px 10px; min-width: 96px;
}
.setup-row .btn-primary { margin-left: auto; }

/* ===== テーブル（フェルト） ===== */
.table-felt {
  position: relative; margin: 6px 16px 16px;
  aspect-ratio: 3 / 4; max-height: 46vh;
  background:
    radial-gradient(ellipse at center, #14351f 0%, #0e241688 70%, transparent 72%);
  border-radius: 46% / 40%;
  border: 2px solid #1f4a2e;
}
.seat {
  position: absolute; transform: translate(-50%, -50%);
  width: 66px; text-align: center;
}
.seat .seat-inner {
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  padding: 6px 4px; display: flex; flex-direction: column; align-items: center; gap: 2px;
  min-height: 54px; justify-content: center;
}
.seat.filled .seat-inner { border-color: var(--seat-c, var(--line)); }
.seat.empty .seat-inner { border-style: dashed; color: var(--txt-dim); }
.seat.hero .seat-inner { border-color: var(--gold); box-shadow: 0 0 0 1px var(--gold) inset; }
.seat .seat-no { position: absolute; top: -8px; left: -6px; font-size: 10px; background: var(--line); color: var(--txt-dim); border-radius: 8px; padding: 0 5px; }
.seat .nm { font-size: 11px; font-weight: 700; line-height: 1.15; max-width: 60px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.seat .tp { font-size: 9px; color: var(--txt-dim); }
.seat .badge { font-size: 9px; padding: 0 5px; border-radius: 6px; font-weight: 700; }
.seat .stack { font-size: 9px; color: var(--green-br); }
.seat .plus { font-size: 20px; color: var(--txt-dim); }

/* 危険度色 */
.d0 { color: var(--d0); } .bg-d0 { background: #113a24; color: var(--d0); }
.d1 { color: var(--d1); } .bg-d1 { background: #143020; color: var(--d1); }
.d2 { color: var(--d2); } .bg-d2 { background: #3a2f12; color: var(--d2); }
.d3 { color: var(--d3); } .bg-d3 { background: #3a1a18; color: var(--d3); }

/* ===== 助言エリア ===== */
.advice-area { padding: 0 14px 20px; display: flex; flex-direction: column; gap: 10px; }
.empty-hint { color: var(--txt-dim); text-align: center; padding: 30px 10px; font-size: 14px; }

.summary-card { background: var(--card2); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.summary-card h3 { margin: 0 0 8px; font-size: 14px; }
.summary-item { padding: 7px 0; border-top: 1px solid var(--line); }
.summary-item:first-of-type { border-top: none; }
.summary-item .st { font-weight: 700; font-size: 13px; display: block; margin-bottom: 2px; }
.summary-item .sb { font-size: 13px; color: var(--txt-dim); }
.summary-item.hero .st { color: var(--gold); }
.summary-item.avoid .st { color: var(--red); }
.summary-item.target .st { color: var(--green-br); }

/* プレイヤー助言カード */
.pcard { background: var(--card); border: 1px solid var(--line); border-left-width: 4px; border-radius: 12px; padding: 11px 13px; }
.pcard .head { display: flex; align-items: center; gap: 8px; }
.pcard .head .nm { font-weight: 700; font-size: 15px; }
.pcard .head .seat-tag { font-size: 10px; color: var(--txt-dim); border: 1px solid var(--line); border-radius: 6px; padding: 0 5px; }
.pcard .head .badge { margin-left: auto; font-size: 11px; padding: 2px 8px; border-radius: 7px; font-weight: 700; }
.pcard .type { font-size: 12px; color: var(--txt-dim); margin: 2px 0 8px; }
.pcard .plan { font-size: 13px; margin-bottom: 8px; }
.flags { display: flex; flex-wrap: wrap; gap: 5px; }
.flag { font-size: 11px; padding: 2px 8px; border-radius: 7px; border: 1px solid var(--line); }
.flag.good { color: var(--good); border-color: #1f5a38; background: #0f2c1c; }
.flag.warn { color: var(--warn); border-color: #5a2420; background: #2c1513; }
.flag.info { color: var(--info); border-color: #24404f; background: #12222c; }
.pcard .rel { font-size: 10px; color: var(--txt-dim); margin-top: 8px; }
.pcard .unknown-note { font-size: 12px; color: var(--gold); }

/* ===== 自分タブ ===== */
#me-content, #import-content { padding: 0 16px 24px; }
.hero-head { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.hero-head .badge-gold { background: #2a2410; color: var(--gold); border: 1px solid #4a3f18; border-radius: 8px; padding: 3px 10px; font-weight: 700; font-size: 12px; }
.section-title { font-size: 13px; color: var(--txt-dim); margin: 18px 0 8px; font-weight: 700; }

.diff-table { width: 100%; border-collapse: collapse; background: var(--card); border-radius: 12px; overflow: hidden; }
.diff-table th, .diff-table td { padding: 9px 8px; text-align: right; font-size: 13px; border-bottom: 1px solid var(--line); }
.diff-table th { color: var(--txt-dim); font-weight: 600; font-size: 11px; }
.diff-table td:first-child, .diff-table th:first-child { text-align: left; }
.diff-pos { color: var(--green-br); font-weight: 700; }
.diff-neg { color: var(--red); font-weight: 700; }
.diff-zero { color: var(--txt-dim); }
.diff-note { font-size: 10px; color: var(--txt-dim); }

.chart-wrap { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 8px 6px; }

.leak-card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 11px 13px; margin-bottom: 8px; border-left: 4px solid var(--gold); }
.leak-card .lh { display: flex; justify-content: space-between; align-items: baseline; }
.leak-card .lt { font-weight: 700; font-size: 14px; }
.leak-card .lv { font-size: 12px; color: var(--txt-dim); }
.leak-card .ln { font-size: 12px; color: var(--txt-dim); margin-top: 4px; }
.leak-card .prio { font-size: 10px; background: var(--card2); border-radius: 6px; padding: 1px 6px; color: var(--gold); }

/* ===== 相手一覧 ===== */
.search-box { padding: 0 16px 10px; }
.search-box input, #picker-search {
  width: 100%; background: var(--card); border: 1px solid var(--line); color: var(--txt);
  border-radius: 12px; padding: 11px 14px;
}
#players-list { padding: 0 16px 24px; display: flex; flex-direction: column; gap: 8px; }
.prow { display: flex; align-items: center; gap: 10px; background: var(--card); border: 1px solid var(--line); border-left-width: 4px; border-radius: 12px; padding: 11px 13px; }
.prow .nm { font-weight: 700; }
.prow .meta { font-size: 11px; color: var(--txt-dim); }
.prow .badge { margin-left: auto; font-size: 11px; padding: 2px 8px; border-radius: 7px; font-weight: 700; }
.prow .stats-mini { font-size: 11px; color: var(--txt-dim); }

/* ===== ボトムナビ ===== */
.bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 20;
  display: flex; background: #0e120e; border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.nav-btn {
  flex: 1; background: none; border: none; color: var(--txt-dim);
  display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 0 7px; font-size: 10px;
}
.nav-btn .ic { font-size: 20px; filter: grayscale(1) opacity(0.7); }
.nav-btn.active { color: var(--green-br); }
.nav-btn.active .ic { filter: none; }

/* ===== モーダル ===== */
.modal-overlay { position: fixed; inset: 0; z-index: 50; background: rgba(0,0,0,.6); display: flex; align-items: flex-end; }
.modal {
  width: 100%; max-height: 82vh; overflow-y: auto; background: var(--bg); border-top: 1px solid var(--line);
  border-radius: 18px 18px 0 0; padding: 14px 16px calc(20px + env(safe-area-inset-bottom));
}
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.modal-head span { font-weight: 700; }
#picker-search { margin-bottom: 10px; }
.picker-list { display: flex; flex-direction: column; gap: 6px; }
.picker-item { display: flex; align-items: center; gap: 8px; background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; }
.picker-item .nm { font-weight: 700; font-size: 14px; }
.picker-item .meta { font-size: 11px; color: var(--txt-dim); margin-left: auto; }
.picker-item.assigned { opacity: .4; }

/* 詳細モーダル */
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 10px 0; }
.stat-cell { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 8px 4px; text-align: center; }
.stat-cell .v { font-size: 16px; font-weight: 700; }
.stat-cell .k { font-size: 9px; color: var(--txt-dim); }
.note-block { background: var(--card2); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; font-size: 13px; color: var(--txt-dim); margin-top: 8px; }

.callout { background: var(--card2); border: 1px solid var(--line); border-radius: 12px; padding: 14px; font-size: 13px; color: var(--txt-dim); }
.callout b { color: var(--txt); }
.callout ol { margin: 8px 0 0; padding-left: 20px; }
.callout li { margin: 5px 0; }

/* スタック行（プレイヤーカード内） */
.summary-item.stack .st { color: var(--green-br); }
.stackline { font-size: 12px; margin: 6px 0; padding: 5px 8px; border-radius: 8px; border: 1px solid var(--line); }
.stackline.good { color: var(--good); border-color: #1f5a38; background: #0f2c1c; }
.stackline.warn { color: var(--warn); border-color: #5a2420; background: #2c1513; }
.stackline.info { color: var(--info); border-color: #24404f; background: #12222c; }
.stackline .stip { color: var(--txt-dim); }

/* セグメント切替（相手タブ カード/一覧） */
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 9px; overflow: hidden; }
.seg button { background: transparent; color: var(--txt-dim); border: none; padding: 6px 12px; font-size: 12px; }
.seg button.active { background: var(--green); color: #04210f; font-weight: 700; }

/* プレイヤー一覧(表) */
.ptable-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; border: 1px solid var(--line); border-radius: 12px; }
.ptable { border-collapse: collapse; width: 100%; font-size: 12px; white-space: nowrap; }
.ptable th, .ptable td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: right; }
.ptable th { color: var(--txt-dim); font-size: 11px; position: sticky; top: 0; background: #0e120e; z-index: 2; }
.ptable td.nmcell, .ptable th.sticky-col { text-align: left; }
.ptable .sticky-col { position: sticky; left: 0; background: var(--bg); z-index: 1; }
.ptable th.sticky-col { z-index: 3; background: #0e120e; }
.ptable tr[data-id] { cursor: pointer; }
.ptable tr[data-id]:hover td { background: var(--card); }
.ptable .nmcell { font-weight: 700; padding-left: 10px; }
.ptable .tsub { display: block; font-size: 10px; color: var(--txt-dim); font-weight: 400; }
.ptable .badge { font-size: 10px; padding: 1px 6px; border-radius: 6px; }

/* ===== レスポンシブ（PC/タブレットでも見やすく中央寄せ） ===== */
#app { max-width: 900px; margin: 0 auto; }
@media (min-width: 760px) {
  body { font-size: 15px; }
  .table-felt { max-height: 52vh; margin: 8px auto 18px; max-width: 560px; }
  .bottom-nav { left: 50%; right: auto; transform: translateX(-50%); width: 100%; max-width: 900px; border-left: 1px solid var(--line); border-right: 1px solid var(--line); }
  /* 助言エリアを2カラム（サマリは全幅） */
  .advice-area { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; align-items: start; }
  .advice-area .summary-card, .advice-area .empty-hint { grid-column: 1 / -1; }
  .setup-row { max-width: 560px; }
  #me-content, #import-content, #players-list, .search-box { max-width: 900px; }
}
@media (min-width: 1100px) {
  #app { max-width: 1040px; }
  .bottom-nav { max-width: 1040px; }
  .advice-area { grid-template-columns: 1fr 1fr 1fr; }
}
