/* ==========================================================================
   シンクロ将棋 (SyncShogi) - コンポーネントスタイル (ボタン・モーダル・パネル)
   ========================================================================== */

/* ボタン共通 */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  font-family: var(--font-sans);
  font-size: 0.95rem;
  font-weight: 700;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all var(--transition-fast);
  outline: none;
  letter-spacing: 0.04em;
}

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

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  pointer-events: none;
}

/* プライマリボタン（ゴールド調） */
.btn-primary {
  background: linear-gradient(135deg, var(--color-gold) 0%, #ca963f 100%);
  color: #1a1005;
  box-shadow: 0 4px 14px rgba(229, 185, 92, 0.3);
}

.btn-primary:hover {
  background: linear-gradient(135deg, var(--color-gold-hover) 0%, #db9f44 100%);
  box-shadow: 0 6px 20px rgba(229, 185, 92, 0.45);
}

/* セカンダリボタン（漆黒・サーフェス調） */
.btn-secondary {
  background: var(--bg-surface-elevated);
  color: var(--text-primary);
  border-color: rgba(255, 255, 255, 0.12);
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: var(--color-gold);
}

/* 朱色ボタン（アクセント/確定/パス） */
.btn-accent {
  background: linear-gradient(135deg, var(--color-vermilion) 0%, #c4382e 100%);
  color: #fff;
  box-shadow: 0 4px 14px var(--color-vermilion-glow);
}

.btn-accent:hover {
  background: linear-gradient(135deg, #ef6056 0%, #d83f34 100%);
  box-shadow: 0 6px 20px rgba(230, 83, 73, 0.5);
}

.btn-lg {
  padding: 14px 28px;
  font-size: 1.1rem;
}

.btn-sm {
  padding: 5px 12px;
  font-size: 0.82rem;
  border-radius: var(--radius-sm);
}

/* 操作パネル（対局画面下部） */
.action-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  max-width: 580px;
  gap: 12px;
  padding: 10px 14px;
  background: var(--bg-glass);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-md);
}

.turn-status-badge {
  display: flex;
  flex-direction: column;
}

.turn-phase-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.turn-phase-name {
  font-family: var(--font-serif);
  font-size: 1rem;
  font-weight: 700;
  color: var(--color-gold);
}

.staged-move-preview {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-top: 2px;
  letter-spacing: 0.02em;
}

.staged-move-preview.active {
  color: var(--color-jade);
  font-weight: 700;
  text-shadow: 0 0 8px rgba(46, 196, 182, 0.4);
}

.action-buttons {
  display: flex;
  gap: 8px;
}

/* モーダルオーバーレイ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(6px);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 100;
  animation: fadeIn var(--transition-fast) ease-out;
}

.modal-overlay.active {
  display: flex;
}

.modal-card {
  width: 100%;
  max-width: 440px;
  background: var(--bg-surface);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--radius-lg);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.8), 0 0 20px rgba(229, 185, 92, 0.1);
  overflow: hidden;
  animation: slideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-title {
  font-family: var(--font-serif);
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--color-gold);
}

.modal-body {
  padding: 20px;
  color: var(--text-secondary);
  font-size: 0.95rem;
  line-height: 1.6;
}

.modal-footer {
  padding: 14px 20px;
  background: rgba(0, 0, 0, 0.2);
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* 成り選択モーダル特化スタイル */
.promote-preview {
  display: flex;
  align-items: center;
  justify-content: space-around;
  margin: 16px 0;
}

.promote-option {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 14px 20px;
  background: var(--bg-surface-elevated);
  border: 2px solid transparent;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.promote-option:hover {
  border-color: var(--color-gold);
  background: rgba(229, 185, 92, 0.1);
  transform: translateY(-2px);
}

.promote-option img {
  width: 52px;
  height: 56px;
  object-fit: contain;
}

.promote-option-label {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-primary);
}

/* アニメーション */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(20px) scale(0.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* ==========================================================================
   相討ち (CRASH!!) カットイン演出スタイル
   ========================================================================== */
.crash-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle, rgba(230, 83, 73, 0.4) 0%, rgba(13, 14, 17, 0.85) 80%);
  backdrop-filter: blur(4px);
  z-index: 200;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease-out;
}

.crash-overlay.active {
  opacity: 1;
  pointer-events: auto;
  animation: screenShake 0.5s cubic-bezier(0.36, 0.07, 0.19, 0.97) both;
}

.crash-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  transform: scale(0.6);
  opacity: 0;
}

