/* マンカラ固有スタイル */

.mk-settings {
  margin-top: 4px;
}

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

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

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

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

.mk-board {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 14px 12px 16px;
  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);
}

.mk-board__label {
  text-align: center;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.08em;
}

.mk-board__label--cpu {
  color: #d8b4fe;
}

.mk-board__label--player {
  color: #67e8f9;
}

.mk-board__inner {
  display: grid;
  grid-template-columns: minmax(56px, 78px) minmax(0, 1fr) minmax(56px, 78px);
  gap: 8px 10px;
  align-items: stretch;
}

.mk-board__lanes {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
}

.mk-row {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 6px;
}

.mk-pit,
.mk-store {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-width: 0;
  border: 2px solid rgba(148, 163, 184, 0.28);
  border-radius: 999px;
  background: radial-gradient(circle at 35% 30%, rgba(255, 255, 255, 0.08), transparent 45%), #132445;
  color: #e2e8f0;
  box-shadow: inset 0 2px 8px rgba(2, 6, 23, 0.45);
  transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.08s ease;
}

.mk-pit {
  appearance: none;
  min-height: 64px;
  padding: 8px 4px;
  font: inherit;
  cursor: default;
}

.mk-pit:disabled {
  cursor: default;
  opacity: 1;
}

.mk-pit--player.is-playable {
  cursor: pointer;
  border-color: rgba(34, 211, 238, 0.55);
  box-shadow:
    inset 0 2px 8px rgba(2, 6, 23, 0.4),
    0 0 0 1px rgba(34, 211, 238, 0.2);
}

.mk-pit--player.is-playable:hover,
.mk-pit--player.is-playable:focus-visible {
  border-color: #67e8f9;
  box-shadow:
    inset 0 2px 8px rgba(2, 6, 23, 0.35),
    0 0 12px rgba(34, 211, 238, 0.35);
  outline: none;
  transform: translateY(-1px);
}

.mk-pit.is-active,
.mk-store.is-active {
  border-color: #fbbf24;
  box-shadow:
    inset 0 2px 8px rgba(2, 6, 23, 0.35),
    0 0 14px rgba(251, 191, 36, 0.35);
}

.mk-pit.is-capture,
.mk-store.is-capture {
  border-color: #f472b6;
  box-shadow:
    inset 0 2px 8px rgba(2, 6, 23, 0.35),
    0 0 14px rgba(244, 114, 182, 0.35);
}

.mk-pit--cpu {
  border-color: rgba(192, 132, 252, 0.28);
}

.mk-pit--player {
  border-color: rgba(34, 211, 238, 0.28);
}

.mk-store {
  min-height: 148px;
  padding: 10px 6px;
  border-radius: 28px;
}

.mk-store--cpu {
  border-color: rgba(192, 132, 252, 0.4);
}

.mk-store--player {
  border-color: rgba(34, 211, 238, 0.4);
}

