/* リバーシ（CPU対戦） */

:root {
  color-scheme: light dark;
  --font: system-ui, -apple-system, "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", "Yu Gothic UI", "Meiryo", sans-serif;

  --bg: #f4efe4;
  --bg-glow: #fbf8f1;
  --surface: #fffdf8;
  --surface-hover: #f5efe2;
  --text: #2a2622;
  --text-muted: #6d665c;
  --border: #ddd2bd;
  --primary: #1f7a4d;
  --primary-hover: #196a42;
  --on-primary: #ffffff;
  --danger: #b83a2e;
  --focus: #e08a00;
  --win: #1f7a4d;
  --lose: #b83a2e;

  --board-cell: #2e8a56;
  --board-line: #1c5c38;
  --board-edge: #174a2e;
  --hint: rgba(0, 0, 0, 0.3);
  --last: #ffd34d;

  --shadow: 0 8px 24px rgba(70, 50, 20, 0.12);
  --radius: 14px;

  /* 駒の画像（JavaScript で config/game.json の画像に置き換える） */
  --piece-black: none;
  --piece-white: none;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #16191d;
    --bg-glow: #1d2227;
    --surface: #23282e;
    --surface-hover: #2b3138;
    --text: #ece8e0;
    --text-muted: #a8a399;
    --border: #3a414a;
    --primary: #23855a;
    --primary-hover: #2a9665;
    --danger: #c9473a;
    --focus: #ffb238;
    --win: #5fd394;
    --lose: #ff8a7d;

    --board-cell: #297a4c;
    --board-line: #143f27;
    --board-edge: #0f311e;
    --hint: rgba(0, 0, 0, 0.38);

    --shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  }
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background: radial-gradient(ellipse at 50% 0%, var(--bg-glow), var(--bg) 70%) fixed var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.6;
  -webkit-tap-highlight-color: transparent;
}

img {
  max-width: 100%;
}

h1,
h2,
p {
  margin: 0;
}

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.app {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.screen {
  flex: 1;
  width: 100%;
  max-width: 1120px;
  margin: 0 auto;
  padding:
    max(16px, env(safe-area-inset-top))
    max(16px, env(safe-area-inset-right))
    max(16px, env(safe-area-inset-bottom))
    max(16px, env(safe-area-inset-left));
}

/* ボタン -------------------------------------------------------------- */

.btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 48px;
  padding: 10px 18px;
  border: 2px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 16px;
  font-weight: 700;
  line-height: 1.3;
  cursor: pointer;
  touch-action: manipulation;
  transition: background-color 0.15s, border-color 0.15s, transform 0.06s;
}

.btn:hover {
  background: var(--surface-hover);
}

.btn:active {
  transform: translateY(1px);
}

.btn-primary {
  background: var(--primary);
  border-color: var(--primary);
  color: var(--on-primary);
}

.btn-primary:hover {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
}

.btn-danger {
  background: var(--danger);
  border-color: var(--danger);
  color: #fff;
}

.btn-danger:hover {
  background: var(--danger);
  filter: brightness(1.08);
}

.btn-ghost {
  background: transparent;
  border-color: transparent;
}

.btn-large {
  min-height: 56px;
  padding: 12px 28px;
  font-size: 18px;
}

.btn-small {
  min-height: 40px;
  padding: 6px 12px;
  font-size: 14px;
}

/* 駒（盤面の外でも使う） ---------------------------------------------- */

.disc {
  display: block;
  background-position: center;
  background-repeat: no-repeat;
  background-size: contain;
}

.disc.black {
  background-image: var(--piece-black);
}

.disc.white {
  background-image: var(--piece-white);
}

/* タイトル ------------------------------------------------------------ */

.screen-title {
  display: flex;
  align-items: center;
  justify-content: center;
}

.title-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  width: 100%;
  max-width: 560px;
  text-align: center;
}

.title-discs {
  display: flex;
}

.title-discs .disc {
  width: 64px;
  height: 64px;
}

.title-discs .disc + .disc {
  margin-left: -14px;
}

.title-heading {
  font-size: clamp(48px, 14vw, 88px);
  font-weight: 800;
  letter-spacing: 0.08em;
  line-height: 1.1;
  margin-right: -0.08em;
}

.title-lead {
  color: var(--text-muted);
  font-weight: 700;
}

.title-characters {
  display: flex;
  justify-content: center;
  width: 100%;
}

.title-character {
  width: clamp(60px, 17vw, 100px);
  height: auto;
  aspect-ratio: 1;
  object-fit: contain;
  margin: 0 -4px;
}

