:root {
  --bg: #f7f4ee;
  --text: #1f1d1a;
  --muted: #8b857b;
  --line: #e2ddd3;
  --accent: #e5533d;
  --accent-soft: rgba(229, 83, 61, 0.2);
  --board: #efd6a3;
  --board-line: #8a6a3a;
  --black: #1f1d1a;
  --white: #ffffff;
  --neutral: #a8a296;
  --win: #f5c518;
  --font-body: "Zen Maru Gothic", system-ui, sans-serif;
  --font-display: "Dela Gothic One", "Zen Maru Gothic", sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1b1a18;
    --text: #efe9df;
    --muted: #9a9286;
    --line: #36332e;
    --board: #c9a86c;
    --board-line: #5a4220;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-weight: 500;
  font-size: 15px;
  line-height: 1.55;
}

button { font: inherit; color: inherit; -webkit-tap-highlight-color: transparent; }

main {
  max-width: 560px;
  margin: 0 auto;
  padding: 0 16px 32px;
}
body[data-screen="game"] main { max-width: 1120px; padding-bottom: 8px; }
body[data-screen="deck"] main, body[data-screen="select"] main { max-width: 1180px; padding-bottom: 12px; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 1120px;
  margin: 0 auto;
  padding: 8px 16px;
}
.topbar-actions { display: flex; align-items: center; gap: 12px; }
.btn-icon { display: grid; place-items: center; width: 30px; height: 30px; padding: 0; background: none; border: none; cursor: pointer; color: var(--muted); }
.btn-icon svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.btn-icon .sound-off { display: none; }
.btn-icon.is-muted .sound-on { display: none; }
.btn-icon.is-muted .sound-off { display: inline; }
.logo { font-weight: 700; font-size: 15px; margin: 0; padding: 4px 0; background: none; border: none; cursor: pointer; color: var(--text); }
.logo:hover { color: var(--accent); }
body[data-screen="title"] .logo { visibility: hidden; }

.btn-primary {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 999px;
  padding: 10px 34px;
  cursor: pointer;
  font-family: var(--font-display);
  font-size: 16px;
}
.btn-primary:active { transform: translateY(1px); }
.btn-small { padding: 4px 18px; font-size: 14px; }
.btn-text {
  background: none;
  border: none;
  padding: 6px 4px;
  cursor: pointer;
  color: var(--muted);
  text-decoration: underline;
  text-underline-offset: 4px;
}