.mk-store__label {
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  color: rgba(226, 232, 240, 0.78);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.mk-pit__stones {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 3px;
  max-width: 42px;
  min-height: 14px;
}

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

.mk-pit__stones--player .mk-stone {
  background: linear-gradient(145deg, #a5f3fc, #06b6d4);
}

.mk-pit__stones--cpu .mk-stone {
  background: linear-gradient(145deg, #e9d5ff, #a855f7);
}

.mk-pit__count {
  font-family: Outfit, "Noto Sans JP", sans-serif;
  font-size: 1.05rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  text-shadow: 0 1px 2px rgba(2, 6, 23, 0.55);
}

@media (max-width: 640px) {
  .mk-board {
    padding: 12px 8px 14px;
    border-radius: 18px;
  }

  .mk-board__inner {
    grid-template-columns: minmax(48px, 64px) minmax(0, 1fr) minmax(48px, 64px);
    gap: 6px 6px;
  }

  .mk-row {
    gap: 4px;
  }

  .mk-pit {
    min-height: 54px;
    padding: 6px 2px;
  }

  .mk-store {
    min-height: 126px;
    padding: 8px 4px;
    border-radius: 22px;
  }

  .mk-pit__count {
    font-size: 0.95rem;
  }

  .mk-stone {
    width: 7px;
    height: 7px;
  }

}

@media (max-width: 380px) {
  .mk-pit {
    min-height: 48px;
  }

  .mk-store {
    min-height: 112px;
  }

  .mk-pit__stones {
    max-width: 34px;
  }

  .mk-board__label {
    font-size: 0.72rem;
  }
}

/* 共通画面の外枠と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 .mk-status__text,
html.gs-playing .game-controls { width: 100%; max-width: 640px; flex: none; }
.mk-settings { margin: 0; min-width: 0; }
.mk-settings .field-label, .option-tab small { display: none; }
.mk-settings .option-tabs { display: flex; gap: 6px; max-width: none; }
.mk-settings .option-tab { min-height: 36px; padding: 6px 12px; font-size: .8rem; }
html.gs-playing .gs-bar { align-items: center; gap: 12px; }
.mk-player-score { color: #22d3ee; }
.mk-cpu-score { color: #c084fc; }
.mk-status__text { min-height: 3em; margin: 0 0 12px; color: var(--play-text-muted); text-align: center; font-size: .9rem; line-height: 1.5; }
.mk-stage { position: relative; flex: none; width: 100%; max-width: 640px; margin: 0 auto 16px; }
.mk-board-wrap { width: 100%; }
.mk-result { position: absolute; inset: 0; z-index: 2; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 12px; border: 1px solid var(--play-border); border-radius: 22px; background: rgba(8,15,31,.94); color: var(--play-text); text-align: center; backdrop-filter: blur(5px); }
.mk-result__title { margin: 0 0 6px; font-size: 1.3rem; font-weight: 700; }
.mk-result__detail { margin: 0 0 12px; color: var(--play-text-muted); }
.mk-result.is-win .mk-result__title { color: var(--play-accent); }
.mk-guide { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
html.gs-playing .game-controls { justify-content: center; margin: 0; }
@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; }
  .mk-status__text { margin-bottom: 20px; }
  .mk-stage { margin-bottom: 24px; }
}
/* 狭い縦画面はゴールを上下に移し、6つの穴のタップ幅を確保する。 */
@media (max-width: 480px) {
  .mk-board__inner { grid-template-columns: minmax(0,1fr); gap: 8px; }
  .mk-store { min-height: 44px; padding: 6px; flex-direction: row; gap: 12px; border-radius: 16px; }
  .mk-store__label { position: static; transform: none; }
  .mk-pit { min-height: 64px; }
  .mk-pit__stones { max-width: 24px; }
}
@media (max-height: 450px) and (min-width: 481px) {
  .mk-status__text { min-height: 1.5em; margin-bottom: 6px; }
  .mk-stage { margin-bottom: 6px; }
  .mk-board { padding: 6px 8px; gap: 2px; }
  .mk-board__lanes { gap: 6px; }
  .mk-pit { min-height: 44px; padding: 4px; }
  .mk-store { min-height: 96px; }
}

html.gs-playing .option-tab {
  flex-direction: column;
  gap: 0;
  min-height: 44px;
  padding: 4px 6px;
  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;
}

@media (hover: hover) {
  html.gs-playing .option-tab:hover {
    border-color: color-mix(in srgb, var(--play-accent) 55%, var(--play-border));
    background: var(--play-btn-hover);
  }
}

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: 2px solid var(--play-accent);
  outline-offset: 2px;
}

@media (max-width: 480px) and (max-height: 600px) {
  .mk-status__text { min-height: 1.5em; margin-bottom: 8px; }
  .mk-pit { min-height: 54px; }
  .mk-store { min-height: 38px; }
  .mk-board { padding-top: 8px; padding-bottom: 8px; }
  .mk-stage { margin-bottom: 10px; }
}
@media (max-height: 450px) and (min-width: 481px) {
  html.gs-playing .game-panel > .gs-bar { margin-bottom: 4px; }
  html.gs-playing .game-panel > .gs-hud { margin-bottom: 4px; }
}
