/*!
 * styles.css — 「挟みゲーム IN A PINCH」ブラウザ版のビジュアル
 *
 * 配色トークンは In_a_Pinch_app_5.py (tkinter版) の漆・和紙・金蒔絵パレットを
 * そのまま踏襲(数値まで同じ。ただし小さい文字の読みやすさのため --text-muted と --accent-dark だけ明るくした)。盤面演出・アニメーションは
 * https://yoshi660.github.io/hasami-game/ の「暗い漆の卓 + 明るい和紙の盤」という
 * 世界観を参考にしつつ、蒔絵の輝きやきらめきを増やして独自に組み直したもの。
 *
 * 画面幅は3段階で組む: スマホ(〜639px)/ タブレット・iPad縦(640〜1023px)/ PC・iPad横(1024px〜)。
 * スマホは1列(対局は盤が最初の画面に収まる順)、PCは盤と情報を2列に並べる。
 */

:root {
  --bg: #241012;
  --bg-deep: #180a0c;
  --surface: #3B171B;
  --surface-alt: #33141A;
  --surface-raised: #4A2024;
  --border: #6B4A26;
  --border-bright: #C9A227;
  --text-primary: #EFE7D5;
  --text-secondary: #B5A489;
  --text-muted: #9E8D74;   /* Python版は #7E6E58。小さい注記が読めるよう明るくした(背景とのコントラスト 3.7 → 5.6) */
  --accent: #C9A227;
  --accent-dark: #A8862A;  /* Python版は #8A6C1D。文字に使うため明るくした(3.7 → 5.3) */
  --accent-light: #3A3220;
  --danger: #E8785C;
  --danger-bg: #4A1F18;
  --success: #8FD9D4;
  --success-bg: #173634;
  --warning: #E4C766;
  --warning-bg: #3A3018;
  --primary-fill: #17130F;

  --board-bg: #E9E0CB;
  --board-bg-alt: #DBD0B4;
  --board-line: #B9AB88;
  --board-dest: #C9A227;
  --board-bad: #8B4A3C;

  --p-a-fill: #5FA9AE;
  --p-a-hi: #F2FFFE;
  --p-a-on: #123033;
  --p-a-legend: #8FD9D4;
  --p-b-fill: #17130F;
  --p-b-hi: #5A4E42;
  --p-b-on: #EFE7D5;
  --p-b-legend: #D8CDBB;

  --f-disp: "Yu Mincho", "YuMincho", "Hiragino Mincho ProN", "Noto Serif JP", "Source Han Serif JP", serif;
  --f-body: "Hiragino Sans", "Yu Gothic", "Noto Sans JP", system-ui, -apple-system, sans-serif;
  --f-mono: "Consolas", "Menlo", ui-monospace, monospace;

  --ease-pop: cubic-bezier(.18, 1.5, .4, 1);
  --ease-slide: cubic-bezier(.22, .9, .28, 1);

  --header-h: 54px;   /* 固定ヘッダーの高さ(盤の大きさ・スクロール位置の計算に使う) */
  --page-max: 1180px; /* 画面全体の最大幅 */
  --col-w: 600px;     /* 1列のときの部品の最大幅 */
  --gutter: 16px;

  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  min-height: 100dvh;
  background: var(--bg);
  background-image:
    radial-gradient(120% 70% at 50% -12%, var(--surface-raised) 0%, var(--bg) 55%, var(--bg-deep) 100%);
  background-attachment: fixed;
  color: var(--text-primary);
  font-family: var(--f-body);
  -webkit-font-smoothing: antialiased;
  line-height: 1.7;
  font-size: 15px;
  overflow-x: hidden;
}
[hidden] { display: none !important; }
button { font-family: inherit; }
::selection { background: rgba(201,162,39,.35); color: var(--text-primary); }
:focus-visible { outline: 2px solid var(--warning); outline-offset: 2px; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(201,162,39,.28); border-radius: 6px; }
::-webkit-scrollbar-thumb:hover { background: rgba(201,162,39,.45); }

#app {
  max-width: var(--page-max);
  margin: 0 auto;
  padding: 16px max(var(--gutter), env(safe-area-inset-left)) calc(48px + env(safe-area-inset-bottom)) max(var(--gutter), env(safe-area-inset-right));
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* ---------- ヘッダー(全画面共通) ---------- */
.site-header {
  position: sticky; top: 0; z-index: 30;
  background: rgba(24,10,12,.86);
  -webkit-backdrop-filter: saturate(1.2) blur(10px);
  backdrop-filter: saturate(1.2) blur(10px);
  border-bottom: 1px solid rgba(201,162,39,.18);
  padding-top: env(safe-area-inset-top);
}
.site-header-inner {
  max-width: var(--page-max); margin: 0 auto; min-height: var(--header-h);
  padding: 0 max(var(--gutter), env(safe-area-inset-right)) 0 max(var(--gutter), env(safe-area-inset-left));
  display: flex; align-items: center; gap: 12px; position: relative;
}
.nav-title {
  display: flex; align-items: baseline; gap: 8px; margin-right: auto;
  text-decoration: none; cursor: pointer; user-select: none; padding: 6px 0;
}
.nav-title .glyph { font-family: var(--f-disp); font-size: 20px; color: var(--accent); letter-spacing: .08em; white-space: nowrap; }
.nav-title .sub { font-family: var(--f-mono); font-size: 9px; letter-spacing: .35em; color: var(--text-muted); text-transform: uppercase; white-space: nowrap; }

.nav-toggle {
  display: inline-flex; align-items: center; gap: 8px; min-height: 40px; padding: 6px 14px;
  border: 1px solid rgba(201,162,39,.4); border-radius: 8px; background: rgba(201,162,39,.08);
  color: var(--warning); font-size: 13px; letter-spacing: .08em; cursor: pointer;
}
.nav-toggle-icon, .nav-toggle-icon::before, .nav-toggle-icon::after {
  display: block; width: 16px; height: 2px; border-radius: 1px; background: currentColor; transition: transform .2s, opacity .2s;
}
.nav-toggle-icon { position: relative; }
.nav-toggle-icon::before, .nav-toggle-icon::after { content: ""; position: absolute; left: 0; }
.nav-toggle-icon::before { top: -5px; }
.nav-toggle-icon::after { top: 5px; }
.nav-open .nav-toggle-icon { background: transparent; }
.nav-open .nav-toggle-icon::before { transform: translateY(5px) rotate(45deg); }
.nav-open .nav-toggle-icon::after { transform: translateY(-5px) rotate(-45deg); }

.nav-link {
  display: flex; flex-direction: column; align-items: flex-start; gap: 0;
  border: 1px solid transparent; border-radius: 8px; background: transparent; cursor: pointer;
  color: var(--text-secondary); font-size: 14px; letter-spacing: .04em; text-align: left;
  -webkit-tap-highlight-color: transparent; transition: background .15s, color .15s, border-color .15s;
}
.nav-link:hover { color: var(--warning); background: rgba(201,162,39,.1); }
.nav-link[aria-current="page"] { color: var(--warning); border-color: rgba(201,162,39,.45); background: rgba(201,162,39,.12); }
.nav-note { font-size: 11px; color: var(--text-muted); letter-spacing: .02em; }
.nav-group-label { font-size: 10.5px; letter-spacing: .3em; color: var(--text-muted); }

/* 狭い画面: 「メニュー」ボタンで開く一覧(グループ見出しと説明つき) */
@media (max-width: 1023px) {
  .nav-links {
    display: none; position: absolute; top: 100%; right: max(var(--gutter), env(safe-area-inset-right));
    width: min(380px, calc(100vw - 2 * var(--gutter))); max-height: calc(100dvh - var(--header-h) - 24px); overflow-y: auto;
    padding: 10px; margin-top: 6px; border-radius: 12px;
    background: var(--surface); border: 1px solid rgba(201,162,39,.35); box-shadow: 0 24px 60px -20px #000;
    -webkit-overflow-scrolling: touch; overscroll-behavior: contain;
  }
  .nav-open .nav-links { display: grid; gap: 6px; animation: menu-in .18s var(--ease-slide); }
  .nav-group { display: grid; gap: 2px; padding: 6px 0; }
  .nav-group + .nav-group { border-top: 1px solid rgba(201,162,39,.14); }
  .nav-group-label { padding: 0 10px 2px; }
  .nav-link { width: 100%; padding: 9px 10px; min-height: 48px; justify-content: center; }
  .nav-wide-only { display: none; }
  .nav-scrim { position: fixed; inset: 0; z-index: 25; background: rgba(10,4,5,.5); }
}
@keyframes menu-in { from { opacity: 0; transform: translateY(-6px); } }
/* 広い画面: 横一列(説明・グループ見出し・各コラムは隠し、「読みもの」1つにまとめる) */
@media (min-width: 1024px) {
  .nav-toggle, .nav-scrim { display: none !important; }
  .nav-links { display: flex; align-items: center; gap: 4px; }
  .nav-group { display: flex; align-items: center; gap: 2px; }
  .nav-group + .nav-group { margin-left: 6px; padding-left: 8px; border-left: 1px solid rgba(201,162,39,.2); }
  .nav-group-label, .nav-note, .nav-drawer-only { display: none; }
  .nav-link { padding: 6px 10px; font-size: 13px; white-space: nowrap; }
  .nav-link-online { color: var(--warning); }
}

/* ---------- ボタン ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 38px;
  padding: 8px 16px;
  font-size: 13px;
  letter-spacing: .05em;
  color: var(--text-secondary);
  background: rgba(255,255,255,.02);
  border: 1px solid rgba(201,162,39,.3);
  border-radius: 6px;
  cursor: pointer;
  transition: border-color .15s, color .15s, background .15s, transform .15s;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.btn:hover { border-color: var(--accent); color: var(--warning); background: rgba(201,162,39,.08); }
.btn:active { transform: translateY(1px) scale(.97); }
/* ボタン(A5): 乗せると金の光が一筋走る */
.btn { position: relative; overflow: hidden; }
.btn::after {
  content: ""; position: absolute; top: 0; left: -70%; width: 45%; height: 100%; pointer-events: none;
  background: linear-gradient(100deg, transparent, rgba(228,199,102,.28), transparent); transform: skewX(-20deg);
}
.btn:hover:not(:disabled)::after { animation: btn-sheen .65s ease-out; }
@keyframes btn-sheen { to { left: 130%; } }