.title-buttons {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 12px;
  width: min(320px, 100%);
  margin-top: 4px;
}

.title-sub-buttons {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

/* 対戦相手選択 -------------------------------------------------------- */

.screen-select {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding-bottom: 0;
}

.screen-header {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 8px;
}

.screen-header .btn {
  justify-self: start;
  white-space: nowrap;
}

.screen-heading {
  font-size: 22px;
  font-weight: 800;
  text-align: center;
  white-space: nowrap;
}

.screen-heading:focus {
  outline: none;
}

fieldset {
  margin: 0;
  padding: 0;
  border: 0;
  min-width: 0;
}

.opponent-list {
  display: grid;
  gap: 10px;
}

.opponent {
  display: grid;
  grid-template-columns: 80px 1fr;
  align-items: center;
  gap: 12px;
  padding: 10px 14px 10px 10px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s, background-color 0.15s;
}

.opponent:hover {
  background: var(--surface-hover);
}

.opponent:has(input:checked) {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 30%, transparent);
}

.opponent:has(input:focus-visible) {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.opponent-img {
  width: 80px;
  height: 80px;
  object-fit: contain;
}

.opponent-body {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.opponent-level {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0 8px;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-muted);
}

.stars {
  color: #e2a400;
  letter-spacing: 0.05em;
}

.opponent-name {
  font-size: 19px;
  font-weight: 800;
  line-height: 1.3;
}

.opponent-intro {
  font-size: 13px;
  line-height: 1.5;
}

.opponent-record {
  font-size: 12px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

@media (min-width: 600px) {
  .opponent-list {
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  }

  .opponent {
    grid-template-columns: 1fr;
    align-content: start;
    justify-items: center;
    padding: 14px 12px;
    text-align: center;
  }

  .opponent-img {
    width: 100%;
    max-width: 150px;
    height: auto;
    aspect-ratio: 1;
  }

  .opponent-body {
    align-items: center;
  }

  .opponent-level {
    flex-direction: column;
    align-items: center;
  }
}

.side-select {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.side-legend {
  float: left;
  width: 100%;
  margin-bottom: 6px;
  text-align: center;
  font-weight: 800;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  width: min(480px, 100%);
  padding: 4px;
  border: 2px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
}

.segment {
  position: relative;
  display: flex;
}

.segment input {
  position: absolute;
  opacity: 0;
  inset: 0;
  margin: 0;
  cursor: pointer;
}

.segment span {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 4px 6px;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 700;
  text-align: center;
  line-height: 1.3;
  cursor: pointer;
  transition: background-color 0.15s, color 0.15s;
}

.segment input:checked + span {
  background: var(--primary);
  color: var(--on-primary);
}

.segment input:focus-visible + span {
  outline: 3px solid var(--focus);
  outline-offset: 1px;
}

.select-footer {
  position: sticky;
  bottom: 0;
  display: flex;
  justify-content: center;
  margin: 0 -16px;
  padding: 12px 16px max(16px, env(safe-area-inset-bottom));
  background: linear-gradient(to bottom, transparent, var(--bg) 30%);
}

.select-footer .btn {
  width: min(360px, 100%);
}

/* 対局 ---------------------------------------------------------------- */

.screen-game {
  --pad-x: 12px;
  --coord-size: 16px;
  --board-border: 6px;
  --board-padding: 2px;
  --cell-gap: 2px;
  /* 盤面の枠の外側の分（枠の太さ + 内側の余白） */
  --board-frame: calc(2 * (var(--board-border) + var(--board-padding)));
  /* 盤面のマスの部分の一辺: 画面の幅と高さから決める（最小280px、最大640px） */
  --grid-size: clamp(280px, min(calc(100vw - 2 * var(--pad-x) - var(--coord-size) - var(--board-frame)), calc(100vh - 300px)), 640px);
  --board-size: calc(var(--grid-size) + var(--board-frame));
  display: flex;
  justify-content: center;
  padding:
    max(8px, env(safe-area-inset-top))
    max(var(--pad-x), env(safe-area-inset-right))
    max(12px, env(safe-area-inset-bottom))
    max(var(--pad-x), env(safe-area-inset-left));
  max-width: none;
}

@supports (height: 100dvh) {
  .screen-game {
    --grid-size: clamp(280px, min(calc(100vw - 2 * var(--pad-x) - var(--coord-size) - var(--board-frame)), calc(100dvh - 300px)), 640px);
  }
}

/* 幅の狭いスマホ（幅320pxなど）: 枠と線を細くして、1マスを約35pxにする */
@media (max-width: 359px) {
  .screen-game {
    --pad-x: 8px;
    --coord-size: 12px;
    --board-border: 4px;
    --board-padding: 1px;
    --cell-gap: 1px;
  }

  .coords {
    font-size: 10px;
  }
}

/* 高さの低い縦長の画面: キャラクターの表示を小さくする */
@media (orientation: portrait) and (max-height: 700px) {
  .char-panel {
    min-height: 72px;
  }

  .char-img {
    width: 68px;
    height: 68px;
  }

  .game-layout {
    gap: 8px;
  }

  .info-panel {
    gap: 6px;
  }

  .game-buttons .btn {
    min-height: 44px;
  }
}

/* 縦長の画面: 上からキャラクターとセリフ、盤面、石の数とボタン */
.game-layout {
  display: grid;
  grid-template-areas:
    "char"
    "board"
    "info";
  justify-items: center;
  align-content: start;
  gap: 10px;
  width: calc(var(--board-size) + var(--coord-size));
  max-width: 100%;
}

.char-panel {
  grid-area: char;
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 92px;
}

.char-img {
  width: 84px;
  height: 84px;
  object-fit: contain;
}

.char-body {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  min-width: 0;
}

.char-name {
  font-weight: 800;
  font-size: 15px;
  line-height: 1.2;
}

.bubble {
  position: relative;
  max-width: 100%;
  padding: 6px 12px;
  border: 2px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  font-size: 14px;
  font-weight: 700;
  line-height: 1.5;
  box-shadow: var(--shadow);
}

/* 吹き出しのしっぽ（左のキャラクターを指す） */
.bubble::before,
.bubble::after {
  content: "";
  position: absolute;
  top: 50%;
  border-style: solid;
  transform: translateY(-50%);
}

.bubble::before {
  left: -11px;
  border-width: 7px 11px 7px 0;
  border-color: transparent var(--border) transparent transparent;
}

.bubble::after {
  left: -7px;
  border-width: 5px 8px 5px 0;
  border-color: transparent var(--surface) transparent transparent;
}

.bubble.pop {
  animation: pop 0.25s ease-out;
}

@keyframes pop {
  from {
    opacity: 0;
    transform: scale(0.88);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.board-panel {
  grid-area: board;
}

.board-frame {
  position: relative;
  display: grid;
  grid-template-columns: var(--coord-size) var(--board-size);
  grid-template-rows: var(--coord-size) var(--board-size);
}

.coords {
  display: grid;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
  user-select: none;
}

.coords-cols {
  grid-column: 2;
  grid-row: 1;
  grid-template-columns: repeat(8, 1fr);
  align-items: center;
  justify-items: center;
  padding: 0 calc(var(--board-border) + var(--board-padding));
}

.coords-rows {
  grid-column: 1;
  grid-row: 2;
  grid-template-rows: repeat(8, 1fr);
  align-items: center;
  justify-items: center;
  padding: calc(var(--board-border) + var(--board-padding)) 0;
}

.board {
  grid-column: 2;
  grid-row: 2;
  position: relative;
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  grid-template-rows: repeat(8, minmax(0, 1fr));
  gap: var(--cell-gap);
  width: var(--board-size);
  height: var(--board-size);
  padding: var(--board-padding);
  border: var(--board-border) solid var(--board-edge);
  border-radius: 10px;
  background: var(--board-line);
  box-shadow: var(--shadow);
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}

.cell {
  appearance: none;
  position: relative;
  display: grid;
  place-items: center;
  min-width: 0;
  min-height: 0;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 2px;
  background: var(--board-cell);
  color: inherit;
  font: inherit;
  cursor: default;
}

.cell > .disc,
.cell::before,
.cell::after {
  grid-area: 1 / 1;
}

.cell .disc {
  width: 88%;
  height: 88%;
  pointer-events: none;
}

/* 置ける場所の小さな点 */
.cell.hint::after {
  content: "";
  width: 26%;
  height: 26%;
  border-radius: 50%;
  background: var(--hint);
  pointer-events: none;
}

.board.interactive .cell.placeable {
  cursor: pointer;
}

/* マウスで置ける場所に乗せたとき、置く石をうすく表示する */
@media (hover: hover) and (pointer: fine) {
  .board.interactive .cell.placeable:hover::before {
    content: "";
    width: 88%;
    height: 88%;
    background: center / contain no-repeat;
    opacity: 0.45;
    pointer-events: none;
  }

  .board.player-black.interactive .cell.placeable:hover::before {
    background-image: var(--piece-black);
  }

  .board.player-white.interactive .cell.placeable:hover::before {
    background-image: var(--piece-white);
  }

  .board.interactive .cell.placeable:hover::after {
    display: none;
  }
}

/* 直前の手 */
.cell.last {
  box-shadow: inset 0 0 0 3px var(--last);
}

.cell:focus-visible {
  z-index: 2;
  outline: 3px solid var(--focus);
  outline-offset: -3px;
}

/* 盤面の4つの点 */
.board-dots {
  position: absolute;
  inset: var(--board-padding);
  z-index: 1;
  pointer-events: none;
  background:
    radial-gradient(circle at 25% 25%, var(--board-line) 0 3px, transparent 3.5px),
    radial-gradient(circle at 75% 25%, var(--board-line) 0 3px, transparent 3.5px),
    radial-gradient(circle at 25% 75%, var(--board-line) 0 3px, transparent 3.5px),
    radial-gradient(circle at 75% 75%, var(--board-line) 0 3px, transparent 3.5px);
}

/* パスなどのお知らせ（盤面の中央に表示） */
.toast {
  position: absolute;
  inset: 0;
  z-index: 5;
  width: fit-content;
  max-width: 86%;
  height: fit-content;
  margin: auto;
  padding: 14px 20px;
  border-radius: 14px;
  background: rgba(20, 22, 26, 0.9);
  color: #fff;
  font-size: 16px;
  font-weight: 800;
  line-height: 1.5;
  text-align: center;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
  pointer-events: none;
}

.toast.pop {
  animation: pop 0.2s ease-out;
}

.info-panel {
  grid-area: info;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
}

.scores {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.score {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  padding: 6px 12px 6px 8px;
  border: 2px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  transition: border-color 0.2s, box-shadow 0.2s;
}

.score.active {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 25%, transparent);
}

.score .disc {
  width: 28px;
  height: 28px;
}

.score-label {
  display: flex;
  flex-direction: column;
  min-width: 0;
  line-height: 1.25;
}

.score-color {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 700;
}

.score-owner {
  overflow: hidden;
  font-size: 14px;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.score-count {
  font-size: 26px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.turn-status {
  min-height: 1.6em;
  font-weight: 800;
  text-align: center;
}

.game-buttons {
  display: flex;
  justify-content: center;
  gap: 10px;
}

.game-buttons .btn {
  flex: 1;
  max-width: 200px;
}

/* 横長の画面（幅900px以上、またはスマホを横にしたとき）: 左に盤面、右にキャラクターなど */
@media (min-width: 900px), (orientation: landscape) and (max-height: 600px) and (min-width: 560px) {
  .screen-game {
    --grid-size: clamp(280px, min(calc(100vw - 440px), calc(100vh - 56px - var(--board-frame))), 640px);
    align-items: center;
  }

  @supports (height: 100dvh) {
    .screen-game {
      --grid-size: clamp(280px, min(calc(100vw - 440px), calc(100dvh - 56px - var(--board-frame))), 640px);
    }
  }

  .game-layout {
    grid-template-areas:
      "board char"
      "board info";
    grid-template-columns: auto minmax(220px, 340px);
    grid-template-rows: 1fr auto;
    align-items: end;
    column-gap: clamp(16px, 3vw, 36px);
    row-gap: 16px;
    width: auto;
  }

  .char-panel {
    grid-template-columns: 1fr;
    justify-items: center;
    align-self: end;
    text-align: center;
  }

  .char-img {
    width: clamp(96px, 26vh, 240px);
    height: clamp(96px, 26vh, 240px);
  }

  .char-body {
    align-items: center;
    width: 100%;
  }

  .char-name {
    font-size: 18px;
  }

  .bubble {
    font-size: 15px;
  }

  /* 対局画面ではキャラクターの下に吹き出しがあるので、しっぽを上（キャラクター）に向ける。
     結果の画面はキャラクターの右に吹き出しがあるので、左向きのまま */
  .char-panel .bubble::before,
  .char-panel .bubble::after {
    top: auto;
    left: 50%;
    transform: translateX(-50%);
  }

  .char-panel .bubble::before {
    top: -11px;
    border-width: 0 7px 11px;
    border-color: transparent transparent var(--border);
  }

  .char-panel .bubble::after {
    top: -7px;
    border-width: 0 5px 8px;
    border-color: transparent transparent var(--surface);
  }

  .board-panel {
    align-self: center;
  }

  .info-panel {
    align-self: start;
  }

  .scores {
    grid-template-columns: 1fr;
  }

  .game-buttons {
    flex-wrap: wrap;
  }

  .game-buttons .btn {
    max-width: none;
  }
}

/* スマホを横にしたとき（高さが低い）は余白を詰める */
@media (orientation: landscape) and (max-height: 600px) and (min-width: 560px) {
  .screen-game {
    --board-border: 4px;
    --board-padding: 1px;
    --cell-gap: 1px;
    --grid-size: clamp(280px, min(calc(100vw - 300px), calc(100vh - 36px - var(--board-frame))), 640px);
    padding-top: max(8px, env(safe-area-inset-top));
    padding-bottom: max(8px, env(safe-area-inset-bottom));
  }

  @supports (height: 100dvh) {
    .screen-game {
      --grid-size: clamp(280px, min(calc(100vw - 300px), calc(100dvh - 36px - var(--board-frame))), 640px);
    }
  }

  .game-layout {
    grid-template-columns: auto minmax(200px, 300px);
    row-gap: 8px;
  }

  .char-panel {
    min-height: 0;
  }

  .char-img {
    width: clamp(64px, 24vh, 120px);
    height: clamp(64px, 24vh, 120px);
  }

  .scores {
    grid-template-columns: 1fr 1fr;
  }

  .score .disc {
    width: 22px;
    height: 22px;
  }

  .score-count {
    font-size: 22px;
  }

  .game-buttons .btn {
    min-height: 42px;
  }
}

/* ダイアログ ---------------------------------------------------------- */

.dialog {
  width: min(460px, calc(100vw - 32px));
  max-height: calc(100vh - 32px);
  max-height: calc(100dvh - 32px);
  padding: 22px;
  border: 0;
  border-radius: 18px;
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  overflow: auto;
}

.dialog::backdrop {
  background: rgba(10, 12, 15, 0.55);
}

.dialog[open] {
  animation: pop 0.2s ease-out;
}

.dialog-title {
  margin-bottom: 12px;
  font-size: 20px;
  font-weight: 800;
}

.dialog-body {
  margin-bottom: 18px;
}

.dialog-buttons {
  display: flex;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 10px;
}

.howto ul {
  margin: 0;
  padding-left: 1.2em;
}

.howto li + li {
  margin-top: 8px;
}

.menu-buttons {
  display: grid;
  gap: 10px;
}

/* 設定のスイッチ */
.settings {
  display: grid;
  gap: 8px;
}

.switch {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 52px;
  padding: 6px 4px;
  font-weight: 700;
  cursor: pointer;
}

.switch input {
  position: absolute;
  right: 0;
  width: 56px;
  height: 32px;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}

.switch-track {
  position: relative;
  flex: none;
  width: 56px;
  height: 32px;
  border-radius: 16px;
  background: var(--border);
  transition: background-color 0.2s;
}

.switch-track::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
  transition: transform 0.2s;
}

.switch input:checked + .switch-track {
  background: var(--primary);
}

.switch input:checked + .switch-track::after {
  transform: translateX(24px);
}

.switch input:focus-visible + .switch-track {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

/* 結果 */
.result {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  text-align: center;
}

.result-title {
  font-size: 30px;
  font-weight: 800;
  line-height: 1.3;
}

.dialog-result[data-outcome="win"] .result-title {
  color: var(--win);
}

.dialog-result[data-outcome="lose"] .result-title {
  color: var(--lose);
}

.result-score {
  display: flex;
  align-items: baseline;
  justify-content: center;
  flex-wrap: wrap;
  gap: 4px 12px;
}

.result-side {
  font-weight: 700;
  color: var(--text-muted);
}

.result-numbers {
  font-size: 34px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
}

.result-character {
  display: grid;
  grid-template-columns: 110px 1fr;
  align-items: center;
  gap: 12px;
  width: 100%;
  text-align: left;
}

.result-img {
  width: 110px;
  height: 110px;
  object-fit: contain;
}

.bubble-result {
  justify-self: start;
}

.result-buttons {
  display: grid;
  gap: 10px;
  width: 100%;
  margin-top: 6px;
}

@media (orientation: landscape) and (max-height: 600px) {
  .dialog {
    padding: 14px 18px;
  }

  .result {
    gap: 6px;
  }

  .result-img {
    width: 72px;
    height: 72px;
  }

  .result-character {
    grid-template-columns: 72px 1fr;
  }

  .result-buttons {
    grid-template-columns: 1fr 1fr 1fr;
  }

  .result-buttons .btn {
    min-height: 44px;
    padding: 8px 10px;
    font-size: 15px;
  }
}

/* その他 -------------------------------------------------------------- */

.noscript,
body.load-error .app {
  padding: 24px;
  font-weight: 700;
  text-align: center;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
