/* =====================================================================
   style.css — マンカラ ツール固有の微調整のみ。
   共通スタイルは /_shared/shirugear.css に任せる。
   ===================================================================== */

/* モード切替 */
.sg-modes {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  margin-top: var(--sg-space-1, 4px);
}
.sg-mode {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  font-size: 0.95rem;
}

/* 詳細設定（折りたたみ） */
.mc-more > summary {
  cursor: pointer;
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--sg-primary, #3b5bdb);
}
.mc-pending {
  color: var(--sg-warm, #b54708);
}

/* 操作ボタン群 */
.mc-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
}
.mc-actions .sg-btn {
  padding: 8px 14px;
  font-size: 0.95rem;
}

/* ステータス（手番・勝敗） */
.mc-status {
  min-height: 2.8em;
  margin: 4px 0 8px;
  text-align: center;
  font-size: 0.95rem;
  font-weight: 600;
  line-height: 1.45;
}
.mc-status.is-ok { color: var(--sg-success, #067647); }
.mc-status.is-warn { color: var(--sg-warm, #b54708); }

/* 得点 */
.mc-scores {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  max-width: 640px;
  margin: 0 auto 6px;
  font-size: 0.9rem;
  color: var(--sg-muted, #666);
}
.mc-score b {
  display: inline-block;
  min-width: 2ch;
  font-size: 1.15rem;
  color: var(--sg-fg, #1a1a1a);
  text-align: center;
}

/* 戦績 */
.mc-record-wrap {
  text-align: center;
  font-size: 0.9rem;
  color: var(--sg-muted, #777);
}

.mc-dir {
  margin: 6px 0 0;
  text-align: center;
  font-size: 0.8rem;
  color: var(--sg-muted, #777);
}

/* ---------- 盤の色（ライト / ダーク） ---------- */
.mc-board {
  --mc-wood: #c08a52;
  --mc-wood-2: #a8733f;
  --mc-hole: #f6e7cc;
  --mc-hole-ink: #3d2a16;
  --mc-store: #f1ddba;
  --mc-ring: #3b5bdb;
  --mc-hot: #ffb020;
  --mc-cap: #e5484d;
}
html.sg-dark .mc-board {
  --mc-wood: #5a4128;
  --mc-wood-2: #47321e;
  --mc-hole: #2a2018;
  --mc-hole-ink: #f3e3c7;
  --mc-store: #32271c;
  --mc-ring: #8aa8ff;
  --mc-hot: #ffc24d;
  --mc-cap: #ff6b6b;
}
@media (prefers-color-scheme: dark) {
  html:not(.sg-dark):not(.sg-light) .mc-board {
    --mc-wood: #5a4128;
    --mc-wood-2: #47321e;
    --mc-hole: #2a2018;
    --mc-hole-ink: #f3e3c7;
    --mc-store: #32271c;
    --mc-ring: #8aa8ff;
    --mc-hot: #ffc24d;
    --mc-cap: #ff6b6b;
  }
}

/* ---------- 盤面（横長：左右にゴール） ---------- */
.mc-stage {
  position: relative;
  max-width: 640px;
  margin: 0 auto;
}
.mc-board {
  display: grid;
  grid-template-columns: minmax(40px, 0.85fr) repeat(6, minmax(0, 1fr)) minmax(40px, 0.85fr);
  grid-template-rows: auto auto;
  gap: 8px 6px;
  padding: 10px;
  border-radius: 22px;
  background: linear-gradient(180deg, var(--mc-wood), var(--mc-wood-2));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 2px 6px rgba(0, 0, 0, 0.25);
}
.mc-row {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 6px;
  grid-column: 2 / span 6;
  border-radius: 14px;
  padding: 3px;
}
.mc-row--top { grid-row: 1; }
.mc-row--bottom { grid-row: 2; }
.mc-board[data-turn="top"] .mc-row--top,
.mc-board[data-turn="bottom"] .mc-row--bottom {
  background: rgba(255, 255, 255, 0.16);
}

.mc-store {
  grid-row: 1 / span 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  border-radius: 999px;
  background: var(--mc-store);
  color: var(--mc-hole-ink);
  box-shadow: inset 0 3px 8px rgba(0, 0, 0, 0.35);
  min-height: 120px;
  padding: 6px 2px;
  transition: box-shadow 0.12s ease;
}
.mc-store--top { grid-column: 1; }
.mc-store--bottom { grid-column: 8; }
.mc-store-label {
  font-size: 0.68rem;
  line-height: 1.2;
  text-align: center;
  writing-mode: vertical-rl;
  text-orientation: upright;
  letter-spacing: 0.05em;
  opacity: 0.8;
}
.mc-store .mc-num {
  font-size: 1.5rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

/* 穴 */
.mc-pit {
  position: relative;
  aspect-ratio: 1 / 1;
  width: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--mc-hole);
  color: var(--mc-hole-ink);
  box-shadow: inset 0 3px 7px rgba(0, 0, 0, 0.38);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  font: inherit;
  cursor: default;
  -webkit-tap-highlight-color: transparent;
  transition: box-shadow 0.12s ease, opacity 0.12s ease;
}
.mc-pit .mc-num {
  font-size: 1.2rem;
  font-weight: 700;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.mc-dots {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 2px;
  max-width: 70%;
  min-height: 7px;
}
.mc-stone {
  display: block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  box-shadow: inset -1px -1px 0 rgba(0, 0, 0, 0.25);
}
.mc-stone--0 { background: #4f7cff; }
.mc-stone--1 { background: #e5484d; }
.mc-stone--2 { background: #30a46c; }
.mc-stone--3 { background: #f5b301; }

/* 選べる穴／選べない穴 */
.mc-board.is-input .mc-pit.is-ok {
  cursor: pointer;
  box-shadow: inset 0 3px 7px rgba(0, 0, 0, 0.38), 0 0 0 2px var(--mc-ring);
}
.mc-board.is-input .mc-pit.is-ok:hover {
  box-shadow: inset 0 3px 7px rgba(0, 0, 0, 0.38), 0 0 0 3px var(--mc-ring);
}
.mc-board.is-input .mc-pit.is-off.is-turn {
  opacity: 0.5;
}
.mc-board.is-input .mc-pit.is-off:not(.is-turn) {
  opacity: 0.85;
}
.mc-pit:focus-visible {
  outline: 3px solid var(--mc-hot);
  outline-offset: 2px;
}

/* もう一度になる穴のヒント */
.mc-pit.is-hint::after {
  content: "↻";
  position: absolute;
  top: -4px;
  right: -4px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--mc-ring);
  color: #fff;
  font-size: 12px;
  line-height: 18px;
  text-align: center;
  font-weight: 700;
}

/* アニメーション：取り出した穴・配っている穴・最後の石・横取り */
.mc-pit.is-from {
  box-shadow: inset 0 3px 7px rgba(0, 0, 0, 0.38), 0 0 0 2px var(--mc-hot);
  opacity: 0.75;
}
.mc-pit.is-sow,
.mc-store.is-sow {
  box-shadow: inset 0 3px 7px rgba(0, 0, 0, 0.2), 0 0 0 3px var(--mc-hot), 0 0 14px var(--mc-hot);
}
.mc-pit.is-last,
.mc-store.is-last {
  box-shadow: inset 0 3px 7px rgba(0, 0, 0, 0.3), 0 0 0 4px var(--mc-hot);
}
.mc-pit.is-cap,
.mc-store.is-cap {
  box-shadow: inset 0 3px 7px rgba(0, 0, 0, 0.3), 0 0 0 4px var(--mc-cap);
}
.mc-pit.is-sow .mc-num {
  animation: mc-bump 0.18s ease-out;
}
@keyframes mc-bump {
  from { transform: scale(1.35); }
  to { transform: scale(1); }
}

/* 「もう一度！」「横取り！」 */
.mc-flash {
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 3;
  margin: 0;
  padding: 6px 16px;
  border-radius: 999px;
  font-weight: 800;
  font-size: 1.1rem;
  white-space: nowrap;
  pointer-events: none;
  transform: translate(-50%, -50%);
  background: var(--sg-surface, #fff);
  color: var(--sg-fg, #1a1a1a);
  box-shadow: var(--sg-shadow, 0 4px 16px rgba(0, 0, 0, 0.2));
  animation: mc-pop 1.3s ease-out forwards;
}
.mc-flash.is-again { border: 2px solid var(--sg-primary, #3b5bdb); color: var(--sg-primary, #3b5bdb); }
.mc-flash.is-cap { border: 2px solid var(--sg-danger, #d92d20); color: var(--sg-danger, #d92d20); }
@keyframes mc-pop {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(0.7); }
  15% { opacity: 1; transform: translate(-50%, -50%) scale(1.08); }
  25% { transform: translate(-50%, -50%) scale(1); }
  75% { opacity: 1; }
  100% { opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .mc-pit,
  .mc-store { transition: none; }
  .mc-pit.is-sow .mc-num { animation: none; }
  .mc-flash { animation: mc-fade 1.6s linear forwards; }
  @keyframes mc-fade {
    0%, 80% { opacity: 1; }
    100% { opacity: 0; }
  }
}

/* ---------- 狭い画面：ゴールを上下に置き、穴は数字を主に ---------- */
@media (max-width: 520px) {
  .mc-board {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto auto auto auto;
    gap: 6px;
    padding: 8px;
    border-radius: 16px;
  }
  .mc-row {
    grid-column: 1;
    gap: 4px;
    padding: 2px;
  }
  .mc-row--top { grid-row: 2; }
  .mc-row--bottom { grid-row: 3; }
  .mc-store {
    grid-column: 1;
    flex-direction: row;
    min-height: 0;
    padding: 4px 12px;
    gap: 10px;
  }
  .mc-store--top { grid-row: 1; justify-content: flex-start; }
  .mc-store--bottom { grid-row: 4; justify-content: flex-end; }
  .mc-store-label {
    writing-mode: horizontal-tb;
    font-size: 0.75rem;
  }
  .mc-store .mc-num { font-size: 1.25rem; }
  .mc-pit .mc-num { font-size: 1.1rem; }
  .mc-dots { display: none; }
  .mc-dir::after { content: "（ゴールは上下に表示）"; }
}

/* 早見表 */
.sg-chart {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 2px 16px;
}
.sg-chart-row {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 5px 0;
  border-bottom: 1px solid var(--sg-border, #e5e7eb);
}
.sg-chart-row__key {
  flex: 0 0 5em;
  font-weight: 600;
}
.sg-chart-row__val {
  flex: 1 1 auto;
  color: var(--sg-muted, #555);
}
