/* チェッカー固有スタイル */

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

.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-player {
  background: color-mix(in srgb, #22d3ee 22%, var(--md-sys-color-surface));
  color: #0e7490;
}

.status-pill.is-cpu {
  background: color-mix(in srgb, #c084fc 20%, var(--md-sys-color-surface));
  color: #7e22ce;
}

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

.ck-result {
  margin-bottom: 14px;
  padding: 14px 16px;
  border-radius: var(--md-sys-shape-corner-medium);
  text-align: center;
  animation: ck-result-in 200ms ease-out;
}

.ck-result.is-win {
  border: 1px solid color-mix(in srgb, var(--success, #16a34a) 38%, var(--md-sys-color-outline-variant));
  background: color-mix(in srgb, var(--success, #16a34a) 10%, var(--md-sys-color-surface));
}

.ck-result.is-lose {
  border: 1px solid color-mix(in srgb, #ef4444 34%, var(--md-sys-color-outline-variant));
  background: color-mix(in srgb, #ef4444 10%, var(--md-sys-color-surface));
}

.ck-result__title {
  margin: 0 0 4px;
  font-family: Outfit, "Noto Sans JP", sans-serif;
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.ck-result__detail {
  margin: 0 0 12px;
  color: var(--md-sys-color-on-surface-variant);
  font-size: 0.95rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

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

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

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

.ck-legend__item {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.ck-legend__swatch {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.35);
}

.ck-legend__swatch--player {
  background: linear-gradient(160deg, #67e8f9, #0891b2);
}

.ck-legend__swatch--cpu {
  background: linear-gradient(160deg, #e9d5ff, #a21caf);
}

.ck-legend__king {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 1.5px solid #fbbf24;
  background: #0b1630;
  color: #fbbf24;
  font-size: 0.62rem;
  font-weight: 800;
  line-height: 1;
}

.ck-board-wrap {
  --ck-player: #22d3ee;
  --ck-player-deep: #0891b2;
  --ck-cpu: #e879f9;
  --ck-cpu-deep: #a21caf;
  --ck-frame: #38bdf8;
  --ck-light: #dbe7f5;
  --ck-dark: #1a3358;
  --ck-board-bg: linear-gradient(160deg, #14284f 0%, #0d1a36 55%, #0a1428 100%);
  display: flex;
  justify-content: center;
  margin: 0 auto 12px;
  max-width: min(100%, 440px);
}

.ck-board {
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  grid-template-rows: repeat(8, minmax(0, 1fr));
  width: 100%;
  aspect-ratio: 1 / 1;
  padding: 10px;
  border: 2px solid color-mix(in srgb, var(--ck-frame) 70%, #0ea5e9);
  border-radius: 18px;
  background: var(--ck-board-bg);
  box-shadow:
    0 0 0 1px rgba(56, 189, 248, 0.18),
    0 10px 28px rgba(8, 20, 48, 0.28);
}

.ck-cell {
  position: relative;
  appearance: none;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: var(--ck-light);
  color: inherit;
  font: inherit;
  cursor: default;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.ck-cell--dark {
  background: var(--ck-dark);
}

.ck-cell--playable {
  cursor: pointer;
}

.ck-cell--playable:focus-visible {
  outline: 2px solid #67e8f9;
  outline-offset: -2px;
  z-index: 2;
}

.ck-cell.is-selected {
  box-shadow: inset 0 0 0 3px #67e8f9;
  z-index: 1;
}

.ck-cell.is-capturable {
  box-shadow: inset 0 0 0 2px color-mix(in srgb, #67e8f9 70%, white);
}

.ck-cell.is-move-target::after,
.ck-cell.is-capture-target::after {
  content: "";
  position: absolute;
  border-radius: 50%;
  pointer-events: none;
}

.ck-cell.is-move-target::after {
  width: 18%;
  height: 18%;
  min-width: 8px;
  min-height: 8px;
  background: color-mix(in srgb, #67e8f9 55%, transparent);
}

.ck-cell.is-capture-target::after {
  width: 42%;
  height: 42%;
  min-width: 16px;
  min-height: 16px;
  border: 2px solid color-mix(in srgb, #67e8f9 85%, white);
  background: color-mix(in srgb, #67e8f9 12%, transparent);
  box-shadow: 0 0 10px color-mix(in srgb, #67e8f9 35%, transparent);
}

.ck-piece {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 72%;
  height: 72%;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.35);
  box-shadow:
    0 2px 6px rgba(0, 0, 0, 0.35),
    inset 0 1px 2px rgba(255, 255, 255, 0.35);
  pointer-events: none;
}

.ck-piece--player {
  background: linear-gradient(160deg, #67e8f9 0%, #22d3ee 45%, #0891b2 100%);
}

.ck-piece--cpu {
  background: linear-gradient(160deg, #f0abfc 0%, #e879f9 45%, #a21caf 100%);
}

.ck-piece--king::before {
  content: "K";
  color: #fef3c7;
  font-family: Outfit, "Noto Sans JP", sans-serif;
  font-size: clamp(0.65rem, 3.2vw, 0.95rem);
  font-weight: 800;
  letter-spacing: 0.02em;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.45);
}

.ck-piece--king::after {
  content: "";
  position: absolute;
  inset: 14%;
  border: 1.5px solid color-mix(in srgb, #fbbf24 80%, white);
  border-radius: 50%;
  opacity: 0.9;
  pointer-events: none;
}

.ck-guide {
  max-width: min(100%, 440px);
  margin: 0 auto 14px;
  color: var(--md-sys-color-on-surface-variant);
  font-size: 0.86rem;
  line-height: 1.55;
  text-align: center;
}

.game-controls {
  justify-content: center;
}

@media (max-width: 480px) {
  .ck-board {
    padding: 8px;
    border-radius: 14px;
  }

  .ck-cell.is-move-target::after {
    width: 22%;
    height: 22%;
  }

  .ck-cell.is-capture-target::after {
    width: 48%;
    height: 48%;
  }

  .ck-guide {
    font-size: 0.82rem;
  }
}

/* 外枠・ボタン・HUDは15パズル／パイプパズルと同じ共通UIを利用する。 */
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-panel > .game-controls,
.ck-stage { width: 100%; max-width: 640px; }
.ck-stage { position: relative; flex: none; }
html.gs-playing .ck-board-wrap {
  width: min(100%, max(180px, min(100dvh - 320px, 560px)));
  max-width: none;
  margin: 0 auto;
}
html.gs-playing .ck-board { border-color: var(--play-border); }
html.gs-playing .status-pill { min-height: 0; padding: 0; font-size: 1.15rem; line-height: 1.2; background: none; }
html.gs-playing .status-pill.is-player { color: var(--play-accent); }
html.gs-playing .status-pill.is-cpu { color: #e9b8fa; }
html.gs-playing .status-pill.is-win { color: #86efac; }
html.gs-playing .status-pill.is-lose { color: #fca5a5; }
html.gs-playing .ck-legend { flex: none; margin: 12px auto 0; color: var(--play-text-muted); font-size: .75rem; gap: 8px 14px; }
html.gs-playing .ck-status__text {
  flex: none;
  width: 100%;
  max-width: 640px;
  min-height: 3.2em;
  margin: 10px auto;
  color: var(--play-text);
  font-size: .9rem;
  line-height: 1.6;
  text-align: center;
}
html.gs-playing .game-controls { flex: none; margin: 0; }
html.gs-playing .ck-result {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  margin: 0;
  border: 1px solid var(--play-border);
  background: rgba(8, 15, 31, .94);
  color: var(--play-text);
}
html.gs-playing .ck-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: 28px; }
  html.gs-playing .game-panel > .gs-hud { margin-bottom: 24px; }
  html.gs-playing .ck-board-wrap { width: min(100%, max(180px, min(100dvh - 370px, 560px))); }
  html.gs-playing .ck-legend { margin-top: 24px; }
}
@media (orientation: landscape) and (max-height: 500px) {
  html.gs-playing .game-panel {
    display: grid;
    grid-template-columns: minmax(200px, 260px) minmax(0, 1fr);
    grid-template-rows: auto auto auto auto 1fr;
    grid-template-areas: "bar board" "status board" "legend board" "hint board" "controls board";
    column-gap: 16px;
    padding-left: max(14px, calc((100% - 640px) / 2), env(safe-area-inset-left));
    padding-right: max(14px, calc((100% - 640px) / 2), env(safe-area-inset-right));
    align-items: start;
  }
  html.gs-playing .game-panel > .gs-bar { grid-area: bar; }
  html.gs-playing .game-panel > .gs-hud { grid-area: status; }
  html.gs-playing .ck-stage { grid-area: board; align-self: center; }
  html.gs-playing .ck-board-wrap { width: min(100%, 100dvh - 24px); }
  html.gs-playing .ck-legend { grid-area: legend; }
  html.gs-playing .ck-status__text { grid-area: hint; }
  html.gs-playing .game-controls { grid-area: controls; }
}
@media (prefers-reduced-motion: reduce) { .ck-result { animation: none; } }