/* ===== タイトル ===== */
/* 文字は上に、アイソメトリックの盤は下から画面をはみ出すように置く */
.title-screen {
  position: relative;
  min-height: calc(100svh - 64px);
  text-align: center;
}
.title-content {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding-top: max(3vh, 12px);
}
.title {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: clamp(40px, min(14vw, 11vh), 120px);
  line-height: 1.12;
  margin: 0 0 min(3vh, 28px);
  text-shadow: 0 0 18px var(--bg), 0 0 6px var(--bg);
}
.title-call {
  margin: 0 0 min(3.5vh, 32px);
  font-size: clamp(15px, min(4.8vw, 3.2vh), 30px);
  font-weight: 700;
  line-height: 1.6;
  text-shadow: 0 0 12px var(--bg), 0 0 4px var(--bg);
}
/* 3つのボタン：大きなアイコンと短い名前。同じ大きさの角の丸い四角を、横一列に */
.title-buttons {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: clamp(10px, 2vw, 18px);
  width: min(100%, 420px);
}
.title-buttons .mode-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  aspect-ratio: 1 / 0.92;
  padding: 0;
  border-radius: 22%;
  font-family: var(--font-body);
  font-weight: 700;
  font-size: clamp(12px, min(3.4vw, 2.2vh), 17px);
  white-space: nowrap;
  transition: transform 0.25s cubic-bezier(0.34, 1.8, 0.5, 1), box-shadow 0.25s;
}
/* ホバー：ぽんと浮いて少し傾き、アイコンが跳ねる。下に色の影 */
.title-buttons .mode-btn:hover { transform: translateY(-8px) scale(1.08) rotate(-3deg); box-shadow: 0 10px 0 -2px rgba(31, 29, 26, 0.18); }
.title-buttons .mode-btn:nth-child(2):hover { transform: translateY(-8px) scale(1.08) rotate(2deg); }
.title-buttons .mode-btn:hover .mode-icon { animation: icon-hop 0.5s cubic-bezier(0.3, 1.6, 0.5, 1); }
.title-buttons .mode-btn:active { transform: translateY(-2px) scale(0.97); transition-duration: 0.08s; }
@keyframes icon-hop { 0% { transform: scale(1); } 35% { transform: translateY(-6px) scale(1.18, 0.9); } 70% { transform: translateY(0) scale(0.94, 1.08); } 100% { transform: scale(1); } }
.mode-icon { width: 46%; height: auto; }
.mode-label { line-height: 1; }
.btn-dark { background: var(--black); }
.btn-online { background: #3d7be0; }
/* 押したボタンが画面いっぱいに広がる演出 */
.expander {
  position: fixed;
  z-index: 100;
  display: grid;
  place-items: center;
  color: #fff;
  font-weight: 700;
  font-size: clamp(16px, min(4vw, 2.6vh), 24px);
  pointer-events: none;
}
.title-art {
  position: fixed;
  z-index: 0;
  left: 50%;
  top: 56vh;
  width: max(150vw, 1300px);
  transform: translateX(-50%);
  pointer-events: none;
}
.title-art svg { display: block; width: 100%; height: auto; }
.art-top { fill: var(--board); }
.art-side-r { fill: color-mix(in srgb, var(--board) 78%, #6b4a1f); }
.art-side-l { fill: color-mix(in srgb, var(--board) 88%, #6b4a1f); }
.art-line { stroke: var(--board-line); stroke-width: 1.2; opacity: 0.55; }
.art-shadow { fill: rgba(60, 40, 10, 0.22); }
.art-stone-w { stroke: rgba(150, 140, 120, 0.5); stroke-width: 0.8; }
.art-icon-b, .art-icon-w { fill: none; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.art-icon-b { stroke: #fff; color: #fff; }
.art-icon-w { stroke: #1f1d1a; color: #1f1d1a; }
body[data-screen="title"] { overflow: hidden; }
body[data-screen="title"] main { padding-bottom: 0; }

/* ===== 石とアイコン ===== */
.stone {
  position: relative;
  display: grid;
  place-items: center;
  width: 84%;
  aspect-ratio: 1;
  border-radius: 50%;
  line-height: 1;
}
.stone-b { background: var(--black); color: #fff; }
.stone-w { background: var(--white); color: var(--black); box-shadow: inset 0 0 0 1.5px var(--black); }
.stone-n { background: var(--neutral); width: 70%; border-radius: 22%; }
.icon {
  width: 62%;
  height: 62%;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.turn-dot {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex: none;
}
.turn-b { background: var(--black); }
.turn-w { background: var(--white); box-shadow: inset 0 0 0 1.5px var(--black); }

/* ===== コマとり ===== */
/* コマとりは画面の高さいっぱいに広げ、タイルを大きくする */
.draft-screen {
  display: flex;
  flex-direction: column;
  height: calc(100svh - 64px);
  min-height: 420px;
  padding-top: 4px;
}
.draft-head { margin-bottom: 12px; }
.phase-call {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px 14px;
  margin-bottom: 10px;
}
.phase-title { font-family: var(--font-display); font-size: clamp(18px, 5vw, 26px); }
/* 「黒！」は札にせず、石と文字だけで見せる */
.phase-who {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: clamp(22px, 6vw, 30px);
  line-height: 1;
}
.who-stone { width: 1.1em; height: 1.1em; border-radius: 50%; display: inline-block; }
.phase-who.is-pop { animation: pop 0.35s cubic-bezier(0.3, 1.6, 0.5, 1); }
@keyframes pop { from { transform: scale(0.4); opacity: 0; } }

/* 取る順番：続けて取る回ごとに区切る（白1｜黒2｜白2…） */
.pick-track {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  list-style: none;
  padding: 0;
  margin: 0;
}
.group {
  display: flex;
  gap: 3px;
  padding: 3px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--text) 7%, transparent);
}
.group.is-done { opacity: 0.55; }
.group.is-current { background: var(--accent-soft); box-shadow: 0 0 0 2px var(--accent); }
.slot {
  display: grid;
  place-items: center;
  width: clamp(16px, 4.4vw, 36px);
  aspect-ratio: 1;
  border-radius: 50%;
}
.slot-b { background: color-mix(in srgb, var(--black) 22%, transparent); }
.slot-w { background: var(--white); box-shadow: inset 0 0 0 1px var(--line); }
.slot.is-current { animation: blink 1s ease-in-out infinite alternate; }
@keyframes blink { to { box-shadow: 0 0 0 2px var(--accent); } }
.slot:has(.stone) { background: none; box-shadow: none; }
.slot .stone { width: 100%; }

/* コマの一覧：枠のないタイル */
.pool {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-template-rows: repeat(3, minmax(0, 1fr));
  align-content: start;
  gap: 2px;
  background: var(--line);
  border: 2px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}
.tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 4px;
  background: var(--bg);
  border: none;
  cursor: pointer;
  text-align: center;
  min-height: 0;
}
.tile-visual > .stone { width: clamp(30px, 9vw, 44px); flex: none; }
.tile-text { display: flex; flex-direction: column; gap: 2px; }
.tile-name { font-size: 14px; font-weight: 700; }
.tile-desc { display: none; color: var(--muted); line-height: 1.5; }
.tile:hover, .tile.is-focus { background: color-mix(in srgb, var(--accent) 12%, var(--bg)); }
.tile:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.tile-info { min-height: 48px; margin: 10px 2px; font-size: 15px; }
.tile-info b { margin-right: 10px; }

.teams { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.team { display: flex; align-items: center; gap: 10px; padding-top: 8px; border-top: 3px solid var(--line); flex-wrap: wrap; }
.team.is-active { border-top-color: var(--accent); }
.team-name { display: flex; align-items: center; gap: 6px; font-weight: 700; font-size: 15px; }
.team-pieces { display: flex; gap: 4px; }
.team-piece { display: grid; place-items: center; width: clamp(20px, 5vw, 32px); aspect-ratio: 1; }
.team-piece .stone { width: 100%; }
.team-piece.is-empty { border-radius: 50%; box-shadow: inset 0 0 0 1.5px var(--line); }
/* この番で埋める枠：カードゲームの「あと何枚」のように光らせる */
.team-piece.is-next { box-shadow: inset 0 0 0 2px var(--accent); background: var(--accent-soft); animation: next 0.9s ease-in-out infinite alternate; }
@keyframes next { to { transform: scale(1.12); } }
.team-piece.is-landing .stone { visibility: hidden; }
.team.is-active .team-name { color: var(--accent); }
/* 取ったコマが飛んでいくときの影 */
.flyer { position: fixed; z-index: 50; pointer-events: none; display: grid; place-items: center; }
.flyer .stone { width: 100%; }
/* CPU が選んでいる間は、タイルを押せない */
.pool.is-waiting { pointer-events: none; }

/* 広い画面：説明をタイルの中に大きく出し、画面を広く使う */
@media (min-width: 900px) {
  .draft-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
  .phase-call { margin-bottom: 0; }
  .tile {
    flex-direction: row;
    align-items: center;
    justify-content: flex-start;
    gap: 16px;
    padding: 16px 20px;
    text-align: left;
  }
  .tile-visual > .stone { width: clamp(44px, 6.5vh, 64px); }
  .tile-text { gap: 6px; }
  .tile-name { font-size: clamp(16px, 2.4vh, 21px); }
  .tile-desc { display: block; font-size: clamp(13px, 1.9vh, 16px); }
  .tile-info { display: none; }
  .teams { margin-top: 14px; }
}

/* ===== 対局の配置 ===== */
/* スマホ：白の手札・手番の表示・盤・黒の手札を縦に並べる */
.game-layout { display: flex; flex-direction: column; gap: 10px; }
.center { display: contents; }
.status-bar { min-height: 30px; }
.status { display: flex; align-items: center; gap: 8px; margin: 0; min-height: 26px; }
.status-text { font-size: 17px; font-weight: 700; }
.status .btn-primary { margin-left: auto; }

.board-wrap {
  position: relative;
  width: min(100%, max(220px, calc(100svh - 360px)));
  margin: 0 auto;
}
.status-bar { width: min(100%, max(220px, calc(100svh - 360px))); margin-left: auto; margin-right: auto; }

/* 広い画面：手札を盤の左右に置き、石を盤の高さに均等に並べる */
@media (min-width: 900px) {
  .game-layout {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    grid-template-areas:
      ". status ."
      "left board right";
    column-gap: 28px;
    row-gap: 4px;
    align-items: stretch;
  }
  .status-bar { grid-area: status; }
  .board-wrap { grid-area: board; }
  /* 黒は盤の左、白は右（デッキを選ぶ画面と同じ並び） */
  #panel-b { grid-area: left; justify-self: end; }
  #panel-w { grid-area: right; justify-self: start; }
  .board-wrap, .status-bar { width: min(620px, calc(100svh - 150px), calc(100vw - 520px)); }
  .player { display: flex; flex-direction: column; width: 220px; }
  .player .hand { flex: 1; flex-direction: column; justify-content: space-evenly; }
}

/* ===== プレイヤーと手札 ===== */
.player { border-top: 3px solid var(--line); padding-top: 8px; }
.player.is-active { border-top-color: var(--accent); }
.player-head { display: flex; align-items: center; gap: 6px; margin-bottom: 6px; }
.player-name { font-weight: 700; font-size: 15px; }
.bag-info { margin-left: auto; font-size: 12px; color: var(--muted); }
.tag { font-size: 11px; color: #fff; background: var(--accent); padding: 0 8px; border-radius: 999px; }

/* 手札は、盤に置く前の石として並べる。石の横に名前、マウスを乗せると説明が出る */
.hand { display: flex; justify-content: space-evenly; gap: 4px; }
.hand.is-turn-start .hand-piece > .stone { animation: hop 0.45s cubic-bezier(0.3, 1.6, 0.5, 1) backwards; }
.hand.is-turn-start .hand-piece:nth-child(2) > .stone { animation-delay: 0.06s; }
.hand.is-turn-start .hand-piece:nth-child(3) > .stone { animation-delay: 0.12s; }
@keyframes hop { from { transform: translateY(10px); opacity: 0.3; } }
.hand-piece {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px;
  background: none;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  text-align: left;
  min-width: 0;
}
.hand-piece > .stone {
  width: clamp(36px, 6vh, 54px);
  flex: none;
  transition: transform 0.15s, box-shadow 0.15s;
}
.hand-name { font-size: 15px; font-weight: 700; white-space: nowrap; }
.hand-key { font-size: 11px; color: var(--muted); }
/* 選べる石は、ふれると少し浮く。選んでいる石は持ち上げて赤い輪で囲む */
.player.is-active .hand-piece:not(:disabled):hover > .stone { transform: translateY(-3px); }
.player.is-active .hand-piece.is-selected > .stone {
  transform: translateY(-4px) scale(1.06);
  box-shadow: 0 0 0 3px var(--bg), 0 0 0 6px var(--accent), 0 6px 0 2px var(--accent-soft);
}
.player.is-active .hand-piece.is-selected .hand-name { color: var(--accent); }
/* 相手の手札は薄くする。吹き出しまで薄くならないよう、石と名前だけを薄くする */
.player:not(.is-active) .hand-piece > .stone, .player:not(.is-active) .hand-piece .hand-name { opacity: 0.4; }
.hand-piece:disabled { cursor: default; }
.hand-piece.is-sealed .hand-name { text-decoration: line-through; }

/* 説明の吹き出し。スマホでは石の上に、PC では盤と反対側の横に出す */
.hand-tip {
  position: absolute;
  left: 50%;
  bottom: calc(100% + 6px);
  transform: translate(-50%, 4px);
  width: max-content;
  max-width: 230px;
  padding: 8px 12px;
  border-radius: 8px;
  background: var(--text);
  color: var(--bg);
  font-size: 13px;
  font-weight: 500;
  line-height: 1.5;
  text-align: left;
  white-space: normal;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.12s, transform 0.12s;
  z-index: 10;
}
.hand-tip b { display: block; margin-bottom: 2px; }
.hand-piece:hover .hand-tip, .hand-piece:focus-visible .hand-tip { opacity: 1; transform: translate(-50%, 0); }
@media (min-width: 900px) {
  /* PC では、盤の側に出す（外側は画面の端で切れ、上はロゴに重なる）。一時的に盤の端に重なる */
  .player .hand-piece { width: 100%; }
  #panel-w .hand-tip { left: auto; right: calc(100% + 6px); bottom: auto; top: 50%; transform: translate(6px, -50%); }
  #panel-b .hand-tip { left: calc(100% + 6px); bottom: auto; top: 50%; transform: translate(-6px, -50%); }
  #panel-b .hand-piece:hover .hand-tip, #panel-w .hand-piece:hover .hand-tip { transform: translate(0, -50%); }
  .hand-tip { max-width: 220px; }
  /* 黒は盤の左側なので、石を盤に近い右側に置く */
  #panel-b .hand-piece { flex-direction: row-reverse; text-align: right; }
  #panel-b .player-head { flex-direction: row-reverse; }
  #panel-b .bag-info { margin-left: 0; margin-right: auto; }
}

/* CPU が考えている間の点 */
.thinking { display: none; gap: 3px; margin-left: 2px; }
.player.is-thinking .thinking { display: inline-flex; }
.thinking i { width: 5px; height: 5px; border-radius: 50%; background: var(--accent); animation: think 0.9s ease-in-out infinite; }
.thinking i:nth-child(2) { animation-delay: 0.15s; }
.thinking i:nth-child(3) { animation-delay: 0.3s; }
@keyframes think { 50% { transform: translateY(-4px); opacity: 0.4; } }

@media (max-width: 899px) {
  .hand-piece { flex-direction: column; gap: 4px; padding: 4px 2px; }
  .hand-piece > .stone { width: clamp(30px, 8.5vw, 40px); }
  .hand-name { font-size: 13px; }
  .hand-key { display: none; }
  .player { padding-top: 4px; }
  .player-head { margin-bottom: 2px; }
}

/* ===== 盤 ===== */
.board {
  display: grid;
  grid-template-columns: repeat(11, minmax(0, 1fr));
  grid-template-rows: repeat(11, minmax(0, 1fr));
  aspect-ratio: 1;
  width: 100%;
  background: var(--board);
  border-radius: 4px;
  padding: 2.5%;
  touch-action: manipulation;
}
.cell {
  position: relative;
  display: grid;
  place-items: center;
  border: none;
  background: transparent;
  padding: 0;
  min-width: 0;
  min-height: 0;
  cursor: pointer;
}
.cell::before, .cell::after {
  content: "";
  position: absolute;
  background: var(--board-line);
  pointer-events: none;
}
.cell::before { left: 0; right: 0; top: 50%; height: 1px; }
.cell::after { top: 0; bottom: 0; left: 50%; width: 1px; }
.cell.edge-l::before { left: 50%; }
.cell.edge-r::before { right: 50%; }
.cell.edge-t::after { top: 50%; }
.cell.edge-b::after { bottom: 50%; }
.cell.star { background: radial-gradient(circle, var(--board-line) 0 3px, transparent 3.5px); }
.cell.in-area { background-color: var(--accent-soft); }
.cell .stone { position: absolute; inset: 0; margin: auto; z-index: 1; }
.cell:disabled { cursor: default; }
.cell:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
/* 乗っ取りで置ける相手の石 */
.cell.is-target .stone { box-shadow: 0 0 0 2px var(--accent-soft); }
.cell.is-target:hover .stone { box-shadow: 0 0 0 3px var(--accent); }

.stone.is-ghost { opacity: 0.45; pointer-events: none; z-index: 2; }
/* タッチで1回目に選んだマス：もう一度押せば置ける、と脈打たせて見せる */
.stone.is-ghost.is-pending { opacity: 0.7; animation: pending 0.8s ease-in-out infinite alternate; }
@keyframes pending { to { box-shadow: 0 0 0 4px var(--accent); } }
/* 直前の一手：石のまわりを赤い輪で囲む */
.cell.is-last .stone:not(.is-ghost) { outline: 2.5px solid var(--accent); outline-offset: 2px; }
.stone.is-win { background: var(--win); color: var(--black); box-shadow: none; }

/* ===== 演出 ===== */
.fx-placed { animation: place 0.2s ease-out; }
@keyframes place { from { transform: scale(1.3); opacity: 0; } }
/* 動いた石は、元の場所から滑ってくる。100% は石の幅なので、マス1つ分は 100% / 0.84 */
.fx-moved { animation: slide 0.45s cubic-bezier(0.2, 0.8, 0.2, 1); z-index: 2; }
@keyframes slide {
  from { transform: translate(calc(var(--from-x) * 119%), calc(var(--from-y) * 119%)); }
}
.fx-flipped { animation: flip 0.45s ease-out; }
@keyframes flip { from { transform: rotateY(180deg); } }
.puff {
  width: 60%;
  aspect-ratio: 1;
  border-radius: 50%;
  background: var(--accent);
  animation: puff 0.5s ease-out forwards;
  z-index: 1;
}
@keyframes puff { to { transform: scale(1.6); opacity: 0; } }

/* 能力名は盤の上の端に出し、盤の動きを隠さない */
.banner {
  position: absolute;
  left: 50%;
  top: 8px;
  transform: translateX(-50%);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 18px;
  border-radius: 999px;
  font-size: 16px;
  font-weight: 700;
  white-space: nowrap;
  pointer-events: none;
  z-index: 5;
  opacity: 0;
}
.banner .icon { width: 1.2em; height: 1.2em; }
.banner-b { background: var(--black); color: #fff; }
.banner-w { background: #fff; color: var(--black); box-shadow: inset 0 0 0 1.5px var(--black); }
.banner.is-show { animation: banner 0.75s ease-out; }
@keyframes banner {
  0%, 100% { opacity: 0; }
  12%, 80% { opacity: 1; }
}

/* ===== ダイアログ（外側を押すと閉じる。中身は dialog-body に入れる） ===== */
.dialog {
  border: none;
  border-radius: 12px;
  padding: 0;
  max-width: min(460px, calc(100vw - 32px));
  max-height: calc(100svh - 48px);
  background: var(--bg);
  color: var(--text);
}
.dialog-body { padding: 22px 24px; }
.dialog::backdrop { background: rgba(0, 0, 0, 0.45); }
.dialog h2 { margin-top: 0; font-family: var(--font-display); font-weight: 400; font-size: 18px; }
.dialog h3 { font-size: 15px; }
.rules { padding-left: 20px; font-size: 14px; }
.rules li { margin: 4px 0; }
.ability-list { font-size: 13px; margin: 0; }
.ability-list dt { display: flex; align-items: center; gap: 8px; font-weight: 700; margin-top: 10px; }
.ability-list dt .stone { width: 22px; }
.ability-list dd { margin: 2px 0 0 30px; color: var(--muted); }
.log { max-height: 50svh; overflow-y: auto; padding-left: 20px; font-size: 13px; margin: 0; }
.dialog-actions { display: flex; justify-content: flex-end; align-items: center; gap: 12px; margin-top: 20px; }
.result-text { font-family: var(--font-display); font-size: 30px; text-align: center; margin: 8px 0; }
.result-sub { text-align: center; color: var(--muted); margin: 0; }

/* ===== 演出の粒（fx.js）。盤より少し大きいキャンバスを重ね、粒がはみ出せるようにする ===== */
.board-fx {
  position: absolute;
  left: -60px;
  top: -60px;
  width: calc(100% + 120px);
  height: calc(100% + 120px);
  pointer-events: none;
  z-index: 6;
}

/* 予兆：石をためる。ふくらみながら震え、最後に内へ縮む（吸い込み）。そのあと弾ける */
.stone.is-charging { animation: charge var(--charge, 0.25s) ease-in forwards; }
@keyframes charge {
  0% { transform: scale(1.18, 0.82); }
  20% { transform: scale(0.95, 1.05); }
  40% { transform: scale(1.06) translate(-1px, 0); }
  55% { transform: scale(1.12) translate(1px, -1px); }
  70% { transform: scale(1.16) translate(-1px, 1px); }
  100% { transform: scale(0.84); }
}

/* ===== 5×5 のお試しの盤 ===== */
.mini { position: relative; display: block; aspect-ratio: 1; }
.mini:empty { display: none; }
.mini-grid {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  grid-template-rows: repeat(5, 1fr);
  background: var(--board);
  border-radius: 6px;
}
.mini-cell { position: relative; display: grid; place-items: center; }
.mini-cell::before, .mini-cell::after { content: ""; position: absolute; background: var(--board-line); opacity: 0.7; }
.mini-cell::before { left: 0; right: 0; top: 50%; height: 1px; }
.mini-cell::after { top: 0; bottom: 0; left: 50%; width: 1px; }
.mini-cell .stone { position: absolute; inset: 0; margin: auto; z-index: 1; }
.mini > .mini-fx { position: absolute; left: -24px; top: -24px; width: calc(100% + 48px); height: calc(100% + 48px); pointer-events: none; z-index: 4; }
/* お試しの盤の碁石は、マスに合わせる（手札・カードの大きさの指定を受けない） */
.mini .mini-cell .stone { width: 84%; box-shadow: none; }
.mini .mini-cell .stone-w { box-shadow: inset 0 0 0 1px var(--black); }

/* ===== 取り合いの3つのカード ===== */
.pool.pool-3, .pool {
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: minmax(0, 1fr);
  gap: 14px;
  background: none;
  border: none;
  overflow: visible;
}
.tile.card3 {
  position: relative;
  overflow: hidden;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  gap: 14px;
  padding: 18px 16px 16px;
  border-radius: 14px;
  background: color-mix(in srgb, var(--el-tint) 55%, var(--bg));
  box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--el-tint) 80%, var(--line));
  transition: transform 0.15s, box-shadow 0.15s, background 0.2s;
}
.tile.card3 > * { position: relative; z-index: 1; }
.tile.card3.is-focus { background: var(--el-tint); transform: translateY(-4px); box-shadow: inset 0 0 0 3px var(--accent); }
@media (hover: hover) {
  .tile.card3:hover { background: var(--el-tint); transform: translateY(-4px); box-shadow: inset 0 0 0 3px var(--accent); }
}
.tile.card3.is-deal { animation: deal 0.28s cubic-bezier(0.2, 0.8, 0.2, 1) backwards; }
@keyframes deal { from { transform: translateY(24px) scale(0.92); opacity: 0; } }
.tile-fx { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 0; }
.tile-el {
  font-size: clamp(12px, 1.7vh, 15px);
  font-weight: 700;
  letter-spacing: 0.1em;
  color: color-mix(in srgb, var(--text) 70%, var(--el-tint));
}
.tile-visual { display: grid; place-items: center; flex: none; min-height: 60px; }
.tile.card3 .tile-visual > .stone { width: clamp(56px, 11vh, 104px); }
.tile-demo { width: clamp(130px, 26vh, 230px); }
.tile.is-demo .tile-visual > .stone { display: none; }
.tile:not(.is-demo) .tile-demo { display: none; }
.tile.card3 .tile-text { align-items: center; }
.tile.card3 .tile-name { font-size: clamp(18px, 3vh, 28px); }
.tile.card3 .tile-desc { display: block; font-size: clamp(13px, 2vh, 17px); max-width: 26em; }
.tile-info { display: flex; align-items: center; gap: 12px; }
.info-demo { width: 104px; flex: none; }
.info-text b { margin-right: 8px; }
.pool.is-waiting .tile.card3 { cursor: default; }

/* 取る順番の12枠（交互なので区切らない） */
.pick-track { gap: 4px; }
.pick-track .slot { list-style: none; }

/* 手札の吹き出しの中のお試し */
.tip-demo { width: 120px; margin-bottom: 8px; }

@media (max-width: 899px) {
  .tile.card3 { padding: 12px 6px 10px; gap: 6px; }
  .tile.card3 .tile-desc { display: none; }
  .tile.card3 .tile-visual > .stone { width: 44px; }
}
@media (min-width: 900px) {
  .tile-info { display: none; }
}


/* ただの石を置いたとき：つぶれて着き、少し震える */
.stone.fx-placed.fx-el-plain { animation: el-plain 0.32s ease-out; }
@keyframes el-plain {
  0% { transform: translateY(-30%) scale(1.15); opacity: 0.6; }
  35% { transform: translateY(0) scale(1.14, 0.86); opacity: 1; }
  55% { transform: scale(0.96, 1.04) translateX(-1px); }
  75% { transform: scale(1.02, 0.98) translateX(1px); }
  100% { transform: none; }
}

/* 演出の途中に予約したマス */
.stone.is-queued { opacity: 0.6; }

/* 増殖のゲージ：石の下に2つの区切り。1つ埋まっていたら、次の自分の番で増える */
.grow-gauge {
  position: absolute;
  left: 50%;
  bottom: -22%;
  transform: translateX(-50%);
  display: flex;
  gap: 8%;
  width: 70%;
  height: 16%;
  min-height: 3px;
  z-index: 2;
}
.grow-gauge i { flex: 1; border-radius: 999px; background: color-mix(in srgb, #4f9a57 25%, var(--board)); box-shadow: inset 0 0 0 1px #2f6b3a; }
.grow-gauge[data-n="1"] i:first-child { background: #4f9a57; }
.grow-gauge[data-n="1"] i:last-child { animation: grow-next 0.9s ease-in-out infinite alternate; }
@keyframes grow-next { to { background: #9ad07a; } }

/* ===== オンライン対戦：相手をさがす画面 ===== */
.online-screen {
  min-height: calc(100svh - 64px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  text-align: center;
}
.online-title { margin: 0; font-family: var(--font-display); font-size: clamp(22px, 6vw, 34px); }
.online-sub { margin: 0; min-height: 1.5em; color: var(--muted); }
/* 碁石が3つ、順に跳ねる */
.online-search { display: flex; gap: 14px; }
.online-search i { width: 28px; height: 28px; border-radius: 50%; background: var(--black); animation: search-hop 1.1s ease-in-out infinite; }
.online-search i:nth-child(2) { background: var(--white); box-shadow: inset 0 0 0 2px var(--black); animation-delay: 0.15s; }
.online-search i:nth-child(3) { animation-delay: 0.3s; }
@keyframes search-hop { 0%, 60%, 100% { transform: translateY(0); } 30% { transform: translateY(-14px) scale(1.06, 0.94); } }

/* ===== デッキを組む ===== */
/* ポイントの段ごとの色（ここでだけ使う。強いほど熱い色） */
.t1 { --tier: #b9b2a4; --tier-ink: #fff; }
.t2 { --tier: #5fb98a; --tier-ink: #fff; }
.t3 { --tier: #4f8fe0; --tier-ink: #fff; }
.t4 { --tier: #9a6ad9; --tier-ink: #fff; }
.t5 { --tier: #f08c2e; --tier-ink: #fff; }
.t6 { --tier: #d6336c; --tier-ink: #fff; }

.deck-screen {
  display: flex;
  flex-direction: column;
  height: calc(100svh - 64px);
  min-height: 460px;
  padding-top: 2px;
  position: relative;
}
.deck-screen.is-swap { animation: swap-in 0.45s cubic-bezier(0.2, 0.8, 0.2, 1); }
@keyframes swap-in { from { transform: translateX(40px); opacity: 0; } }
.deck-head { display: flex; flex-direction: column; gap: 8px; margin-bottom: 10px; }
.deck-head .phase-call { margin-bottom: 0; }

/* スターターデッキ：横に並ぶ札。選んでいるものは墨で塗る */
.deck-starters {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  scrollbar-width: none;
  padding: 4px 2px;
  margin: -4px -2px;
}
.deck-starters::-webkit-scrollbar { display: none; }
.starter {
  flex: none;
  display: grid;
  grid-template-columns: auto;
  gap: 4px;
  min-width: 132px;
  padding: 8px 12px 9px;
  border: none;
  border-radius: 12px;
  background: color-mix(in srgb, var(--text) 6%, var(--bg));
  text-align: left;
  cursor: pointer;
  transition: transform 0.18s cubic-bezier(0.3, 1.6, 0.5, 1), background 0.15s;
}
.starter:hover { transform: translateY(-3px); background: color-mix(in srgb, var(--text) 11%, var(--bg)); }
.starter.is-on { background: var(--text); color: var(--bg); }
.starter-name { font-weight: 700; font-size: 15px; line-height: 1.2; }
.starter-stones { display: flex; align-items: center; gap: 3px; height: 18px; }
.starter-stones .stone { width: 18px; flex: none; }
.starter-stones .stone .icon { width: 64%; }
.starter.is-on .starter-stones .stone-b { box-shadow: inset 0 0 0 1.5px var(--bg); }
.starter-stones .more { font-size: 11px; font-weight: 700; opacity: 0.7; }
.starter-note { font-size: 11.5px; opacity: 0.7; white-space: nowrap; }

.deck-main { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) auto; gap: 10px; }

/* 碁石の一覧：ポイントの段ごとに見出し。押すとデッキに入る */
.deck-catalog {
  min-height: 0;
  overflow-y: auto;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(92px, 1fr));
  align-content: start;
  gap: 6px;
  padding: 2px 2px 8px;
  scrollbar-width: thin;
}
.dk-head {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 8px 0 0;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
}
.dk-head:first-child { margin-top: 0; }
.dk-coin {
  display: inline-grid;
  place-items: center;
  min-width: 1.6em;
  height: 1.6em;
  padding: 0 0.3em;
  border-radius: 99px;
  background: var(--tier);
  color: var(--tier-ink);
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.dk-tile {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  padding: 10px 4px 8px;
  border-radius: 12px;
  background: color-mix(in srgb, var(--tier) 9%, var(--bg));
  box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--tier) 30%, transparent);
  cursor: pointer;
  user-select: none;
  transition: transform 0.18s cubic-bezier(0.3, 1.6, 0.5, 1), background 0.15s, box-shadow 0.15s;
}
.dk-tile:hover, .dk-tile.is-focus { transform: translateY(-3px); background: color-mix(in srgb, var(--tier) 18%, var(--bg)); box-shadow: inset 0 0 0 2px var(--tier); }
.dk-tile:active { transform: scale(0.94); transition-duration: 0.06s; }
.dk-tile:focus-visible { outline: 2px solid var(--text); outline-offset: 2px; }
.dk-tile.is-in { background: color-mix(in srgb, var(--tier) 22%, var(--bg)); box-shadow: inset 0 0 0 2.5px var(--tier); }
.dk-tile.is-off:not(.is-in) { opacity: 0.5; }
.dk-tile.is-off:not(.is-in):hover { transform: none; }
.dk-visual { position: relative; display: grid; place-items: center; width: 42px; }
.dk-visual > .stone { width: 100%; }
.dk-count {
  position: absolute;
  right: -10px;
  top: -6px;
  min-width: 24px;
  padding: 2px 5px;
  border-radius: 99px;
  background: var(--tier);
  color: var(--tier-ink);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.2;
  text-align: center;
  font-variant-numeric: tabular-nums;
}
.dk-count:empty { display: none; }
.dk-name { font-size: 12.5px; font-weight: 700; line-height: 1.2; text-align: center; }
.dk-minus {
  position: absolute;
  left: 4px;
  top: 4px;
  width: 24px;
  height: 24px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: var(--text);
  color: var(--bg);
  font-size: 15px;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  display: none;
}
.dk-tile.is-in .dk-minus { display: grid; place-items: center; }
.dk-minus:hover { background: var(--accent); }
.dk-tile.is-bump { animation: bump 0.32s; }
@keyframes bump { 20%, 60% { transform: translateX(-5px); } 40%, 80% { transform: translateX(5px); } }

/* 右側：ポイントのメーター、デッキの中身、説明、決定 */
.deck-side { display: flex; flex-direction: column; gap: 10px; min-height: 0; }
.deck-meter { display: flex; flex-direction: column; gap: 8px; }
.deck-meter.is-bump .meter-bar { animation: bump 0.32s; }
.deck-meter.is-bump .meter-num:first-child b { color: var(--accent); }
.meter-nums { display: flex; gap: 18px; align-items: flex-end; }
.meter-clear { margin-left: auto; align-self: center; font-size: 12.5px; }
.meter-num { display: flex; align-items: baseline; gap: 6px; }
.meter-num b { font-family: var(--font-display); font-weight: 400; font-size: clamp(26px, 4.2vh, 36px); line-height: 1; font-variant-numeric: tabular-nums; transition: color 0.2s; }
.meter-num small { font-size: 12px; font-weight: 700; color: var(--muted); }
.meter-bar { display: grid; grid-template-columns: repeat(var(--n), 1fr); gap: 2px; }
.meter-bar i { display: block; height: 14px; background: var(--tier); }
.meter-bar i.is-first { border-radius: 4px 0 0 4px; }
.meter-bar i:not(.is-first):not(.is-empty) + i.is-first, .meter-bar i.is-empty { border-radius: 4px; }
.meter-bar i.is-empty { background: color-mix(in srgb, var(--text) 9%, var(--bg)); }
.meter-bar i:not(.is-first):not(.is-empty) { margin-left: -2px; }
.meter-bar i.is-pop { animation: cell-pop 0.35s cubic-bezier(0.3, 1.8, 0.5, 1); }
@keyframes cell-pop { from { transform: scaleY(0.2); } }

/* デッキの中身：置ける碁石を全部並べる。多いと細かく、少ないと大きく見える */
.deck-bag {
  display: flex;
  flex-wrap: wrap;
  align-content: flex-start;
  gap: 4px;
  min-height: 34px;
}
.deck-bag .stone { width: 28px; flex: none; }
.deck-bag .stone .icon { width: 62%; }
.deck-bag .stone.is-landing { visibility: hidden; }

.deck-info { display: flex; gap: 12px; align-items: center; min-height: 72px; }
.deck-demo { width: 96px; flex: none; }
.deck-text { display: flex; flex-direction: column; gap: 3px; font-size: 13.5px; line-height: 1.55; }
.deck-text b { display: flex; align-items: center; gap: 8px; font-size: 16px; }
.deck-hint { margin: 0; color: var(--muted); font-size: 13.5px; }
.deck-go { width: 100%; padding: 0.8em 1em; font-weight: 700; }
.deck-go:disabled { opacity: 0.4; cursor: default; }

.deck-toast {
  position: absolute;
  left: 50%;
  bottom: 84px;
  transform: translateX(-50%);
  margin: 0;
  padding: 8px 16px;
  border-radius: 99px;
  background: var(--text);
  color: var(--bg);
  font-weight: 700;
  font-size: 14px;
  pointer-events: none;
  opacity: 0;
  z-index: 20;
}
.deck-toast.is-show { animation: toast 1.4s ease; }
@keyframes toast { 0% { opacity: 0; transform: translate(-50%, 8px); } 12%, 75% { opacity: 1; transform: translate(-50%, 0); } 100% { opacity: 0; } }

/* スマホ：一覧はその中でスクロール。説明とデッキの中身は小さく */
@media (max-width: 899px) {
  .deck-catalog { grid-template-columns: repeat(auto-fill, minmax(76px, 1fr)); }
  .dk-visual { width: 34px; }
  .dk-name { font-size: 11.5px; }
  .deck-side { gap: 8px; }
  .deck-info { min-height: 0; }
  .deck-info:has(.deck-hint) { display: none; }
  .deck-demo { width: 64px; }
  .deck-text { font-size: 12.5px; }
  .deck-bag .stone { width: 20px; }
  .meter-bar i { height: 10px; }
}
@media (max-width: 899px) and (max-height: 700px) {
  .deck-bag { display: none; }
  .deck-demo { display: none; }
}

/* 広い画面：左に一覧、右にデッキ */
@media (min-width: 900px) {
  .deck-head { flex-direction: row; align-items: center; justify-content: space-between; gap: 20px; }
  .deck-main { grid-template-columns: minmax(0, 1fr) 340px; grid-template-rows: minmax(0, 1fr); gap: 24px; }
  .deck-side { padding: 14px 16px; border-radius: 16px; background: color-mix(in srgb, var(--text) 4%, var(--bg)); }
  .deck-bag { max-height: 40%; overflow: hidden; }
  .deck-info { flex: 1; min-height: 110px; align-items: flex-start; padding-top: 6px; border-top: 1.5px dashed var(--line); }
  .deck-demo { width: 120px; }
  .deck-toast { bottom: 24px; }
}

/* スパイ：相手にリーチがあると使えない（斜線で消して、押すと揺れる） */
.hand-piece.is-blocked > .stone { opacity: 0.35; }
.hand-piece.is-blocked > .stone::after { content: ""; position: absolute; left: 8%; right: 8%; top: 50%; height: 3px; margin-top: -1.5px; border-radius: 3px; background: var(--accent); transform: rotate(-35deg); }
.hand-piece.is-blocked .hand-name { text-decoration: line-through; color: var(--muted); }
.hand-piece.is-bump { animation: bump 0.32s; }
/* デッキの見出しまわりの細かい直し */
.meter-num small, .meter-clear { white-space: nowrap; }
.meter-nums { gap: 14px; }
.deck-starters { min-width: 0; }
.deck-head .phase-call { flex-wrap: nowrap; white-space: nowrap; }
.deck-head .phase-who { font-size: clamp(20px, 5vw, 26px); }

/* ===== デッキをえらぶ ===== */
.select-screen {
  display: flex;
  flex-direction: column;
  height: calc(100svh - 64px);
  min-height: 420px;
  padding-top: 2px;
}
.select-heading {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 4px 12px;
    margin-bottom: 12px;
}
.select-title { margin: 0; font-weight: 400; }
#deck-import { flex-shrink: 0; }
#deck-copy-announcement {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
}
#deck-code-status:empty { margin: 0; }
#deck-code-form { width: min(420px, calc(100vw - 32px)); }
#deck-code, #deck-copy-text {
    width: 100%;
    resize: vertical;
    padding: 9px 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--bg);
    color: var(--text);
    font-size: 16px;
}
#deck-code-status, #deck-copy-status { font-size: 13px; overflow-wrap: anywhere; }
#deck-copy-status { margin: 4px 6px; }
#deck-copy-status:empty { margin: 0; }
#deck-copy-menu {
    position: fixed;
    inset: auto;
    width: min(218px, calc(100vw - 16px));
    max-height: calc(100dvh - 16px);
    margin: 0;
    padding: 4px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--bg);
    color: var(--text);
    box-shadow: 0 4px 14px rgb(0 0 0 / 14%);
}
#deck-copy-menu button {
    display: block;
    width: 100%;
    padding: 8px 10px;
    border-radius: 6px;
    color: inherit;
    text-align: left;
    text-decoration: none;
}
#deck-copy-menu button:enabled:hover, #deck-copy-menu button:focus-visible {
    background: color-mix(in srgb, var(--text) 8%, var(--bg));
}
#deck-copy-text { margin-top: 4px; }
.select-cols { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; }
.select-screen:is([data-mode="pvp"], [data-mode="cpu"]) .select-cols { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.sel-col { display: flex; flex-direction: column; min-height: 0; gap: 8px; }
.sel-head { display: flex; align-items: center; gap: 8px; margin: 0; font-weight: 700; font-size: clamp(15px, 4vw, 19px); }
.sel-head .who-stone { width: 1.15em; height: 1.15em; }
.stone-w.who-stone { box-shadow: inset 0 0 0 2px var(--black); }
.sel-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  align-content: start;
  gap: 10px;
  padding: 4px;
  margin: -4px;
  scrollbar-width: thin;
}
.select-screen:is([data-mode="pvp"], [data-mode="cpu"]) .sel-list { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }

.sel-card {
  color: inherit;
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 7px;
  padding: 12px 14px 11px;
  border: none;
  border-radius: 14px;
  background: color-mix(in srgb, var(--text) 5%, var(--bg));
  box-shadow: inset 0 0 0 1.5px var(--line);
  text-align: left;
  cursor: pointer;
  transition: transform 0.2s cubic-bezier(0.3, 1.6, 0.5, 1), background 0.15s, box-shadow 0.15s;
}
.sel-card:hover { transform: translateY(-3px); box-shadow: inset 0 0 0 2px var(--text); }
.sel-card:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.sel-card.is-on { background: var(--text); color: var(--bg); box-shadow: none; }
.sel-card.is-on::after {
  content: "";
  position: absolute;
  right: 12px;
  bottom: 12px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--accent) url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="white" stroke-width="3.2" stroke-linecap="round" stroke-linejoin="round"><path d="M6 12.5l4 4 8-9"/></svg>') center / 70% no-repeat;
}
.sel-card.is-picked { animation: picked 0.35s cubic-bezier(0.3, 1.6, 0.5, 1); }
@keyframes picked { 40% { transform: scale(1.04); } }
.sel-name { display: flex; align-items: center; gap: 8px; padding-right: 36px; font-weight: 700; font-size: 16px; line-height: 1.25; overflow-wrap: anywhere; }
.sel-tag { padding: 1px 7px; border-radius: 99px; background: color-mix(in srgb, var(--text) 10%, transparent); font-size: 10.5px; font-weight: 700; opacity: 0.8; white-space: nowrap; }
.sel-card.is-on .sel-tag { background: color-mix(in srgb, var(--bg) 20%, transparent); }
.sel-stones { display: flex; align-items: center; gap: 4px; min-height: 24px; flex-wrap: wrap; }
.sel-stones .stone { width: 24px; flex: none; }
.sel-stones .stone .icon { width: 62%; }
.sel-card.is-on .sel-stones .stone-b { box-shadow: inset 0 0 0 1.5px var(--bg); }
.sel-stones .more { font-size: 12px; font-weight: 700; opacity: 0.7; }
.sel-meta { font-size: 12px; opacity: 0.72; padding-right: 28px; }
.sel-meta b { font-size: 15px; margin-right: 1px; }
.sel-version { font-size: 12px; font-weight: 700; }
.sel-actions {
    position: absolute;
    top: 8px;
    right: 8px;
    display: flex;
    gap: 2px;
}
.sel-card.is-mine .sel-name { padding-right: 64px; }
.sel-actions button {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: inherit;
  opacity: 0.55;
  cursor: pointer;
  transition: opacity 0.15s, background 0.15s, transform 0.15s;
}
.sel-actions svg { width: 18px; height: 18px; }
.sel-actions button:hover { opacity: 1; background: color-mix(in srgb, currentColor 14%, transparent); transform: rotate(-8deg) scale(1.08); }
.sel-new {
  align-items: center;
  justify-content: center;
  flex-direction: row;
  gap: 8px;
  min-height: 90px;
  background: none;
  box-shadow: none;
  border: 2px dashed var(--line);
  color: var(--muted);
  font-weight: 700;
}
.sel-new:hover { box-shadow: none; border-color: var(--text); color: var(--text); }
.sel-plus { font-size: 22px; line-height: 1; }
.select-foot { display: flex; justify-content: center; padding-top: 12px; }
.select-go { width: min(100%, 420px); padding: 0.85em 1em; font-weight: 700; }

/* 2人で対戦のスマホ：列が細いので、札を小さく */
@media (max-width: 599px) {
  .select-screen:is([data-mode="pvp"], [data-mode="cpu"]) .sel-list { grid-template-columns: minmax(0, 1fr); gap: 8px; }
  .select-screen:is([data-mode="pvp"], [data-mode="cpu"]) .sel-card { padding: 9px 10px; gap: 5px; }
  .select-screen:is([data-mode="pvp"], [data-mode="cpu"]) .sel-name { font-size: 14px; flex-wrap: wrap; gap: 4px; }
  .select-screen:is([data-mode="pvp"], [data-mode="cpu"]) .sel-stones .stone { width: 18px; }
  .select-screen:is([data-mode="pvp"], [data-mode="cpu"]) .sel-actions { right: 4px; top: 4px; }
  .select-screen:is([data-mode="pvp"], [data-mode="cpu"]) .sel-actions button { width: 28px; height: 28px; }
  .select-screen:is([data-mode="pvp"], [data-mode="cpu"]) .sel-card.is-mine .sel-name { padding-right: 54px; }
  .select-screen:is([data-mode="pvp"], [data-mode="cpu"]) .sel-new { min-height: 64px; font-size: 13px; }
}

/* ===== デッキを作る：見出し（もどる・名前・ひな形） ===== */
.build-call { display: flex; align-items: center; gap: 10px; min-width: 0; }
.build-back {
  flex: none;
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: color-mix(in srgb, var(--text) 8%, var(--bg));
  cursor: pointer;
  transition: background 0.15s, transform 0.2s cubic-bezier(0.3, 1.6, 0.5, 1);
}
.build-back:hover { background: var(--text); color: var(--bg); transform: translateX(-3px); }
.build-back svg { width: 20px; height: 20px; }
.deck-name {
  min-width: 0;
  width: 12em;
  padding: 4px 2px;
  border: none;
  border-bottom: 2px dashed var(--line);
  background: none;
  color: var(--text);
  font: inherit;
  font-weight: 700;
  font-size: clamp(19px, 5vw, 24px);
  outline: none;
}
.deck-name:focus { border-bottom-color: var(--accent); }
.deck-templates { display: flex; align-items: center; gap: 10px; min-width: 0; }
.templates-label { flex: none; font-size: 12px; font-weight: 700; color: var(--muted); writing-mode: vertical-rl; letter-spacing: 0.1em; }
.deck-actions { display: flex; align-items: center; gap: 14px; }
.deck-actions .deck-go { flex: 1; }
.deck-delete { flex: none; }
/* 小さな漢字が太い見出しの字でつぶれないよう、決定のボタンは本文の字にする */
.deck-go, .select-go { font-family: var(--font-body); font-size: 17px; letter-spacing: 0.04em; }
.meter-nums { gap: 10px; }
.meter-num b { font-size: clamp(24px, 3.6vh, 32px); }
@media (max-width: 599px) {
  .select-screen:is([data-mode="pvp"], [data-mode="cpu"]) .sel-meta { font-size: 11px; }
  .select-screen:is([data-mode="pvp"], [data-mode="cpu"]) .sel-meta span, .select-screen:is([data-mode="pvp"], [data-mode="cpu"]) .sel-note { display: none; }
}

/* ===== デッキを選ぶ：選んだ札は強調色 ===== */
.sel-card.is-on { background: var(--accent); color: #fff; box-shadow: 0 6px 0 -2px color-mix(in srgb, var(--accent) 45%, transparent); }
.sel-card.is-on::after { background-color: #fff; background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="%23e5533d" stroke-width="3.2" stroke-linecap="round" stroke-linejoin="round"><path d="M6 12.5l4 4 8-9"/></svg>'); }
.sel-card.is-on .sel-stones .stone-b { box-shadow: inset 0 0 0 1.5px #fff; }
.sel-card.is-on .sel-stones .stone-w { box-shadow: none; }
.sel-card.is-on .sel-tag { background: rgba(255, 255, 255, 0.25); }
.sel-card.is-on:hover { box-shadow: 0 6px 0 -2px color-mix(in srgb, var(--accent) 45%, transparent); }

/* ===== デッキを作る：碁石の札を大きく。説明と −・＋ を札の中に ===== */
.deck-catalog { grid-template-columns: repeat(auto-fill, minmax(196px, 1fr)); gap: 10px; }
.dk-head { margin-top: 12px; font-size: 13px; }
.dk-head .dk-coin { font-size: 13px; }
.dk-tile {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  grid-template-rows: 1fr auto;
  align-items: start;
  column-gap: 12px;
  row-gap: 8px;
  padding: 12px 12px 10px;
  border-radius: 16px;
  text-align: left;
}
.dk-visual { grid-row: 1 / 3; align-self: center; width: 58px; transition: transform 0.2s; }
.dk-visual.is-pop { animation: dk-pop 0.35s cubic-bezier(0.3, 1.8, 0.5, 1); }
@keyframes dk-pop { 40% { transform: scale(1.18) rotate(-6deg); } }
.dk-visual > .stone .icon { width: 58%; }
.dk-body { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.dk-name { font-size: 15px; text-align: left; }
.dk-desc {
  font-size: 11.5px;
  line-height: 1.45;
  color: var(--muted);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.dk-step { display: flex; align-items: center; gap: 6px; justify-self: start; }
.dk-step .dk-minus, .dk-plus {
  position: static;
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  font-size: 15px;
  font-weight: 700;
  line-height: 1;
}
.dk-step .dk-minus { display: grid; background: color-mix(in srgb, var(--text) 10%, transparent); color: var(--text); visibility: hidden; }
.dk-tile.is-in .dk-step .dk-minus { visibility: visible; }
.dk-step .dk-minus:hover { background: var(--text); color: var(--bg); }
.dk-plus { background: var(--tier); color: var(--tier-ink); transition: transform 0.15s; }
.dk-tile:hover .dk-plus { transform: scale(1.12); }
.dk-n { min-width: 1.4em; text-align: center; font-size: 17px; font-variant-numeric: tabular-nums; opacity: 0.35; }
.dk-tile.is-in .dk-n { opacity: 1; }
.dk-tile.is-off .dk-plus { background: color-mix(in srgb, var(--text) 15%, transparent); color: var(--muted); }
.dk-count { display: none; }

/* デッキの中身と、ひな形の石も大きく */
.deck-bag { gap: 6px; }
.deck-bag .stone { width: 36px; }
.starter-stones { height: 22px; }
.starter-stones .stone { width: 22px; }

@media (max-width: 899px) {
  .deck-catalog { grid-template-columns: repeat(auto-fill, minmax(156px, 1fr)); gap: 8px; }
  .dk-tile { padding: 10px 10px 8px; column-gap: 9px; row-gap: 6px; }
  .dk-visual { width: 46px; }
  .dk-name { font-size: 14px; }
  .dk-desc { font-size: 11px; }
  .deck-bag .stone { width: 24px; }
}
@media (max-width: 359px) {
  .deck-catalog { grid-template-columns: minmax(0, 1fr); }
}
/* ポイントが足りない札も、文字は読めるままにする（石と＋だけ薄く） */
.dk-tile.is-off:not(.is-in) { opacity: 1; }
.dk-tile.is-off:not(.is-in) .dk-visual { opacity: 0.45; }

/* 対局中のデッキの名前：PC では名前の下の行、スマホでは名前の横 */
.player-head { flex-wrap: wrap; }
.player-deck { font-size: 12px; font-weight: 700; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 9em; }
@media (min-width: 900px) { .player-deck { order: 9; flex-basis: 100%; max-width: none; } #panel-b .player-deck { text-align: right; } }
@media (max-width: 899px) { .player-head { flex-wrap: nowrap; } .player-deck { font-size: 11px; } }
@media (min-width: 900px) { .player-head { row-gap: 0; margin-bottom: 2px; } .player-deck { line-height: 1.2; } }

/* CPU 対戦とオンライン対戦：ユーザー名 */
.select-foot { flex-wrap: wrap; gap: 10px 16px; align-items: center; }
.name-field { display: flex; align-items: center; gap: 10px; font-size: 13px; font-weight: 700; color: var(--muted); }
.name-field input {
  width: 11em;
  padding: 6px 2px;
  border: none;
  border-bottom: 2px dashed var(--line);
  background: none;
  color: var(--text);
  font: inherit;
  font-size: 17px;
  outline: none;
}
.name-field input:focus { border-bottom-color: var(--accent); }
.name-field input::placeholder { color: var(--muted); opacity: 0.6; }
/* 名前の欄は、ボタンのすぐ上に、ボタンと同じ幅で置く */
.select-foot { flex-direction: column; align-items: center; gap: 10px; }
.name-field { width: min(100%, 420px); justify-content: center; }
.name-field input { flex: 1; min-width: 0; text-align: center; }

/* 手札の吹き出しは盤の上に重ねる（白の手札は、HTML では盤より前にあるので、そのままだと盤の後ろに隠れる） */
.player { position: relative; z-index: 8; }

/* 盤の上の碁石の説明（手札の吹き出しと同じ見た目） */
.stone-tip {
  position: fixed;
  z-index: 60;
  width: max-content;
  max-width: 240px;
  padding: 8px 12px 10px;
  border-radius: 8px;
  background: var(--text);
  color: var(--bg);
  font-size: 13px;
  line-height: 1.5;
  pointer-events: none;
  animation: tip-in 0.14s ease-out;
}
.stone-tip b { display: block; font-size: 14px; }
.stone-tip .tip-owner { display: block; margin-bottom: 3px; font-size: 11.5px; opacity: 0.7; }
.stone-tip .tip-demo { display: block; width: 120px; margin-bottom: 8px; }
@keyframes tip-in { from { opacity: 0; transform: translateY(4px); } }

/* 時限爆弾のゲージ：のこりの手数だけ赤く光る。あと1手になると点滅する */
.fuse-gauge { position: absolute; left: 50%; bottom: -22%; transform: translateX(-50%); display: flex; gap: 8%; width: 70%; height: 16%; min-height: 3px; z-index: 2; }
.fuse-gauge i { flex: 1; border-radius: 999px; background: color-mix(in srgb, #e5533d 20%, var(--board)); box-shadow: inset 0 0 0 1px #9c2f1f; }
.fuse-gauge[data-n="2"] i { background: #e5533d; }
.fuse-gauge[data-n="1"] i:first-child { background: #e5533d; animation: fuse-blink 0.45s ease-in-out infinite alternate; }
@keyframes fuse-blink { to { background: #ffd23f; } }

/* スナイパー：狙えている石に照準 */
.board.is-aiming .cell { cursor: default; }
.board.is-aiming .cell.is-target { cursor: crosshair; }
.board.is-aiming .cell.is-target > .stone::after {
  content: "";
  position: absolute;
  inset: -12%;
  border-radius: 50%;
  border: 2px dashed var(--accent);
  animation: aim-spin 2.4s linear infinite;
}
.board.is-aiming .cell.is-target:hover > .stone::after { border-style: solid; inset: -18%; }
@keyframes aim-spin { to { transform: rotate(360deg); } }

/* スマホのオンライン対戦で自分が白のとき：自分の手札を下（親指の近く）に、相手（黒）を上に */
@media (max-width: 899px) {
  #game-screen.me-w #panel-b { order: -1; }
  #game-screen.me-w #panel-w { order: 2; }
}

/* 棋譜の画像 */
/* 画像を大きく見せる：横長（16:9）の画像を、画面の幅いっぱい近くまで */
.dialog.share-dialog { max-width: calc(100vw - 24px); max-height: calc(100svh - 24px); }
.share-dialog .dialog-body { padding: 14px 14px 16px; }
.share-img { display: block; width: min(calc(100vw - 52px), calc((100svh - 130px) * 16 / 9), 900px); height: auto; border-radius: 10px; box-shadow: 0 0 0 1.5px var(--line); }
.share-dialog .dialog-actions { margin-top: 12px; }

/* 結果のダイアログ：ボタンの文字を途中で折り返さない。入らなければ、ボタンごと次の行へ */
.dialog-actions { flex-wrap: wrap; justify-content: center; gap: 10px 18px; }
.dialog-actions button { white-space: nowrap; }
.dialog-actions .btn-primary { font-family: var(--font-body); font-weight: 700; padding: 0.7em 1.6em; }