/* 効果音のオン・オフ(ヘッダー) */
.sound-toggle {
  display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px; flex: none;
  border: 1px solid rgba(201,162,39,.3); border-radius: 8px; background: transparent; color: var(--warning); cursor: pointer;
  -webkit-tap-highlight-color: transparent; transition: border-color .15s, color .15s, background .15s;
}
.sound-toggle:hover { border-color: var(--accent); background: rgba(201,162,39,.1); }
.sound-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.sound-toggle .snd-off { display: none; }
.sound-toggle.is-off { color: var(--text-muted); }
.sound-toggle.is-off .snd-on { display: none; }
.sound-toggle.is-off .snd-off { display: inline; }
@media (min-width: 1024px) { .sound-toggle { order: 3; width: 36px; height: 36px; } .settings-btn { order: 4; } }
@media (max-width: 380px) { .site-header-inner { gap: 8px; } .nav-title .sub { display: none; } }
.btn:disabled { opacity: .35; cursor: not-allowed; }
.btn:disabled:hover { border-color: rgba(201,162,39,.3); color: var(--text-secondary); background: rgba(255,255,255,.02); }
.btn-compact { padding: 6px 12px; font-size: 12.5px; min-height: 34px; }
.btn-accent { border-color: var(--accent); color: var(--warning); background: rgba(201,162,39,.12); font-weight: 600; }
.btn-nav {
  background: linear-gradient(160deg, rgba(201,162,39,.16), rgba(0,0,0,.25));
  border-color: rgba(201,162,39,.5);
  color: var(--warning);
  font-weight: 600;
}
.btn-primary {
  width: 100%;
  padding: 16px 20px;
  font-family: var(--f-disp);
  font-size: 22px;
  letter-spacing: .22em;
  text-indent: .22em;
  color: var(--warning);
  border: 2px solid var(--accent);
  border-radius: 8px;
  background: linear-gradient(170deg, #8E2318 0%, #6D1A12 55%, #4D1210 100%);
  box-shadow: inset 0 1px rgba(255,220,150,.25), inset 0 -10px 24px rgba(0,0,0,.4), 0 14px 34px -18px rgba(0,0,0,.8);
  cursor: pointer;
  transition: transform .18s var(--ease-slide), box-shadow .18s, border-color .18s;
}
.btn-primary:hover { border-color: var(--warning); transform: translateY(-2px); box-shadow: inset 0 1px rgba(255,220,150,.35), inset 0 -10px 24px rgba(0,0,0,.35), 0 20px 44px -18px rgba(228,199,102,.5); }
.btn-primary:active { transform: translateY(1px); }
.btn-danger { border-color: rgba(232,120,92,.5); color: var(--danger); }
.btn-danger:hover { border-color: var(--danger); background: rgba(232,120,92,.1); }
.link-btn {
  border: none; background: none; padding: 2px 0; cursor: pointer; color: var(--warning);
  font-size: inherit; text-align: left; text-decoration: underline; text-decoration-color: rgba(228,199,102,.4); text-underline-offset: 3px;
}
.link-btn:hover { text-decoration-color: var(--warning); }

/* ---------- セグメント(小刻みな選択肢) ---------- */
.seg { display: inline-flex; border: 1px solid rgba(201,162,39,.32); border-radius: 6px; overflow: hidden; }
.seg button {
  border: none; background: transparent; color: var(--text-secondary);
  font-family: var(--f-mono); font-size: 13px; padding: 8px 14px; min-height: 38px; cursor: pointer; transition: .15s;
}
.seg button + button { border-left: 1px solid rgba(201,162,39,.22); }
.seg button[aria-checked="true"] { background: var(--accent); color: var(--bg-deep); font-weight: 700; }
.seg button:hover:not([aria-checked="true"]) { background: rgba(201,162,39,.14); color: var(--warning); }
.seg button:disabled { opacity: .4; cursor: not-allowed; }

select.field-select {
  background: var(--surface-alt);
  color: var(--text-primary);
  border: 1px solid rgba(201,162,39,.3);
  border-radius: 6px;
  padding: 8px 10px;
  min-height: 38px;
  font-family: var(--f-mono);
  font-size: 13px;
  min-width: 92px;
  max-width: 100%;
}
select.field-select:disabled { opacity: .5; }
.field-select-wide { width: 100%; }

/* ---------- カード / 画面 ---------- */
.screen { display: flex; flex-direction: column; align-items: center; gap: 16px; width: 100%; animation: screen-in .4s var(--ease-slide) both; }
@keyframes screen-in { from { opacity: 0; transform: translateY(10px); } }

.card {
  width: min(var(--col-w), 100%);
  background: linear-gradient(155deg, var(--surface-raised), #241012 70%);
  border: 1px solid rgba(201,162,39,.24);
  border-radius: 10px;
  box-shadow: 0 26px 60px -30px #000, inset 0 1px rgba(255,255,255,.05);
  padding: 22px;
}
.card-title { font-family: var(--f-disp); color: var(--accent); font-size: 18px; font-weight: 400; letter-spacing: .1em; margin: 0 0 4px; }
.card-lede { color: var(--text-muted); font-size: 12px; letter-spacing: .06em; margin: 0 0 14px; }

/* 各画面の見出し(パンくず・タイトル・説明) */
.page-head { width: min(var(--page-w, 760px), 100%); display: grid; gap: 4px; }
.page-title { font-family: var(--f-disp); font-weight: 400; color: var(--accent); font-size: clamp(22px, 5vw, 28px); letter-spacing: .1em; margin: 0; line-height: 1.4; }
.page-lede { margin: 0; color: var(--text-secondary); font-size: 13px; line-height: 1.7; }
.crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 6px; font-size: 12.5px; color: var(--text-muted); }
.crumb { border: none; background: none; color: var(--text-secondary); padding: 6px 0; cursor: pointer; font-size: inherit; text-decoration: underline; text-decoration-color: rgba(181,164,137,.35); text-underline-offset: 3px; }
.crumb:hover { color: var(--warning); }
.crumb-sep { color: var(--text-muted); }
.crumb-here { color: var(--text-muted); }

.masthead { display: flex; align-items: center; justify-content: center; gap: 14px; padding: 4px 0 0; text-align: left; }
.masthead .kanji { font-family: var(--f-disp); font-size: 52px; line-height: 1; color: var(--accent); text-shadow: 0 0 40px rgba(228,199,102,.28); }
.masthead h1 { font-family: var(--f-disp); font-weight: 400; font-size: clamp(26px, 7vw, 38px); margin: 0; line-height: 1.2; color: var(--text-primary); letter-spacing: .08em; }
.masthead .sub { font-family: var(--f-mono); font-size: 10px; letter-spacing: .45em; color: var(--text-muted); text-transform: uppercase; margin-top: 2px; }
.masthead .tag { color: var(--text-secondary); font-size: 13px; margin-top: 4px; text-wrap: balance; }
.page-lede, .tile-desc, .welcome-text span { text-wrap: pretty; }

.field-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 10px; padding: 11px 0; border-bottom: 1px solid rgba(201,162,39,.13); }
.field-row:last-of-type { border-bottom: none; }
.field-row-stack { display: grid; grid-template-columns: minmax(0, 1fr); }
.field-label { font-size: 13.5px; color: var(--text-primary); }
.field-label-sub { margin-left: 8px; font-size: 11.5px; color: var(--text-muted); }
.field-hint { display: block; font-size: 11.5px; color: var(--text-muted); margin-top: 2px; line-height: 1.6; }
.field-control { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.radio-row { display: flex; align-items: center; gap: 8px; padding: 6px 0; cursor: pointer; color: var(--text-secondary); font-size: 13.5px; }
.radio-row input { accent-color: var(--accent); width: 16px; height: 16px; }
.radio-row.is-checked { color: var(--text-primary); }

.stock-input {
  width: 68px; padding: 7px 8px; min-height: 38px; text-align: center;
  background: var(--surface-alt); color: var(--text-primary);
  border: 1px solid rgba(201,162,39,.3); border-radius: 6px; font-family: var(--f-mono); font-size: 13px;
}
.stock-input:disabled { opacity: .5; }
.stock-sep { color: var(--text-muted); }

.hr { height: 1px; background: rgba(201,162,39,.15); margin: 14px 0; border: none; }
.error-text { color: var(--danger); font-size: 12.5px; min-height: 16px; margin: 8px 0 4px; }

/* ---------- ホーム ---------- */
.home { gap: 18px; }
.home-top { width: 100%; display: flex; flex-direction: column; align-items: center; gap: 14px; }
.welcome {
  width: min(var(--col-w), 100%); display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 14px;
  padding: 12px 16px; border-radius: 10px; background: var(--success-bg); border: 1px solid rgba(143,217,212,.3);
}
.welcome-text { display: grid; gap: 2px; font-size: 13px; color: var(--text-primary); flex: 1 1 240px; }
.welcome-text b { color: var(--success); letter-spacing: .1em; }
.home-grid { width: 100%; display: grid; grid-template-columns: minmax(0, 1fr); gap: 18px; justify-items: center; }
.play-card { width: min(var(--col-w), 100%); }
.play-card .card-title { font-size: 20px; margin-bottom: 12px; }
.play-card .btn-primary { margin-top: 6px; }
.home-side { width: min(var(--col-w), 100%); display: grid; gap: 18px; align-content: start; }

.mode-tiles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-bottom: 4px; }
.mode-tile {
  position: relative; display: grid; gap: 2px; align-content: center; text-align: center; min-height: 66px; padding: 10px 6px;
  border: 1px solid rgba(201,162,39,.28); border-radius: 8px; background: rgba(255,255,255,.02); cursor: pointer;
  transition: border-color .15s, background .15s, box-shadow .15s; -webkit-tap-highlight-color: transparent;
}
.mode-tile:hover { border-color: var(--accent); }
.mode-tile.is-checked { border-color: var(--accent); background: rgba(201,162,39,.16); box-shadow: inset 0 0 0 1px var(--accent); }
.mode-tile:focus-within { outline: 2px solid var(--warning); outline-offset: 2px; }
.mode-name { font-family: var(--f-disp); font-size: 17px; color: var(--text-primary); letter-spacing: .08em; }
.mode-tile.is-checked .mode-name { color: var(--warning); }
.mode-sub { font-size: 11px; color: var(--text-muted); line-height: 1.4; }

.level-guide { display: grid; gap: 4px; margin: 2px 0 6px; padding: 8px 10px; border-radius: 6px; background: rgba(0,0,0,.18); border-left: 2px solid var(--accent-dark); font-size: 12px; color: var(--text-secondary); }
.level-guide-line { display: flex; flex-wrap: wrap; gap: 2px 10px; align-items: baseline; }
.level-guide-line span { white-space: nowrap; }
.level-guide-line b { color: var(--text-primary); font-weight: 600; min-width: 3em; }
.level-guide-foot { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 2px 10px; color: var(--text-muted); font-size: 11.5px; }

details.adv { margin-top: 10px; border: 1px solid rgba(201,162,39,.22); border-radius: 8px; background: rgba(0,0,0,.12); }
details.adv > summary {
  list-style: none; cursor: pointer; display: grid; gap: 2px; padding: 10px 36px 10px 12px; position: relative; min-height: 48px;
}
details.adv > summary::-webkit-details-marker { display: none; }
details.adv > summary::after {
  content: ""; position: absolute; right: 14px; top: 50%; width: 8px; height: 8px; margin-top: -6px;
  border-right: 2px solid var(--accent); border-bottom: 2px solid var(--accent); transform: rotate(45deg); transition: transform .2s;
}
details.adv[open] > summary::after { transform: rotate(-135deg); margin-top: -2px; }
.adv-title { font-size: 13.5px; color: var(--text-primary); }
.adv-summary { font-family: var(--f-mono); font-size: 11.5px; color: var(--text-muted); }
.adv-body { padding: 0 12px 12px; border-top: 1px solid rgba(201,162,39,.14); }

.home-section { display: grid; gap: 8px; }
.home-section-title { margin: 0; font-family: var(--f-disp); font-weight: 400; font-size: 15px; letter-spacing: .2em; color: var(--accent); }
.tile-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.tile, .reading-card {
  display: grid; align-content: start; gap: 3px; text-align: left; min-height: 82px; padding: 12px 14px; cursor: pointer;
  border: 1px solid rgba(201,162,39,.22); border-radius: 10px; color: var(--text-secondary);
  background: linear-gradient(155deg, rgba(74,32,36,.75), rgba(36,16,18,.75));
  transition: border-color .15s, transform .15s, box-shadow .15s; -webkit-tap-highlight-color: transparent;
}
.tile:hover, .reading-card:hover { border-color: var(--accent); transform: translateY(-1px); box-shadow: 0 12px 30px -18px rgba(228,199,102,.5); }
.tile-title { display: flex; align-items: center; gap: 8px; font-size: 14.5px; color: var(--text-primary); font-weight: 600; letter-spacing: .04em; }
.tile-desc { font-size: 12px; line-height: 1.5; color: var(--text-secondary); }
.tile-meta { font-family: var(--f-mono); font-size: 11px; color: var(--accent); margin-top: 2px; }
.tile-badge { font-size: 9.5px; font-weight: 700; letter-spacing: .08em; padding: 1px 6px; border-radius: 999px; background: var(--accent); color: var(--bg-deep); }

