@charset "UTF-8";
/*!
 * 鬼リバーシ — スタイル
 * ------------------------------------------------------------
 * ▼デザインを変えたい時はまず :root のCSS変数だけ触れば全体の色が変わる。
 * ▼盤面スキン/石スキンを追加する場合は body に .skin-xxx を付けて
 *   変数を上書きする形にすれば既存コードを壊さずに増やせる。
 */

/* ==========================================================
   テーマ変数
   ========================================================== */
:root {
  /* 背景 */
  --bg: #0a0b0d;
  --bg-grad-a: #121418;
  --bg-grad-b: #07080a;

  /* 盤面（深いウォールナット） */
  --board-a: #241a13;
  --board-b: #120c08;
  --board-edge: #2e2118;
  --board-line: rgba(0, 0, 0, .62);
  --board-frame: #080605;

  /* 石 */
  --stone-black-a: #2b2d31;
  --stone-black-b: #050506;
  --stone-white-a: #fffdf6;
  --stone-white-b: #cdc4b0;

  /* アクセント（真鍮） */
  --accent: #c8a45c;
  --accent-soft: rgba(200, 164, 92, .18);
  --accent-line: rgba(200, 164, 92, .34);

  /* 文字 */
  --fg: #ece7dc;
  --fg-dim: #8d8577;
  --fg-faint: #5d5749;

  --panel: rgba(255, 255, 255, .035);
  --panel-line: rgba(255, 255, 255, .09);

  --radius: 4px;
  --tap: 46px;                 /* 指で押せる最小サイズ */

  --font-jp: "Shippori Mincho B1", "Hiragino Mincho ProN", "Yu Mincho", serif;
  --font-num: "Cormorant Garamond", "Shippori Mincho B1", Georgia, serif;

  --board-size: min(94vw, 62vh, 540px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  overflow-x: hidden;          /* 横スクロール禁止 */
}

body {
  min-height: 100dvh;
  background:
    radial-gradient(120% 80% at 50% -10%, var(--bg-grad-a), var(--bg-grad-b) 62%),
    var(--bg);
  color: var(--fg);
  font-family: var(--font-jp);
  font-feature-settings: "palt" 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: clamp(8px, 2vh, 18px);
  padding: clamp(10px, 2.4vh, 22px) 12px calc(14px + env(safe-area-inset-bottom));
  -webkit-text-size-adjust: 100%;
  touch-action: manipulation;
}

/* ==========================================================
   ヘッダー（非対称: タイトル左寄せ・サブコピーを段差で置く）
   ========================================================== */
.head {
  width: var(--board-size);
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
}

.head h1 {
  margin: 0;
  font-size: clamp(19px, 5.2vw, 27px);
  font-weight: 600;
  letter-spacing: .1em;
  line-height: 1.1;
  color: var(--fg);
}

.head h1 .k {
  color: var(--accent);
  text-shadow: 0 0 22px rgba(200, 164, 92, .3);
}

.head .sub {
  margin: 0;
  font-size: clamp(10px, 2.9vw, 12px);
  color: var(--fg-dim);
  letter-spacing: .06em;
  white-space: nowrap;
}

/* ==========================================================
   スコアバー
   ========================================================== */
.score {
  width: var(--board-size);
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 8px;
  padding: 9px 12px;
  background: var(--panel);
  border: 1px solid var(--panel-line);
  border-radius: var(--radius);
}

.side {
  position: relative;
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
}
.side.w { justify-content: flex-end; }

.chip {
  width: 19px; height: 19px;
  border-radius: 50%;
  flex: 0 0 auto;
  box-shadow: inset 0 1px 1px rgba(255, 255, 255, .22), 0 1px 3px rgba(0, 0, 0, .6);
}
.chip.b { background: radial-gradient(circle at 34% 28%, var(--stone-black-a), var(--stone-black-b) 72%); }
.chip.w { background: radial-gradient(circle at 34% 28%, var(--stone-white-a), var(--stone-white-b) 78%); }

.side .name { font-size: 11px; color: var(--fg-dim); letter-spacing: .09em; }
.side .num {
  font-family: var(--font-num);
  font-size: clamp(25px, 7vw, 33px);
  font-weight: 600;
  line-height: 1;
  font-variant-numeric: tabular-nums lining-nums;
  font-feature-settings: "lnum" 1, "tnum" 1;
  min-width: 1.6em;
  text-align: center;
  transition: color .25s ease;
}
.side.turn-on .num { color: var(--accent); }

.score .mid {
  font-size: 10px;
  color: var(--fg-faint);
  letter-spacing: .18em;
  text-align: center;
  white-space: nowrap;
}

/* 手番インジケータ */
.side::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: -9px;
  height: 2px;
  background: var(--accent);
  transform: scaleX(0);
  transition: transform .3s cubic-bezier(.2, .8, .2, 1);
  transform-origin: left center;
}
.side.w::after { transform-origin: right center; }
.side.turn-on::after { transform: scaleX(1); }