.crash-overlay.active .crash-content {
  animation: crashBurst 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

.crash-badge {
  font-family: var(--font-sans);
  font-size: 0.85rem;
  font-weight: 800;
  letter-spacing: 0.2em;
  color: #ffb4a2;
  text-transform: uppercase;
  margin-bottom: 8px;
}

.crash-title {
  font-family: var(--font-serif);
  font-size: 4rem;
  font-weight: 900;
  color: #fff;
  text-shadow: 0 0 20px rgba(230, 83, 73, 0.9), 0 0 40px rgba(230, 83, 73, 0.6);
  letter-spacing: 0.15em;
  line-height: 1.1;
}

.crash-subtitle {
  font-family: var(--font-sans);
  font-size: 2.2rem;
  font-weight: 900;
  color: var(--color-gold);
  text-shadow: 0 0 15px rgba(229, 185, 92, 0.8);
  letter-spacing: 0.1em;
  margin-top: 4px;
}

.crash-desc {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-top: 14px;
  background: rgba(0, 0, 0, 0.6);
  padding: 6px 18px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(255, 255, 255, 0.15);
}

@keyframes screenShake {
  10%, 90% { transform: translate3d(-2px, 0, 0); }
  20%, 80% { transform: translate3d(4px, 0, 0); }
  30%, 50%, 70% { transform: translate3d(-6px, 0, 0); }
  40%, 60% { transform: translate3d(6px, 0, 0); }
}

@keyframes crashBurst {
  0% {
    transform: scale(0.3) rotate(-3deg);
    opacity: 0;
  }
  60% {
    transform: scale(1.1) rotate(1deg);
    opacity: 1;
  }
  100% {
    transform: scale(1) rotate(0deg);
    opacity: 1;
  }
}

/* ==========================================================================
   終局結果モーダル スタイル
   ========================================================================== */
.text-center {
  text-align: center;
}

.result-message-badge {
  display: inline-block;
  font-family: var(--font-serif);
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--color-gold);
  padding: 8px 24px;
  background: rgba(229, 185, 92, 0.12);
  border: 1px solid rgba(229, 185, 92, 0.3);
  border-radius: var(--radius-md);
  margin-bottom: 16px;
}

.result-detail-text {
  font-size: 1.05rem;
  line-height: 1.6;
  color: var(--text-primary);
}

/* ==========================================================================
   P2Pルームモーダル＆相手インジケータースタイル
   ========================================================================== */
.modal-close-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.5rem;
  cursor: pointer;
  padding: 4px 8px;
  line-height: 1;
  transition: color var(--transition-fast);
}

.modal-close-btn:hover {
  color: var(--text-primary);
}

.modal-desc {
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin-bottom: 16px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 16px;
}

.form-label {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-secondary);
}

.form-input {
  background: var(--bg-surface-elevated);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  color: var(--text-primary);
  font-family: var(--font-en);
  font-size: 0.95rem;
  outline: none;
  transition: border-color var(--transition-fast);
  width: 65%;
}

.form-input:focus {
  border-color: var(--color-gold);
}

.room-share-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.room-id-display {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-en);
}

.room-id-label {
  font-size: 0.9rem;
  color: var(--text-muted);
}

.room-id-value {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--color-gold);
  letter-spacing: 0.08em;
}

