/* ============================================================
   Othello 固有スタイル (共通は shared.css 参照)
   ============================================================ */

/* body に flex センタリングを追加（3画面フロー用） */
body {
  display: flex;
  flex-direction: column;
  position: static;
}

/* ---- 設定カード：h1 下マージンを縮めてサブタイトルと近づける ---- */
.settings-card h1 { margin-bottom: 6px; }

/* ---- 設定サブタイトル ---- */
.settings-subtitle {
  color: var(--md-on-surface-variant);
  font-size: 0.78rem;
  letter-spacing: 0.22em;
  text-align: center;
  margin-bottom: 28px;
}

/* ============================================================
   画面共通（3画面フロー: 設定 → コイントス → ゲーム）
   ============================================================ */
.screen {
  position: relative;
  inset: auto;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  z-index: 1;
  min-height: calc(100dvh - 180px);
  padding: 20px 16px;
  width: 100%;
  opacity: 1;
  visibility: visible;
  transition: opacity 0.5s ease, visibility 0s linear 0.5s;
}

.screen.hidden {
  display: none;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.5s ease, visibility 0s;
}

/* ============================================================
   コイントス画面
   ============================================================ */
.coin-scene { text-align: center; user-select: none; }

.coin-title {
  color: var(--md-on-surface-variant);
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 60px;
  letter-spacing: 0.06em;
}

.coin-wrapper { perspective: 700px; width: 150px; height: 150px; margin: 0 auto 60px; }

.coin {
  width: 150px;
  height: 150px;
  position: relative;
  transform-style: preserve-3d;
  will-change: transform;
}