/* ==========================================================
   盤面
   ========================================================== */
.board-wrap {
  position: relative;
  width: var(--board-size);
  height: var(--board-size);
  flex: 0 0 auto;
}

.board {
  position: absolute;
  inset: 0;
  padding: clamp(6px, 1.6vw, 11px);
  border-radius: 6px;
  background:
    linear-gradient(145deg, var(--board-edge), var(--board-frame) 70%);
  box-shadow:
    0 20px 50px rgba(0, 0, 0, .72),
    0 1px 0 rgba(200, 164, 92, .10) inset,
    0 0 0 1px rgba(0, 0, 0, .85),
    0 0 0 2px rgba(200, 164, 92, .07);
}

.grid {
  position: relative;
  width: 100%;
  height: 100%;
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  grid-template-rows: repeat(8, 1fr);
  border-radius: 3px;
  overflow: hidden;
  /* 木目: 細い縞を低コントラストで重ねる */
  background-image:
    repeating-linear-gradient(94deg,
      rgba(255, 255, 255, .012) 0 3px,
      rgba(0, 0, 0, .020) 3px 7px,
      rgba(255, 255, 255, 0) 7px 17px),
    linear-gradient(160deg, var(--board-a), var(--board-b));
  box-shadow: inset 0 0 40px rgba(0, 0, 0, .6);
}

.cell {
  position: relative;
  border-right: 1px solid var(--board-line);
  border-bottom: 1px solid var(--board-line);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: default;
}
.cell:nth-child(8n) { border-right: none; }
.cell:nth-child(n+57) { border-bottom: none; }

/* 星（4隅の目印） */
.cell.star::before {
  content: "";
  position: absolute;
  width: 5px; height: 5px;
  border-radius: 50%;
  background: rgba(0, 0, 0, .55);
  top: -3px; left: -3px;
  pointer-events: none;
}

/* 合法手マーカー */
.cell.legal { cursor: pointer; }
.cell.legal::after {
  content: "";
  position: absolute;
  width: 26%; height: 26%;
  border-radius: 50%;
  background: var(--accent);
  opacity: .26;
  transition: opacity .2s ease, transform .2s ease;
  animation: pulse 2.4s ease-in-out infinite;
}
.cell.legal:active::after { opacity: .6; transform: scale(1.25); }
@keyframes pulse {
  0%, 100% { opacity: .2; }
  50% { opacity: .38; }
}

/* CPUの直前の手（星印のセルと重なっても壊れないよう box-shadow で描く） */
.cell.last-move {
  box-shadow: inset 0 0 0 1px var(--accent-line);
}

/* ==========================================================
   石
   ========================================================== */
.stone {
  position: relative;
  width: 84%;
  height: 84%;
  transform-style: preserve-3d;
  transition: transform .34s cubic-bezier(.3, .9, .35, 1);
  will-change: transform;
  z-index: 2;
}
.stone.white { transform: rotateY(180deg); }

.stone .face {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}

/* 黒石: 黒曜石・ピアノブラック */
.stone .face.b {
  background:
    radial-gradient(circle at 33% 26%, rgba(255, 255, 255, .30), rgba(255, 255, 255, 0) 42%),
    radial-gradient(circle at 50% 52%, var(--stone-black-a), var(--stone-black-b) 74%);
  box-shadow:
    0 2px 5px rgba(0, 0, 0, .68),
    inset 0 -2px 4px rgba(0, 0, 0, .8),
    inset 0 1px 1px rgba(255, 255, 255, .12);
}

