/* ========================================
   OTHELLO — style.css
   Refined luxury minimal aesthetic + CPU mode
   ======================================== */

/* ── CSS変数 ── */
:root {
  --bg: #f7f5f2;
  --bg-panel: #ffffff;
  --board-green: #2d6a4f;
  --board-dark:  #1b4332;
  --board-line:  rgba(0,0,0,0.15);
  --board-hover: rgba(255,255,255,0.10);
  --stone-black: #111111;
  --stone-black-hi: #3a3a3a;
  --stone-white: #f0ede8;
  --stone-white-hi: #ffffff;
  --hint-color:  rgba(255,255,255,0.22);
  --accent:      #3b82f6;
  --text-primary: #1a1a1a;
  --text-secondary: #6b6b6b;
  --card-shadow: 0 4px 24px rgba(0,0,0,0.08);
  --board-shadow: 0 24px 80px rgba(0,0,0,0.28), 0 4px 16px rgba(0,0,0,0.18);
  --radius-card: 20px;
  --radius-btn:  14px;
  --font-display: 'Cormorant Garamond', serif;
  --font-body: 'DM Sans', sans-serif;
}

/* ── リセット ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text-primary);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image:
    radial-gradient(ellipse at 20% 10%, rgba(59,130,246,0.04) 0%, transparent 60%),
    radial-gradient(ellipse at 80% 90%, rgba(45,106,79,0.06) 0%, transparent 60%);
  pointer-events: none;
  z-index: 0;
}

/* ======================================
   SETUP MODAL
   ====================================== */
.setup-backdrop {
  position: fixed;
  inset: 0;
  z-index: 2000;
  background: rgba(20,18,15,0.72);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.4s ease;
}

.setup-backdrop.hidden {
  opacity: 0;
  pointer-events: none;
}

.setup-card {
  background: var(--bg-panel);
  border-radius: 28px;
  padding: 52px 48px 48px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 28px;
  box-shadow: 0 40px 120px rgba(0,0,0,0.3), 0 4px 16px rgba(0,0,0,0.1);
  min-width: 380px;
  max-width: 440px;
  width: 92vw;
  animation: setupCardIn 0.45s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

@keyframes setupCardIn {
  from { transform: scale(0.88) translateY(16px); opacity: 0; }
  to   { transform: scale(1) translateY(0); opacity: 1; }
}

.setup-ornament {
  font-size: 18px;
  color: var(--text-secondary);
  opacity: 0.35;
  letter-spacing: 0.1em;
}

.setup-logo {
  font-family: var(--font-display);
  font-size: 36px;
  font-weight: 600;
  letter-spacing: 0.28em;
  color: var(--text-primary);
  margin-top: -8px;
}

.setup-section {
  width: 100%;
}

.setup-subtitle {
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.18em;
  color: var(--text-secondary);
  text-align: center;
  text-transform: uppercase;
  margin-bottom: 16px;
}

/* モードボタン */
.mode-btn-group {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.mode-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 22px 16px;
  background: var(--bg);
  border: 2px solid transparent;
  border-radius: 16px;
  cursor: pointer;
  transition: all 0.22s ease;
  font-family: var(--font-body);
}

.mode-btn:hover {
  background: #f0ede8;
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0,0,0,0.08);
}

.mode-btn.selected {
  border-color: var(--text-primary);
  background: var(--text-primary);
  color: #fff;
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0,0,0,0.2);
}

.mode-icon {
  width: 32px;
  height: 32px;
  opacity: 0.7;
}

.mode-btn.selected .mode-icon { opacity: 0.9; }

.mode-label {
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 0.04em;
}

.mode-sub {
  font-size: 11px;
  color: var(--text-secondary);
  font-weight: 400;
}

.mode-btn.selected .mode-sub { color: rgba(255,255,255,0.65); }

/* CPU設定セクション */
.setup-cpu-section {
  animation: slideDown 0.28s ease both;
}

