/* キツネとガチョウ（Fox and Geese）固有スタイル（ネオン強度：中程度） */

.game-panel {
  margin-top: 20px;
}

.fg-settings {
  max-width: min(100%, 560px);
  margin: 0 auto 14px;
  display: grid;
  gap: 14px;
}

.fg-settings .field-label {
  margin-bottom: 8px;
}

.fg-field {
  margin: 0;
}

.option-tabs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  max-width: 420px;
}

.option-tabs--level {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  max-width: 520px;
}

.option-tab {
  appearance: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-height: 48px;
  padding: 8px 6px;
  border: 1px solid var(--md-sys-color-outline-variant);
  border-radius: var(--md-sys-shape-corner-medium);
  background: var(--md-sys-color-surface);
  color: var(--md-sys-color-on-surface);
  font: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease, transform 0.04s ease;
}

.option-tab small {
  font-size: 0.7rem;
  font-weight: 500;
  opacity: 0.75;
}

.option-tab:hover {
  background: var(--md-sys-color-primary-container);
}

.option-tab:active {
  transform: translateY(1px);
}

.option-tab.is-active {
  background: var(--md-sys-color-primary);
  border-color: var(--md-sys-color-primary);
  color: var(--md-sys-color-on-primary);
}

.option-tab:focus-visible {
  outline: 2px solid var(--md-sys-color-primary);
  outline-offset: 2px;
}

/* ---- ステータス ---- */

.fg-status {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px 16px;
  max-width: min(100%, 560px);
  margin: 0 auto 10px;
  padding: 12px 14px;
  border: 1px solid var(--md-sys-color-outline-variant);
  border-radius: var(--md-sys-shape-corner-medium);
  background: var(--md-sys-color-surface);
}

.fg-scores {
  display: flex;
  gap: 8px;
  min-width: 0;
}

.fg-score {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  min-width: 6.4rem;
  padding: 6px 10px;
  border-radius: var(--md-sys-shape-corner-medium);
}