.coin-face {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.coin-face.omote {
  background: radial-gradient(ellipse at 32% 28%, #fff8c0 0%, #f0c800 30%, #c89000 70%, #906000 100%);
  border: 4px solid #b07818;
  box-shadow: inset 0 4px 10px rgba(255,250,180,0.5), inset 0 -4px 10px rgba(0,0,0,0.35), 0 6px 24px rgba(0,0,0,0.6);
}

.coin-face.ura {
  background: radial-gradient(ellipse at 32% 28%, #ffe880 0%, #d8b400 30%, #b07800 70%, #785000 100%);
  border: 4px solid #906010;
  box-shadow: inset 0 4px 10px rgba(255,240,120,0.4), inset 0 -4px 10px rgba(0,0,0,0.35), 0 6px 24px rgba(0,0,0,0.6);
  transform: rotateY(180deg);
}

.coin-kanji {
  font-size: 2.8rem;
  font-weight: 900;
  color: #6b4000;
  text-shadow: 0 1px 0 rgba(255,230,100,0.5), 0 -1px 0 rgba(0,0,0,0.3);
  line-height: 1;
}

.coin-sub { font-size: 0.72rem; font-weight: 700; color: #7a5010; letter-spacing: 0.1em; }

.coin-result { min-height: 70px; opacity: 0; transition: opacity 0.6s ease; }
.coin-result.show { opacity: 1; }

.coin-result-big {
  display: block;
  font-size: 2.2rem;
  font-weight: 900;
  color: #f8f5ec;
  letter-spacing: 0.05em;
  margin-bottom: 10px;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.24);
}

.coin-result-big.heads { color: #228a4f; }
.coin-result-big.tails { color: #b87512; }

.coin-result-sub { color: var(--md-on-surface-variant); font-size: 1.05rem; font-weight: 600; letter-spacing: 0.05em; }

/* ============================================================
   ゲーム画面
   ============================================================ */
.game-container { display: flex; flex-direction: column; align-items: center; gap: 18px; width: min(1120px, 100%); }

.scoreboard {
  display: flex;
  align-items: center;
  background: var(--md-surface-container);
  border: 1px solid var(--md-outline-variant);
  border-radius: 18px;
  overflow: hidden;
  box-shadow: var(--md-elev-2);
}

.score-half {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 28px;
  transition: background 0.3s ease;
}

.score-half.active-turn { background: var(--md-surface-container-high); }

.score-disc { width: 30px; height: 30px; border-radius: 50%; flex-shrink: 0; }

.score-disc.black { background: radial-gradient(circle at 35% 30%, #777 0%, #111 60%, #000 100%); box-shadow: 2px 2px 8px rgba(0,0,0,0.7), inset 0 1px 3px rgba(255,255,255,0.15); }
.score-disc.white { background: radial-gradient(circle at 35% 30%, #fff 0%, #e8e8e8 50%, #c0c0c0 100%); box-shadow: 2px 2px 8px rgba(0,0,0,0.5), inset 0 1px 3px rgba(255,255,255,0.8); }

.score-num { font-size: 2rem; font-weight: 900; color: var(--md-on-surface); min-width: 36px; text-align: center; }

.score-sep { width: 1px; height: 40px; background: var(--md-outline-variant); }

.info-row { display: flex; align-items: center; justify-content: center; gap: 10px; width: 100%; }

.turn-banner {
  padding: 9px 28px;
  border-radius: var(--md-shape-full);
  font-size: 0.92rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  transition: all 0.3s ease;
  min-width: 220px;
  text-align: center;
}

.turn-banner.player  { background: rgba(67,233,123,0.22); border: 1.5px solid rgba(67,233,123,0.36); color: #175b34; }
.turn-banner.cpu     { background: rgba(255,183,77,0.26);  border: 1.5px solid rgba(255,183,77,0.4);  color: #7c4a00; }
.turn-banner.pass    { background: rgba(255,100,80,0.22);  border: 1.5px solid rgba(255,100,80,0.35);  color: #8f2f22; }
.turn-banner.gameover { background: rgba(180,100,255,0.22); border: 1.5px solid rgba(180,100,255,0.38); color: #63308a; }

.diff-badge { font-size: 0.72rem; padding: 3px 10px; border-radius: var(--md-shape-sm); font-weight: 700; letter-spacing: 0.08em; }
.diff-badge.easy   { background: rgba(67,233,123,0.2); color: #43e97b; border: 1px solid rgba(67,233,123,0.3); }
.diff-badge.normal { background: rgba(255,183,77,0.2);  color: #ffb74d; border: 1px solid rgba(255,183,77,0.3); }
.diff-badge.hard   { background: rgba(255,100,80,0.2);  color: #ff7060; border: 1px solid rgba(255,100,80,0.3); }

/* ============================================================
   オセロ盤
   ============================================================ */
.board-wrap { position: relative; width: max-content; max-width: 100%; }

#board-3d {
  display: block;
  width: min(588px, calc(100vw - 64px));
  height: min(588px, calc(100vw - 64px));
  border: 6px solid #5c3800;
  border-radius: 4px;
  box-shadow: 0 0 0 2px #7a5200, 0 0 0 3px #3a2000, 0 25px 60px rgba(0,0,0,0.7);
}

#board {
  display: grid;
  grid-template-columns: repeat(8, 72px);
  grid-template-rows:    repeat(8, 72px);
  background: #1a5c28;
  border: 6px solid #5c3800;
  border-radius: 4px;
  box-shadow: 0 0 0 2px #7a5200, 0 0 0 3px #3a2000, 0 25px 60px rgba(0,0,0,0.7), inset 0 0 60px rgba(0,0,0,0.25);
}

.cell {
  width: 72px;
  height: 72px;
  border: 1px solid rgba(0,0,0,0.28);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: default;
  position: relative;
  transition: background 0.12s ease;
}

.cell.hint { cursor: pointer; }

.cell.hint::after {
  content: '';
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: rgba(255,255,255,0.22);
  border: 2px solid rgba(255,255,255,0.38);
  pointer-events: none;
  transition: transform 0.1s ease;
}

.cell.hint:hover { background: rgba(255,255,255,0.07); }
.cell.hint:hover::after { transform: scale(1.15); }

.cell[data-r="2"][data-c="2"]::before,
.cell[data-r="2"][data-c="5"]::before,
.cell[data-r="5"][data-c="2"]::before,
.cell[data-r="5"][data-c="5"]::before {
  content: '';
  position: absolute;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(0,0,0,0.45);
  pointer-events: none;
  z-index: 0;
}

.disc { width: 60px; height: 60px; border-radius: 50%; position: relative; z-index: 1; pointer-events: none; }
.disc.black { background: radial-gradient(circle at 35% 30%, #666 0%, #1a1a1a 50%, #000 100%); box-shadow: 2px 3px 8px rgba(0,0,0,0.7), inset 0 1px 4px rgba(255,255,255,0.12); }
.disc.white { background: radial-gradient(circle at 35% 30%, #fff 0%, #efefef 40%, #cccccc 100%); box-shadow: 2px 3px 8px rgba(0,0,0,0.5), inset 0 2px 6px rgba(255,255,255,0.9); }

@keyframes place {
  0%   { transform: scale(0) translateY(-8px); opacity: 0; }
  65%  { transform: scale(1.12) translateY(0); opacity: 1; }
  100% { transform: scale(1)    translateY(0); opacity: 1; }
}

.disc.placing { animation: place 0.28s ease-out forwards; }

/* ============================================================
   ゲームオーバーオーバーレイ
   ============================================================ */
#overlay {
  position: absolute;
  inset: -6px;
  background: rgba(0,0,0,0);
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.5s ease, background 0.5s ease;
  z-index: 20;
}

#overlay.show { opacity: 1; pointer-events: all; background: rgba(0,0,0,0.82); }

.overlay-box { text-align: center; color: #fff; }

.overlay-title  { font-size: 2.2rem; font-weight: 900; letter-spacing: 0.1em; margin-bottom: 14px; }
.overlay-score  { font-size: 1.1rem; color: var(--md-on-surface-variant); margin-bottom: 12px; }
.overlay-winner { font-size: 1.6rem; font-weight: 900; margin-bottom: 28px; }

.win-player { color: #43e97b; }
.win-cpu    { color: #ff6b6b; }
.win-draw   { color: #ffd700; }

.replay-btn {
  padding: 12px 36px;
  background: var(--md-primary);
  color: var(--md-on-primary);
  border-radius: var(--md-shape-full);
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  box-shadow: var(--md-elev-1);
  transition: box-shadow 200ms;
}
.replay-btn:hover { box-shadow: var(--md-elev-2); }

/* ============================================================
   フッター
   ============================================================ */
.game-footer { display: flex; gap: 10px; width: 100%; justify-content: center; order: -1; }

.back-btn {
  padding: 9px 22px;
  background: var(--md-secondary-container);
  color: var(--md-on-secondary-container);
  border-radius: var(--md-shape-full);
  font-size: 0.85rem;
  font-weight: 600;
  box-shadow: var(--md-elev-1);
  transition: box-shadow 200ms;
}
.back-btn:hover { box-shadow: var(--md-elev-2); }

@media (max-width: 760px) {
  #board-3d {
    width: min(520px, calc(100vw - 32px));
    height: min(520px, calc(100vw - 32px));
  }

  #board {
    grid-template-columns: repeat(8, min(12vw, 56px));
    grid-template-rows: repeat(8, min(12vw, 56px));
  }

  .cell {
    width: min(12vw, 56px);
    height: min(12vw, 56px);
  }

  .disc {
    width: min(10vw, 46px);
    height: min(10vw, 46px);
  }
}