/* 白石: アイボリー・セラミック */
.stone .face.w {
  transform: rotateY(180deg);
  background:
    radial-gradient(circle at 33% 26%, #ffffff, rgba(255, 255, 255, 0) 46%),
    radial-gradient(circle at 50% 54%, var(--stone-white-a), var(--stone-white-b) 76%);
  box-shadow:
    0 2px 5px rgba(0, 0, 0, .55),
    inset 0 -2px 4px rgba(120, 105, 80, .42),
    inset 0 1px 1px rgba(255, 255, 255, .9);
}

/* 落下してから着地する動き */
.stone.dropping { animation: drop .26s cubic-bezier(.34, 1.3, .5, 1) both; }
@keyframes drop {
  0%   { transform: translateY(-58%) scale(.72); opacity: 0; }
  55%  { opacity: 1; }
  78%  { transform: translateY(0) scale(1.06); }
  100% { transform: translateY(0) scale(1); }
}
/* 白石が落ちる時は反転状態を保ったまま落とす */
.stone.white.dropping { animation-name: drop-w; }
@keyframes drop-w {
  0%   { transform: translateY(-58%) rotateY(180deg) scale(.72); opacity: 0; }
  55%  { opacity: 1; }
  78%  { transform: translateY(0) rotateY(180deg) scale(1.06); }
  100% { transform: translateY(0) rotateY(180deg) scale(1); }
}

/* ==========================================================
   ステータス行
   ========================================================== */
.status {
  width: var(--board-size);
  min-height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  font-size: clamp(11px, 3.1vw, 13px);
  letter-spacing: .1em;
  color: var(--fg-dim);
}
.status .dots { display: inline-flex; gap: 4px; }
.status .dots i {
  width: 4px; height: 4px; border-radius: 50%;
  background: var(--accent);
  opacity: .25;
  animation: blink 1.05s infinite;
}
.status .dots i:nth-child(2) { animation-delay: .17s; }
.status .dots i:nth-child(3) { animation-delay: .34s; }
@keyframes blink { 0%, 100% { opacity: .2; } 50% { opacity: 1; } }

/* ==========================================================
   操作ボタン
   ========================================================== */
.controls {
  width: var(--board-size);
  display: flex;
  gap: 8px;
}

.btn {
  flex: 1 1 0;
  min-height: var(--tap);
  padding: 0 10px;
  font-family: var(--font-jp);
  font-size: clamp(10.5px, 2.9vw, 12.5px);
  letter-spacing: .06em;
  color: var(--fg);
  background: var(--panel);
  border: 1px solid var(--panel-line);
  border-radius: var(--radius);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  white-space: nowrap;
  transition: border-color .2s, background .2s, color .2s;
}
.btn:hover { border-color: var(--accent-line); }
.btn:active { background: var(--accent-soft); }
.btn[aria-pressed="false"] { color: var(--fg-faint); }
.btn .ic { font-size: 14px; line-height: 1; }

/* ==========================================================
   終局モーダル
   ========================================================== */
.modal {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(4, 5, 6, .82);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
  opacity: 0;
  pointer-events: none;
  transition: opacity .3s ease;
  z-index: 50;
}
.modal.show { opacity: 1; pointer-events: auto; }

.modal .box {
  width: min(360px, 92vw);
  padding: 30px 24px 22px;
  text-align: center;
  background: linear-gradient(170deg, #16181c, #0b0c0e);
  border: 1px solid var(--panel-line);
  border-radius: 6px;
  box-shadow: 0 28px 70px rgba(0, 0, 0, .75);
  transform: translateY(14px) scale(.97);
  transition: transform .34s cubic-bezier(.2, .9, .3, 1);
}
.modal.show .box { transform: none; }

.modal .result {
  font-family: var(--font-num);
  font-size: clamp(38px, 12vw, 54px);
  font-weight: 600;
  line-height: 1;
  letter-spacing: .06em;
  margin: 0 0 4px;
  color: var(--fg);
}
.modal .result.win { color: var(--accent); text-shadow: 0 0 34px rgba(200, 164, 92, .34); }
.modal .result.lose { color: #7d8288; }

.modal .final {
  font-family: var(--font-num);
  font-size: clamp(20px, 6vw, 26px);
  font-variant-numeric: tabular-nums lining-nums;
  font-feature-settings: "lnum" 1, "tnum" 1;
  color: var(--fg-dim);
  margin: 12px 0 2px;
  letter-spacing: .04em;
}
.modal .final b { color: var(--fg); font-weight: 600; }
.modal .note { font-size: 11px; color: var(--fg-faint); letter-spacing: .08em; margin: 0 0 20px; }
.modal .btn { width: 100%; min-height: 50px; font-size: 13.5px; border-color: var(--accent-line); }

/* ==========================================================
   横画面 / 大きい画面
   ========================================================== */
@media (orientation: landscape) and (max-height: 560px) {
  :root { --board-size: min(76vh, 92vw); }
  body {
    display: grid;
    grid-template-columns: auto minmax(180px, 250px);
    grid-template-rows: auto;
    align-content: center;
    align-items: center;
    column-gap: 22px;
    padding: 10px 14px;
  }
  .board-wrap { grid-row: 1 / span 4; grid-column: 1; }
  .head, .score, .status, .controls { grid-column: 2; width: 100%; }
  .head { align-self: end; }
}

@media (min-width: 900px) and (min-height: 700px) {
  :root { --board-size: min(560px, 66vh); }
}

/* 動きを減らす設定の人には控えめに */
@media (prefers-reduced-motion: reduce) {
  .stone { transition-duration: .01ms; }
  .stone.dropping, .stone.white.dropping { animation: none; }
  .cell.legal::after { animation: none; }
}