.fg-score--fox {
  background: color-mix(in srgb, #fb923c 12%, var(--md-sys-color-surface));
  border: 1px solid color-mix(in srgb, #fb923c 42%, transparent);
}

.fg-score--goose {
  background: color-mix(in srgb, #22d3ee 10%, var(--md-sys-color-surface));
  border: 1px solid color-mix(in srgb, #22d3ee 38%, transparent);
}

.fg-score__label {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--md-sys-color-on-surface-variant);
  font-size: 0.72rem;
  font-weight: 700;
  white-space: nowrap;
}

.fg-score__label .fg-piece {
  width: 16px;
  height: 16px;
}

.fg-score__value {
  color: var(--md-sys-color-on-surface);
  font-size: 0.82rem;
  font-weight: 700;
  white-space: nowrap;
}

.fg-score__value strong {
  font-size: 1.15rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.fg-status__main {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  min-width: 0;
}

.fg-status__text {
  margin: 0;
  color: var(--md-sys-color-on-surface);
  font-size: 0.92rem;
  font-weight: 700;
  text-align: right;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--md-sys-color-primary) 14%, var(--md-sys-color-surface));
  color: var(--md-sys-color-on-surface);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.status-pill.is-fox {
  background: linear-gradient(135deg, #fb923c, #c2410c);
  color: #fff;
}

.status-pill.is-goose {
  background: linear-gradient(135deg, #22d3ee, #0284c7);
  color: #fff;
}

.status-pill.is-draw {
  background: #64748b;
  color: #fff;
}

.status-pill.is-win {
  background: color-mix(in srgb, var(--success, #16a34a) 18%, var(--md-sys-color-surface));
  color: var(--success, #15803d);
}

.status-pill.is-lose {
  background: color-mix(in srgb, #ef4444 16%, var(--md-sys-color-surface));
  color: #b91c1c;
}

.fg-guide {
  max-width: min(100%, 560px);
  margin: 0 auto 12px;
  text-align: center;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--md-sys-color-on-surface);
}

.fg-result {
  max-width: min(100%, 560px);
  margin: 0 auto 14px;
  padding: 14px 16px;
  border-radius: var(--md-sys-shape-corner-medium);
  border: 1px solid var(--md-sys-color-outline-variant);
  background: var(--md-sys-color-surface);
  text-align: center;
  animation: fg-result-in 200ms ease-out;
}

.fg-result.is-fox {
  border-color: color-mix(in srgb, #fb923c 45%, var(--md-sys-color-outline-variant));
  background: color-mix(in srgb, #fb923c 7%, var(--md-sys-color-surface));
}

.fg-result.is-goose {
  border-color: color-mix(in srgb, #22d3ee 45%, var(--md-sys-color-outline-variant));
  background: color-mix(in srgb, #22d3ee 8%, var(--md-sys-color-surface));
}

.fg-result.is-draw {
  border-color: color-mix(in srgb, #94a3b8 45%, var(--md-sys-color-outline-variant));
}

.fg-result__title {
  margin: 0 0 6px;
  font-size: 1.1rem;
  font-weight: 800;
  line-height: 1.45;
}

.fg-result__detail {
  margin: 0 0 12px;
  color: var(--md-sys-color-on-surface-variant);
  font-size: 0.92rem;
  font-weight: 600;
}

.fg-result__actions {
  display: flex;
  justify-content: center;
}

@keyframes fg-result-in {
  from {
    opacity: 0;
    transform: translateY(-4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ---- 連続捕獲 ---- */

.fg-chain {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 8px 12px;
  max-width: min(100%, 560px);
  margin: 12px auto 0;
  padding: 10px 12px;
  border: 1px solid color-mix(in srgb, #ec4899 50%, transparent);
  border-radius: var(--md-sys-shape-corner-medium);
  background: color-mix(in srgb, #ec4899 8%, var(--md-sys-color-surface));
}

.fg-chain[hidden] {
  display: none;
}

.fg-chain__text {
  flex: 1 1 100%;
  margin: 0;
  color: #be185d;
  font-size: 0.88rem;
  font-weight: 700;
  text-align: center;
}

.fg-chain .btn {
  min-width: 10rem;
  min-height: 44px;
}

/* ---- 凡例 ---- */

.fg-legend {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px 16px;
  max-width: min(100%, 560px);
  margin: 0 auto 14px;
  padding: 0;
  list-style: none;
  color: var(--md-sys-color-on-surface-variant);
  font-size: 0.8rem;
  font-weight: 600;
}

.fg-legend__item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.fg-legend__item .fg-piece {
  width: 18px;
  height: 18px;
}

.fg-legend__dot {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #22d3ee;
  border: 2px solid #a5f3fc;
}

.fg-legend__dot--capture {
  border-radius: 3px;
  background: #f472b6;
  border-color: #fbcfe8;
  transform: rotate(45deg);
}

/* ---- 盤面 ---- */

.fg-board-wrap {
  max-width: min(100%, 500px);
  margin: 0 auto;
}

.fg-board {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: 18px;
  background:
    radial-gradient(110% 80% at 15% 0%, rgba(56, 189, 248, 0.16), transparent 55%),
    radial-gradient(110% 80% at 85% 100%, rgba(168, 85, 247, 0.14), transparent 55%),
    linear-gradient(160deg, #15284f 0%, #0f1c38 55%, #0c1630 100%);
  border: 1px solid rgba(56, 189, 248, 0.38);
  box-shadow:
    0 0 0 1px rgba(15, 23, 42, 0.35),
    0 12px 28px rgba(15, 23, 42, 0.28);
  box-sizing: border-box;
}

.fg-board-grid {
  position: absolute;
  inset: 7%;
}

.fg-lines {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
  pointer-events: none;
}

.fg-area {
  fill: rgba(56, 189, 248, 0.06);
  stroke: rgba(129, 140, 248, 0.35);
  stroke-width: 1;
  stroke-linejoin: round;
  vector-effect: non-scaling-stroke;
}

.fg-line {
  stroke: rgba(125, 211, 252, 0.55);
  stroke-width: 1.6;
  stroke-linecap: round;
  vector-effect: non-scaling-stroke;
}

.fg-point {
  --point-size: clamp(36px, 10.5vw, 56px);
  appearance: none;
  position: absolute;
  z-index: 1;
  display: grid;
  place-items: center;
  width: var(--point-size);
  height: var(--point-size);
  margin: 0;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: transparent;
  transform: translate(-50%, -50%);
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.fg-point:disabled {
  cursor: default;
}

.fg-point:focus-visible {
  outline: 2px solid #67e8f9;
  outline-offset: 2px;
}

/* 空き交点 */
.fg-point::before {
  content: '';
  position: absolute;
  left: 50%;
  top: 50%;
  width: 22%;
  height: 22%;
  border-radius: 50%;
  background: rgba(148, 163, 184, 0.45);
  border: 1.5px solid rgba(186, 230, 253, 0.5);
  transform: translate(-50%, -50%);
  box-sizing: border-box;
  transition: background 0.12s ease, box-shadow 0.12s ease;
}

.fg-point.has-fox::before,
.fg-point.has-goose::before {
  display: none;
}

/* 駒 */
.fg-piece {
  display: block;
  overflow: visible;
}

.fg-point .fg-piece {
  position: relative;
  width: 82%;
  height: 82%;
  border-radius: 50%;
  transition: filter 0.12s ease, transform 0.12s ease;
}

.fg-fox__head {
  fill: #fb923c;
  stroke: #fff7ed;
  stroke-width: 1.6;
  stroke-linejoin: round;
}

.fg-fox__ear {
  fill: #fed7aa;
}

.fg-fox__muzzle {
  fill: #fff7ed;
}

.fg-fox__eye {
  fill: #431407;
}

.fg-goose__body {
  fill: #f8fafc;
  stroke: #38bdf8;
  stroke-width: 2.4;
}

.fg-goose__beak {
  fill: #fbbf24;
  stroke: #b45309;
  stroke-width: 0.8;
  stroke-linejoin: round;
}

.fg-goose__eye {
  fill: #0f172a;
}

.fg-goose__wing {
  fill: none;
  stroke: #94a3b8;
  stroke-width: 2;
  stroke-linecap: round;
}

.fg-point.has-fox .fg-piece {
  filter: drop-shadow(0 0 6px rgba(251, 146, 60, 0.45));
}

.fg-point.has-goose .fg-piece {
  filter: drop-shadow(0 1px 2px rgba(2, 6, 23, 0.5));
}

/* 動かせる駒 */
.fg-point.is-movable::after {
  content: '';
  position: absolute;
  inset: 4%;
  border-radius: 50%;
  border: 2px dashed rgba(103, 232, 249, 0.6);
  pointer-events: none;
}

.fg-point.is-movable:hover .fg-piece {
  transform: scale(1.06);
}

/* 選択中 */
.fg-point.is-selected::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 3px solid #67e8f9;
  box-shadow: 0 0 14px rgba(34, 211, 238, 0.6);
  pointer-events: none;
}

/* 移動先・捕獲先 */
.fg-point.is-move::before {
  width: 36%;
  height: 36%;
  background: rgba(34, 211, 238, 0.85);
  border: 2px solid rgba(165, 243, 252, 0.95);
  box-shadow: 0 0 10px rgba(34, 211, 238, 0.55);
}

.fg-point.is-capture::before {
  width: 34%;
  height: 34%;
  border-radius: 4px;
  background: rgba(244, 114, 182, 0.92);
  border: 2px solid rgba(251, 207, 232, 0.95);
  box-shadow: 0 0 12px rgba(236, 72, 153, 0.6);
  transform: translate(-50%, -50%) rotate(45deg);
}

.fg-point.is-move:hover::before,
.fg-point.is-capture:hover::before {
  box-shadow: 0 0 16px rgba(255, 255, 255, 0.5);
}

/* 捕獲対象のガチョウ */
.fg-point.is-prey::after {
  content: '';
  position: absolute;
  inset: 2%;
  border-radius: 50%;
  border: 3px solid #f472b6;
  box-shadow: 0 0 12px rgba(236, 72, 153, 0.55);
  pointer-events: none;
}

/* 最終手 */
.fg-point.is-last-to .fg-piece {
  outline: 2px solid rgba(192, 132, 252, 0.85);
  outline-offset: 2px;
}

.fg-point.is-last-from::before {
  width: 30%;
  height: 30%;
  background: transparent;
  border: 2px solid rgba(192, 132, 252, 0.75);
}

.fg-point.is-last-capture::before {
  width: 30%;
  height: 30%;
  background: rgba(244, 114, 182, 0.18);
  border: 2px dashed rgba(244, 114, 182, 0.7);
}

.fg-howto {
  margin-top: 12px;
  color: var(--md-sys-color-on-surface-variant);
  font-size: 0.9rem;
}

@media (max-width: 560px) {
  .option-tabs--level {
    gap: 6px;
  }

  .fg-status {
    flex-direction: column;
    align-items: stretch;
    padding: 10px;
  }

  .fg-status__main {
    align-items: flex-start;
  }

  .fg-status__text {
    text-align: left;
  }

  .fg-scores {
    width: 100%;
  }

  .fg-score {
    flex: 1 1 0;
    min-width: 0;
  }

  .fg-score__label {
    justify-content: center;
    white-space: normal;
    text-align: center;
  }

  .fg-board-grid {
    inset: 6%;
  }

  .fg-point {
    --point-size: clamp(32px, 10.5vw, 50px);
  }
}

@media (prefers-reduced-motion: reduce) {
  .fg-result {
    animation: none;
  }
}

/* 外枠・HUD・ボタンは共通テーマ。交点盤と陣営選択のみ固有の配置を使う。 */
html.gs-playing .game-panel { align-items: center; }
html.gs-playing .game-panel > .gs-bar,
html.gs-playing .game-panel > .gs-hud,
html.gs-playing .game-controls,
.fg-stage { width: 100%; max-width: 640px; flex: none; }
html.gs-playing .gs-bar { align-items: flex-start; gap: 10px; }
html.gs-playing .fg-settings { flex: 1; min-width: 0; max-width: none; margin: 0; gap: 6px; }
html.gs-playing .fg-settings .field-label { display: none; }
html.gs-playing .option-tabs { max-width: none; gap: 6px; }
html.gs-playing .option-tab { min-height: 44px; padding: 4px; gap: 0; border-color: var(--play-border); background: var(--play-hud-bg); color: var(--play-text); font-size: .8125rem; }
html.gs-playing .option-tab small { font-size: .6875rem; }
html.gs-playing .option-tab.is-active { border-color: var(--play-accent); background: color-mix(in srgb, var(--play-accent) 18%, var(--play-hud-bg)); color: var(--play-accent); }
html.gs-playing .option-tab:focus-visible { outline-color: var(--play-accent); }
html.gs-playing .gs-hud__value { font-size: 1rem; }
html.gs-playing .status-pill { min-width: 0; padding: 0; background: none; font-size: 1rem; }
html.gs-playing .status-pill.is-fox { color: #fbbf24; }
html.gs-playing .status-pill.is-goose { color: var(--play-accent); }
html.gs-playing .fg-status__text,
html.gs-playing .fg-guide { flex: none; width: 100%; max-width: 640px; margin: 0; color: var(--play-text); text-align: center; font-size: .8125rem; line-height: 1.5; }
html.gs-playing .fg-status__text { min-height: 1.5em; }
html.gs-playing .fg-guide { min-height: 3em; margin: 6px 0; }
html.gs-playing .fg-legend { flex: none; margin: 0 auto 8px; color: var(--play-text-muted); font-size: .75rem; gap: 4px 12px; }
.fg-stage { position: relative; }
html.gs-playing .fg-board-wrap { width: min(100%, max(180px, calc(100dvh - 400px))); max-width: 480px; }
html.gs-playing .fg-board { border-color: var(--play-border); }
html.gs-playing .fg-point { --point-size: clamp(30px, 10vw, 56px); }
html.gs-playing .fg-howto { display: none; }
html.gs-playing .game-controls { justify-content: center; margin: 12px 0 0; }
html.gs-playing .fg-result { position: absolute; inset: 0; z-index: 3; max-width: none; margin: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; border-color: var(--play-border); background: rgba(8, 15, 31, .95); color: var(--play-text); }
html.gs-playing .fg-result__detail { color: var(--play-text-muted); }
@media (min-width: 768px) and (min-height: 600px) {
  html.gs-playing .game-panel { padding-top: max(clamp(24px, 5vh, 56px), env(safe-area-inset-top)); }
  html.gs-playing .game-panel > .gs-bar { margin-bottom: 24px; }
  html.gs-playing .game-panel > .gs-hud { margin-bottom: 18px; }
  html.gs-playing .fg-guide { margin: 10px 0; }
  html.gs-playing .fg-legend { margin-bottom: 16px; }
  html.gs-playing .fg-board-wrap { width: min(100%, max(180px, calc(100dvh - 480px))); }
}
@media (orientation: landscape) and (max-height: 500px) {
  html.gs-playing .game-panel { display: grid; grid-template-columns: minmax(240px, 300px) minmax(0, 340px); grid-template-areas: "bar board" "hud board" "status board" "chain legend" "guide controls"; gap: 4px 16px; align-content: start; justify-content: center; }
  html.gs-playing .game-panel > .gs-bar { grid-area: bar; }
  html.gs-playing .gs-hud { grid-area: hud; }
  html.gs-playing .fg-status__text { grid-area: status; }
  html.gs-playing .fg-guide { grid-area: guide; margin: 0; }
  html.gs-playing .fg-stage { grid-area: board; }
  html.gs-playing .fg-board-wrap { width: min(100%, calc(100dvh - 115px)); }
  html.gs-playing .fg-legend { grid-area: legend; margin: 0; }
  html.gs-playing .game-controls { grid-area: controls; margin: 0; }
}
@media (max-height: 650px) and (orientation: portrait) {
  html.gs-playing .game-panel > .gs-bar,
  html.gs-playing .game-panel > .gs-hud { margin-bottom: 4px; }
  html.gs-playing .option-tab small { display: none; }
  html.gs-playing .fg-guide { margin: 2px 0; }
  html.gs-playing .fg-legend { margin-bottom: 4px; font-size: .6875rem; }
  html.gs-playing .game-controls { margin-top: 6px; }
}

html.gs-playing .fg-settings { gap: 4px; }
html.gs-playing .fg-settings small { display: none; }
html.gs-playing .gs-hud__label { text-align: center; overflow-wrap: anywhere; }
html.gs-playing .fg-guide { min-height: 3em; }
html.gs-playing .fg-chain { display: flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; margin: 6px 0 0; padding: 0; border: 0; background: none; width: 100%; max-width: 640px; flex: none; }
html.gs-playing .fg-chain[hidden] { display: flex !important; visibility: hidden; pointer-events: none; }
html.gs-playing .fg-chain__text { display: none; }
html.gs-playing .fg-legend { font-size: .6875rem; }
html.gs-playing .fg-board-wrap { width: min(100%, max(180px, calc(100dvh - 470px))); }
@media (min-width: 768px) and (min-height: 600px) {
  html.gs-playing .fg-board-wrap { width: min(100%, max(180px, calc(100dvh - 550px))); }
}
@media (max-width: 600px) { html.gs-playing .fg-guide { min-height: 4.5em; } }
@media (orientation: landscape) and (max-height: 500px) {
  html.gs-playing .fg-chain { grid-area: chain; margin: 0; }
  html.gs-playing .fg-board-wrap { width: min(100%, calc(100dvh - 115px)); }
}
@media (max-width: 600px) and (orientation: portrait) {
  html.gs-playing .fg-settings { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  html.gs-playing #difficulty-field,
  html.gs-playing .fg-settings:has(#side-field[hidden]) .fg-field:first-child { grid-column: 1 / -1; }
  html.gs-playing .option-tab { font-size: .75rem; }
}

/* 連続捕獲の操作も同じ操作列に領域を確保する。 */
html.gs-playing .game-controls { gap: 8px; }
html.gs-playing .fg-chain { width: auto; max-width: none; margin: 0; }
html.gs-playing .fg-chain .btn { min-width: 0; padding-inline: 12px; }
@media (max-height: 650px) and (orientation: portrait) {
  html.gs-playing .fg-guide { font-size: .75rem; line-height: 1.4; min-height: 4.2em; }
  html.gs-playing .gs-hud__label { font-size: .625rem; }
}
@media (orientation: landscape) and (max-height: 500px) {
  html.gs-playing .fg-board-wrap { width: min(100%, calc(100dvh - 160px)); }
  html.gs-playing .game-panel { grid-template-areas: "bar board" "hud board" "status board" "guide legend" "controls legend"; }
}
@media (orientation: landscape) and (max-height: 500px) {
  html.gs-playing .fg-settings { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  html.gs-playing #difficulty-field,
  html.gs-playing .fg-settings:has(#side-field[hidden]) .fg-field:first-child { grid-column: 1 / -1; }
  html.gs-playing .option-tab { font-size: .75rem; }
}
