/* ナイン・メンズ・モリス固有スタイル */

.nmm-settings {
  margin-top: 4px;
  margin-bottom: 20px;
  text-align: center;
}

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

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

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

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

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

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

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

.nmm-score--player {
  background: color-mix(in srgb, #22d3ee 16%, var(--md-sys-color-surface));
}

.nmm-score--cpu {
  background: color-mix(in srgb, #c084fc 16%, var(--md-sys-color-surface));
}

.nmm-score__label {
  color: var(--md-sys-color-on-surface-variant);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.nmm-score__value {
  color: var(--md-sys-color-on-surface);
  font-size: 1.2rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
}

.nmm-score__hint {
  margin: 0 0 10px;
  color: var(--md-sys-color-on-surface-variant);
  font-size: 0.8rem;
  font-weight: 600;
  text-align: center;
}

.nmm-status__main {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  min-width: 0;
}

.nmm-status__text {
  margin: 0;
  color: var(--md-sys-color-on-surface);
  font-size: 0.95rem;
  font-weight: 600;
}

.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: #15803d;
}

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

.status-pill.is-draw {
  background: color-mix(in srgb, #94a3b8 22%, var(--md-sys-color-surface));
  color: #475569;
}

.nmm-flying {
  max-width: min(100%, 520px);
  margin: 0 auto 12px;
  padding: 10px 12px;
  border: 1px solid color-mix(in srgb, #38bdf8 35%, var(--md-sys-color-outline-variant));
  border-radius: var(--md-sys-shape-corner-medium);
  background: color-mix(in srgb, #22d3ee 10%, var(--md-sys-color-surface));
  color: #0e7490;
  font-size: 0.88rem;
  font-weight: 700;
  text-align: center;
}

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

.nmm-result.is-win {
  border-color: color-mix(in srgb, #22c55e 40%, var(--md-sys-color-outline-variant));
  background: color-mix(in srgb, #22c55e 8%, var(--md-sys-color-surface));
}

.nmm-result.is-lose {
  border-color: color-mix(in srgb, #f43f5e 35%, var(--md-sys-color-outline-variant));
  background: color-mix(in srgb, #f43f5e 7%, var(--md-sys-color-surface));
}

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

.nmm-result__title {
  margin: 0 0 6px;
  font-size: 1.15rem;
  font-weight: 800;
}

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

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

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

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

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

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

.nmm-legend__swatch--cpu {
  background: linear-gradient(145deg, #e9d5ff, #9333ea);
  border-radius: 3px;
}

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

.nmm-board {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  padding: 8%;
  border-radius: 22px;
  background:
    radial-gradient(120% 90% at 20% 0%, rgba(56, 189, 248, 0.16), transparent 55%),
    radial-gradient(120% 90% at 80% 100%, rgba(168, 85, 247, 0.16), transparent 55%),
    linear-gradient(160deg, #15284f 0%, #0f1c38 55%, #0c1630 100%);
  border: 1px solid rgba(56, 189, 248, 0.35);
  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;
}

.nmm-lines {
  position: absolute;
  inset: 8%;
  width: 84%;
  height: 84%;
  overflow: visible;
  pointer-events: none;
}

.nmm-line {
  stroke: rgba(103, 232, 249, 0.55);
  stroke-width: 1.4;
  stroke-linecap: round;
  vector-effect: non-scaling-stroke;
  transition: stroke 0.2s ease, stroke-width 0.2s ease;
}

.nmm-line.is-mill {
  stroke: #fbbf24;
  stroke-width: 2.4;
}

.nmm-point {
  --point-size: clamp(40px, 11vw, 52px);
  appearance: none;
  position: absolute;
  z-index: 1;
  width: var(--point-size);
  height: var(--point-size);
  margin: 0;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: transparent;
  transform: translate(-50%, -50%);
  cursor: default;
  touch-action: manipulation;
}

.nmm-point::before {
  content: '';
  position: absolute;
  left: 50%;
  top: 50%;
  width: 34%;
  height: 34%;
  border-radius: 50%;
  background: rgba(148, 163, 184, 0.35);
  border: 1.5px solid rgba(186, 230, 253, 0.45);
  transform: translate(-50%, -50%);
  transition: width 0.12s ease, height 0.12s ease, background 0.12s ease, box-shadow 0.12s ease, border-color 0.12s ease, border-radius 0.12s ease;
}

.nmm-point.is-player::before {
  width: 52%;
  height: 52%;
  border-radius: 50%;
  background: linear-gradient(145deg, #67e8f9, #0891b2);
  border-color: rgba(255, 255, 255, 0.45);
  box-shadow:
    0 0 0 1px rgba(8, 145, 178, 0.45),
    0 4px 10px rgba(2, 6, 23, 0.35);
}

.nmm-point.is-cpu::before {
  width: 52%;
  height: 52%;
  border-radius: 22%;
  background: linear-gradient(145deg, #e9d5ff, #9333ea);
  border-color: rgba(255, 255, 255, 0.4);
  box-shadow:
    0 0 0 1px rgba(147, 51, 234, 0.4),
    0 4px 10px rgba(2, 6, 23, 0.35);
}

.nmm-point.is-placeable {
  cursor: pointer;
}

.nmm-point.is-placeable::before {
  background: rgba(34, 211, 238, 0.28);
  border-color: rgba(103, 232, 249, 0.75);
  box-shadow: 0 0 0 1px rgba(34, 211, 238, 0.18);
}

.nmm-point.is-selectable {
  cursor: pointer;
}

.nmm-point.is-target {
  cursor: pointer;
}

.nmm-point.is-target::before {
  width: 40%;
  height: 40%;
  background: rgba(251, 191, 36, 0.35);
  border-color: #fbbf24;
  box-shadow: 0 0 10px rgba(251, 191, 36, 0.35);
}

.nmm-point.is-selected::before {
  box-shadow:
    0 0 0 3px rgba(251, 191, 36, 0.85),
    0 0 14px rgba(251, 191, 36, 0.45);
}

.nmm-point.is-mill::before {
  box-shadow:
    0 0 0 3px rgba(251, 191, 36, 0.9),
    0 0 16px rgba(251, 191, 36, 0.5);
}

.nmm-point.is-removable {
  cursor: pointer;
}

.nmm-point.is-removable::before {
  box-shadow:
    0 0 0 3px rgba(244, 114, 182, 0.9),
    0 0 14px rgba(244, 114, 182, 0.45);
}

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

.nmm-point:focus-visible {
  outline: none;
}

.nmm-point:focus-visible::after {
  content: '';
  position: absolute;
  inset: 8%;
  border: 2px solid #67e8f9;
  border-radius: 50%;
  pointer-events: none;
}

.nmm-point.is-placeable:hover::before,
.nmm-point.is-target:hover::before,
.nmm-point.is-removable:hover::before,
.nmm-point.is-selectable:hover::before {
  transform: translate(-50%, -50%) scale(1.08);
}

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

.game-controls {
  margin-top: 16px;
  justify-content: center;
}

@media (max-width: 480px) {
  .nmm-status {
    align-items: flex-start;
  }

  .nmm-status__text {
    font-size: 0.9rem;
  }

  .nmm-board {
    padding: 7%;
  }

  .nmm-lines {
    inset: 7%;
    width: 86%;
    height: 86%;
  }

  .nmm-point {
    --point-size: clamp(42px, 12.5vw, 50px);
  }

  .option-tabs {
    max-width: none;
  }
}

/* 外枠・ボタン・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,
.nmm-stage { width: 100%; max-width: 640px; }
.nmm-stage { position: relative; flex: none; }
html.gs-playing .nmm-board-wrap {
  width: min(100%, max(180px, min(100dvh - 380px, 560px)));
  max-width: none;
  margin: 0 auto;
}
html.gs-playing .nmm-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 .nmm-legend { flex: none; margin: 12px auto 0; color: var(--play-text-muted); font-size: .75rem; gap: 8px 14px; }
html.gs-playing .nmm-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 .nmm-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 .nmm-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 .nmm-board-wrap { width: min(100%, max(180px, min(100dvh - 510px, 560px))); }
  html.gs-playing .nmm-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;
    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 .nmm-stage { grid-area: board; align-self: center; }
  html.gs-playing .nmm-board-wrap { width: min(100%, 100dvh - 24px); }
  html.gs-playing .nmm-legend { grid-area: legend; }
  html.gs-playing .nmm-status__text { grid-area: hint; }
  html.gs-playing .game-controls { grid-area: controls; }
}
@media (prefers-reduced-motion: reduce) { .nmm-result { animation: none; } }

html.gs-playing .nmm-settings { width: 100%; max-width: 640px; flex: none; margin: 0 0 14px; }
html.gs-playing .nmm-settings .field-label { display: none; }
html.gs-playing .option-tabs { max-width: none; gap: 8px; }
html.gs-playing .option-tab { min-height: 44px; padding: 5px 8px; border-color: var(--play-border); background: var(--play-hud-bg); color: var(--play-text-muted); }
html.gs-playing .option-tab.is-active { border-color: var(--play-accent); background: rgba(70,217,243,.14); color: var(--play-accent); }
html.gs-playing .nmm-score__hint { flex: none; margin: 0 0 10px; color: var(--play-text-muted); }
html.gs-playing .nmm-notices { width: 100%; max-width: 640px; flex: none; min-height: 6.4em; margin: 10px auto; font-size: .85rem; line-height: 1.6; text-align: center; }
html.gs-playing .nmm-status__text { min-height: 0; margin: 0; font-size: inherit; }
html.gs-playing .nmm-flying { margin: 0; padding: 0; border: 0; background: none; color: var(--play-accent); font-size: inherit; }
@media (orientation: landscape) and (max-height: 500px) {
  html.gs-playing .game-panel { grid-template-rows: auto auto auto auto auto 1fr; grid-template-areas: "bar board" "settings board" "status board" "counts board" "legend board" "hint board"; }
  html.gs-playing .nmm-settings { grid-area: settings; margin-bottom: 8px; }
  html.gs-playing .nmm-score__hint { grid-area: counts; }
  html.gs-playing .nmm-notices { grid-area: hint; margin: 6px 0; }
  html.gs-playing .game-controls { grid-area: bar; justify-self: end; width: auto; }
  html.gs-playing .nmm-legend { margin-top: 0; }
}
@media (max-width: 767px), (max-height: 599px) {
  html.gs-playing .option-tab small { display: none; }
  html.gs-playing .nmm-notices { min-height: 4.8em; }
  html.gs-playing .nmm-board-wrap { width: min(100%, max(180px, min(100dvh - 430px, 560px))); }
}
@media (orientation: landscape) and (max-height: 500px) {
  html.gs-playing .nmm-board-wrap { width: min(100%, 100dvh - 24px); }
}
@media (max-width: 767px) and (orientation: portrait) and (max-height: 600px) {
  html.gs-playing .game-panel { display: grid; grid-template-columns: 44px minmax(0, 1fr); grid-template-rows: repeat(7, auto) 1fr; grid-template-areas: "bar settings" "status status" "counts counts" "board board" "hint hint" "controls controls"; column-gap: 10px; align-content: start; align-items: start; }
  html.gs-playing .game-panel > .gs-bar { grid-area: bar; }
  html.gs-playing .nmm-settings { grid-area: settings; margin-bottom: 10px; }
  html.gs-playing .gs-hud { grid-area: status; }
  html.gs-playing .nmm-score__hint { grid-area: counts; }
  html.gs-playing .nmm-stage { grid-area: board; }
  html.gs-playing .nmm-board-wrap { width: min(100%, 240px); }
  html.gs-playing .nmm-legend { display: none; }
  html.gs-playing .nmm-notices { grid-area: hint; }
  html.gs-playing .game-controls { grid-area: controls; }
}
/* 線と交点を同じ内側84%の座標に合わせる。 */
html.gs-playing .nmm-board { container-type: inline-size; padding: 8%; }
html.gs-playing .nmm-lines { inset: 8%; width: 84%; height: 84%; }
html.gs-playing .nmm-point { --point-size: clamp(28px, 15cqw, 52px); }
@media (orientation: landscape) and (max-height: 500px) {
  html.gs-playing .game-panel > .game-controls { width: auto; }
}