@keyframes slideDown {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.setup-divider {
  height: 1px;
  background: rgba(0,0,0,0.07);
  margin-bottom: 20px;
}

.setup-option-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.setup-option-row:last-child { margin-bottom: 0; }

.option-label {
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.06em;
  color: var(--text-secondary);
}

.option-btn-group {
  display: flex;
  gap: 6px;
}

.opt-btn {
  font-family: var(--font-body);
  font-size: 12px;
  font-weight: 500;
  padding: 7px 14px;
  border-radius: 10px;
  border: 1.5px solid rgba(0,0,0,0.12);
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.18s ease;
  display: flex;
  align-items: center;
  gap: 6px;
}

.opt-btn:hover {
  border-color: rgba(0,0,0,0.25);
  color: var(--text-primary);
}

.opt-btn.active {
  background: var(--text-primary);
  border-color: var(--text-primary);
  color: #fff;
}

/* mini stones in buttons */
.mini-stone {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}

.mini-stone.black {
  background: radial-gradient(circle at 35% 30%, #444 0%, #111 60%);
  box-shadow: 0 1px 3px rgba(0,0,0,0.5);
}

.mini-stone.white {
  background: radial-gradient(circle at 35% 30%, #fff 0%, #e8e5e0 60%);
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

/* Start ボタン */
.btn-start {
  width: 100%;
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 0.08em;
  color: #fff;
  background: var(--text-primary);
  border: none;
  padding: 16px;
  border-radius: var(--radius-btn);
  cursor: pointer;
  transition: transform 0.22s ease, box-shadow 0.22s ease, background 0.22s ease;
  box-shadow: 0 4px 16px rgba(0,0,0,0.2);
  animation: fadeInUp 0.3s ease both;
}

@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.btn-start:hover {
  background: #2a2a2a;
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0,0,0,0.25);
}

.btn-start:active { transform: translateY(1px); }

.hidden { display: none !important; }

/* ======================================
   HEADER
   ====================================== */
.site-header {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 100;
  height: 64px;
  background: rgba(247,245,242,0.88);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid rgba(0,0,0,0.07);
}

.header-inner {
  max-width: 1100px;
  margin: 0 auto;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 32px;
}

.header-logo {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 600;
  letter-spacing: 0.22em;
  color: var(--text-primary);
}

.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.mode-badge {
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.1em;
  color: var(--text-secondary);
  background: rgba(0,0,0,0.05);
  padding: 4px 10px;
  border-radius: 20px;
  display: none;
}

.mode-badge.visible { display: inline-block; }

/* ======================================
   BUTTONS
   ====================================== */
.btn-reset {
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.06em;
  color: var(--text-secondary);
  background: transparent;
  border: 1.5px solid rgba(0,0,0,0.15);
  padding: 8px 20px;
  border-radius: var(--radius-btn);
  cursor: pointer;
  transition: all 0.22s ease;
}
.btn-reset:hover {
  color: var(--text-primary);
  border-color: rgba(0,0,0,0.35);
  background: rgba(0,0,0,0.03);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}
.btn-reset:active { transform: translateY(1px); box-shadow: none; }

/* ======================================
   MAIN LAYOUT
   ====================================== */
.main-layout {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  padding-top: 64px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 32px;
  padding-left: 24px;
  padding-right: 24px;
  padding-bottom: 40px;
}

/* ======================================
   SIDE PANELS
   ====================================== */
.side-panel {
  width: 160px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.player-card {
  width: 100%;
  background: var(--bg-panel);
  border-radius: var(--radius-card);
  padding: 28px 20px;
  box-shadow: var(--card-shadow);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  border: 1px solid rgba(0,0,0,0.05);
  transition: box-shadow 0.3s ease, transform 0.3s ease;
}

.player-card.active {
  box-shadow: 0 8px 32px rgba(59,130,246,0.14), 0 2px 8px rgba(0,0,0,0.06);
  transform: translateY(-3px);
}

.player-info {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.player-label {
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.18em;
  color: var(--text-secondary);
}

.player-score {
  font-family: var(--font-display);
  font-size: 48px;
  font-weight: 300;
  line-height: 1;
  color: var(--text-primary);
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.player-score.bump {
  animation: scoreBump 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes scoreBump {
  0%   { transform: scale(1); }
  40%  { transform: scale(1.22); }
  100% { transform: scale(1); }
}

/* ターンインジケーター */
.turn-indicator {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 9px;
  font-weight: 500;
  letter-spacing: 0.14em;
  color: var(--accent);
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 0.25s ease, transform 0.25s ease;
}

.turn-indicator.visible {
  opacity: 1;
  transform: translateY(0);
}

.turn-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  flex-shrink: 0;
  animation: pulse 1.4s ease infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%       { opacity: 0.5; transform: scale(0.7); }
}

/* ======================================
   THINKING BADGE (CPU)
   ====================================== */
.thinking-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.1em;
  color: var(--text-secondary);
  animation: fadeInUp 0.25s ease both;
}

.thinking-dots {
  display: flex;
  gap: 3px;
  align-items: center;
}

.thinking-dots span {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--text-secondary);
  animation: dotBounce 1.1s ease infinite;
}

.thinking-dots span:nth-child(2) { animation-delay: 0.18s; }
.thinking-dots span:nth-child(3) { animation-delay: 0.36s; }

@keyframes dotBounce {
  0%, 100% { transform: translateY(0); opacity: 0.4; }
  40%       { transform: translateY(-4px); opacity: 1; }
}

/* ======================================
   BOARD SECTION
   ====================================== */
.board-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
}

.turn-banner {
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
}

#turnText {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 300;
  letter-spacing: 0.08em;
  color: var(--text-primary);
  animation: fadeSlideIn 0.3s ease;
}

@keyframes fadeSlideIn {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.pass-notice {
  min-height: 24px;
  font-size: 12px;
  font-weight: 400;
  letter-spacing: 0.06em;
  color: var(--accent);
  text-align: center;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.pass-notice.visible {
  opacity: 1;
  animation: fadeSlideIn 0.3s ease;
}

/* ======================================
   BOARD LABELS
   ====================================== */
.board-wrapper { position: relative; }

.board-container {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.col-labels {
  display: grid;
  grid-template-columns: 24px repeat(8, 80px);
  width: calc(80px * 8 + 24px);
}

.col-labels span,
.row-labels span {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 400;
  letter-spacing: 0.08em;
  color: var(--text-secondary);
  height: 24px;
}

.board-body {
  display: flex;
  gap: 4px;
}

.row-labels {
  display: flex;
  flex-direction: column;
  width: 24px;
}

.row-labels span {
  width: 24px;
  height: 80px;
}

/* ======================================
   BOARD & CELLS
   ====================================== */
.board {
  display: grid;
  grid-template-columns: repeat(8, 80px);
  grid-template-rows:    repeat(8, 80px);
  background: var(--board-dark);
  border-radius: 10px;
  overflow: hidden;
  box-shadow: var(--board-shadow);
  border: 3px solid var(--board-dark);
  gap: 1px;
}

.cell {
  position: relative;
  width: 80px;
  height: 80px;
  background: var(--board-green);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: default;
  transition: background 0.18s ease;
}

/* 星点 */
.cell[data-row="2"][data-col="2"]::after,
.cell[data-row="2"][data-col="6"]::after,
.cell[data-row="6"][data-col="2"]::after,
.cell[data-row="6"][data-col="6"]::after {
  content: '';
  position: absolute;
  width: 6px;
  height: 6px;
  background: rgba(0,0,0,0.22);
  border-radius: 50%;
  z-index: 1;
}

/* 合法手セル */
.cell.legal { cursor: pointer; }
.cell.legal:hover { background: rgba(255,255,255,0.07); }

/* ======================================
   HINT / PREVIEW
   ====================================== */
.hint-dot {
  position: absolute;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--hint-color);
  border: 1.5px solid rgba(255,255,255,0.3);
  pointer-events: none;
  animation: hintAppear 0.25s ease forwards;
}

@keyframes hintAppear {
  from { opacity: 0; transform: scale(0.6); }
  to   { opacity: 1; transform: scale(1); }
}

.cell.legal:hover .hint-dot { opacity: 0; }

.preview-stone {
  position: absolute;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  pointer-events: none;
  opacity: 0;
  transform: scale(0.85);
  transition: opacity 0.15s ease, transform 0.15s ease;
}

.cell.legal:hover .preview-stone {
  opacity: 0.38;
  transform: scale(1);
}

/* ======================================
   STONES
   ====================================== */
.stone {
  position: absolute;
  width: 62px;
  height: 62px;
  border-radius: 50%;
  z-index: 2;
}

.stone.placing {
  animation: stoneDrop 0.32s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes stoneDrop {
  0%   { transform: scale(0.55); opacity: 0; }
  70%  { transform: scale(1.06); opacity: 1; }
  100% { transform: scale(1);    opacity: 1; }
}

/* 黒石 */
.stone.black {
  background: radial-gradient(circle at 36% 32%, var(--stone-black-hi) 0%, var(--stone-black) 55%);
  box-shadow:
    inset 0 -3px 6px rgba(0,0,0,0.6),
    inset 0  2px 4px rgba(255,255,255,0.12),
    0 4px 14px rgba(0,0,0,0.55),
    0 1px 3px rgba(0,0,0,0.4);
}

/* 白石 */
.stone.white {
  background: radial-gradient(circle at 36% 32%, var(--stone-white-hi) 0%, var(--stone-white) 60%);
  box-shadow:
    inset 0 -3px 6px rgba(0,0,0,0.10),
    inset 0  2px 5px rgba(255,255,255,0.95),
    0 4px 14px rgba(0,0,0,0.22),
    0 1px 3px rgba(0,0,0,0.15);
}

/* プレビュー石 */
.preview-stone.black {
  background: radial-gradient(circle at 36% 32%, var(--stone-black-hi) 0%, var(--stone-black) 55%);
}
.preview-stone.white {
  background: radial-gradient(circle at 36% 32%, var(--stone-white-hi) 0%, var(--stone-white) 60%);
}

/* ======================================
   石の反転アニメーション
   ====================================== */
.stone.flip-out {
  animation: flipOut 0.15s ease-in forwards;
}
@keyframes flipOut {
  from { transform: rotateY(0deg) scale(1); }
  to   { transform: rotateY(90deg) scale(0.85); }
}

.stone.flip-in {
  animation: flipIn 0.15s ease-out forwards;
}
@keyframes flipIn {
  from { transform: rotateY(90deg) scale(0.85); }
  to   { transform: rotateY(0deg) scale(1); }
}

/* ======================================
   CPU最終手ハイライト
   ====================================== */
.cell.cpu-last::before {
  content: '';
  position: absolute;
  inset: 3px;
  border-radius: 4px;
  border: 2px solid rgba(59,130,246,0.55);
  z-index: 3;
  pointer-events: none;
  animation: cpuGlow 0.8s ease forwards;
}

@keyframes cpuGlow {
  0%   { opacity: 0; }
  30%  { opacity: 1; }
  100% { opacity: 0.4; }
}

/* ======================================
   GAME OVER MODAL
   ====================================== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(20,18,15,0);
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  transition: background 0.4s ease;
}

.modal-backdrop.open {
  background: rgba(20,18,15,0.72);
  pointer-events: all;
  backdrop-filter: blur(6px);
}

.modal-card {
  background: var(--bg-panel);
  border-radius: 24px;
  padding: 52px 56px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  box-shadow: 0 32px 100px rgba(0,0,0,0.28), 0 4px 16px rgba(0,0,0,0.12);
  transform: scale(0.88);
  opacity: 0;
  transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.3s ease;
  min-width: 340px;
}

.modal-backdrop.open .modal-card {
  transform: scale(1);
  opacity: 1;
}

.modal-ornament {
  font-size: 22px;
  color: var(--text-secondary);
  opacity: 0.4;
}

.modal-title {
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 400;
  letter-spacing: 0.22em;
  color: var(--text-secondary);
  text-transform: uppercase;
}

.modal-winner {
  font-family: var(--font-display);
  font-size: 42px;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: 0.04em;
  text-align: center;
}

.modal-backdrop.open .modal-winner {
  animation: winnerReveal 0.5s 0.3s ease both;
}

@keyframes winnerReveal {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.modal-scores {
  display: flex;
  align-items: center;
  gap: 20px;
  margin: 4px 0;
}

.modal-score-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.modal-score-item span {
  font-family: var(--font-display);
  font-size: 36px;
  font-weight: 300;
  color: var(--text-primary);
}

.modal-score-sep {
  font-size: 20px;
  color: var(--text-secondary);
  opacity: 0.4;
  margin-bottom: 8px;
}

/* stones in panels/modal */
.stone-preview { border-radius: 50%; }

.stone-preview.stone-black {
  width: 44px; height: 44px;
  background: radial-gradient(circle at 36% 32%, var(--stone-black-hi) 0%, var(--stone-black) 55%);
  box-shadow: 0 3px 10px rgba(0,0,0,0.4);
}

.stone-preview.stone-white {
  width: 44px; height: 44px;
  background: radial-gradient(circle at 36% 32%, var(--stone-white-hi) 0%, var(--stone-white) 60%);
  box-shadow: 0 3px 10px rgba(0,0,0,0.18);
}

.stone-preview.small { width: 36px; height: 36px; }

.btn-play-again {
  margin-top: 8px;
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 0.08em;
  color: #fff;
  background: var(--text-primary);
  border: none;
  padding: 14px 40px;
  border-radius: var(--radius-btn);
  cursor: pointer;
  transition: transform 0.22s ease, box-shadow 0.22s ease, background 0.22s ease;
  box-shadow: 0 4px 16px rgba(0,0,0,0.22);
}
.btn-play-again:hover {
  background: #2a2a2a;
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0,0,0,0.28);
}
.btn-play-again:active { transform: translateY(1px); }

/* ======================================
   RESPONSIVE
   ====================================== */
@media (max-width: 860px) {
  .main-layout {
    flex-direction: column;
    gap: 20px;
    padding-top: 80px;
  }

  .side-panel {
    width: 100%;
    flex-direction: row;
    justify-content: center;
  }

  .player-card {
    flex-direction: row;
    padding: 16px 28px;
    gap: 20px;
    width: auto;
  }

  .player-info { flex-direction: row; align-items: baseline; gap: 10px; }
  .player-score { font-size: 32px; }
  .turn-indicator { display: none; }
  .thinking-badge { font-size: 9px; }

  .board {
    grid-template-columns: repeat(8, min(9vw, 70px));
    grid-template-rows:    repeat(8, min(9vw, 70px));
  }
  .cell {
    width: min(9vw, 70px);
    height: min(9vw, 70px);
  }
  .stone {
    width: calc(min(9vw, 70px) - 16px);
    height: calc(min(9vw, 70px) - 16px);
  }
  .preview-stone {
    width: calc(min(9vw, 70px) - 16px);
    height: calc(min(9vw, 70px) - 16px);
  }

  .col-labels {
    grid-template-columns: 20px repeat(8, min(9vw, 70px));
    width: calc(min(9vw, 70px) * 8 + 20px);
  }
  .row-labels { width: 20px; }
  .row-labels span { width: 20px; height: min(9vw, 70px); }
}

@media (max-width: 540px) {
  .col-labels, .row-labels { display: none; }
  .modal-card { padding: 36px 28px; min-width: 280px; }
  .modal-winner { font-size: 32px; }
  .setup-card { padding: 40px 28px 36px; }
  .mode-btn { padding: 18px 12px; }
}
