/* コナネ（Kōnane）固有スタイル（ネオン強度：中程度） */

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

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

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

.kn-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;
}

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

.kn-status {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px 16px;
  max-width: min(100%, 520px);
  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);
}

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

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

.kn-score--black {
  background: color-mix(in srgb, #1f2937 10%, var(--md-sys-color-surface));
  border: 1px solid color-mix(in srgb, #1f2937 35%, transparent);
}

.kn-score--white {
  background: color-mix(in srgb, #22d3ee 10%, var(--md-sys-color-surface));
  border: 1px solid color-mix(in srgb, #94a3b8 50%, transparent);
}

.kn-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;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.kn-score__label .kn-stone {
  width: 12px;
  height: 12px;
  border-width: 1px;
}

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

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

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

.kn-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-black {
  background: #1f2937;
  color: #f8fafc;
}

.status-pill.is-white {
  background: #f8fafc;
  color: #1f2937;
  box-shadow: inset 0 0 0 1px #94a3b8;
}

.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;
}

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

.kn-result {
  max-width: min(100%, 520px);
  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: kn-result-in 200ms ease-out;
}

.kn-result.is-black {
  border-color: color-mix(in srgb, #1f2937 40%, var(--md-sys-color-outline-variant));
  background: color-mix(in srgb, #1f2937 6%, var(--md-sys-color-surface));
}

.kn-result.is-white {
  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));
}

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

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

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

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

/* ---- 連続ジャンプ案内 ---- */

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

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

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

.kn-chain .btn {
  flex: 1 1 0;
  min-width: 9rem;
  min-height: 44px;
}

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

.kn-board-wrap {
  display: flex;
  justify-content: center;
  max-width: min(100%, 520px);
  margin: 0 auto 12px;
}

.kn-frame {
  --kn-pad: 8px;
  --kn-gap: 3px;
  display: grid;
  grid-template-columns: 16px minmax(0, 1fr);
  grid-template-rows: 16px auto;
  gap: 4px;
  width: 100%;
  padding: 10px 12px 12px 8px;
  border: 2px solid color-mix(in srgb, #38bdf8 65%, #0ea5e9);
  border-radius: 18px;
  background: linear-gradient(160deg, #14284f 0%, #0d1a36 55%, #0a1428 100%);
  box-shadow:
    0 0 0 1px rgba(56, 189, 248, 0.18),
    0 0 14px rgba(56, 189, 248, 0.16),
    0 10px 28px rgba(8, 20, 48, 0.28);
}

.kn-coords {
  display: grid;
  gap: var(--kn-gap);
  color: #93b4dc;
  font-family: Outfit, "Noto Sans JP", sans-serif;
  font-size: 0.7rem;
  font-weight: 600;
  line-height: 1;
}

.kn-coords span {
  display: flex;
  align-items: center;
  justify-content: center;
}

.kn-coords--cols {
  grid-column: 2;
  grid-row: 1;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  padding: 0 var(--kn-pad);
}

.kn-coords--rows {
  grid-column: 1;
  grid-row: 2;
  grid-template-rows: repeat(8, minmax(0, 1fr));
  padding: var(--kn-pad) 0;
}

.kn-board {
  grid-column: 2;
  grid-row: 2;
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  grid-template-rows: repeat(8, minmax(0, 1fr));
  gap: var(--kn-gap);
  aspect-ratio: 1 / 1;
  padding: var(--kn-pad);
  border-radius: 12px;
  background: #0b1630;
  box-shadow: inset 0 0 0 1px rgba(56, 189, 248, 0.22);
}

.kn-cell {
  position: relative;
  appearance: none;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: #2a4a78;
  color: inherit;
  font: inherit;
  cursor: default;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  box-shadow: inset 0 0 0 1px rgba(125, 211, 252, 0.14);
}

.kn-cell:disabled {
  cursor: default;
}

.kn-cell.is-playable {
  cursor: pointer;
}

.kn-cell.is-playable:hover {
  background: color-mix(in srgb, #38bdf8 22%, #2a4a78);
}

.kn-cell.is-last-from {
  background: color-mix(in srgb, #38bdf8 18%, #2a4a78);
}

.kn-cell.is-last-to {
  outline: 2px solid color-mix(in srgb, #7dd3fc 75%, transparent);
  outline-offset: -2px;
}

.kn-cell:focus-visible {
  outline: 2px solid #ffffff;
  outline-offset: -2px;
  z-index: 2;
}

.kn-cell.is-selected {
  outline: 3px solid #67e8f9;
  outline-offset: -3px;
  z-index: 1;
}

/* 空きマス：くぼみで石と区別 */
.kn-hole {
  width: 30%;
  height: 30%;
  border-radius: 50%;
  background: #12264a;
  box-shadow: inset 0 2px 3px rgba(0, 0, 0, 0.55), 0 1px 0 rgba(148, 197, 255, 0.18);
  pointer-events: none;
}

/* ---- 石 ---- */

.kn-stone {
  position: relative;
  z-index: 1;
  display: block;
  width: 78%;
  height: 78%;
  border-radius: 50%;
  border: 2px solid transparent;
  pointer-events: none;
}

.kn-stone--black {
  border-color: #94a3b8;
  background: radial-gradient(circle at 34% 30%, #6b7280 0%, #2d3340 38%, #0b0f17 100%);
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.55);
}

.kn-stone--white {
  border-color: #475569;
  background: radial-gradient(circle at 34% 30%, #ffffff 0%, #f1f5f9 45%, #c3cdd9 100%);
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.45);
}

/* ジャンプできる石・取り除ける石 */
.kn-cell.is-movable .kn-stone,
.kn-cell.is-remove-target .kn-stone {
  box-shadow:
    0 0 0 2px #0b1630,
    0 0 0 4px color-mix(in srgb, #67e8f9 70%, transparent),
    0 2px 5px rgba(0, 0, 0, 0.45);
}

.kn-cell.is-remove-target .kn-stone {
  box-shadow:
    0 0 0 2px #0b1630,
    0 0 0 4px color-mix(in srgb, #f0abfc 85%, transparent),
    0 2px 5px rgba(0, 0, 0, 0.45);
}

.kn-cell.is-selected .kn-stone {
  box-shadow:
    0 0 0 2px #0b1630,
    0 0 0 4px #67e8f9,
    0 0 12px color-mix(in srgb, #22d3ee 55%, transparent);
}

.kn-cell.is-jump-over .kn-stone {
  opacity: 0.6;
}

.kn-cell.is-move-target::after {
  content: "";
  position: absolute;
  z-index: 2;
  width: 40%;
  height: 40%;
  min-width: 12px;
  min-height: 12px;
  border-radius: 50%;
  border: 2px solid #cffafe;
  background: color-mix(in srgb, #22d3ee 70%, transparent);
  box-shadow: 0 0 10px color-mix(in srgb, #22d3ee 60%, transparent);
  pointer-events: none;
}

.kn-cell.is-captured {
  animation: kn-capture-flash 420ms ease-out;
}

@keyframes kn-capture-flash {
  0% {
    background: color-mix(in srgb, #f472b6 55%, #2a4a78);
  }
  100% {
    background: #2a4a78;
  }
}

/* ---- 凡例・説明 ---- */

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

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

.kn-legend__swatch {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  flex: 0 0 auto;
  border-radius: 5px;
  background: #2a4a78;
}

.kn-legend__swatch .kn-stone {
  width: 14px;
  height: 14px;
  border-width: 1px;
}

.kn-legend__swatch--movable .kn-stone {
  box-shadow: 0 0 0 1px #0b1630, 0 0 0 2.5px color-mix(in srgb, #67e8f9 80%, transparent);
}

.kn-legend__swatch--target::after {
  content: "";
  width: 9px;
  height: 9px;
  border-radius: 50%;
  border: 1.5px solid #cffafe;
  background: #22d3ee;
}

.kn-howto {
  max-width: min(100%, 520px);
  margin: 0 auto 12px;
  text-align: center;
  color: var(--md-sys-color-on-surface-variant);
  font-size: 0.85rem;
  font-weight: 600;
}

.game-controls {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-top: 4px;
}

@media (max-width: 520px) {
  .kn-status {
    max-width: 100%;
    padding: 10px;
  }

  .kn-score {
    min-width: 5.4rem;
    padding: 5px 8px;
  }

  .kn-board-wrap {
    max-width: none;
    margin-left: -12px;
    margin-right: -12px;
  }

  .kn-frame {
    --kn-pad: 4px;
    --kn-gap: 2px;
    grid-template-columns: 12px minmax(0, 1fr);
    grid-template-rows: 12px auto;
    gap: 3px;
    padding: 6px 6px 6px 4px;
    border-radius: 14px;
  }

  .kn-coords {
    font-size: 0.6rem;
  }

  .kn-cell {
    border-radius: 5px;
  }

  .kn-stone {
    width: 80%;
    height: 80%;
    border-width: 1.5px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .kn-cell.is-captured,
  .kn-result {
    animation: none;
  }
}

/* 外枠と操作は共通プレイUI。8×8盤面・連続ジャンプは固有領域。 */
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 { width: 100%; max-width: 640px; flex: none; }
html.gs-playing .gs-bar { gap: 10px; align-items: flex-start; }
html.gs-playing .kn-settings { flex: 1; min-width: 0; max-width: none; margin: 0; gap: 6px; grid-template-columns: minmax(0, 2fr) minmax(0, 3fr); }
html.gs-playing .kn-field:first-child { grid-column: 1 / -1; }
html.gs-playing .kn-settings .field-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
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); }
@media (hover: hover) {
  html.gs-playing .option-tab:hover { background: var(--play-btn-hover); border-color: var(--play-accent); }
}
html.gs-playing .status-pill { padding: 0; min-height: 0; background: none; box-shadow: none; color: var(--play-accent); font-size: 1.15rem; line-height: 1.2; }
html.gs-playing .status-pill.is-white,
html.gs-playing .status-pill.is-lose { color: #f0abfc; }
html.gs-playing .kn-status__text { flex: none; width: 100%; max-width: 640px; height: 3em; margin: 0; text-align: center; color: var(--play-text); font-size: .8125rem; line-height: 1.5; }
html.gs-playing .kn-guide { flex: none; width: 100%; max-width: 640px; min-height: 3em; margin: 0 0 8px; color: var(--play-text-muted); font-size: .75rem; line-height: 1.5; }
html.gs-playing .kn-board-wrap { position: relative; flex: none; width: min(100%, max(220px, calc(100dvh - 445px))); max-width: 460px; margin: 0; }
html.gs-playing .kn-chain-slot { flex: none; width: 100%; max-width: 640px; min-height: 92px; padding-top: 8px; }
html.gs-playing .kn-chain { max-width: none; margin: 0; padding: 6px; gap: 4px 8px; border-color: var(--play-border); background: var(--play-hud-bg); }
html.gs-playing .kn-chain__text { color: var(--play-text-muted); font-size: .75rem; }
html.gs-playing .kn-chain .btn { min-width: 0; font-size: .8125rem; }
html.gs-playing .kn-legend { flex: none; width: 100%; max-width: 640px; gap: 4px 12px; color: var(--play-text-muted); font-size: .75rem; }
html.gs-playing .game-controls { margin: 0; }
html.gs-playing .kn-result { position: absolute; inset: 0; z-index: 3; display: flex; flex-direction: column; align-items: center; justify-content: center; max-width: none; margin: 0; border-color: var(--play-border); background: rgba(8, 15, 31, .95); color: var(--play-text); }
html.gs-playing .kn-result[hidden] { display: none; }
html.gs-playing .kn-result__detail { color: var(--play-text-muted); }
@media (min-width: 720px) and (min-height: 650px) {
  html.gs-playing .game-panel { padding-top: max(clamp(24px, 4vh, 48px), env(safe-area-inset-top)); }
  html.gs-playing .game-panel > .gs-bar { margin-bottom: 20px; }
  html.gs-playing .game-panel > .gs-hud { margin-bottom: 12px; }
  html.gs-playing .kn-guide { margin-bottom: 16px; }
  html.gs-playing .kn-board-wrap { width: min(100%, max(220px, calc(100dvh - 450px))); }
}
@media (max-height: 500px) and (min-width: 640px) {
  html.gs-playing .game-panel { display: grid; grid-template-columns: minmax(0, 300px) minmax(0, 300px); grid-template-areas: 'bar board' 'hud board' 'status board' 'guide board' 'chain legend' 'controls legend'; gap: 4px 16px; align-content: start; justify-content: center; }
  html.gs-playing .gs-bar { grid-area: bar; }
  html.gs-playing .gs-hud { grid-area: hud; }
  html.gs-playing .kn-status__text { grid-area: status; }
  html.gs-playing .kn-guide { grid-area: guide; margin: 0; }
  html.gs-playing .kn-board-wrap { grid-area: board; width: min(100%, calc(100dvh - 100px)); justify-self: center; }
  html.gs-playing .kn-chain-slot { grid-area: chain; }
  html.gs-playing .kn-legend { grid-area: legend; }
  html.gs-playing .game-controls { grid-area: controls; }
}

html.gs-playing .kn-error { position: fixed; bottom: 8px; left: 50%; transform: translateX(-50%); z-index: 4; width: min(90%, 480px); margin: 0; text-align: center; }