.qr-code-wrapper {
  width: 150px;
  height: 150px;
  background: #fff;
  border-radius: var(--radius-sm);
  padding: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

.qr-image {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.qr-placeholder {
  color: #666;
  font-size: 0.8rem;
  text-align: center;
}

.invite-url-container {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
  gap: 8px;
  flex-wrap: wrap;
}

.invite-url-container .form-input {
  flex: 1;
  min-width: 160px;
  width: auto;
}

.invite-url-container .btn {
  white-space: nowrap;
}

/* X (旧Twitter) ポストボタン */
.btn-x {
  background: #000000;
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.25);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

.btn-x:hover {
  background: #14171a;
  border-color: rgba(255, 255, 255, 0.6);
  box-shadow: 0 4px 16px rgba(255, 255, 255, 0.2);
}

.copy-feedback {
  font-size: 0.8rem;
  color: var(--color-jade);
  font-weight: 600;
  min-height: 1.2em;
}

.connection-status-box {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: rgba(0, 0, 0, 0.3);
  border-radius: var(--radius-sm);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.status-indicator-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.status-indicator-dot.waiting {
  background: #f4a261;
  box-shadow: 0 0 8px rgba(244, 162, 97, 0.8);
  animation: pulseDot 1.4s infinite;
}

.status-indicator-dot.connecting {
  background: #e76f51;
  box-shadow: 0 0 8px rgba(231, 111, 81, 0.8);
  animation: pulseDot 1.4s infinite;
}

.status-indicator-dot.connected {
  background: var(--color-jade);
  box-shadow: 0 0 8px rgba(46, 196, 182, 0.8);
}

.status-indicator-text {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

@keyframes pulseDot {
  0% { transform: scale(0.9); opacity: 0.6; }
  50% { transform: scale(1.2); opacity: 1; }
  100% { transform: scale(0.9); opacity: 0.6; }
}

/* 相手コミットインジケーター（奥側駒台） */
.opponent-commit-indicator {
  margin-left: auto;
  font-size: 0.78rem;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-muted);
  border: 1px solid rgba(255, 255, 255, 0.1);
  display: none;
}

.opponent-commit-indicator.active {
  display: inline-block;
}

.opponent-commit-indicator.committed {
  background: rgba(46, 196, 182, 0.2);
  color: var(--color-jade);
  border-color: rgba(46, 196, 182, 0.5);
  box-shadow: 0 0 8px rgba(46, 196, 182, 0.3);
}

/* ==========================================================================
   フェーズ4: タイマー、ルール設定、棋譜コピー スタイル
   ========================================================================== */
.modal-card-lg {
  max-width: 520px;
}

/* ヘッダー内タイマー */
.turn-timer-badge {
  font-family: var(--font-en);
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--color-gold);
  padding: 4px 10px;
  background: rgba(229, 185, 92, 0.12);
  border: 1px solid rgba(229, 185, 92, 0.25);
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  transition: all var(--transition-fast);
}

.turn-timer-badge.urgent {
  color: #fff;
  background: var(--color-vermilion);
  border-color: var(--color-vermilion);
  box-shadow: 0 0 12px var(--color-vermilion-glow);
  animation: pulseUrgent 0.8s infinite;
}

@keyframes pulseUrgent {
  0% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.06); opacity: 0.85; }
  100% { transform: scale(1); opacity: 1; }
}

/* ルール設定セクション */
.room-settings-section {
  width: 100%;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  margin-bottom: 16px;
}

.section-subtitle {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--color-gold);
  margin-bottom: 10px;
  letter-spacing: 0.05em;
}

.settings-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px 14px;
}

.form-select {
  background: var(--bg-surface-elevated);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: var(--radius-sm);
  padding: 7px 10px;
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 0.85rem;
  outline: none;
  cursor: pointer;
  transition: border-color var(--transition-fast);
  width: 100%;
}

.form-select:focus {
  border-color: var(--color-gold);
}

/* ゲスト側ルールプレビュー */
.rules-preview-box {
  background: rgba(229, 185, 92, 0.08);
  border: 1px solid rgba(229, 185, 92, 0.25);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  margin-bottom: 14px;
}

.preview-title {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--color-gold);
  margin-bottom: 4px;
}

.preview-content {
  font-size: 0.9rem;
  color: var(--text-primary);
}

/* 棋譜コピーセクション */
.kifu-copy-section {
  margin-top: 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

/* ==========================================================================
   対戦復帰・再接続モーダル スタイル
   ========================================================================== */
.reconnect-spinner-wrapper {
  padding: 16px 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* ヘッダー内対局情報 & アクション */
.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

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

/* ==========================================================================
   遊び方・ルール説明モーダル スタイル
   ========================================================================== */
.modal-card-lg {
  max-width: 580px;
}

.rules-modal-body {
  max-height: 68vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 16px 20px;
}

.rules-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.rules-heading {
  font-family: var(--font-serif);
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--color-gold);
  border-bottom: 1px solid rgba(229, 185, 92, 0.25);
  padding-bottom: 4px;
}

.rule-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 10px;
}

.rule-card {
  background: var(--bg-surface-elevated);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 0.88rem;
  line-height: 1.5;
}

.rule-card-title {
  font-weight: 700;
  color: var(--color-gold);
  margin-bottom: 4px;
}

.rules-list {
  padding-left: 18px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.9rem;
  line-height: 1.5;
}
