/* 戦績アプリ（仮）— 画面の共通スタイル。
   メイン画面のモック（mock/main.html）のトークン・部品を正とし、他画面はその部品を流用する。
   数値ルール: better-ui（同心角丸・影の輪・hover は @media (hover:hover) 内のみ・overscroll-behavior）
             better-motion（押下 scale 0.96 / 150ms ease-out、初回だけ 100ms 間隔の段差入場、reduced-motion では opacity のみ） */
:root {
  --bg: #0c1016;
  --surface: #151b24;
  --surface-inset: #1b232f;
  --surface-hover: #232d3b;
  --text: #e9edf3;
  --muted: #97a3b2;
  --accent: #f99e1a;
  --win: #3fb68b;
  --loss: #e5534b;
  --draw: #8c96a3;
  --input-border: #6b7686;          /* 入力欄の境界（背景に対し 3:1 以上） */
  --radius-card: 24px;               /* = 内側 8 + パディング 16（同心角丸） */
  --radius-inner: 8px;
  --radius-tabs: 16px;               /* = 内側 12 + パディング 4 */
  --radius-tab: 12px;
  --shadow-border: 0 0 0 1px oklch(1 0 0 / 0.08);        /* better-ui ダークモードの輪 */
  --shadow-border-hover: 0 0 0 1px oklch(1 0 0 / 0.13);
  --divider: oklch(1 0 0 / 0.06);
  color-scheme: dark;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html { background: var(--bg); }
body {
  font-family: "Hiragino Kaku Gothic ProN", "Hiragino Sans", "Noto Sans JP", system-ui, sans-serif;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  min-height: 100dvh;
}
.wrap { max-width: 560px; margin: 0 auto; padding: 20px 16px 28px; }
.num, table, .tabular { font-variant-numeric: tabular-nums; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
.muted { color: var(--muted); }
.small { font-size: 11px; line-height: 1.6; }
.hidden { display: none !important; }

/* ---------- 押下の手触り（better-motion: 0.96 / 150ms / ease-out、disabled は縮まない） ---------- */
.press {
  transition-property: scale, background-color, color, box-shadow;
  transition-duration: 150ms;
  transition-timing-function: ease-out;
}
.press:not(:disabled):active { scale: 0.96; }
.press:disabled { opacity: 0.45; cursor: not-allowed; }

/* ---------- ヘッダー ---------- */
header.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; min-height: 40px; }
h1 { font-size: 20px; font-weight: 700; letter-spacing: .02em; }
h1.sub { font-size: 17px; }
.back { display: inline-flex; align-items: center; gap: 2px; font-size: 13px; font-weight: 600; color: var(--muted); padding: 8px 10px 8px 6px; margin-left: -6px; border-radius: 10px; }
.back svg { width: 18px; height: 18px; }
.gear {
  width: 40px; height: 40px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--surface); color: var(--muted);
  box-shadow: var(--shadow-border); border: 1px solid transparent;
}
.gear svg { width: 20px; height: 20px; }

/* ---------- アカウント切替タブ ---------- */
.tabs {
  display: flex; gap: 4px; padding: 4px; margin-bottom: 16px;
  background: var(--surface); border-radius: var(--radius-tabs);
  box-shadow: var(--shadow-border); border: 1px solid transparent;
}
.tab {
  flex: 1; text-align: center; padding: 9px 0; border-radius: var(--radius-tab);
  font-size: 14px; font-weight: 600; color: var(--muted); min-height: 44px;
}
.tab small { display: block; font-size: 11px; font-weight: 500; margin-top: 1px; }
.tab[aria-selected="true"] { background: var(--surface-inset); color: var(--text); }
.tab[aria-selected="true"] small { color: var(--accent); }

/* ---------- カード ---------- */
.card {
  background: var(--surface);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-border);
  border: 1px solid transparent;
  padding: 16px;
  margin-bottom: 16px;
}
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin-bottom: 12px; }
.card-title { font-size: 13px; font-weight: 700; color: var(--muted); letter-spacing: .06em; }
.card-link { font-size: 12px; color: var(--accent); font-weight: 600; padding: 4px 0 4px 8px; white-space: nowrap; }
.empty { font-size: 13px; color: var(--muted); line-height: 1.7; }