/* ---------- 盤面 ---------- */
.board-wrap { display: flex; flex-direction: column; align-items: center; gap: 10px; width: 100%; }
.board-frame {
  width: min(var(--board-w, 560px), 100%);
  padding: 18px 18px 14px;
  background: linear-gradient(155deg, var(--surface-raised), #241012 70%);
  border: 1px solid rgba(201,162,39,.22);
  border-radius: 10px;
  box-shadow: 0 26px 60px -30px #000, inset 0 1px rgba(255,255,255,.05);
  position: relative;
}
.board-frame.is-shaking { animation: frame-shake .34s cubic-bezier(.36,.07,.19,.97); }
@keyframes frame-shake { 10%,90%{transform:translate(-1px,1px)} 30%,70%{transform:translate(3px,-2px)} 50%{transform:translate(-3px,2px)} }

/* 追加仕様: 座標ラベル(A-G/1-7)は盤面と重ならないよう、専用のグリッド段に
   配置する(以前は絶対配置の固定px値で、狭い画面だと盤に隠れてしまっていた)。
   グリッドの列・行として確保するので、どんな画面幅でも盤とラベルは物理的に
   重なりようがない。 */
.board-shell {
  --rail-size: 20px;
  display: grid;
  grid-template-columns: var(--rail-size) 1fr;
  grid-template-rows: var(--rail-size) 1fr;
  column-gap: 4px;
  row-gap: 4px;
}
@media (max-width: 480px) {
  .board-shell { --rail-size: 16px; }
}
.rail-top, .rail-left { display: flex; font-family: var(--f-mono); font-size: 10px; color: var(--text-muted); letter-spacing: .06em; pointer-events: none; user-select: none; min-width: 0; min-height: 0; }
.rail-top { grid-column: 2; grid-row: 1; align-items: center; }
.rail-left { grid-column: 1; grid-row: 2; flex-direction: column; align-items: center; }
.rail-top span, .rail-left span { flex: 1; display: flex; align-items: center; justify-content: center; overflow: hidden; }

.board {
  grid-column: 2;
  grid-row: 2;
  position: relative;
  aspect-ratio: 1 / 1;
  width: 100%;
  min-width: 0;
  border-radius: 4px;
  overflow: hidden;
  background: linear-gradient(155deg, var(--board-bg) 0%, var(--board-bg-alt) 100%);
  box-shadow: inset 0 0 42px rgba(122,98,58,.3), 0 2px rgba(255,255,255,.06);
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}
.board::after {
  content: ""; position: absolute; inset: 0; pointer-events: none; opacity: .5;
  background-image:
    repeating-linear-gradient(90deg, rgba(160,140,100,.09) 0px, rgba(160,140,100,.09) 1px, transparent 1px, transparent 3px),
    repeating-linear-gradient(0deg, rgba(160,140,100,.07) 0px, rgba(160,140,100,.07) 1px, transparent 1px, transparent 4px);
}
.grid { position: absolute; inset: 0; display: grid; }
.cell { position: relative; border-right: 1px solid var(--board-line); border-bottom: 1px solid var(--board-line); cursor: default; -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
.cell.is-hot { cursor: pointer; }
.cell.is-hot::before {
  content: ""; position: absolute; inset: 12%; border-radius: 50%;
  background: rgba(201,162,39,0); transition: background .18s;
}
.cell.is-hot:hover::before { background: rgba(201,162,39,.18); }
.cell.is-dest::after {
  content: ""; position: absolute; top: 50%; left: 50%; width: 22%; height: 22%;
  background: var(--board-dest); border-radius: 50%; opacity: .55; transform: translate(-50%,-50%);
  animation: dest-in .25s var(--ease-pop) backwards;
}
.cell.is-dest:hover::after { opacity: .95; transform: translate(-50%,-50%) scale(1.5); }
@keyframes dest-in { from { opacity: 0; transform: translate(-50%,-50%) scale(.2); } }
.cell.is-bad::after {
  content: ""; position: absolute; inset: 30%; border-radius: 3px; background: var(--board-bad); opacity: .5;
}
.cell.is-obligated-target { outline: 2px solid var(--danger); outline-offset: -2px; }

.layer { position: absolute; inset: 0; pointer-events: none; }
.piece {
  position: absolute; top: 0; left: 0; display: flex; align-items: center; justify-content: center;
  transition: transform .32s var(--ease-slide);
  will-change: transform;
}
.disc {
  position: relative; width: 78%; height: 78%; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--f-body); font-weight: 700;
}
.disc .label { position: relative; z-index: 1; }
.p-A .disc {
  background: radial-gradient(circle at 33% 26%, #8fd0d4 0%, var(--p-a-fill) 45%, #3d7a7d 100%);
  color: var(--p-a-on);
  box-shadow: 0 3px 8px rgba(10,30,30,.5), inset 0 -3px 6px rgba(0,0,0,.35), inset 0 2px 4px rgba(255,255,255,.5);
}
.p-B .disc {
  background: radial-gradient(circle at 33% 26%, #4a4038 0%, var(--p-b-fill) 55%, #050403 100%);
  color: var(--p-b-on);
  box-shadow: 0 3px 8px rgba(0,0,0,.55), inset 0 -2px 6px rgba(0,0,0,.7), inset 0 2px 4px rgba(255,255,255,.1);
}
.piece.is-selected .disc { animation: sel-pulse 1.4s ease-in-out infinite; }
@keyframes sel-pulse {
  0%,100% { box-shadow: 0 0 0 2px var(--accent), 0 0 16px 2px rgba(228,199,102,.55); }
  50% { box-shadow: 0 0 0 3px var(--warning), 0 0 26px 5px rgba(228,199,102,.8); }
}
.piece.is-obligated .disc::before {
  content: ""; position: absolute; inset: -16%; border: 2px solid var(--danger); border-radius: 50%;
  animation: seal-snap .45s cubic-bezier(.2,1.4,.4,1) backwards, seal-breathe 1.7s ease-in-out .45s infinite;
}
@keyframes seal-snap { from { opacity: 0; transform: scale(2.2) rotate(-30deg);} }
@keyframes seal-breathe {
  0%,100% { opacity: .85; box-shadow: 0 0 8px rgba(206,74,46,.5); }
  50% { opacity: 1; box-shadow: 0 0 20px 4px rgba(206,74,46,.85); }
}
.piece.is-last .disc { outline: 1px dashed rgba(201,162,39,.65); outline-offset: 3px; }
.piece.just-dropped .disc { animation: drop-in .5s var(--ease-pop) backwards; }
@keyframes drop-in {
  0% { opacity: 0; transform: translateY(-24px) scale(1.7) rotate(-12deg); }
  55% { opacity: 1; }
  70% { transform: translateY(0) scale(.92) rotate(2deg); }
  100% { transform: translateY(0) scale(1) rotate(0); }
}
.fx-svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }

/* ---------- 盤の演出(第1弾) ---------- */
/* 駒を選ぶ(A1): 少し持ち上がり、影が伸びる */
.disc { transition: transform .2s var(--ease-pop); }
.piece.is-selected .disc { transform: translateY(-7%) scale(1.06); }
/* 2方向から挟まれた駒(B3): 朱い輪が少し遅れてもう1本 */
.piece.is-obligated-2 .disc::after {
  content: ""; position: absolute; inset: -31%; border: 1.5px solid var(--danger); border-radius: 50%; pointer-events: none;
  animation: seal-snap .45s cubic-bezier(.2,1.4,.4,1) .16s backwards, seal-breathe 1.7s ease-in-out .85s infinite;
}
/* 挟んだ瞬間(B0): 挟まれた駒が挟まれた向きにつぶれ、挟んだ2駒が内へ寄る */
.piece.sq-h .disc { animation: sq-h .46s cubic-bezier(.3,1.5,.5,1); }
.piece.sq-v .disc { animation: sq-v .46s cubic-bezier(.3,1.5,.5,1); }
@keyframes sq-h { 35% { transform: scaleX(.74) scaleY(1.1); } }
@keyframes sq-v { 35% { transform: scaleY(.74) scaleX(1.1); } }
.piece.nd-r .disc { animation: nd-r .4s ease-out; } .piece.nd-l .disc { animation: nd-l .4s ease-out; }
.piece.nd-d .disc { animation: nd-d .4s ease-out; } .piece.nd-u .disc { animation: nd-u .4s ease-out; }
@keyframes nd-r { 35% { transform: translateX(8%); } } @keyframes nd-l { 35% { transform: translateX(-8%); } }
@keyframes nd-d { 35% { transform: translateY(8%); } } @keyframes nd-u { 35% { transform: translateY(-8%); } }
/* 終局で動けなくなった駒: 朱い輪が2回だけ脈打つ */
.piece.is-trapped .disc::before { animation: trap .62s ease-in-out 2; }
@keyframes trap { 50% { opacity: 1; box-shadow: 0 0 22px 6px rgba(206,74,46,.9); transform: scale(1.08); } }

/* 一瞬の演出の層(駒の下): 波紋(A2/A3)・壁の光(B0)・割れる輪(B4) */
.fx-under { overflow: hidden; }
.fx-under > span { position: absolute; pointer-events: none; }
.fx-ripple {
  width: calc(var(--cell) * .22); height: calc(var(--cell) * .22); border: 1.5px solid rgba(110,80,40,.5); border-radius: 50%;
  transform: translate(-50%,-50%); animation: fx-ripple .95s cubic-bezier(.1,.7,.3,1) both;
}
.fx-ripple.r2 { border-color: rgba(201,162,39,.55); animation-delay: .12s; }
@keyframes fx-ripple { 0% { opacity: .9; border-width: 2.5px; } 100% { opacity: 0; width: calc(var(--cell) * 2); height: calc(var(--cell) * 2); border-width: .5px; } }
.fx-wallhit { background: var(--danger); border-radius: 2px; animation: fx-wallhit .7s ease-out forwards; }
@keyframes fx-wallhit { 0% { opacity: 0; } 20% { opacity: .9; } 100% { opacity: 0; } }
.fx-shatter { width: 0; height: 0; }
.fx-shatter .burst { position: absolute; left: -30px; top: -30px; width: 60px; height: 60px; border-radius: 50%; border: 2px solid rgba(232,120,92,.7); animation: fx-burst .5s ease-out forwards; }
@keyframes fx-burst { to { opacity: 0; transform: scale(1.5); } }
.fx-shatter .shard { position: absolute; left: -6px; top: -4px; width: 12px; height: 8px; background: var(--danger); clip-path: polygon(0 0,100% 30%,40% 100%); opacity: 0; animation: .75s cubic-bezier(.15,.8,.3,1) forwards; }
.fx-shatter .s0 { animation-name: sh0; } .fx-shatter .s1 { animation-name: sh1; animation-delay: .02s; }
.fx-shatter .s2 { animation-name: sh2; animation-delay: .01s; } .fx-shatter .s3 { animation-name: sh3; animation-delay: .03s; }
.fx-shatter .s4 { animation-name: sh4; } .fx-shatter .s5 { animation-name: sh5; animation-delay: .02s; }
.fx-shatter .s6 { animation-name: sh6; animation-delay: .01s; } .fx-shatter .s7 { animation-name: sh7; animation-delay: .03s; }
@keyframes sh0 { 0% { opacity: 1; transform: translate(0,-30px); } 100% { opacity: 0; transform: translate(6px,-62px) rotate(140deg); } }
@keyframes sh1 { 0% { opacity: 1; transform: translate(21px,-21px) rotate(45deg); } 100% { opacity: 0; transform: translate(48px,-40px) rotate(230deg); } }
@keyframes sh2 { 0% { opacity: 1; transform: translate(30px,0) rotate(90deg); } 100% { opacity: 0; transform: translate(64px,8px) rotate(260deg); } }
@keyframes sh3 { 0% { opacity: 1; transform: translate(21px,21px) rotate(135deg); } 100% { opacity: 0; transform: translate(44px,52px) rotate(300deg); } }
@keyframes sh4 { 0% { opacity: 1; transform: translate(0,30px) rotate(180deg); } 100% { opacity: 0; transform: translate(-8px,66px) rotate(20deg); } }
@keyframes sh5 { 0% { opacity: 1; transform: translate(-21px,21px) rotate(225deg); } 100% { opacity: 0; transform: translate(-50px,46px) rotate(60deg); } }
@keyframes sh6 { 0% { opacity: 1; transform: translate(-30px,0) rotate(270deg); } 100% { opacity: 0; transform: translate(-62px,-10px) rotate(90deg); } }
@keyframes sh7 { 0% { opacity: 1; transform: translate(-21px,-21px) rotate(315deg); } 100% { opacity: 0; transform: translate(-44px,-54px) rotate(120deg); } }

/* 動いた跡(A3): 出発点の輪 + 墨の線。先手=青墨・後手=墨、直前に指した側を濃く。1マス=1 の座標 */
.trail-svg { width: 100%; height: 100%; overflow: visible; }
.trail-line { fill: none; stroke-width: .075; stroke-linecap: round; stroke-dasharray: 1; }
.trail-from { fill: none; stroke-width: .05; }
.trail.side-a .trail-line { stroke: rgba(47,110,114,.62); } .trail.side-a .trail-from { stroke: rgba(47,110,114,.78); }
.trail.side-b .trail-line { stroke: rgba(23,19,15,.5); } .trail.side-b .trail-from { stroke: rgba(23,19,15,.62); }
.trail.side-a .trail-drop { fill: rgba(47,110,114,.13); stroke: rgba(47,110,114,.35); stroke-width: .03; }
.trail.side-b .trail-drop { fill: rgba(23,19,15,.09); stroke: rgba(23,19,15,.3); stroke-width: .03; }
.trail.is-old { opacity: .42; }
.trail.is-new .trail-line { animation: trail-draw .32s cubic-bezier(.22,.9,.28,1) both; }
.trail.is-new .trail-from, .trail.is-new .trail-drop { animation: trail-in .3s ease-out both; }
.trail.is-new .trail-drop { animation-delay: .2s; }
@keyframes trail-draw { from { stroke-dashoffset: 1; } to { stroke-dashoffset: 0; } }
@keyframes trail-in { from { opacity: 0; } }

/* 対局開始(C1): 盤が少し奥から現れる */
.board-frame.is-entering { animation: board-enter .8s var(--ease-slide) both; }
@keyframes board-enter { from { opacity: 0; transform: translateY(8px); } } /* 大きさは変えない(盤の寸法を測る処理に影響させない) */

/* 終局(C2〜C4・控えめ): 薄い幕・縦書きの結果・勝ちは金粉10粒・負けは墨のにじみ・引き分けは円相 */
.vd-layer { position: absolute; inset: 0; z-index: 3; pointer-events: none; }
.vd-shade { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; background: rgba(20,6,8,.42); animation: vd-fade .8s ease-out .5s both; }
.vd-lose .vd-shade { background: rgba(14,6,6,.5); }
.vd-draw .vd-shade { background: rgba(20,6,8,.38); animation-delay: .2s; }
@keyframes vd-fade { from { opacity: 0; } }
.vd-ink { position: absolute; inset: 0; animation: vd-ink 1.6s ease-out .2s both; box-shadow: inset 0 0 27cqw 8cqw rgba(8,4,3,.7); }
@keyframes vd-ink { from { box-shadow: inset 0 0 0 0 rgba(8,4,3,0); } }
.vd-text { position: relative; display: flex; align-items: center; gap: 4%; }
.vd-title {
  writing-mode: vertical-rl; font-family: var(--f-disp); font-weight: 600; font-size: clamp(30px, 11cqw, 60px); letter-spacing: .24em;
  text-shadow: 0 2px 18px rgba(20,6,8,.9); clip-path: inset(0 0 100% 0); animation: vd-wipe .9s cubic-bezier(.5,0,.3,1) .9s forwards;
}
.board { container-type: inline-size; }
.vd-win .vd-title { color: var(--warning); }
.vd-lose .vd-title { color: #E6DCC8; }
.vd-title.is-long { font-size: clamp(22px, 7cqw, 40px); letter-spacing: .18em; }
.vd-draw .vd-title { color: #D8CDBB; animation-delay: 1.3s; }
@keyframes vd-wipe { to { clip-path: inset(0 0 0 0); } }
.vd-sub { writing-mode: vertical-rl; font-size: clamp(11px, 2.6cqw, 13px); letter-spacing: .2em; color: var(--text-secondary); text-shadow: 0 2px 10px rgba(20,6,8,.95); opacity: 0; animation: vd-show .6s ease-out 1.6s forwards; }
.vd-draw .vd-sub { animation-delay: 2s; }
@keyframes vd-show { to { opacity: 1; } }
.vd-dust { position: absolute; width: 4px; height: 4px; border-radius: 50%; background: radial-gradient(circle, #fff9e2 0%, var(--warning) 50%, transparent 72%); opacity: 0; animation: vd-dust 2.6s ease-out forwards; }
.vd-dust.d0 { left: 22%; top: 70%; animation-delay: 1s; } .vd-dust.d1 { left: 34%; top: 62%; animation-delay: 1.25s; }
.vd-dust.d2 { left: 47%; top: 74%; animation-delay: 1.1s; } .vd-dust.d3 { left: 58%; top: 66%; animation-delay: 1.4s; }
.vd-dust.d4 { left: 69%; top: 72%; animation-delay: 1.05s; } .vd-dust.d5 { left: 28%; top: 52%; animation-delay: 1.55s; }
.vd-dust.d6 { left: 41%; top: 46%; animation-delay: 1.35s; } .vd-dust.d7 { left: 63%; top: 50%; animation-delay: 1.6s; }
.vd-dust.d8 { left: 76%; top: 58%; animation-delay: 1.2s; } .vd-dust.d9 { left: 52%; top: 56%; animation-delay: 1.7s; }
@keyframes vd-dust { 0% { opacity: 0; transform: translateY(0) scale(.6); } 20% { opacity: .9; } 100% { opacity: 0; transform: translateY(-70px) scale(1.2); } }
.vd-enso { position: absolute; left: 50%; top: 50%; width: 46%; height: 46%; transform: translate(-50%,-50%); overflow: visible; }
.vd-enso path { fill: none; stroke-linecap: round; stroke-dasharray: 1; stroke-dashoffset: 1; animation: vd-draw 1.3s cubic-bezier(.6,.05,.35,1) .25s forwards; }
.vd-enso .e1 { stroke: rgba(216,205,187,.75); stroke-width: 10px; }
.vd-enso .e2 { stroke: rgba(216,205,187,.35); stroke-width: 4px; animation-delay: .32s; }
@keyframes vd-draw { to { stroke-dashoffset: 0; } }
/* 終わった対局を開き直したとき・動きを減らす設定: 最後の状態で止めて出す */
.vd-layer.is-static *, .vd-layer.is-static { animation: none !important; }
.vd-layer.is-static .vd-title { clip-path: none; }
.vd-layer.is-static .vd-sub { opacity: 1; }
.vd-layer.is-static .vd-enso path { stroke-dashoffset: 0; }
.vd-layer.is-static .vd-dust { display: none; }

/* ---------- 演出(第2弾) ---------- */
/* AIの思考中(D1): 盤の縁を金の光がゆっくり一周し続ける(3.4秒で1周)。縁だけを残すマスクで枠の上に描く */
@property --think-angle { syntax: "<angle>"; inherits: false; initial-value: 0deg; }
.board-frame::before {
  content: ""; position: absolute; inset: -2px; border-radius: 12px; padding: 2px; pointer-events: none; opacity: 0; transition: opacity .5s;
  background: conic-gradient(from var(--think-angle), rgba(228,199,102,0) 0deg 250deg, rgba(228,199,102,.25) 300deg, rgba(255,240,190,.95) 350deg, rgba(228,199,102,0) 360deg);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0); -webkit-mask-composite: xor;
  mask: linear-gradient(#000 0 0) content-box exclude, linear-gradient(#000 0 0);
}
.board-frame.is-thinking::before { opacity: 1; animation: think-spin 3.4s linear infinite; }
@keyframes think-spin { to { --think-angle: 360deg; } }
/* AIが指す直前の合図(D2): 動かす駒に金の輪が一瞬重なる */
.piece.is-cue .disc { box-shadow: 0 0 0 2px var(--warning), 0 0 18px 4px rgba(228,199,102,.7); transition: box-shadow .15s; }
/* 秒読みの最後5秒(E): 盤の縁が秒に合わせて赤く脈打つ */
.board-frame.is-urgent { animation: urgent 1s ease-out infinite; }
@keyframes urgent { 0% { box-shadow: 0 0 0 0 rgba(232,120,92,0); } 12% { box-shadow: 0 0 0 3px rgba(232,120,92,.85), 0 0 34px 4px rgba(232,120,92,.35); } 100% { box-shadow: 0 0 0 0 rgba(232,120,92,0); } }
/* 形勢が大きく動いた(D3)・詰みを読み切った(D4) */
.eval-meter { position: relative; }
.eval-flash { position: absolute; inset: 0; background: linear-gradient(90deg, transparent, rgba(255,244,210,.85), transparent); transform: translateX(-100%); animation: eval-flash .7s ease-out forwards; pointer-events: none; }
@keyframes eval-flash { to { transform: translateX(100%); } }
.eval-swing {
  position: absolute; right: 10px; top: -12px; z-index: 2; font-family: var(--f-disp); font-size: 13px; letter-spacing: .18em; font-weight: 600;
  padding: 2px 10px; border-radius: 4px; background: var(--warning-bg); color: var(--warning); border: 1px solid rgba(228,199,102,.5);
  animation: swing-in .3s var(--ease-pop) both, swing-out .4s ease-in 1.6s forwards; pointer-events: none;
}
.eval-swing.is-bad { background: var(--danger-bg); color: var(--danger); border-color: rgba(232,120,92,.5); }
@keyframes swing-in { from { opacity: 0; transform: translateY(6px) scale(.9); } }
@keyframes swing-out { to { opacity: 0; } }
.eval-meter.is-mate .eval-fill {
  background: linear-gradient(90deg, #A8862A, #E4C766 40%, #fff1c0 50%, #E4C766 60%, #A8862A); background-size: 220% 100%;
  animation: mate-gold 2.2s linear infinite;
}
@keyframes mate-gold { from { background-position: 120% 0; } to { background-position: -100% 0; } }
.eval-meter.is-mate .eval-note { color: var(--warning); }

/* 初めての「音を出しますか?」 */
.sound-prompt {
  position: fixed; left: 50%; bottom: max(16px, env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 35; /* 確認の窓(40)より下 */
  width: min(560px, calc(100vw - 2 * var(--gutter))); display: flex; align-items: center; gap: 14px; flex-wrap: wrap; justify-content: space-between;
  padding: 14px 16px; border-radius: 10px; background: var(--warning-bg); border: 1px solid rgba(228,199,102,.45); box-shadow: 0 20px 50px -20px #000;
  animation: swing-in .3s var(--ease-slide) both;
}
.sound-prompt-text { display: grid; gap: 2px; min-width: 0; flex: 1 1 260px; }
.sound-prompt-text b { font-family: var(--f-disp); font-size: 15px; color: var(--warning); }
.sound-prompt-text span { font-size: 12px; color: var(--text-secondary); line-height: 1.6; }
.sound-prompt-actions { display: flex; gap: 8px; }

/* 音と演出の設定(H) */
.settings-modal { width: min(560px, 100%); max-height: calc(100dvh - 40px); overflow-y: auto; }
.settings-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 6px; }
.settings-head h2 { margin: 0; font-family: var(--f-disp); font-size: 19px; letter-spacing: .08em; color: var(--text-primary); font-weight: 600; }
.set-row { display: grid; grid-template-columns: 112px minmax(0, 1fr) auto; gap: 4px 12px; align-items: center; padding: 12px 0; border-bottom: 1px solid rgba(201,162,39,.12); }
.set-row:last-child { border-bottom: 0; }
.set-label { font-size: 13.5px; color: var(--text-primary); }
.set-help { grid-column: 2 / 4; font-size: 11.5px; color: var(--text-muted); line-height: 1.6; }
.set-num { font-family: var(--f-mono); font-size: 12.5px; color: var(--text-secondary); min-width: 4ch; text-align: right; }
.set-slider { width: 100%; accent-color: var(--accent); min-height: 32px; }
.set-pair { display: flex; align-items: center; gap: 12px; min-width: 0; }
.set-pair .set-slider { flex: 1; min-width: 0; }
.switch { position: relative; flex: none; width: 46px; height: 26px; border-radius: 13px; padding: 0; cursor: pointer; background: var(--bg-deep); border: 1px solid var(--border); transition: background .2s, border-color .2s; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: var(--text-muted); transition: transform .2s var(--ease-slide), background .2s; }
.switch.is-on { background: var(--accent-light); border-color: var(--accent); }
.switch.is-on::after { transform: translateX(20px); background: var(--warning); }
.switch:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
@media (max-width: 480px) { .set-row { grid-template-columns: 76px minmax(0, 1fr) auto; } .set-row .seg button { padding: 8px 10px; } }

/* ---------- 演出(第3弾) ---------- */
/* 画面の切り替え(F1): 新しい画面の上を、墨が刷毛でひと塗り分抜ける/襖が左右に開く */
.screen-wipe { position: fixed; left: 0; right: 0; bottom: 0; top: var(--header-h); z-index: 20; pointer-events: none; overflow: hidden; }
.screen-wipe .ink {
  position: absolute; top: 0; bottom: 0; left: 0; width: 160%;
  background: linear-gradient(90deg, rgba(14,7,6,0) 0%, rgba(14,7,6,.96) 18%, #0E0706 25%, #0E0706 100%);
  transform: translateX(-25%); animation: wipe-ink .55s cubic-bezier(.55,0,.35,1) forwards;
}
@keyframes wipe-ink { to { transform: translateX(62.5%); } }
.screen-wipe .fu {
  position: absolute; top: 0; bottom: 0; width: 50%; box-sizing: border-box; border: 7px solid #17130F;
  background: #E9E0CB; background-image: repeating-linear-gradient(0deg, rgba(160,140,100,.10) 0 1px, transparent 1px 5px), repeating-linear-gradient(90deg, rgba(160,140,100,.08) 0 1px, transparent 1px 4px);
}
.screen-wipe .fu::after { content: ""; position: absolute; top: 50%; width: 22px; height: 22px; margin-top: -11px; border-radius: 50%; border: 2px solid var(--border); background: var(--accent); box-shadow: inset 0 0 0 5px var(--accent-light); }
.screen-wipe .fu-l { left: 0; animation: fu-open-l .5s cubic-bezier(.6,0,.3,1) .08s forwards; }
.screen-wipe .fu-r { right: 0; animation: fu-open-r .5s cubic-bezier(.6,0,.3,1) .08s forwards; }
.screen-wipe .fu-l::after { right: 14px; } .screen-wipe .fu-r::after { left: 14px; }
@keyframes fu-open-l { to { transform: translateX(-102%); } }
@keyframes fu-open-r { to { transform: translateX(102%); } }
/* ホームの背景(F2): 薄く傾けた盤で、駒がゆっくり動き続ける */
.home-backdrop { position: fixed; z-index: 0; pointer-events: none; right: max(-60px, -6vw); top: calc(var(--header-h) + 40px); width: min(70vw, 520px); aspect-ratio: 1; opacity: .07; transform: rotate(-7deg); }
#app { position: relative; z-index: 1; }
.home-backdrop-board {
  position: absolute; inset: 0; border-radius: 6px; background-color: var(--board-bg);
  background-image: repeating-linear-gradient(90deg, transparent 0 calc(100% / 7 - 1px), var(--board-line) calc(100% / 7 - 1px) calc(100% / 7)),
    repeating-linear-gradient(0deg, transparent 0 calc(100% / 7 - 1px), var(--board-line) calc(100% / 7 - 1px) calc(100% / 7));
}
.bd-piece { position: absolute; top: 0; left: 0; width: calc(100% / 7); height: calc(100% / 7); display: flex; align-items: center; justify-content: center; transition: transform 1.4s cubic-bezier(.45,0,.25,1); }
.bd-piece i { width: 76%; height: 76%; border-radius: 50%; display: block; }
.bd-piece.a i { background: #3d7a7d; } .bd-piece.b i { background: #050403; }
/* 詰めピンチの星(F3): 判のように1つずつ押す */
.tsume-star { display: inline-block; color: var(--text-muted); }
.tsume-star.is-got { color: var(--warning); }
.tsume-star.is-stamp { animation: star-stamp .42s cubic-bezier(.2,1.5,.4,1) both; }
@keyframes star-stamp { 0% { opacity: 0; transform: scale(2.1) rotate(-18deg); } 60% { opacity: 1; transform: scale(.92) rotate(3deg); } 100% { transform: none; } }
/* チュートリアルの課題達成(F4): 朱の判子「よし」 */
.yoshi { position: absolute; inset: 0; z-index: 4; pointer-events: none; display: flex; align-items: center; justify-content: center; animation: yoshi-out .5s ease-in 1.9s forwards; }
.yoshi-seal {
  position: relative; width: 30%; aspect-ratio: 1; border-radius: 50%; border: 4px solid #C2402A; color: #C2402A; display: flex; align-items: center; justify-content: center;
  font-family: var(--f-disp); font-weight: 700; font-size: clamp(20px, 8cqw, 36px); writing-mode: vertical-rl; transform: rotate(-8deg); mix-blend-mode: multiply; opacity: .88;
  animation: yoshi-stamp .38s cubic-bezier(.3,1.4,.5,1) both;
}
.yoshi-blot { position: absolute; width: 36%; aspect-ratio: 1; border-radius: 50%; background: radial-gradient(circle, rgba(194,64,42,.18), transparent 65%); animation: vd-fade .6s ease-out .1s both; }
@keyframes yoshi-stamp { 0% { opacity: 0; transform: scale(1.7) rotate(-14deg); } 55% { opacity: .95; transform: scale(.96) rotate(-7deg); } 100% { transform: rotate(-8deg); } }
@keyframes yoshi-out { to { opacity: 0; } }
/* レートの更新(F5) */
.rating-delta { font-family: var(--f-mono); font-size: 15px; }
.rating-delta.is-up { color: var(--warning); animation: swing-in .4s var(--ease-pop) both; }
.rating-delta.is-down { color: var(--danger); }
.rating-value.is-best { color: var(--warning); text-shadow: 0 0 18px rgba(228,199,102,.45); }
.rating-note.is-up { text-shadow: 0 0 14px rgba(228,199,102,.4); }

/* 演出の強さ: 控えめ(二重の波紋・線の描き込み・盤の脈打ち・金粉を省く)/ オフ(動きなし) */
.fx-calm .trail.is-new *, .fx-calm .board-frame.is-urgent { animation: none !important; }
.fx-off .board-frame.is-entering, .fx-off .board-frame.is-shaking, .fx-off .board-frame.is-urgent, .fx-off .trail.is-new *,
.fx-off .piece .disc, .fx-off .eval-meter.is-mate .eval-fill, .fx-off .tsume-star, .fx-off .screen, .fx-off .vd-layer * { animation: none !important; }
.fx-off .vd-layer .vd-title { clip-path: none; } .fx-off .vd-layer .vd-sub { opacity: 1; } .fx-off .vd-enso path { stroke-dashoffset: 0; }
.fx-off .btn::after, .fx-off .home-backdrop { display: none; }

.legend-row { display: flex; align-items: center; gap: 14px; font-size: 12px; color: var(--text-secondary); flex-wrap: wrap; justify-content: center; }
.legend-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 5px; }

/* ---------- ステータス(手番/持ち駒) ---------- */
.status-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; width: min(var(--col-w), 100%); }
.side-card {
  background: linear-gradient(rgba(255,255,255,.04), rgba(0,0,0,.16));
  border: 1px solid rgba(201,162,39,.18);
  border-radius: 8px; padding: 10px 12px; transition: border-color .3s, box-shadow .3s; min-width: 0;
}
.side-card.is-active { border-color: rgba(201,162,39,.72); box-shadow: 0 0 0 1px rgba(201,162,39,.18), 0 10px 34px -18px rgba(228,199,102,.6); }
.side-role { font-size: 10px; letter-spacing: .3em; color: var(--text-muted); text-transform: uppercase; }
.side-name { font-family: var(--f-disp); font-size: 17px; margin-top: 2px; }
.side-name.a { color: #d5c9b6; }
.side-name.b { color: #f4efe3; }
.side-turn { font-size: 10.5px; letter-spacing: .2em; color: var(--warning); opacity: 0; margin-top: 6px; padding-top: 6px; border-top: 1px solid rgba(201,162,39,.25); transition: opacity .25s; }
.side-turn::before { content: "▸ "; color: var(--accent); }
.side-card.is-active .side-turn { opacity: 1; }
.stock-row { display: flex; align-items: baseline; justify-content: space-between; margin-top: 8px; font-size: 10px; letter-spacing: .18em; color: var(--text-muted); }
.stock-count { font-family: var(--f-mono); font-size: 16px; color: var(--text-primary); letter-spacing: 0; }
.stock-dots { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; min-height: 10px; }
.stock-dot { width: 9px; height: 9px; border-radius: 50%; }
.side-card.side-a .stock-dot { background: radial-gradient(circle at 32% 28%, #8fd0d4, var(--p-a-fill) 60%); }
.side-card.side-b .stock-dot { background: radial-gradient(circle at 32% 28%, #6a5f52, var(--p-b-fill) 55%); }
.stock-dot.is-spent { opacity: .15; }
.side-alert { display: none; margin-top: 9px; padding: 6px 9px; font-size: 11.5px; color: var(--danger); background: rgba(232,120,92,.12); border-left: 2px solid var(--danger); }
.side-alert.is-on { display: block; }

/* ---------- 対戦ログ ---------- */
.log-panel { width: min(var(--col-w), 100%); }
.log-head { display: flex; justify-content: space-between; align-items: baseline; font-size: 11px; letter-spacing: .18em; color: var(--text-muted); border-bottom: 1px solid rgba(201,162,39,.18); padding-bottom: 6px; }
.log-list { max-height: 150px; overflow-y: auto; list-style: none; margin: 8px 0 0; padding: 0; font-size: 12.5px; color: var(--text-secondary); }
.log-list li { padding: 3px 0; border-bottom: 1px solid rgba(201,162,39,.06); }
.log-list li:first-child { color: var(--text-primary); }
.log-empty { color: var(--text-muted); font-size: 12px; padding: 6px 0; }

/* ---------- バナー ---------- */
.banner { width: 100%; border-radius: 8px; padding: 12px 16px; font-weight: 700; font-size: 13.5px; display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.banner.success { background: var(--success-bg); color: var(--success); }
.banner.danger { background: var(--danger-bg); color: var(--danger); }
.banner.neutral { background: var(--accent-light); color: var(--warning); }
.banner.warning { background: var(--warning-bg); color: var(--warning); }
.screen > .banner { width: min(var(--col-w), 100%); }

/* ---------- 対局画面 ---------- */
.top-bar { display: flex; align-items: center; gap: 10px; width: min(var(--col-w), 100%); }
.top-bar .btn-back { flex-shrink: 0; }
.top-bar .mode-text { color: var(--text-secondary); font-size: 12px; line-height: 1.5; min-width: 0; }
.top-bar .grow { flex: 1 1 auto; }
.game-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; width: min(var(--col-w), 100%); }
.game-actions .btn { flex: 1 1 auto; min-width: 7.5em; }
.turn-row { display: grid; gap: 0; width: min(var(--col-w), 100%); }
.turn-text { font-family: var(--f-disp); font-size: 16px; color: var(--accent); min-height: 1.5em; }
.obligation-text { color: var(--danger); font-size: 12.5px; min-height: 1.4em; }
.banner-host { width: min(var(--col-w), 100%); display: grid; }
.banner-host:empty { display: none; }

/* ---------- テキスト系画面(チュートリアル/読みもの) ---------- */
.doc { width: min(760px, 100%); background: var(--surface); border: 1px solid rgba(201,162,39,.2); border-radius: 10px; padding: 24px 28px; }
.doc h2 { font-family: var(--f-disp); font-weight: 400; color: var(--accent); font-size: 20px; margin: 28px 0 10px; letter-spacing: .06em; }
.doc h2:first-child { margin-top: 0; }
.doc h3 { font-family: var(--f-disp); color: var(--warning); font-weight: 400; font-size: 16px; margin: 18px 0 6px; }
.doc p { color: var(--text-primary); font-size: 14.5px; line-height: 1.9; margin: 0 0 12px; }
.doc pre { font-family: var(--f-mono); font-size: 12px; color: var(--text-secondary); background: var(--surface-alt); border-radius: 6px; padding: 10px 12px; white-space: pre; overflow-x: auto; margin: 0 0 14px; line-height: 1.7; -webkit-overflow-scrolling: touch; }
.doc .lede { color: var(--text-secondary); text-align: center; font-size: 13px; margin-bottom: 16px; }
.doc .doc-note { font-size: 12px; color: var(--text-muted); }
.doc .doc-list { margin: 0 0 14px; padding-left: 1.4em; color: var(--text-primary); font-size: 14px; line-height: 1.85; }
.doc .doc-list li { margin: 2px 0; }
.policy-doc h3 { font-size: 15px; }

/* ページの下の小さな案内(利用規約・プライバシーポリシー)。対局の画面では出さない */
.site-footer { position: relative; z-index: 1; display: flex; justify-content: center; margin-top: -32px; padding: 0 16px calc(20px + env(safe-area-inset-bottom)); }
.footer-link {
  min-height: 36px; padding: 6px 10px; border: none; background: none; cursor: pointer;
  color: var(--text-muted); font-size: 12px; letter-spacing: .06em; text-decoration: underline; text-decoration-color: rgba(158,141,116,.4); text-underline-offset: 3px;
}
.footer-link:hover { color: var(--warning); }
body[data-screen="game"] .site-footer, body[data-screen="review"] .site-footer { display: none; }
.doc-cta { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 18px; }

.tutorial-nav { display: flex; align-items: center; justify-content: center; gap: 14px; flex-wrap: wrap; }
.tutorial-page-indicator { font-family: var(--f-mono); color: var(--text-muted); font-size: 12px; }

/* 操作できるチュートリアル: スマホは「説明→課題→盤→結果」の縦並び、広い画面は説明の右に盤 */
.tut-chips { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; width: min(980px, 100%); }
.tut-chip {
  min-width: 36px; height: 34px; padding: 0 8px; border-radius: 17px; cursor: pointer;
  border: 1px solid rgba(201,162,39,.3); background: rgba(255,255,255,.02); color: var(--text-muted);
  font-family: var(--f-mono); font-size: 12px;
}
.tut-chip:hover { border-color: var(--accent); color: var(--warning); }
.tut-chip.is-done { color: var(--success); border-color: rgba(143,217,212,.4); }
.tut-chip.is-current { background: var(--accent); border-color: var(--accent); color: var(--bg-deep); font-weight: 700; }
.tut-layout {
  display: grid; gap: 14px; width: min(980px, 100%);
  grid-template-columns: minmax(0, 1fr);
  grid-template-areas: "lesson" "task" "board" "feedback";
}
.tut-lesson { grid-area: lesson; width: 100%; }
.tut-task { grid-area: task; }
.tut-board { grid-area: board; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.tut-feedback-area { grid-area: feedback; display: flex; flex-direction: column; gap: 10px; min-height: 48px; }
@media (min-width: 900px) {
  .tut-layout {
    grid-template-columns: minmax(0, 1fr) 440px;
    grid-template-rows: auto auto 1fr;
    grid-template-areas: "lesson board" "task board" "feedback board";
    align-items: start;
  }
  .tut-board { position: sticky; top: calc(var(--header-h) + 12px); }
  .tut-layout.no-board { grid-template-columns: minmax(0, 1fr); grid-template-areas: "lesson" "task" "feedback"; width: min(680px, 100%); }
}
.tut-board .board-frame { width: min(440px, 100%); }
.tut-kicker { font-family: var(--f-mono); font-size: 11px; letter-spacing: .2em; color: var(--text-muted); margin-bottom: 4px; }
.tut-task {
  background: var(--surface-alt); border: 1px solid rgba(201,162,39,.3); border-left: 3px solid var(--accent);
  border-radius: 6px; padding: 12px 14px;
}
.tut-task-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; font-family: var(--f-disp); color: var(--accent); font-size: 15px; letter-spacing: .1em; margin-bottom: 6px; }
.tut-step-count { font-family: var(--f-mono); font-size: 11px; color: var(--text-muted); letter-spacing: .1em; }
.tut-task-text { margin: 0 0 10px; font-size: 14px; line-height: 1.8; color: var(--text-primary); }
.tut-note { margin: 10px 0 0; font-size: 12px; color: var(--text-muted); line-height: 1.6; }
.tut-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.tut-actions .btn-primary { width: auto; flex: 1 1 auto; padding: 11px 18px; font-size: 16px; letter-spacing: .12em; text-indent: 0; }
.tut-feedback { border-radius: 8px; padding: 10px 14px; font-size: 13.5px; line-height: 1.75; }
.tut-feedback p { margin: 0; }
.tut-feedback p + p { margin-top: 6px; }
.tut-feedback.info { background: var(--surface-alt); color: var(--text-primary); border: 1px solid rgba(201,162,39,.2); }
.tut-feedback.success { background: var(--success-bg); color: var(--success); font-weight: 700; }
.tut-feedback.success p + p { font-weight: 400; color: var(--text-primary); }
.tut-feedback.warn { background: var(--warning-bg); color: var(--warning); }
.tut-feedback.danger { background: var(--danger-bg); color: var(--danger); }
.tut-status { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 6px 14px; font-size: 12px; color: var(--text-secondary); width: min(440px, 100%); }
.tut-turn { font-family: var(--f-disp); font-size: 15px; color: var(--accent); }
.tut-obl { color: var(--danger); flex-basis: 100%; text-align: center; }
.cell.is-mark::after, .cell.is-mark-done::after {
  content: "✕"; position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  color: var(--board-bad); font-size: clamp(16px, 5vw, 30px); font-weight: 700; opacity: .75;
}
.cell.is-mark-done::after { opacity: .3; }
.tut-flank { stroke: var(--danger); stroke-width: 1.4; stroke-linecap: round; stroke-dasharray: 2.5 1.8; opacity: .85; }

.strategy-item { border-bottom: 1px solid rgba(201,162,39,.12); padding: 16px 0; }
.strategy-item:first-child { padding-top: 0; }
.strategy-item:last-child { border-bottom: none; padding-bottom: 0; }
.strategy-item h3 { margin: 0 0 8px; display: flex; align-items: baseline; gap: 10px; }
.item-no { flex-shrink: 0; font-family: var(--f-mono); font-size: 12px; color: var(--bg-deep); background: var(--accent); border-radius: 999px; min-width: 22px; height: 22px; display: inline-flex; align-items: center; justify-content: center; }

/* 読みもの: 一覧・前後の案内・目次・AIのレベル解説 */
.reading-list { width: min(760px, 100%); display: grid; gap: 10px; }
.reading-card { min-height: 0; padding: 16px 18px; }
.reading-card .tile-title { font-size: 16px; }
.reading-card .tile-desc { font-size: 13px; }
.reading-pager { width: min(760px, 100%); display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 10px; }
.pager-link {
  display: grid; gap: 2px; text-align: left; padding: 10px 12px; min-height: 56px; cursor: pointer;
  border: 1px solid rgba(201,162,39,.22); border-radius: 8px; background: rgba(255,255,255,.02); color: var(--text-primary); font-size: 13.5px;
}
.pager-link:hover { border-color: var(--accent); color: var(--warning); }
.pager-link.is-next { text-align: right; }
.pager-dir { font-size: 11px; color: var(--text-muted); }
.toc { margin: 0 0 18px; padding: 10px 14px; border-radius: 8px; background: var(--surface-alt); border: 1px solid rgba(201,162,39,.18); }
.toc > summary { cursor: pointer; font-family: var(--f-disp); color: var(--accent); letter-spacing: .2em; min-height: 32px; display: flex; align-items: center; }
.toc-list { margin: 6px 0 0; padding-left: 1.4em; display: grid; gap: 2px; font-size: 13px; }
.toc-list .link-btn { padding: 4px 0; color: var(--text-secondary); text-decoration-color: rgba(181,164,137,.35); }
.toc-list .link-btn:hover { color: var(--warning); }

.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 0 0 8px; border-radius: 8px; border: 1px solid rgba(201,162,39,.18); }
.level-table { border-collapse: collapse; width: 100%; min-width: 460px; font-size: 13px; }
.level-table th, .level-table td { padding: 8px 10px; text-align: left; border-bottom: 1px solid rgba(201,162,39,.1); white-space: nowrap; }
.level-table thead th { font-size: 11px; letter-spacing: .12em; color: var(--text-muted); font-weight: 400; background: rgba(0,0,0,.2); }
.level-table tbody th { font-weight: 600; }
.level-table td { color: var(--text-secondary); }
.level-table td.num { font-family: var(--f-mono); color: var(--accent); text-align: right; }
.level-table tr.is-special { background: rgba(201,162,39,.08); }
.kind-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 10px; margin-bottom: 8px; }
.kind-card { padding: 12px 14px; border-radius: 8px; background: var(--surface-alt); border: 1px solid rgba(201,162,39,.18); }
.kind-card h3 { margin-top: 0; }
.kind-card p { font-size: 13.5px; margin: 0; }
.level-card { padding: 14px 16px; margin: 0 0 10px; border-radius: 10px; background: rgba(0,0,0,.16); border: 1px solid rgba(201,162,39,.16); scroll-margin-top: calc(var(--header-h) + 12px); }
.level-card.is-special { border-color: rgba(201,162,39,.5); background: rgba(201,162,39,.07); }
.level-card-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 4px 12px; }
.level-card-head h3 { margin: 0; font-size: 19px; }
.level-rating { font-family: var(--f-mono); font-size: 13px; color: var(--accent); }
.level-facts { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0 8px; }
.level-facts span { font-size: 11.5px; padding: 2px 8px; border-radius: 999px; border: 1px solid rgba(201,162,39,.28); color: var(--text-secondary); }
.level-card p { margin-bottom: 8px; }
.level-card p:last-child { margin-bottom: 0; }
.level-tip { font-size: 13px !important; color: var(--text-secondary) !important; }
.level-tip b { color: var(--success); font-weight: 600; }

/* ---------- 対戦履歴 / 感想戦 ---------- */
.history-list { list-style: none; margin: 0; padding: 0; max-height: 60vh; overflow-y: auto; }
.history-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 11px 4px; border-bottom: 1px solid rgba(201,162,39,.12); }
.history-row:first-child { border-top: 1px solid rgba(201,162,39,.12); }
.history-text { min-width: 0; flex: 1; }
.history-head { font-size: 13px; color: var(--text-primary); }
.history-sub { font-family: var(--f-mono); font-size: 11px; color: var(--text-muted); }
.history-actions { display: flex; gap: 6px; flex-shrink: 0; }
.history-pick { display: flex; align-items: center; gap: 10px; min-width: 0; flex: 1; cursor: pointer; }
.history-check { width: 20px; height: 20px; flex-shrink: 0; margin: 0; accent-color: var(--accent); cursor: pointer; }
.history-bulk { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 12px; padding: 0 4px 12px; }
.history-bulk-pickers { display: flex; flex-wrap: wrap; gap: 6px; }
.history-bulk-action { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.history-bulk-count { font-family: var(--f-mono); font-size: 11.5px; color: var(--text-muted); }
.history-empty { color: var(--text-muted); font-size: 12.5px; padding: 14px 0; text-align: center; }

.review-toolbar { display: flex; align-items: center; justify-content: center; gap: 8px; }
.review-step { font-family: var(--f-mono); color: var(--text-primary); font-size: 13px; min-width: 78px; text-align: center; }
.review-desc { width: min(var(--col-w), 100%); color: var(--text-secondary); font-size: 13px; text-align: center; min-height: 1.6em; }
.review-list { list-style: none; margin: 0; padding: 0; max-height: 220px; overflow-y: auto; width: min(var(--col-w), 100%); font-size: 12.5px; color: var(--text-secondary); }
.review-list li { padding: 5px 8px; border-radius: 4px; cursor: pointer; }
.review-list li:hover { background: rgba(201,162,39,.08); }
.review-list li.is-current { background: rgba(201,162,39,.18); color: var(--text-primary); }

/* ---------- オンライン(手番リンク) ---------- */
.online-note { width: min(var(--col-w), 100%); background: var(--warning-bg); color: var(--warning); border-left: 3px solid var(--warning); border-radius: 6px; padding: 12px 14px; font-size: 12.5px; line-height: 1.7; }
.share-box { display: flex; gap: 8px; align-items: stretch; flex-wrap: wrap; }
.share-box input { flex: 1 1 220px; min-width: 0; padding: 9px 10px; background: var(--surface-alt); color: var(--text-primary); border: 1px solid rgba(201,162,39,.3); border-radius: 6px; font-family: var(--f-mono); font-size: 12px; }

/* ---------- オンライン対戦(サーバー版): ロビー ---------- */
.online-screen { --page-w: 1000px; }
.online-notice { width: min(1000px, 100%); }
/* タブ(対局する・観戦・ランキング) */
.net-tabs { display: flex; width: min(var(--col-w), 100%); border-bottom: 1px solid rgba(201,162,39,.3); gap: 4px; }
.net-tabs [role="tab"] {
  flex: 1 1 0; min-height: 44px; padding: 8px 6px; border: 1px solid transparent; border-bottom: none; border-radius: 8px 8px 0 0;
  background: transparent; color: var(--text-secondary); font-size: 14px; letter-spacing: .08em; cursor: pointer; margin-bottom: -1px;
}
.net-tabs [role="tab"]:hover { color: var(--warning); }
.net-tabs [role="tab"][aria-selected="true"] {
  color: var(--accent); background: var(--surface); border-color: rgba(201,162,39,.3); border-bottom: 1px solid var(--surface); font-weight: 600;
}
.net-tabpanel { display: flex; flex-direction: column; align-items: center; gap: 16px; width: 100%; }
.net-card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }

/* スマホ・タブレットは1列で「あなた → ランダムマッチ → 続きの対局 → 部屋を作る → 部屋番号で入る」、PCは左に対局の始め方・右にほか */
.net-grid { display: flex; flex-direction: column; gap: 16px; width: min(var(--col-w), 100%); }
.net-col { display: contents; }
.net-me-card { order: 1; }
.net-match-card { order: 2; }
.net-games-card { order: 3; }
.net-create { order: 4; }
.net-join-card { order: 5; }
.net-me-name .net-me-rating { font-family: var(--f-mono); color: var(--warning); }
.net-me-record { font-size: 12px; color: var(--text-muted); }
.net-me-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.net-me-links { display: flex; flex-wrap: wrap; gap: 4px 16px; font-size: 12px; }
.net-me-links .link-btn { font-size: 12px; color: var(--text-muted); }
.net-consent { margin: 4px 0 0; }
.net-consent a { color: var(--warning); }
.net-transfer-code { margin: 4px 0 8px; padding: 12px; border-radius: 8px; background: var(--surface-alt); border: 1px dashed rgba(201,162,39,.5); text-align: center; font-family: var(--f-mono); font-size: clamp(20px, 6vw, 26px); letter-spacing: .12em; color: var(--warning); user-select: all; }
.net-transfer-copy { display: flex; justify-content: center; margin-bottom: 6px; }
.modal .net-code-input { width: 100%; margin: 0 0 2px; }

/* ランダムマッチ: 持ち時間のタイル(待っている人・対局中の数つき) */
.pool-tiles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin: 12px 0 8px; }
.pool-tile {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-height: 64px; padding: 8px 6px;
  border: 1px solid rgba(201,162,39,.3); border-radius: 8px; background: rgba(255,255,255,.02); cursor: pointer; text-align: center;
}
.pool-tile:hover { border-color: var(--accent); }
.pool-tile.is-checked { border-color: var(--accent); background: rgba(201,162,39,.12); box-shadow: inset 0 0 0 1px rgba(201,162,39,.4); }
.pool-tile.is-searching { animation: pool-search 1.6s ease-in-out infinite; }
@keyframes pool-search { 50% { box-shadow: inset 0 0 0 1px rgba(201,162,39,.4), 0 0 0 4px rgba(201,162,39,.18); } }
.pool-tile:focus-within { outline: 2px solid var(--warning); outline-offset: 2px; }
.pool-name { font-family: var(--f-disp); font-size: 15px; color: var(--text-primary); }
.pool-tile.is-checked .pool-name { color: var(--warning); font-weight: 600; }
.pool-sub { display: flex; flex-direction: column; font-size: 10.5px; line-height: 1.45; color: var(--text-muted); }
.net-search-status { min-height: 1.6em; font-size: 13px; color: var(--warning); margin-bottom: 4px; }
.btn.is-searching { border-color: rgba(232,120,92,.6); color: var(--danger); background: rgba(232,120,92,.08); box-shadow: none; }

/* ランキング */
.rank-list { list-style: none; margin: 8px 0 0; padding: 0; }
.rank-row {
  display: grid; grid-template-columns: 2.4em minmax(0, 1fr) auto; grid-template-areas: "no name rating" "no sub rating";
  align-items: center; column-gap: 10px; padding: 8px 4px; border-bottom: 1px solid rgba(201,162,39,.12);
}
.rank-row:last-child { border-bottom: none; }
.rank-row.is-you { background: rgba(201,162,39,.1); border-radius: 6px; }
.rank-no { grid-area: no; font-family: var(--f-mono); font-size: 15px; color: var(--accent); text-align: center; }
.rank-row:nth-child(-n+3) .rank-no { color: var(--warning); font-weight: 700; }
.rank-name { grid-area: name; font-size: 14px; color: var(--text-primary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank-rating { grid-area: rating; font-family: var(--f-mono); font-size: 16px; color: var(--warning); }
.rank-sub { grid-area: sub; font-size: 11px; color: var(--text-muted); }
.rank-empty { color: var(--text-muted); font-size: 12.5px; padding: 12px 0; }
.rank-you { display: grid; gap: 8px; }
.rank-you-head { display: flex; align-items: baseline; gap: 14px; }
.rank-you-rating { font-family: var(--f-mono); font-size: 34px; color: var(--warning); line-height: 1.1; }
.rank-you-rank { font-size: 14px; color: var(--text-secondary); }
.rank-recent-head { margin-top: 6px; }
.rank-recent { list-style: none; margin: 0; padding: 0; font-size: 12.5px; }
.rank-recent li { display: flex; align-items: baseline; gap: 8px; padding: 4px 0; border-bottom: 1px solid rgba(201,162,39,.06); }
.rank-recent-result { flex: none; width: 3.6em; font-weight: 600; }
.rank-recent-result.is-win { color: var(--success); }
.rank-recent-result.is-loss { color: var(--danger); }
.rank-recent-result.is-draw { color: var(--text-secondary); }
.rank-recent-opp { flex: 1 1 auto; min-width: 0; color: var(--text-secondary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank-recent-diff { flex: none; font-family: var(--f-mono); color: var(--text-secondary); }
.rank-recent-diff.is-up, .net-rating-line.is-up b { color: var(--success); }
.rank-recent-diff.is-down, .net-rating-line.is-down b { color: var(--danger); }
.net-card { width: 100%; }
.net-create .btn-primary { margin-top: 10px; }
.net-me { display: grid; gap: 10px; justify-items: start; color: var(--text-secondary); font-size: 13px; }
.net-me .share-box { width: 100%; }
.net-me-name { display: flex; align-items: baseline; gap: 10px; }
.net-me-name b { font-family: var(--f-disp); font-size: 20px; font-weight: 600; color: var(--text-primary); letter-spacing: .06em; }
.net-me-label { font-size: 11px; letter-spacing: .18em; color: var(--text-muted); }
.net-name-input, .net-code-input {
  flex: 1 1 160px; min-width: 0; min-height: 40px; padding: 8px 10px;
  background: var(--surface-alt); color: var(--text-primary); border: 1px solid rgba(201,162,39,.3); border-radius: 6px; font-size: 15px;
}
.net-code-input { font-family: var(--f-mono); letter-spacing: .14em; text-transform: uppercase; }
.modal .net-name-input { width: 100%; margin: 0 0 2px; }
.net-join-box { margin-top: 10px; }
.net-games { list-style: none; margin: 4px 0 0; padding: 0; }
.net-game-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 2px; border-bottom: 1px solid rgba(201,162,39,.12); }
.net-game-row:last-child { border-bottom: none; }
.net-game-row.is-your-turn .history-head { color: var(--warning); }
.net-link-mode { width: min(var(--col-w), 100%); }
.net-link-card .card-title { margin-top: 10px; }
@media (min-width: 1024px) {
  .net-tabs { width: min(1000px, 100%); }
  .net-grid { display: grid; width: min(1000px, 100%); grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); align-items: start; }
  .net-col { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
  .net-link-mode { width: min(1000px, 100%); }
}

/* ---------- オンライン対戦: 対局画面(部屋の知らせ・提案・定型文とスタンプ) ---------- */
.net-panel, .chat-panel { width: min(var(--col-w), 100%); }
.net-panel { display: grid; gap: 8px; }

.net-line { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; font-size: 13px; color: var(--text-secondary); }
.net-line.is-warn { padding: 9px 12px; border-radius: 8px; background: var(--warning-bg); color: var(--warning); }
.net-line.is-bad { padding: 9px 12px; border-radius: 8px; background: var(--danger-bg); color: var(--danger); justify-content: space-between; }
.net-line.is-warn .btn { margin-left: auto; }
.net-people { display: grid; gap: 4px; }
.net-watch-line { gap: 4px 14px; font-size: 12px; color: var(--text-muted); }
.net-watch-line .link-btn { font-size: 12px; }
.net-rating-line { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; width: 100%; padding: 6px 4px 0; font-size: 13px; color: var(--text-secondary); }
.net-rating-line b { font-family: var(--f-mono); font-size: 15px; color: var(--text-primary); }
.net-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--text-muted); opacity: .6; flex: none; }
.net-dot.is-on { background: var(--success); opacity: 1; box-shadow: 0 0 0 3px rgba(143,217,212,.18); }
.net-opp b { color: var(--text-primary); font-weight: 600; }
.net-opp-rating { margin-left: 6px; font-family: var(--f-mono); font-size: 12.5px; color: var(--warning); }
.net-state { font-size: 12px; color: var(--text-muted); }
.net-offer {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 12px;
  padding: 10px 12px; border-radius: 8px; border: 1px solid rgba(201,162,39,.3); background: var(--accent-light);
  color: var(--text-primary); font-size: 13px;
}
.net-offer.is-incoming { border-color: var(--warning); box-shadow: 0 0 0 1px rgba(228,199,102,.25), 0 12px 30px -18px rgba(228,199,102,.6); animation: offer-in .45s var(--ease-pop) both; }
@keyframes offer-in { from { opacity: 0; transform: translateY(-6px) scale(.98); } }
.net-offer-actions { display: flex; gap: 8px; }
.net-rematch { margin-top: 8px; }
.net-banner-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.net-invite { display: grid; gap: 8px; padding: 14px; border-radius: 10px; border: 1px dashed rgba(201,162,39,.45); background: rgba(201,162,39,.05); }
.net-invite-title { font-family: var(--f-disp); font-size: 17px; color: var(--warning); letter-spacing: .08em; }
.net-invite-code { font-size: 12.5px; color: var(--text-secondary); }
.net-invite-code b { font-family: var(--f-mono); font-size: 16px; letter-spacing: .14em; color: var(--text-primary); margin-right: 6px; }

.chat-stamps { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; margin-top: 10px; }
.chat-stamp {
  display: flex; align-items: center; justify-content: center; min-height: 44px; padding: 4px; cursor: pointer;
  border: 1.5px solid rgba(194,64,42,.55); border-radius: 8px; background: rgba(194,64,42,.07);
  color: #E8785C; font-family: var(--f-disp); font-weight: 700; font-size: 14px; letter-spacing: .08em;
  transition: transform .15s, background .15s, border-color .15s;
  -webkit-tap-highlight-color: transparent; touch-action: manipulation;
}
.chat-stamp:hover:not(:disabled) { background: rgba(194,64,42,.16); border-color: #E8785C; transform: rotate(-3deg); }
.chat-stamp:active:not(:disabled) { transform: scale(.94) rotate(-3deg); }
.chat-stamp:disabled { opacity: .4; cursor: not-allowed; }
.chat-send { display: flex; gap: 8px; margin-top: 8px; }
.chat-send .chat-phrase { flex: 1 1 auto; min-width: 0; }
.chat-log { list-style: none; margin: 8px 0 0; padding: 0; max-height: 132px; overflow-y: auto; font-size: 12.5px; color: var(--text-secondary); }
.chat-log li { display: flex; gap: 8px; align-items: baseline; padding: 3px 0; border-bottom: 1px solid rgba(201,162,39,.06); }
.chat-log li b { flex: none; max-width: 9em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; color: var(--text-primary); }
.chat-log li.is-mine b { color: var(--success); }
.chat-log-stamp { padding: 0 6px; border: 1px solid rgba(194,64,42,.6); border-radius: 4px; color: #E8785C; font-family: var(--f-disp); font-weight: 700; }

/* 盤の上に出す吹き出し(定型文)と朱の判子(スタンプ)。相手は上、自分は下 */
.net-bubble {
  position: absolute; left: 50%; z-index: 6; pointer-events: none; max-width: 86%;
  display: flex; flex-direction: column; align-items: flex-start; gap: 1px;
  padding: 7px 14px 8px; border-radius: 14px; background: rgba(36,16,18,.92); border: 1px solid rgba(201,162,39,.55);
  color: var(--text-primary); font-size: clamp(13px, 3.4cqw, 16px); line-height: 1.45; box-shadow: 0 12px 30px -12px #000;
  animation: bubble-in .35s var(--ease-pop) both, bubble-out .4s ease-in 3.4s forwards;
}
.net-bubble.is-theirs { top: 5%; transform: translateX(-50%); }
.net-bubble.is-mine { bottom: 5%; transform: translateX(-50%); border-color: rgba(143,217,212,.55); }
.net-bubble-name { font-size: 10.5px; letter-spacing: .12em; color: var(--text-muted); }
@keyframes bubble-in { from { opacity: 0; margin-top: -8px; } }
@keyframes bubble-out { to { opacity: 0; } }
.net-stamp { position: absolute; z-index: 6; pointer-events: none; width: 30%; aspect-ratio: 1; display: flex; align-items: center; justify-content: center; animation: bubble-out .45s ease-in 2.1s forwards; }
.net-stamp.is-theirs { top: 6%; right: 6%; }
.net-stamp.is-mine { bottom: 6%; left: 6%; }
.net-stamp-seal {
  width: 100%; height: 100%; border-radius: 50%; border: 4px solid #C2402A; color: #C2402A;
  display: flex; align-items: center; justify-content: center; writing-mode: vertical-rl;
  font-family: var(--f-disp); font-weight: 700; font-size: clamp(16px, 6.4cqw, 30px); letter-spacing: .08em;
  background: radial-gradient(circle, rgba(194,64,42,.08), transparent 70%); mix-blend-mode: multiply; opacity: .9;
  animation: yoshi-stamp .38s cubic-bezier(.3,1.4,.5,1) both;
}
.net-stamp.is-mine .net-stamp-seal { transform: rotate(-8deg); }
.net-stamp.is-theirs .net-stamp-seal { transform: rotate(8deg); }
@media (prefers-reduced-motion: reduce) { .net-bubble, .net-stamp-seal, .net-offer.is-incoming { animation: none; } }
body.fx-off .net-bubble, body.fx-off .net-stamp-seal, body.fx-off .net-offer.is-incoming { animation: none; }

/* ---------- モーダル ---------- */
.veil { position: fixed; inset: 0; background: rgba(20,6,8,.82); backdrop-filter: blur(3px); z-index: 40; display: flex; align-items: center; justify-content: center; padding: 20px; }
.modal { width: min(420px, 100%); background: var(--surface); border: 1px solid rgba(201,162,39,.4); border-radius: 10px; padding: 22px; box-shadow: 0 30px 80px -30px #000; }
.modal p { color: var(--text-primary); font-size: 13.5px; line-height: 1.7; margin: 0 0 18px; }
.modal-title { margin: 0 0 10px; font-family: var(--f-disp); font-size: 18px; font-weight: 600; letter-spacing: .06em; color: var(--warning); }
.modal .modal-actions { display: flex; justify-content: flex-end; gap: 10px; flex-wrap: wrap; }

.thinking-dots::after { content: ""; display: inline-block; width: 1.2em; text-align: left; animation: dots 1.1s steps(4,end) infinite; }
@keyframes dots { 0%{content:""} 25%{content:"."} 50%{content:".."} 75%{content:"..."} 100%{content:""} }

@media (max-width: 480px) {
  .card, .doc { padding: 16px; }
  .board-frame { padding: 10px 8px 8px; }
}

/* ---------- 詰めピンチ ---------- */
.tsume-progress { font-family: var(--f-mono); font-size: 12px; color: var(--accent); letter-spacing: .04em; }
.tsume-tabs { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; width: min(580px, 100%); }
.tsume-tab {
  display: inline-flex; align-items: baseline; gap: 6px; padding: 7px 11px; border-radius: 999px; cursor: pointer;
  background: var(--surface-alt); color: var(--text-secondary); border: 1px solid rgba(201,162,39,.25);
  font: inherit; font-size: 12.5px; transition: background .15s, color .15s;
}
.tsume-tab:hover { color: var(--warning); background: rgba(201,162,39,.12); }
.tsume-tab[aria-selected="true"] { background: var(--accent); color: var(--bg-deep); border-color: var(--accent); font-weight: 700; }
.tsume-tab-count { font-family: var(--f-mono); font-size: 10.5px; opacity: .8; }
.tsume-cat-head { font-family: var(--f-disp); font-size: 15px; color: var(--accent); margin-bottom: 8px; }
.tsume-stars { margin-left: 10px; font-size: 12px; letter-spacing: 1px; color: var(--text-muted); }
.tsume-stars.is-on { color: var(--warning); }
.tsume-viewed { margin-left: 8px; font-size: 10.5px; color: var(--text-muted); border: 1px solid rgba(201,162,39,.25); border-radius: 4px; padding: 1px 5px; }
.tsume-gen-actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 12px; }
.tsume-gen-status { margin: 0; }
.tsume-panel {
  width: min(var(--col-w), 100%); background: var(--surface-alt); border: 1px solid rgba(201,162,39,.22);
  border-left: 3px solid var(--accent); border-radius: 6px; padding: 9px 12px; display: grid; gap: 3px;
}
.tsume-rule { font-size: 13px; color: var(--text-primary); font-weight: 700; }
.tsume-meta { font-family: var(--f-mono); font-size: 11px; color: var(--text-muted); }
.tsume-hint { font-size: 12.5px; color: var(--warning); }
.cell.is-hint { box-shadow: inset 0 0 0 3px var(--warning); animation: hint-pulse 1.2s ease-in-out infinite; }
@keyframes hint-pulse { 50% { box-shadow: inset 0 0 0 3px rgba(228,199,102,.25); } }
@media (prefers-reduced-motion: reduce) { .cell.is-hint { animation: none; } }

/* ---------- 持ち時間(メニューの設定) ---------- */
.time-custom { display: flex; flex-wrap: wrap; gap: 10px 16px; padding: 4px 0 10px; }
.time-custom-item { display: inline-flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--text-secondary); }
.check-row { display: flex; align-items: center; gap: 8px; padding: 4px 0 6px; cursor: pointer; color: var(--text-secondary); font-size: 13px; }
.check-row input { accent-color: var(--accent); width: 16px; height: 16px; }

/* ---------- 対局時計(対人戦の持ち時間) ---------- */
.clock-bar { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; width: min(var(--col-w), 100%); }
.clock {
  display: grid; gap: 2px; padding: 8px 14px; border-radius: 8px;
  background: linear-gradient(rgba(255,255,255,.03), rgba(0,0,0,.2));
  border: 1px solid rgba(201,162,39,.18); transition: border-color .25s, background .25s, opacity .25s;
  opacity: .62;
}
.clock-head { display: flex; align-items: baseline; gap: 8px; font-size: 11.5px; color: var(--text-secondary); }
.clock-role { font-size: 10px; letter-spacing: .3em; color: var(--text-muted); }
.clock-time { font-family: var(--f-mono); font-size: 30px; line-height: 1.1; color: var(--text-primary); font-variant-numeric: tabular-nums; }
.clock-sub { font-size: 11px; color: var(--text-muted); min-height: 1.3em; }
.clock.is-active { opacity: 1; border-color: rgba(201,162,39,.72); box-shadow: 0 0 0 1px rgba(201,162,39,.18), 0 10px 34px -18px rgba(228,199,102,.6); }
.clock.is-active .clock-time { color: var(--warning); }
.clock.is-low .clock-time { color: var(--danger); animation: clock-pulse 1s steps(2, end) infinite; }
.clock.is-paused .clock-time { animation: none; opacity: .55; }
.clock.is-out { opacity: 1; background: var(--danger-bg); border-color: var(--danger); }
.clock.is-out .clock-time { color: var(--danger); font-size: 22px; }
@keyframes clock-pulse { 50% { opacity: .55; } }
@media (prefers-reduced-motion: reduce) { .clock.is-low .clock-time { animation: none; } }
@media (max-width: 480px) { .clock-time { font-size: 24px; } .clock { padding: 7px 10px; } }

/* ---------- 形勢表示(対局中の優勢・劣勢の%) ---------- */
.eval-meter {
  width: min(var(--col-w), 100%); display: grid; gap: 4px; padding: 7px 12px 9px; border-radius: 8px;
  background: linear-gradient(rgba(255,255,255,.03), rgba(0,0,0,.2));
  border: 1px solid rgba(201,162,39,.18);
}
.eval-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; font-size: 11px; }
.eval-title { font-size: 10px; letter-spacing: .3em; color: var(--text-muted); }
.eval-note { color: var(--text-muted); text-align: right; min-height: 1.3em; }
.eval-row { display: grid; grid-template-columns: minmax(0, auto) 1fr minmax(0, auto); align-items: center; gap: 10px; }
.eval-side { display: inline-flex; align-items: baseline; gap: 6px; font-size: 12px; color: var(--text-secondary); white-space: nowrap; }
.eval-side-a .eval-pct { color: var(--p-a-legend); }
.eval-side-b .eval-pct { color: var(--p-b-legend); }
.eval-pct { font-family: var(--f-mono); font-size: 17px; font-variant-numeric: tabular-nums; min-width: 3.2ch; text-align: center; }
.eval-bar {
  position: relative; height: 12px; border-radius: 6px; overflow: hidden;
  background: var(--p-b-fill); border: 1px solid rgba(216,205,187,.35);
}
.eval-fill { position: absolute; inset: 0 auto 0 0; width: 50%; background: linear-gradient(var(--p-a-hi) -80%, var(--p-a-fill)); transition: width .45s var(--ease-slide); }
.eval-mid { position: absolute; left: 50%; top: -1px; bottom: -1px; width: 1px; background: var(--accent); opacity: .8; }
.eval-meter.is-stale .eval-bar, .eval-meter.is-stale .eval-pct { opacity: .5; }
.eval-option { margin-top: 6px; }
@media (prefers-reduced-motion: reduce) { .eval-fill { transition: none; } }
@media (max-width: 480px) { .eval-pct { font-size: 15px; } .eval-side { font-size: 11px; gap: 4px; } .eval-row { gap: 6px; } }

/* ---------- 感想戦: 勝率グラフと悪手判定 ---------- */
.review-graph-card {
  width: min(var(--col-w), 100%); display: grid; gap: 6px; padding: 10px 12px; border-radius: 8px;
  background: linear-gradient(rgba(255,255,255,.03), rgba(0,0,0,.2)); border: 1px solid rgba(201,162,39,.18);
}
.review-summary { display: grid; gap: 4px; font-size: 12px; color: var(--text-secondary); min-height: 1.4em; }
.review-progress { color: var(--text-muted); }
.review-score { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; }
.review-score b { font-weight: 600; min-width: 9em; }
.review-score.side-a b { color: var(--p-a-legend); }
.review-score.side-b b { color: var(--p-b-legend); }
.review-avg { font-family: var(--f-mono); color: var(--text-muted); }
.review-graph { width: 100%; height: 120px; display: block; cursor: pointer; border-radius: 4px; }
.review-graph .g-bg { fill: var(--p-b-fill); }
.review-graph .g-area { fill: var(--p-a-fill); opacity: .38; }
.review-graph .g-line { fill: none; stroke: var(--p-a-legend); stroke-width: 1.6; }
.review-graph .g-mid { stroke: var(--accent); stroke-width: 1; stroke-dasharray: 4 3; opacity: .7; }
.review-graph .g-cursor { stroke: var(--warning); stroke-width: 1.5; }
.review-graph .g-mk-big { fill: var(--danger); }
.review-graph .g-mk-small { fill: var(--warning); }
.review-graph-legend { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px 12px; font-size: 11px; color: var(--text-muted); }
.review-graph-legend .mk { display: inline-block; width: 8px; height: 8px; margin: 0 4px 0 6px; vertical-align: middle; }
.review-graph-legend .mk-big { background: var(--danger); }
.review-graph-legend .mk-small { background: var(--warning); }
.review-verdict { width: min(var(--col-w), 100%); display: grid; gap: 2px; text-align: center; font-size: 12.5px; color: var(--text-secondary); min-height: 2.8em; }
.review-judge.is-bad { color: var(--danger); }
.review-judge.is-dubious { color: var(--warning); }
.review-judge.is-ok { color: var(--text-muted); }
.review-tag { font-size: 11.5px; }
.review-list li.is-bad .review-tag { color: var(--danger); }
.review-list li.is-dubious .review-tag { color: var(--warning); }
@media (max-width: 480px) { .review-graph { height: 96px; } .review-score b { min-width: 0; } }
.review-toolbar { flex-wrap: wrap; }
.review-graph .g-mate { fill: var(--warning); opacity: .16; }
.review-graph .g-mate-edge { fill: var(--warning); opacity: .9; }
.review-graph .g-line-mate { fill: none; stroke: var(--warning); stroke-width: 2.6; }
.review-graph .g-mate-start { stroke: var(--warning); stroke-width: 1.2; stroke-dasharray: 3 2; }
.review-graph-legend .mk-mate { background: var(--warning); opacity: .75; width: 12px; }
.review-mate-line { color: var(--warning); }
.review-list li.is-mate { box-shadow: inset 3px 0 0 var(--warning); }

/* ---------- 感想戦: AIの検討(最善手・読み筋・詰み手順の樹形図) ---------- */
.study-card {
  width: min(var(--col-w), 100%); display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; padding: 10px 12px; border-radius: 8px;
  background: linear-gradient(rgba(255,255,255,.03), rgba(0,0,0,.2)); border: 1px solid rgba(201,162,39,.18);
  font-size: 12.5px; color: var(--text-secondary); line-height: 1.6; box-sizing: border-box;
}
.study-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px 12px; }
.study-title { font-family: var(--f-disp); font-size: 15px; letter-spacing: .1em; color: var(--text-primary); }
.study-check { display: flex; align-items: center; gap: 6px; font-size: 12px; cursor: pointer; }
.study-check input { accent-color: var(--accent); margin: 0; }
.study-best b { font-family: var(--f-mono); font-size: 14px; color: var(--text-primary); }
.study-muted { color: var(--text-muted); font-size: 11.5px; }
.study-pv { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; }
.pv-chip { font-family: var(--f-mono); font-size: 11.5px; padding: 0 7px; border-radius: 10px; border: 1px solid; white-space: nowrap; }
.pv-chip.side-a { color: var(--p-a-legend); border-color: rgba(143,217,212,.45); background: rgba(95,169,174,.12); }
.pv-chip.side-b { color: var(--p-b-legend); border-color: rgba(216,205,187,.35); background: rgba(0,0,0,.3); }
.study-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.study-mate {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px 10px;
  padding: 8px 10px; border-radius: 6px; background: var(--warning-bg); border-left: 3px solid var(--warning); color: var(--warning);
}
.mate-tree-area { display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; }
.mt-head { font-size: 12px; }
.mate-tree-scroll { overflow: auto; max-height: 380px; border-radius: 6px; background: rgba(0,0,0,.25); border: 1px solid rgba(201,162,39,.14); -webkit-overflow-scrolling: touch; }
.mate-tree { display: block; }
.mt-link { fill: none; stroke: rgba(201,162,39,.32); stroke-width: 1.2; }
.mt-link.on-path { stroke: var(--warning); stroke-width: 2; }
.mt-node { cursor: pointer; outline: none; }
.mt-node rect { fill: var(--surface-alt); stroke: rgba(201,162,39,.3); stroke-width: 1; }
.mt-node text { fill: var(--text-primary); font-family: var(--f-mono); font-size: 11px; }
.mt-node .tag { fill: var(--text-muted); font-family: var(--f-body); font-size: 10px; }
.mt-node .dot { stroke-width: 1; }
.mt-node.side-a .dot { fill: var(--p-a-fill); stroke: var(--p-a-hi); }
.mt-node.side-b .dot { fill: var(--p-b-fill); stroke: var(--p-b-legend); }
.mt-node.is-root rect { fill: var(--surface-raised); }
.mt-node.is-end rect { stroke: var(--warning); stroke-width: 1.6; fill: var(--warning-bg); }
.mt-node.is-end .tag { fill: var(--warning); font-weight: 700; }
.mt-node.on-path rect { stroke: var(--warning); }
.mt-node.is-sel rect { fill: var(--accent-light); stroke: var(--warning); stroke-width: 2.2; }
.mt-node.is-pending rect { fill: transparent; stroke-dasharray: 3 2; }
.mt-node.is-pending text { fill: var(--text-secondary); font-family: var(--f-body); }
.mt-node:hover rect, .mt-node:focus-visible rect { stroke: var(--warning); stroke-width: 2; }
.mt-info { display: grid; gap: 4px; font-size: 12px; }
.mt-steps { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.var-banner {
  width: min(var(--col-w), 100%); display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px 10px;
  padding: 6px 10px; border-radius: 6px; background: var(--warning-bg); border: 1px solid var(--warning); color: var(--warning); font-size: 12.5px;
}
/* 盤の矢印(最善手・変化手順の次の手)。駒の色と紛れないよう青で描く */
.best-arrow { --arrow: #2F6FD6; opacity: .88; }
.best-arrow .arrow-shaft { stroke: var(--arrow); stroke-linecap: round; }
.best-arrow .arrow-head { fill: var(--arrow); }
.best-arrow .arrow-ring { fill: none; stroke: var(--arrow); stroke-dasharray: 2 1.2; stroke-linecap: round; }
.best-arrow .arrow-plus { fill: none; stroke: var(--arrow); stroke-linecap: round; }

/* ---------- レート ---------- */
.rating-body { width: min(640px, 100%); display: grid; gap: 14px; }
.rating-body .card { width: 100%; }
.rating-head { display: grid; gap: 4px; }
.rating-now { display: flex; align-items: baseline; flex-wrap: wrap; gap: 6px 14px; }
.rating-label { font-size: 11px; letter-spacing: .3em; color: var(--text-muted); }
.rating-value { font-family: var(--f-mono); font-size: 40px; line-height: 1.1; color: var(--accent); font-variant-numeric: tabular-nums; }
.rating-sub { font-size: 12px; color: var(--text-secondary); }
.rating-chart-wrap { display: grid; gap: 6px; }
.rating-chart { width: 100%; height: auto; display: block; background: var(--bg-deep); border-radius: 6px; }
.rating-chart .rc-grid { stroke: rgba(201,162,39,.12); stroke-width: 1; }
.rating-chart .rc-axis { fill: var(--text-muted); font-size: 11px; font-family: var(--f-mono); }
.rating-chart .rc-level { stroke: var(--p-a-legend); stroke-width: 1; stroke-dasharray: 3 4; opacity: .35; }
.rating-chart .rc-level-label { fill: var(--p-a-legend); font-size: 10px; opacity: .7; }
.rating-chart .rc-line { fill: none; stroke: var(--accent); stroke-width: 2.2; stroke-linejoin: round; }
.rating-chart .rc-perf { fill: var(--text-muted); opacity: .55; }
.rating-chart .rc-pt { stroke: var(--bg-deep); stroke-width: 1.5; }
.rating-chart .rc-pt.res-win { fill: var(--success); }
.rating-chart .rc-pt.res-loss { fill: var(--danger); }
.rating-chart .rc-pt.res-draw { fill: var(--warning); }
.rating-chart-legend { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 11px; color: var(--text-muted); }
.rating-chart-legend .lg { display: inline-block; width: 10px; height: 10px; margin-right: 5px; vertical-align: middle; border-radius: 50%; }
.rating-chart-legend .lg-line { height: 3px; border-radius: 2px; background: var(--accent); }
.rating-chart-legend .lg-perf { width: 6px; height: 6px; background: var(--text-muted); }
.rating-chart-legend .lg-win { background: var(--success); }
.rating-chart-legend .lg-loss { background: var(--danger); }
.rating-chart-legend .lg-level { height: 0; border-radius: 0; border-top: 1px dashed var(--p-a-legend); }
.rating-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.rating-row {
  display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 2px 10px; padding: 8px 12px; border-radius: 6px;
  background: var(--surface); border: 1px solid rgba(201,162,39,.14);
}
.rating-row-main, .rating-row-sub { grid-column: 1; }
.rating-row .btn { grid-row: 1 / span 2; grid-column: 2; }
.rating-row-main { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; font-size: 13px; color: var(--text-secondary); }
.rating-row-sub { font-size: 11px; color: var(--text-muted); }
.rating-res { font-weight: 600; min-width: 4em; }
.rating-res.res-win { color: var(--success); }
.rating-res.res-loss { color: var(--danger); }
.rating-res.res-draw { color: var(--warning); }
.rating-after { font-family: var(--f-mono); color: var(--text-primary); }
.rating-diff { font-family: var(--f-mono); font-size: 12px; }
.rating-diff.up { color: var(--success); }
.rating-diff.down { color: var(--danger); }
.rating-how-p { margin: 4px 0; font-size: 12.5px; color: var(--text-secondary); line-height: 1.6; }
.rating-levels { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.rating-level-chip { font-size: 11.5px; font-family: var(--f-mono); padding: 3px 8px; border-radius: 999px; border: 1px solid rgba(201,162,39,.3); color: var(--text-secondary); }
.rating-note {
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px; margin-top: 8px;
  padding: 8px 12px; border-radius: 8px; font-size: 12.5px; border: 1px solid rgba(201,162,39,.25); background: var(--surface);
}
.rating-note.ok { color: var(--accent); }
.rating-note.muted { color: var(--text-muted); }
.rating-hint { margin: 0 0 4px; }
@media (max-width: 480px) { .rating-value { font-size: 32px; } .rating-row { grid-template-columns: 1fr; } .rating-row .btn { grid-row: auto; grid-column: auto; justify-self: start; } }

/* =====================================================================
 * 画面幅ごとのレイアウト(スマホ / タブレット・iPad縦 / PC・iPad横)
 * 対局・感想戦は「盤の列」と「情報の列」の2つの入れ物を持ち、狭い画面では
 * 入れ物を解いて(display: contents)中身を order で1列に並べ直す。
 * ===================================================================== */

/* 上の各部品(時計・形勢・感想戦のカード)は1列の幅にそろえる */
.clock-bar, .eval-meter, .review-graph-card, .study-card, .var-banner, .tsume-panel { width: min(var(--col-w), 100%); }
.online-share { width: min(var(--col-w), 100%); }
.online-share .card-title { font-size: 14px; }

/* ---- 対局画面 ---- */
.game-screen { gap: 12px; }
.game-layout { width: 100%; display: flex; flex-direction: column; align-items: center; gap: 12px; }
.game-board-col, .game-side-col { display: contents; }
.game-layout .banner-host { order: 1; }
.game-layout .online-share, .game-layout .net-panel { order: 2; }
.game-layout .chat-panel { order: 8; } /* 操作ボタンのすぐ下(DOM でもボタンの後ろ) */
.game-layout .tsume-panel { order: 3; }
.game-layout .turn-row { order: 4; }
.game-layout .clock-bar { order: 5; }
.game-layout .eval-meter { order: 6; }
.game-layout .board-wrap { order: 7; }
.game-layout .game-actions { order: 8; }
.game-layout .status-grid { order: 9; }
.game-layout .log-panel { order: 10; }
.game-screen .board-frame { --board-w: 600px; }

/* ---- 感想戦 ---- */
.review-screen { --page-w: var(--col-w); gap: 12px; }
.review-layout { width: 100%; display: flex; flex-direction: column; align-items: center; gap: 12px; }
.review-main, .review-side { display: contents; }
.review-layout .review-graph-card { order: 1; }
.review-layout .var-banner { order: 2; }
.review-layout .board-wrap { order: 3; }
.review-layout .review-desc { order: 4; }
.review-layout .review-verdict { order: 5; }
.review-layout .review-toolbar { order: 6; }
.review-layout .review-jumps { order: 7; }
.review-layout .study-card { order: 8; }
.review-layout .review-resume { order: 9; }
.review-layout .review-list { order: 10; }
.review-screen .board-frame { --board-w: 600px; }

/* ---- スマホ(〜639px) ---- */
@media (max-width: 639px) {
  :root { --gutter: 12px; --header-h: 50px; }
  #app { padding-top: 12px; gap: 12px; }
  .nav-title .sub { display: none; }
  .masthead { gap: 10px; }
  .masthead .kanji { font-size: 40px; }
  .masthead .tag { font-size: 12px; }
  .play-card { padding: 16px 14px; }
  .mode-name { font-size: 15px; }
  .mode-sub { font-size: 10.5px; }
  .doc { padding: 18px 16px; }
  .doc p { font-size: 14px; line-height: 1.85; }
  .reading-pager { grid-template-columns: 1fr 1fr; }
  .level-table { min-width: 0; font-size: 12px; }
  .level-table th, .level-table td { padding: 7px 5px; white-space: normal; }
  .level-table thead th { letter-spacing: 0; }
  .doc .kind-card, .doc .level-card { padding: 12px; }
  .reading-pager > .btn { grid-column: 1 / -1; grid-row: 2; justify-self: center; }
  .game-actions .btn { min-width: 0; }
  .top-bar .mode-text { font-size: 11.5px; }
  .review-toolbar .btn { padding: 6px 10px; }
  .review-toolbar:not(.review-jumps) { flex-wrap: nowrap; gap: 5px; width: 100%; }
  .review-toolbar:not(.review-jumps) .btn { padding: 6px 7px; font-size: 12px; letter-spacing: 0; flex: 1 1 auto; }
  .review-step { min-width: 56px; font-size: 12px; }
  .history-row { flex-wrap: wrap; }
  .history-actions { margin-left: 30px; }
}

/* ---- タブレット・iPad縦(640〜1023px) ---- */
@media (min-width: 640px) and (max-width: 1023px) {
  :root { --col-w: 640px; }
  .home-side { width: min(760px, 100%); }
  .home-side .tile-grid { grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); }
  .play-card { width: min(760px, 100%); }
  .game-screen .board-frame { --board-w: 640px; }
  /* 感想戦は盤の下の手送りボタンまで最初の画面に入るよう、高さに合わせて盤を少し小さくする */
  .review-screen .board-frame { --board-w: max(400px, min(640px, calc(100dvh - 500px))); }
}

/* ---- PC・iPad横(1024px〜) ---- */
@media (min-width: 1024px) {
  /* ホーム: 左に対局の設定、右に入口のタイル */
  .home-grid { grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); align-items: start; justify-items: stretch; gap: 24px; max-width: 1100px; }
  .play-card, .home-side { width: 100%; }
  .home-side .tile-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .home-top { flex-direction: row; justify-content: space-between; align-items: center; max-width: 1100px; }
  .home-top .masthead { justify-content: flex-start; padding: 0; }
  .home-top .welcome { width: auto; max-width: 560px; }
  .home-top .masthead:only-child { margin: 0 auto; }

  /* 対局: 左に盤(画面の高さに収まる大きさ)、右に情報と操作 */
  .game-screen .top-bar { width: min(1100px, 100%); }
  .game-layout {
    display: grid; grid-template-columns: minmax(0, 1fr) minmax(300px, 360px); align-items: start; gap: 24px;
    width: min(1100px, 100%);
  }
  .game-board-col { display: block; position: sticky; top: calc(var(--header-h) + 12px); }
  .game-side-col { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
  .game-side-col > * { width: 100%; }
  .game-screen .board-frame { --board-w: max(380px, min(680px, calc(100dvh - var(--header-h) - 110px))); margin: 0 auto; }
  .game-side-col .log-list { max-height: 240px; }
  .game-side-col .game-actions { justify-content: stretch; }

  /* 感想戦: 左に盤と操作、右に勝率グラフ・AIの検討・棋譜 */
  .review-screen { --page-w: 1100px; }
  .review-layout {
    display: grid; grid-template-columns: minmax(0, 1fr) minmax(320px, 440px); align-items: start; gap: 24px;
    width: min(1100px, 100%);
  }
  .review-main { display: flex; flex-direction: column; align-items: center; gap: 12px; position: sticky; top: calc(var(--header-h) + 12px); }
  .review-side { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
  .review-side > *, .review-main > .var-banner, .review-main > .review-desc, .review-main > .review-verdict { width: 100%; }
  .review-screen .board-frame { --board-w: max(360px, min(620px, calc(100dvh - var(--header-h) - 230px))); }
  .review-side .review-list { max-height: 360px; }
  .review-toolbar { flex-wrap: wrap; }
}

/* ---- 横向きのスマホなど、高さが足りない画面: 盤を高さに合わせ、情報を横に並べる ---- */
@media (max-height: 560px) and (orientation: landscape) and (min-width: 640px) {
  .game-layout { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: start; gap: 16px; }
  .game-board-col { display: block; position: sticky; top: calc(var(--header-h) + 8px); }
  .game-side-col { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
  .game-side-col > * { width: 100%; }
  .game-screen .board-frame { --board-w: max(240px, calc(100dvh - var(--header-h) - 70px)); }
  .game-screen .legend-row { display: none; }
}

/* ---- タッチ操作の端末: 押しやすい大きさ・入力欄でのズームを防ぐ文字サイズ ---- */
@media (pointer: coarse) {
  .btn-compact { min-height: 40px; }
  .seg button { min-height: 42px; }
  select.field-select, .stock-input, .share-box input { font-size: 16px; min-height: 42px; }
  .review-list li { padding: 8px; }
  .crumb { padding: 8px 0; }
  .link-btn { min-height: 40px; }
}

@media (prefers-reduced-motion: reduce) {
  .screen, .nav-open .nav-links { animation: none; }
  .tile:hover, .reading-card:hover { transform: none; }
  .board-frame.is-entering, .board-frame.is-shaking, .trail.is-new *, .piece .disc { animation: none !important; }
  .btn::after { display: none; }
}
