/* リバーシツール固有スタイル */

.mode-buttons {
  margin-top: 20px;
}

.mode-buttons .btn {
  flex: 1 1 0;
  min-width: 9rem;
  justify-content: center;
}

.difficulty-group {
  margin-top: 20px;
}

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

.option-tab {
  appearance: none;
  min-height: 48px;
  padding: 10px 12px;
  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: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);
}

.game-panel {
  margin-top: 20px;
}

.game-status {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 16px;
  margin-bottom: 12px;
  padding: 14px 16px;
  border: 1px solid var(--md-sys-color-outline-variant);
  border-radius: var(--md-sys-shape-corner-medium);
  background: var(--md-sys-color-surface);
}

.status-pill {
  display: inline-block;
  padding: 5px 12px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--md-sys-color-primary) 12%, var(--md-sys-color-surface));
  color: var(--md-sys-color-primary);
  font-size: 0.8125rem;
  font-weight: 700;
}

.status-pill.is-black {
  background: color-mix(in srgb, #1a1a1a 14%, var(--md-sys-color-surface));
  color: var(--md-sys-color-on-surface);
}

.status-pill.is-white {
  background: color-mix(in srgb, #888 12%, var(--md-sys-color-surface));
  color: var(--md-sys-color-on-surface);
}

.status-pill.is-win {
  background: color-mix(in srgb, var(--success) 14%, var(--md-sys-color-surface));
  color: var(--success);
}

.status-pill.is-lose {
  background: var(--danger-container);
  color: var(--danger);
}

.status-pill.is-draw {
  background: color-mix(in srgb, var(--md-sys-color-outline) 18%, var(--md-sys-color-surface));
  color: var(--md-sys-color-on-surface-variant);
}

.game-status__text {
  margin: 0;
  color: var(--md-sys-color-on-surface);
  font-size: 0.9375rem;
  font-weight: 700;
  line-height: 1.5;
}

.score-text {
  margin: 0 0 10px;
  color: var(--md-sys-color-on-surface);
  font-size: 0.9375rem;
  font-weight: 700;
  text-align: center;
}

.pass-message {
  margin: 0 0 12px;
  padding: 10px 12px;
  border-radius: var(--md-sys-shape-corner-medium);
  background: color-mix(in srgb, var(--md-sys-color-primary) 10%, var(--md-sys-color-surface));
  color: var(--md-sys-color-on-surface);
  font-size: 0.8125rem;
  font-weight: 600;
  text-align: center;
}

.player-info {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 12px;
  padding: 0;
  list-style: none;
  justify-content: center;
}

.player-info__item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--md-sys-color-outline-variant) 40%, var(--md-sys-color-surface));
  color: var(--md-sys-color-on-surface-variant);
  font-size: 0.8125rem;
  font-weight: 600;
}

.player-info__item.is-active {
  outline: 2px solid var(--md-sys-color-primary);
  outline-offset: 1px;
}

.stone-dot {
  inline-size: 12px;
  block-size: 12px;
  border-radius: 50%;
  flex: 0 0 auto;
}

.stone-dot--black {
  background: radial-gradient(circle at 35% 35%, #666, #111);
  box-shadow: inset 0 -1px 2px rgba(255, 255, 255, 0.15);
}

.stone-dot--white {
  background: radial-gradient(circle at 35% 35%, #fff, #ccc);
  border: 1px solid #bbb;
}

.board-wrap {
  width: 100%;
  max-width: min(100%, 480px);
  margin: 0 auto;
  padding: 4px;
  box-sizing: border-box;
}

.board {
  position: relative;
  width: 100%;
  aspect-ratio: 1;
  padding: 2.5%;
  box-sizing: border-box;
  background: #1f7a4d;
  border: 2px solid #0f4d30;
  border-radius: var(--md-sys-shape-corner-small);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.12);
  touch-action: manipulation;
}

.board__grid {
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  grid-template-rows: repeat(8, minmax(0, 1fr));
  width: 100%;
  height: 100%;
  gap: 0;
  background: #0f4d30;
  border: 1px solid #0a3a24;
}

.board__cell {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0;
  padding: 0;
  border: 1px solid rgba(0, 0, 0, 0.22);
  background: #258a58;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.board__cell:disabled {
  cursor: default;
}

.board__cell:not(:disabled):hover,
.board__cell:not(:disabled):focus-visible {
  background: #2c9a64;
}

.board__hint {
  position: absolute;
  inline-size: 18%;
  block-size: 18%;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.32);
  pointer-events: none;
}

.board__stone {
  position: relative;
  inline-size: 78%;
  block-size: 78%;
  border-radius: 50%;
  pointer-events: none;
  transform-style: preserve-3d;
}

.board__stone--black {
  background: radial-gradient(circle at 32% 28%, #555, #0a0a0a);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
}

.board__stone--white {
  background: radial-gradient(circle at 32% 28%, #fff, #d8d8d8);
  border: 1px solid #aaa;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.15);
}

.board__stone.is-last::after {
  content: "";
  position: absolute;
  inset: 38%;
  border-radius: 50%;
  background: rgba(255, 80, 80, 0.85);
}

.board__stone--white.is-last::after {
  background: rgba(220, 50, 50, 0.75);
}

.board__stone.is-flipping {
  animation: stone-flip 0.28s ease;
}

@keyframes stone-flip {
  0% {
    transform: scaleX(1);
  }
  45% {
    transform: scaleX(0.08);
  }
  100% {
    transform: scaleX(1);
  }
}

.qr-preview {
  margin-top: 18px;
  padding: 18px;
  border: 1px solid var(--md-sys-color-outline-variant);
  border-radius: var(--md-sys-shape-corner-large);
  background: var(--md-sys-color-surface);
  text-align: center;
}

#room-qr-code {
  display: flex;
  justify-content: center;
  margin: 0 auto 12px;
}

#room-qr-code img,
#room-qr-code canvas {
  display: block;
  width: 220px;
  height: 220px;
  max-width: 100%;
}

.qr-preview p {
  margin: 0;
  color: var(--md-sys-color-on-surface-variant);
  font-size: 0.875rem;
  line-height: 1.6;
}

.qr-actions {
  justify-content: center;
  margin-top: 16px;
}

.waiting-message {
  margin: 14px 0 0;
  padding: 12px 14px;
  border-radius: var(--md-sys-shape-corner-medium);
  background: color-mix(in srgb, var(--md-sys-color-primary) 10%, var(--md-sys-color-surface));
  color: var(--md-sys-color-on-surface);
  font-size: 0.875rem;
  font-weight: 600;
  text-align: center;
}

@media (max-width: 480px) {
  .board-wrap {
    padding: 2px;
  }

  .game-status {
    padding: 12px;
  }

  .option-tab {
    min-height: 46px;
    padding: 9px 8px;
    font-size: 0.8125rem;
  }

  .board__hint {
    inline-size: 22%;
    block-size: 22%;
  }
}