/* 直近セッション */
.session-main { display: flex; align-items: flex-end; gap: 16px; }
.wl { font-size: 34px; font-weight: 800; line-height: 1; white-space: nowrap; }
.wl .w { color: var(--win); } .wl .l { color: var(--loss); }
.wl-label { font-size: 12px; color: var(--muted); margin-top: 6px; }
.winrate { margin-left: auto; text-align: right; white-space: nowrap; }
.winrate .v { font-size: 22px; font-weight: 700; }
.winrate .k { font-size: 11px; color: var(--muted); }
.bar { height: 8px; border-radius: 4px; background: oklch(0.45 0.15 25 / 0.35); margin-top: 14px; overflow: hidden; }
.bar > i { display: block; height: 100%; width: 100%; background: var(--win); border-radius: 4px; transform-origin: left; }
.rankrow { display: flex; align-items: center; gap: 8px; margin-top: 14px; flex-wrap: wrap; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--surface-inset); border-radius: var(--radius-inner);
  padding: 6px 10px; font-size: 12px; font-weight: 600; min-height: 30px;
}
.chip .dot { width: 8px; height: 8px; border-radius: 50%; background: #b388ff; }
.chip .dot.damage { background: #ff8a80; }
.chip .dot.support { background: #80d8ff; }
.api-state { font-size: 11px; color: var(--muted); margin-top: 10px; display: flex; gap: 6px; align-items: baseline; flex-wrap: wrap; line-height: 1.6; }
.api-state .ok { color: var(--win); font-weight: 700; }
.api-state .warn { color: var(--accent); font-weight: 700; }
.api-state .err { color: var(--loss); font-weight: 700; }

/* マップ行 */
.maprow { display: flex; align-items: center; gap: 10px; padding: 10px 0; }
.maprow + .maprow { border-top: 1px solid var(--divider); }
.maplist > .maprow:first-child { padding-top: 2px; }
.maplist > .maprow:last-child { padding-bottom: 2px; }
.map-info { min-width: 0; flex: 1; }
.map-name { font-size: 13px; font-weight: 700; line-height: 1.35; overflow-wrap: anywhere; }
.map-mode { font-size: 11px; color: var(--muted); margin-top: 1px; }
.map-wl { font-size: 13px; font-weight: 700; text-align: right; white-space: nowrap; }
.map-wl small { display: block; font-size: 11px; color: var(--muted); font-weight: 500; }
.badge {
  font-size: 10px; font-weight: 700; color: var(--muted);
  border: 1px solid oklch(1 0 0 / 0.18); border-radius: 6px; padding: 2px 6px; white-space: nowrap;
}
.badge.strong { color: var(--win); border-color: color-mix(in oklch, var(--win) 55%, transparent); }
.badge.weak { color: var(--loss); border-color: color-mix(in oklch, var(--loss) 55%, transparent); }
.mapbar { width: 56px; height: 6px; border-radius: 3px; background: oklch(1 0 0 / 0.08); overflow: hidden; flex: none; }
.mapbar > i { display: block; height: 100%; background: var(--win); transform-origin: left; }
.mapbar > i.loss { background: var(--loss); }

/* 予測・検証 */
.p-line { font-size: 12px; color: var(--muted); margin-bottom: 10px; line-height: 1.6; }
.p-line b { color: var(--text); }
.headline { display: flex; align-items: baseline; gap: 10px; }
.headline .v { font-size: 30px; font-weight: 800; color: var(--accent); }
.headline .k { font-size: 12px; color: var(--muted); line-height: 1.5; }
.note { font-size: 11px; color: var(--muted); margin-top: 8px; line-height: 1.6; }
.note b { color: var(--text); font-weight: 600; }
table.mini { width: 100%; border-collapse: collapse; margin-top: 12px; font-size: 12px; }
table.mini th, table.mini td { padding: 7px 4px; text-align: right; }
table.mini th { color: var(--muted); font-weight: 600; border-bottom: 1px solid oklch(1 0 0 / 0.08); }
table.mini td { border-bottom: 1px solid oklch(1 0 0 / 0.05); }
table.mini th:first-child, table.mini td:first-child { text-align: left; }
table.mini tr:last-child td { border-bottom: none; }
.verdict {
  display: flex; gap: 10px; align-items: flex-start;
  background: var(--surface-inset); border-radius: var(--radius-inner);
  padding: 10px 12px; margin-top: 12px;
}
.verdict .tag {
  flex: none; font-size: 11px; font-weight: 800; color: #0c1016; background: var(--muted);
  border-radius: 6px; padding: 3px 8px; margin-top: 1px;
}
.verdict .tag.within_chance { background: var(--win); }
.verdict .tag.hard_to_explain { background: var(--accent); }
.verdict p { font-size: 12px; line-height: 1.6; color: var(--text); }
.verdict p small { color: var(--muted); font-size: 11px; }

/* ボタン */
.btn {
  display: block; width: 100%; text-align: center;
  background: var(--surface-inset); color: var(--text);
  font-size: 13px; font-weight: 700;
  border-radius: 12px; padding: 12px 0; margin-top: 4px; min-height: 44px;
  border: 1px solid transparent;
}
.btn.primary { background: var(--accent); color: #1a1205; }
.btn.danger { color: var(--loss); }
.btn.inline { display: inline-block; width: auto; padding: 10px 16px; margin-top: 0; }
.btn-row { display: flex; gap: 8px; margin-top: 12px; }
.btn-row > .btn { flex: 1; margin-top: 0; }
.card > .btn:first-child { margin-top: 0; }
.verdict + .btn, table + .btn { margin-top: 12px; }

/* セグメント（並び替え・勝敗・主観判定・チルト） */
.seg { display: flex; gap: 4px; padding: 4px; background: var(--surface-inset); border-radius: 12px; }
.seg button { flex: 1; min-height: 40px; border-radius: 8px; font-size: 13px; font-weight: 600; color: var(--muted); padding: 0 6px; }
.seg button[aria-pressed="true"] { background: var(--surface-hover); color: var(--text); box-shadow: var(--shadow-border); }
.seg button[aria-pressed="true"].win { color: var(--win); }
.seg button[aria-pressed="true"].loss { color: var(--loss); }

/* 試合一覧 */
.group-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.group-head .title { font-size: 14px; font-weight: 700; flex: 1; min-width: 0; }
.group-head .title small { display: block; font-size: 11px; font-weight: 500; color: var(--muted); margin-top: 2px; }
.lock { font-size: 10px; font-weight: 700; color: var(--accent); border: 1px solid color-mix(in oklch, var(--accent) 55%, transparent); border-radius: 6px; padding: 1px 5px; margin-left: 6px; vertical-align: 1px; }
.icon-btn { min-width: 40px; min-height: 40px; border-radius: 10px; display: inline-grid; place-items: center; color: var(--muted); font-size: 12px; font-weight: 600; padding: 0 10px; background: var(--surface-inset); }
.mrow { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; padding: 10px 8px; margin: 0 -8px; border-radius: var(--radius-inner); min-height: 52px; width: calc(100% + 16px); }
.mrow + .mrow { box-shadow: 0 -1px 0 var(--divider); }
.res { flex: none; width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center; font-size: 12px; font-weight: 800; color: #0c1016; }
.res.win { background: var(--win); } .res.loss { background: var(--loss); } .res.draw { background: var(--draw); }
.mrow .info { flex: 1; min-width: 0; }
.mrow .info .name { display: block; font-size: 13px; font-weight: 700; overflow-wrap: anywhere; }
.mrow .info .sub { display: block; font-size: 11px; color: var(--muted); margin-top: 2px; }
.mrow .meta { text-align: right; font-size: 12px; font-weight: 600; white-space: nowrap; }
.mrow .meta small { display: block; font-size: 11px; color: var(--muted); font-weight: 500; margin-top: 2px; }
.tagline { display: inline-flex; gap: 4px; flex-wrap: wrap; }
.mini-tag { font-size: 10px; color: var(--muted); background: oklch(1 0 0 / 0.06); border-radius: 4px; padding: 1px 5px; }
.unmapped { color: var(--accent); }

/* フォーム */
.field { display: block; margin-top: 12px; }
.field:first-child { margin-top: 0; }
.field > span { display: block; font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 6px; }
.field input, .field select, .field textarea {
  width: 100%; font: inherit; font-size: 16px; color: var(--text);
  background: var(--surface-inset); border: 1px solid var(--input-border); border-radius: var(--radius-inner);
  padding: 9px 10px; min-height: 44px;
}
.field textarea { min-height: 72px; resize: vertical; }
.field-row { display: flex; gap: 8px; }
.field-row > .field { flex: 1; min-width: 0; margin-top: 12px; }
.err-text { color: var(--loss); font-size: 12px; margin-top: 8px; min-height: 1em; }
.secret { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; background: var(--surface-inset); border-radius: var(--radius-inner); padding: 10px; overflow-wrap: anywhere; margin-top: 8px; user-select: all; }

/* ダイアログ（モーダル: 入場 350ms・0.98 から、退場 150ms・0.99 へ。reduced-motion は opacity のみ） */
dialog.sheet {
  margin: auto; width: min(520px, calc(100vw - 24px)); max-height: calc(100dvh - 24px);
  background: var(--surface); color: var(--text);
  border: 1px solid transparent; border-radius: var(--radius-card); box-shadow: var(--shadow-border);
  padding: 16px; overflow: auto; overscroll-behavior: contain;
  opacity: 0;
  transition-property: opacity, display, overlay;
  transition-duration: 150ms;
  transition-timing-function: ease-out;
  transition-behavior: allow-discrete;
}
dialog.sheet[open] { opacity: 1; transition-duration: 350ms; }
@starting-style { dialog.sheet[open] { opacity: 0; } }
dialog.sheet::backdrop { background: oklch(0 0 0 / 0.6); }
@media (prefers-reduced-motion: no-preference) {
  dialog.sheet { scale: 0.99; transition-property: opacity, scale, display, overlay; }
  dialog.sheet[open] { scale: 1; }
  @starting-style { dialog.sheet[open] { scale: 0.98; } }
}
.sheet h2 { font-size: 16px; font-weight: 700; margin-bottom: 12px; }

/* 通知（静的な文言が主。opacity の切り替えだけ） */
.toast {
  position: fixed; left: 50%; bottom: 20px; translate: -50% 0; z-index: 10;
  background: var(--surface-hover); color: var(--text); box-shadow: var(--shadow-border); border: 1px solid transparent;
  border-radius: 12px; padding: 10px 14px; font-size: 13px; font-weight: 600; max-width: calc(100vw - 32px);
  opacity: 0; pointer-events: none; transition: opacity 150ms ease-out;
}
.toast.show { opacity: 1; }
.toast.err { color: var(--loss); }

/* ログイン */
.login { min-height: 100dvh; display: grid; place-items: center; padding: 16px; }
.login .card { width: min(400px, 100%); }

/* ランク推移のステップ表示 */
.step { display: flex; align-items: center; gap: 10px; padding: 8px 0; }
.step + .step { border-top: 1px solid var(--divider); }
.step .when { width: 92px; flex: none; font-size: 11px; color: var(--muted); line-height: 1.4; }
.step .lvl { flex: 1; height: 8px; border-radius: 4px; background: oklch(1 0 0 / 0.06); overflow: hidden; }
.step .lvl > i { display: block; height: 100%; background: #b388ff; transform-origin: left; }
.step .lvl > i.damage { background: #ff8a80; } .step .lvl > i.support { background: #80d8ff; }
.step .rk { width: 116px; flex: none; text-align: right; font-size: 12px; font-weight: 700; }
.step .rk small { display: block; font-size: 10px; color: var(--muted); font-weight: 500; }

footer { font-size: 11px; color: var(--muted); text-align: center; line-height: 1.7; margin-top: 4px; }

/* hover は hover できるポインタだけ（better-ui） */
@media (hover: hover) {
  .btn:not(:disabled):hover { background: var(--surface-hover); }
  .btn.primary:not(:disabled):hover { background: #ffb040; }
  .tab:hover { color: var(--text); }
  .gear:hover, .back:hover { color: var(--text); }
  .gear:hover { box-shadow: var(--shadow-border-hover); }
  .card-link:hover { text-decoration: underline; }
  .mrow:hover, .icon-btn:hover { background: var(--surface-hover); }
  .seg button:not([aria-pressed="true"]):hover { color: var(--text); }
}

/* 初回表示だけの段差入場（100ms 間隔・300ms・12px・blur 4px）。reduced-motion では opacity のみ */
.rise { animation: fade-in 300ms ease-out both; }
@media (prefers-reduced-motion: no-preference) {
  .rise { animation-name: rise-in; }
}
.rise:nth-child(2) { animation-delay: 100ms; }
.rise:nth-child(3) { animation-delay: 200ms; }
.rise:nth-child(4) { animation-delay: 300ms; }
.rise:nth-child(5) { animation-delay: 400ms; }
.rise:nth-child(6) { animation-delay: 500ms; }
.rise:nth-child(n+7) { animation-delay: 600ms; }
@keyframes fade-in { from { opacity: 0; } }
@keyframes rise-in { from { opacity: 0; transform: translateY(12px); filter: blur(4px); } }
