:root {
  --bg-dark: #0b0f17;
  --bg-panel: #131924;
  --bg-card: #1c2436;
  --border-color: #273449;
  --text-main: #f0f4f8;
  --text-muted: #8e9bb0;
  --board-wood: #dfb16b;
  --board-wood-dark: #b8863f;
  --board-line: #3b2810;
  --sente-color: #3b82f6;
  --gote-color: #ef4444;
  --evo-gold: #f59e0b;
  --evo-glow: rgba(245, 158, 11, 0.45);
  --step-green: #10b981;
  --ray-cyan: #06b6d4;

  /* スマホ画面幅に完全に合わせた動的盤面セルサイズ (iPhone SE〜大画面スマホ〜PC) */
  --cell-w: clamp(34px, calc((100vw - 44px) / 9.6), 52px);
  --cell-h: calc(var(--cell-w) * 1.05);
  --matrix-cell-sz: clamp(32px, calc((100vw - 64px) / 5.4), 44px);
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Hiragino Kaku Gothic ProN", "Yu Gothic", sans-serif;
  background-color: var(--bg-dark);
  color: var(--text-main);
  min-height: 100vh;
  overflow-x: hidden;
  touch-action: manipulation;
}

/* スマホ中心の縦型コンテナ（PCでも中央に見やすく収まる） */
.app-container {
  max-width: 580px;
  margin: 0 auto;
  padding: 8px 10px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* ==========================================
   1行コンパクトヘッダー
   ========================================== */
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--bg-panel);
  padding: 6px 10px;
  border-radius: 10px;
  border: 1px solid var(--border-color);
  min-height: 44px;
}

.logo-area h1 {
  font-size: 1.05rem;
  font-weight: 900;
  letter-spacing: 0.04em;
  color: #fff;
  display: flex;
  align-items: baseline;
  gap: 4px;
}

.logo-area .subtitle {
  font-size: 0.65rem;
  color: var(--evo-gold);
  font-weight: 800;
  letter-spacing: 0.08em;
}

.header-controls {
  display: flex;
  align-items: center;
  gap: 5px;
}

/* ヘッダーボタン */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.12s ease;
  user-select: none;
}

.btn-header {
  padding: 5px 8px;
  font-size: 0.72rem;
  background: var(--bg-card);
  color: var(--text-main);
  border-color: var(--border-color);
}
.btn-header:active {
  transform: scale(0.96);
}

.btn-primary {
  background: var(--sente-color);
  color: #fff;
}
.btn-secondary {
  background: var(--bg-card);
  color: var(--text-main);
  border-color: var(--border-color);
}
.btn-outline {
  background: transparent;
  color: var(--evo-gold);
  border-color: rgba(245, 158, 11, 0.5);
}
.btn-accent {
  background: linear-gradient(135deg, #f59e0b, #d97706);
  color: #fff;
  box-shadow: 0 0 8px rgba(245, 158, 11, 0.4);
}
.btn:disabled {
  opacity: 0.38;
  cursor: not-allowed;
  filter: grayscale(1);
}

/* ==========================================
   プレイヤーバー (上側: 後手 / 下側: 先手)
   ========================================== */
.player-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--bg-panel);
  border: 1.5px solid var(--border-color);
  border-radius: 8px;
  padding: 5px 10px;
  transition: all 0.2s ease;
}

.player-bar.active-turn.sente-bar {
  border-color: var(--sente-color);
  box-shadow: 0 0 10px rgba(59, 130, 246, 0.35);
  background: linear-gradient(90deg, rgba(59, 130, 246, 0.12), var(--bg-panel));
}

.player-bar.active-turn.gote-bar {
  border-color: var(--gote-color);
  box-shadow: 0 0 10px rgba(239, 68, 68, 0.35);
  background: linear-gradient(90deg, rgba(239, 68, 68, 0.12), var(--bg-panel));
}

.player-meta {
  display: flex;
  align-items: center;
  gap: 6px;
}

.player-badge {
  padding: 2px 7px;
  border-radius: 4px;
  font-weight: 800;
  font-size: 0.72rem;
}
.sente-badge {
  background: rgba(59, 130, 246, 0.2);
  color: #60a5fa;
  border: 1px solid rgba(59, 130, 246, 0.4);
}
.gote-badge {
  background: rgba(239, 68, 68, 0.2);
  color: #f87171;
  border: 1px solid rgba(239, 68, 68, 0.4);
}

.player-name {
  font-weight: 700;
  font-size: 0.82rem;
}

.player-indicators {
  display: flex;
  align-items: center;
  gap: 10px;
}

.indicator-item {
  display: flex;
  align-items: baseline;
  gap: 3px;
  font-size: 0.72rem;
  color: var(--text-muted);
}

.indicator-item .ind-label {
  font-size: 0.65rem;
}
.indicator-item .ind-value {
  font-weight: 800;
  color: var(--text-main);
  font-size: 0.82rem;
}
.indicator-item small {
  font-size: 0.6rem;
  color: var(--text-muted);
}

.indicator-item.bank-item .ind-value.bank-val {
  color: var(--evo-gold);
  font-size: 0.95rem;
  font-weight: 900;
}

/* ==========================================
   ステータス＆サドンデスバナー
   ========================================== */
.status-banner {
  background: linear-gradient(135deg, #182030, #0f1420);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 6px 8px;
  text-align: center;
  transition: all 0.2s ease;
}

.turn-text {
  font-size: 0.88rem;
  font-weight: 800;
}

.sub-status-text {
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-top: 1px;
}

/* 進化モード発光 */
.status-banner.evo-mode {
  background: linear-gradient(135deg, #451a03, #78350f) !important;
  border-color: var(--evo-gold) !important;
  box-shadow: 0 0 12px var(--evo-glow) !important;
}
.status-banner.evo-mode .sub-status-text {
  color: #fef08a !important;
}

/* サドンデス発光（80手〜） */
.status-banner.sudden-death-mode {
  background: linear-gradient(135deg, #450a0a, #7f1d1d) !important;
  border-color: #ef4444 !important;
  box-shadow: 0 0 16px rgba(239, 68, 68, 0.7) !important;
  animation: pulse-sd 1.4s infinite;
}
.status-banner.sudden-death-mode .turn-text {
  color: #fef08a !important;
}
.status-banner.sudden-death-mode .sub-status-text {
  color: #fca5a5 !important;
}

@keyframes pulse-sd {
  0%, 100% { box-shadow: 0 0 10px rgba(239, 68, 68, 0.5); }
  50% { box-shadow: 0 0 20px rgba(239, 68, 68, 0.85); }
}

/* ==========================================
   将棋盤（スマホ幅完全レスポンシブ）
   ========================================== */
.board-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.board-wrapper {
  background: linear-gradient(145deg, var(--board-wood), var(--board-wood-dark));
  padding: 6px 8px 8px 8px;
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.55), inset 0 1px 2px rgba(255, 255, 255, 0.35);
  border: 2px solid #784f1d;
  user-select: none;
}

.col-labels {
  display: grid;
  grid-template-columns: repeat(9, var(--cell-w));
  text-align: center;
  font-weight: 800;
  color: #2b1d0c;
  font-size: 0.7rem;
  margin-bottom: 2px;
  padding-right: 14px;
}

.board-middle {
  display: flex;
  align-items: center;
}

.row-labels {
  display: grid;
  grid-template-rows: repeat(9, var(--cell-h));
  align-items: center;
  justify-items: center;
  font-weight: 800;
  color: #2b1d0c;
  font-size: 0.7rem;
  margin-left: 3px;
  width: 14px;
}

.shogi-board {
  display: grid;
  grid-template-columns: repeat(9, var(--cell-w));
  grid-template-rows: repeat(9, var(--cell-h));
  border: 2px solid var(--board-line);
  background-color: var(--board-wood);
  background-image: radial-gradient(rgba(130, 82, 24, 0.08) 1px, transparent 0);
  background-size: 10px 10px;
}

.board-cell {
  border: 1px solid rgba(59, 40, 16, 0.65);
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background-color 0.1s ease;
}

/* 天王山（５五） */
.board-cell.tennozan-cell {
  background: radial-gradient(circle, rgba(245, 158, 11, 0.35) 0%, rgba(223, 177, 107, 0) 75%);
  box-shadow: inset 0 0 0 1.5px rgba(245, 158, 11, 0.75);
}

.board-cell.tennozan-cell::before {
  content: "★";
  position: absolute;
  font-size: calc(var(--cell-w) * 0.45);
  color: rgba(180, 83, 9, 0.28);
  font-weight: 900;
  pointer-events: none;
  z-index: 1;
}

.board-cell.tennozan-cell.tennozan-sente {
  background: radial-gradient(circle, rgba(59, 130, 246, 0.38) 0%, rgba(245, 158, 11, 0.15) 70%);
  box-shadow: inset 0 0 0 2px #3b82f6;
}

.board-cell.tennozan-cell.tennozan-gote {
  background: radial-gradient(circle, rgba(239, 68, 68, 0.38) 0%, rgba(245, 158, 11, 0.15) 70%);
  box-shadow: inset 0 0 0 2px #ef4444;
}

/* 直前移動ハイライト */
.board-cell.last-move-from {
  background-color: rgba(234, 179, 8, 0.28);
}
.board-cell.last-move-to {
  background-color: rgba(234, 179, 8, 0.52);
  box-shadow: inset 0 0 0 2px #d97706;
}

/* 選択中マス */
.board-cell.selected-cell {
  background-color: rgba(59, 130, 246, 0.48) !important;
  box-shadow: inset 0 0 0 2px #2563eb, 0 0 8px rgba(59, 130, 246, 0.6);
}
.board-cell.enemy-selected-cell {
  background-color: rgba(239, 68, 68, 0.4) !important;
  box-shadow: inset 0 0 0 2px #dc2626;
}

/* 移動可能先（自軍） */
.board-cell.valid-move {
  background-color: rgba(16, 185, 129, 0.25) !important;
  box-shadow: inset 0 0 0 1px rgba(16, 185, 129, 0.6);
}
.board-cell.valid-move::after {
  content: "";
  width: calc(var(--cell-w) * 0.3);
  height: calc(var(--cell-w) * 0.3);
  border-radius: 50%;
  background: rgba(16, 185, 129, 0.85);
  box-shadow: 0 0 6px rgba(16, 185, 129, 0.9);
  pointer-events: none;
  z-index: 4;
}

.board-cell.valid-capture {
  background-color: rgba(239, 68, 68, 0.38) !important;
  box-shadow: inset 0 0 0 2.5px #dc2626;
}

/* 敵駒の利き */
.board-cell.enemy-valid-move {
  background-color: rgba(239, 68, 68, 0.16) !important;
  box-shadow: inset 0 0 0 1px rgba(239, 68, 68, 0.5);
}
.board-cell.enemy-valid-move::after {
  content: "";
  width: calc(var(--cell-w) * 0.28);
  height: calc(var(--cell-w) * 0.28);
  border-radius: 50%;
  background: rgba(239, 68, 68, 0.85);
  pointer-events: none;
  z-index: 4;
}

.board-cell.enemy-target-capture {
  background-color: rgba(220, 38, 38, 0.45) !important;
  box-shadow: inset 0 0 0 2.5px #ef4444;
}

.board-cell.has-pending-evo {
  background-color: rgba(245, 158, 11, 0.45) !important;
  box-shadow: inset 0 0 0 2px #fff, 0 0 10px var(--evo-gold);
}

/* ミニ凡例 */
.board-mini-legend {
  display: flex;
  gap: 10px;
  font-size: 0.68rem;
  color: var(--text-muted);
  justify-content: center;
  align-items: center;
}
.legend-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  margin-right: 2px;
}
.dot-step { background: var(--step-green); }
.dot-ray { background: var(--ray-cyan); }
.dot-enemy { background: #ef4444; }

/* ==========================================
   駒デザイン（レスポンシブスケール）
   ========================================== */
.piece {
  width: calc(var(--cell-w) * 0.86);
  height: calc(var(--cell-h) * 0.88);
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  clip-path: polygon(50% 3%, 93% 19%, 100% 96%, 0% 96%, 7% 19%);
  background: linear-gradient(180deg, #fffbeb 0%, #f5d08a 100%);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.4);
  transition: transform 0.12s ease;
}

.piece.gote {
  transform: rotate(180deg);
  background: linear-gradient(180deg, #fff1f2 0%, #f3c69f 100%);
}

.piece.is-evolved {
  background: linear-gradient(180deg, #fef9c3 0%, #fbbf24 100%);
}
.piece.is-tier2 {
  background: linear-gradient(180deg, #fae8ff 0%, #c084fc 50%, #f59e0b 100%);
}
.piece.is-king {
  background: linear-gradient(180deg, #fef08a 0%, #f59e0b 65%, #b45309 100%);
}

.piece-crown {
  font-size: calc(var(--cell-w) * 0.22);
  line-height: 1;
  margin-top: 1px;
  margin-bottom: -1px;
}

/* 持ちポイント数字（駒の中央） */
.piece-pt-num {
  font-size: calc(var(--cell-w) * 0.44);
  font-weight: 900;
  color: #1c1309;
  line-height: 1;
  font-family: "Arial Black", "Segoe UI", sans-serif;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.7);
}
.piece.is-king .piece-pt-num {
  color: #451a03;
  font-size: calc(var(--cell-w) * 0.4);
}

.piece-sub-tag {
  font-size: calc(var(--cell-w) * 0.18);
  font-weight: 800;
  color: #451a03;
  line-height: 1;
  margin-top: 1px;
}

/* 駒周囲の8方向インジケーター */
.dir-dots {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  pointer-events: none;
  z-index: 3;
}

.dir-dot {
  position: absolute;
  width: 3.5px;
  height: 3.5px;
  border-radius: 50%;
  transform: translate(-50%, -50%);
}
.dir-dot.step { background: var(--step-green); box-shadow: 0 0 3px var(--step-green); }
.dir-dot.evolved { background: var(--evo-gold); box-shadow: 0 0 3px var(--evo-gold); }
.dir-dot.ray { background: var(--ray-cyan); box-shadow: 0 0 5px var(--ray-cyan); width: 4.5px; height: 4.5px; }

.d-0--1 { top: 6%; left: 50%; }
.d-1--1 { top: 12%; left: 88%; }
.d-1-0 { top: 50%; left: 94%; }
.d-1-1 { top: 88%; left: 88%; }
.d-0-1 { top: 94%; left: 50%; }
.d--1-1 { top: 88%; left: 12%; }
.d--1-0 { top: 50%; left: 6%; }
.d--1--1 { top: 12%; left: 12%; }

/* ==========================================
   進化＆インスペクター統合ドック（盤面直下に常駐）
   ========================================== */
.evolution-inspector-dock {
  background: var(--bg-panel);
  border: 1.5px solid var(--border-color);
  border-radius: 10px;
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.dock-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.piece-mini-info {
  display: flex;
  align-items: center;
  gap: 8px;
}

.mini-kanji {
  width: 34px;
  height: 34px;
  border-radius: 6px;
  background: linear-gradient(180deg, #fffbeb, #f5d08a);
  color: #1c1309;
  font-size: 1.05rem;
  font-weight: 900;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s ease, background 0.15s ease;
}

.mini-kanji.gote {
  transform: rotate(180deg);
  background: linear-gradient(180deg, #fff1f2, #f3c69f);
  color: #1c1309;
}

.mini-details {
  display: flex;
  flex-direction: column;
}

.mini-title-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.mini-name {
  font-weight: 800;
  font-size: 0.82rem;
}

.owner-mini-badge {
  font-size: 0.65rem;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 4px;
}

.mini-sub-row {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.7rem;
}

.mini-pt {
  color: var(--evo-gold);
  font-weight: 800;
}
.mini-tier {
  color: var(--text-muted);
}

.dock-evo-actions {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
}

.dock-points-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.72rem;
  color: var(--text-muted);
}
.dock-points-badge strong {
  color: var(--evo-gold);
  font-size: 0.85rem;
}
.dock-points-badge .alloc-badge strong {
  color: #34d399;
}

.dock-buttons {
  display: flex;
  gap: 5px;
}

.btn-dock {
  padding: 4px 9px;
  font-size: 0.74rem;
  border-radius: 5px;
}

.dock-caption {
  font-size: 0.68rem;
  color: #fde68a;
  background: rgba(245, 158, 11, 0.1);
  padding: 3px 8px;
  border-radius: 4px;
  border-left: 2px solid var(--evo-gold);
}

/* 5x5 マトリックスエリア */
.dock-matrix-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  background: #0d121c;
  padding: 6px 8px;
  border-radius: 8px;
  border: 1px solid #1f2a3c;
}

.matrix-direction-hint {
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--text-muted);
  letter-spacing: 0.06em;
  transition: color 0.15s ease;
}

.matrix-direction-hint.gote-dir,
.matrix-direction-hint.gote-hint {
  color: #f87171;
}

.move-matrix {
  display: grid;
  grid-template-columns: repeat(5, var(--matrix-cell-sz));
  grid-template-rows: repeat(5, var(--matrix-cell-sz));
  gap: 3px;
}

.matrix-cell {
  border-radius: 5px;
  background: #171f2d;
  border: 1px solid #233045;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  font-weight: 800;
  user-select: none;
  cursor: default;
  transition: all 0.12s ease;
}

.matrix-cell.inner-ring {
  background: #1c2738;
  border-color: #324460;
}

.matrix-cell.center-self {
  background: #fde68a;
  color: #1c1309;
  font-size: 0.95rem;
  font-weight: 900;
  border: 1.5px solid #f59e0b;
  transition: transform 0.15s ease, background 0.15s ease;
}

.matrix-cell.center-self.gote {
  transform: rotate(180deg);
  background: linear-gradient(180deg, #fff1f2, #f3c69f);
  border-color: #f87171;
  color: #1c1309;
}

.matrix-cell.has-step {
  background: rgba(16, 185, 129, 0.22);
  border-color: var(--step-green);
  color: #6ee7b7;
}

.matrix-cell.has-evolved {
  background: rgba(245, 158, 11, 0.28);
  border-color: var(--evo-gold);
  color: #fde68a;
}

.matrix-cell.has-ray {
  background: rgba(6, 182, 212, 0.28);
  border-color: var(--ray-cyan);
  color: #67e8f9;
  font-size: 0.88rem;
}

/* 解放可能マス */
.matrix-cell.can-unlock {
  cursor: pointer;
  border: 1px dashed var(--evo-gold);
  color: var(--evo-gold);
  animation: pulse-cell 1.3s infinite;
}
.matrix-cell.can-unlock:active {
  transform: scale(0.92);
  background: rgba(245, 158, 11, 0.4);
}

/* 走り覚醒可能マス */
.matrix-cell.can-ray-upgrade {
  border: 1.5px dashed #06b6d4 !important;
  color: #67e8f9 !important;
  background: rgba(6, 182, 212, 0.18) !important;
  animation: pulse-ray-cell 1.3s infinite !important;
}
.matrix-cell.can-ray-upgrade:active {
  transform: scale(0.92);
  background: rgba(6, 182, 212, 0.45) !important;
}

/* 仮割当マス */
.matrix-cell.pending-unlock {
  cursor: pointer;
  background: linear-gradient(135deg, #f59e0b, #d97706);
  color: #fff;
  border: 1.5px solid #fff;
  box-shadow: 0 0 8px var(--evo-gold);
}

@keyframes pulse-cell {
  0%, 100% { background-color: rgba(245, 158, 11, 0.08); }
  50% { background-color: rgba(245, 158, 11, 0.25); }
}

@keyframes pulse-ray-cell {
  0%, 100% { background-color: rgba(6, 182, 212, 0.15); box-shadow: 0 0 4px rgba(6, 182, 212, 0.4); }
  50% { background-color: rgba(6, 182, 212, 0.32); box-shadow: 0 0 10px rgba(6, 182, 212, 0.8); }
}

.matrix-quick-legend {
  display: flex;
  gap: 8px;
  font-size: 0.62rem;
  color: var(--text-muted);
  flex-wrap: wrap;
  justify-content: center;
}

/* ==========================================
   最新ログ1行ティッカー
   ========================================== */
.log-ticker-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-panel);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 5px 8px;
  font-size: 0.72rem;
  cursor: pointer;
  transition: background 0.15s ease;
}
.log-ticker-bar:active {
  background: var(--bg-card);
}
.ticker-icon {
  font-size: 0.85rem;
}
.ticker-text {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text-main);
}
.ticker-badge {
  background: var(--bg-card);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.65rem;
  color: var(--text-muted);
  border: 1px solid var(--border-color);
}

/* ==========================================
   モーダル群 (スマホ最適化)
   ========================================== */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.78);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 12px;
}
.modal-overlay.hidden {
  display: none !important;
}

.modal-card {
  background: var(--bg-panel);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  width: 100%;
  max-width: 480px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.6);
  animation: modal-pop 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modal-pop {
  0% { transform: scale(0.92); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-color);
}
.modal-header h2 {
  font-size: 0.95rem;
  font-weight: 800;
}
.btn-close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.15rem;
  cursor: pointer;
  padding: 4px;
}

.modal-body {
  padding: 12px 14px;
  overflow-y: auto;
  font-size: 0.8rem;
  line-height: 1.5;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* 設定モーダル */
.setting-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.setting-item label {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 700;
}
.styled-select {
  background: var(--bg-card);
  color: var(--text-main);
  border: 1px solid var(--border-color);
  padding: 8px 10px;
  border-radius: 6px;
  font-size: 0.85rem;
  font-weight: 700;
  outline: none;
}
.styled-select option {
  background: var(--bg-panel);
}
.btn-full {
  width: 100%;
  padding: 10px;
  font-size: 0.85rem;
  margin-top: 6px;
}

/* ログリスト */
.log-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 60vh;
}
.log-entry {
  padding: 6px 8px;
  border-radius: 5px;
  background: var(--bg-card);
  font-size: 0.76rem;
  line-height: 1.4;
}
.log-entry.log-capture {
  border-left: 3px solid var(--evo-gold);
  background: rgba(245, 158, 11, 0.12);
}
.log-entry.log-evo {
  border-left: 3px solid var(--step-green);
  color: #a7f3d0;
}

/* ルール表 */
.rule-block {
  margin-bottom: 8px;
}
.rule-block h4 {
  font-size: 0.85rem;
  color: var(--evo-gold);
  margin-bottom: 3px;
}
.rule-block p, .rule-block ul {
  font-size: 0.76rem;
  color: #cbd5e1;
}
.rule-block ul {
  padding-left: 18px;
  margin-top: 3px;
}
.rule-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 6px;
  font-size: 0.72rem;
}
.rule-table th, .rule-table td {
  border: 1px solid var(--border-color);
  padding: 4px 6px;
  text-align: left;
}
.rule-table th {
  background: var(--bg-card);
  color: var(--evo-gold);
}

/* 決着モーダル */
.gameover-card {
  text-align: center;
  padding: 20px 14px;
  align-items: center;
}
.gameover-card h2 {
  font-size: 1.45rem;
  color: var(--evo-gold);
  margin-bottom: 6px;
}
.gameover-desc {
  font-size: 0.85rem;
  color: var(--text-main);
  margin-bottom: 16px;
}
.gameover-actions {
  display: flex;
  gap: 8px;
  width: 100%;
}
.gameover-actions .btn {
  flex: 1;
  padding: 10px;
}

/* 王手＆サドンデス全画面バナー */
.check-banner-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: radial-gradient(circle, rgba(185, 28, 28, 0.88) 0%, rgba(15, 23, 42, 0.94) 80%);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  pointer-events: none;
}
.check-banner-overlay.hidden {
  display: none !important;
}
.check-banner-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  animation: banner-pop 1.35s forwards;
}
.check-banner-kanji {
  font-size: clamp(3.8rem, 16vw, 6.2rem);
  font-weight: 900;
  color: #fff;
  letter-spacing: 0.18em;
  padding-left: 0.18em;
  text-shadow: 0 0 20px #ef4444, 0 0 45px #dc2626;
  font-family: "Hiragino Mincho ProN", "Yu Mincho", serif;
}
.check-banner-sub {
  font-size: clamp(1rem, 4.2vw, 1.4rem);
  font-weight: 800;
  color: #fef08a;
  letter-spacing: 0.12em;
  margin-top: -4px;
}

.sudden-death-overlay {
  background: radial-gradient(circle, rgba(127, 29, 29, 0.94) 0%, rgba(15, 23, 42, 0.96) 85%) !important;
}
.sudden-death-title {
  font-size: clamp(2.4rem, 9.5vw, 4.8rem) !important;
  color: #fef08a !important;
  text-shadow: 0 0 20px #ef4444, 0 0 45px #dc2626 !important;
}
.sudden-death-sub {
  font-size: clamp(0.78rem, 3.2vw, 1.05rem) !important;
  max-width: 90vw;
  line-height: 1.4;
}

@keyframes banner-pop {
  0% { transform: scale(0.6); opacity: 0; filter: blur(10px); }
  20% { transform: scale(1.05); opacity: 1; filter: blur(0); }
  80% { transform: scale(1); opacity: 1; }
  100% { transform: scale(1.15); opacity: 0; }
}

/* 相手の進化通知タブ (スライドイン) */
.enemy-evo-toast {
  position: fixed;
  top: 50px;
  left: 50%;
  transform: translateX(-50%);
  width: min(92vw, 420px);
  background: linear-gradient(135deg, rgba(30, 41, 59, 0.97), rgba(15, 23, 42, 0.99));
  border: 1.5px solid #f59e0b;
  border-radius: 10px;
  box-shadow: 0 8px 26px rgba(0, 0, 0, 0.7), 0 0 16px rgba(245, 158, 11, 0.35);
  z-index: 1500;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  animation: evo-slide-down 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  backdrop-filter: blur(8px);
}

@keyframes evo-slide-down {
  0% { transform: translate(-50%, -24px); opacity: 0; }
  100% { transform: translate(-50%, 0); opacity: 1; }
}

.enemy-evo-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid rgba(245, 158, 11, 0.25);
  padding-bottom: 4px;
}

.enemy-evo-title {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 800;
  font-size: 0.82rem;
  color: #fef08a;
}

.enemy-evo-icon {
  font-size: 0.95rem;
  animation: pulse-glow 1.5s infinite;
}

.enemy-evo-close-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1rem;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
  line-height: 1;
}
.enemy-evo-close-btn:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.1);
}

.enemy-evo-body {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 150px;
  overflow-y: auto;
}

.enemy-evo-piece-card {
  background: rgba(245, 158, 11, 0.08);
  border-left: 3px solid #f59e0b;
  border-radius: 4px;
  padding: 5px 8px;
}

.enemy-evo-piece-name {
  font-size: 0.78rem;
  font-weight: 800;
  color: #fff;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.enemy-evo-piece-pos {
  color: #fcd34d;
  font-size: 0.72rem;
}

.enemy-evo-changes-list {
  list-style: none;
  padding: 0;
  margin: 3px 0 0 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.enemy-evo-change-item {
  font-size: 0.73rem;
  color: #cbd5e1;
  display: flex;
  align-items: center;
  gap: 4px;
}

.enemy-evo-change-item.is-ray {
  color: #a7f3d0;
  font-weight: 700;
}

.enemy-evo-actions {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
  margin-top: 2px;
}

.btn-inspect-evo {
  background: linear-gradient(135deg, #d97706, #b45309);
  color: #fff;
  border: 1px solid #f59e0b;
  border-radius: 5px;
  padding: 5px 12px;
  font-size: 0.74rem;
  font-weight: 800;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.3);
}
.btn-inspect-evo:hover {
  background: linear-gradient(135deg, #f59e0b, #d97706);
}

.hidden {
  display: none !important;
}


/* ==========================================
   解説セクション & フッター（SEO・AdSense審査対策）
   ========================================== */
.site-about-section {
  background: var(--bg-panel);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 16px 14px;
  margin-top: 10px;
  color: var(--text-main);
  line-height: 1.75;
}

.site-about-section h2 {
  font-size: 1.15rem;
  color: #fde68a;
  border-left: 4px solid var(--evo-gold);
  padding-left: 8px;
  margin-bottom: 10px;
}

.site-about-section h3 {
  font-size: 0.95rem;
  color: #fbbf24;
  margin-top: 14px;
  margin-bottom: 6px;
}

.site-about-section p,
.site-about-section ul {
  font-size: 0.85rem;
  color: #cbd5e1;
  margin-bottom: 10px;
}

.site-about-section ul {
  padding-left: 20px;
}

.site-about-section li {
  margin-bottom: 4px;
}

.site-footer {
  text-align: center;
  padding: 18px 10px 24px;
  margin-top: 10px;
  border-top: 1px solid var(--border-color);
  font-size: 0.78rem;
  color: var(--text-muted);
}

.footer-nav {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 10px;
}

.footer-nav a {
  color: #94a3b8;
  text-decoration: none;
  transition: color 0.15s ease;
}

.footer-nav a:hover {
  color: #fde68a;
}

.btn-share {
  background: #09090b;
  color: #f4f4f5;
  border: 1.5px solid #3f3f46;
  font-weight: 800;
}
.btn-share:hover {
  background: #18181b;
  border-color: var(--evo-gold);
  color: #fde68a;
}

/* ==========================================
   エントランス（タイトル・モード選択）画面
   ========================================== */
.view-entrance {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 8px 0 20px;
  animation: fadeIn 0.25s ease-out;
}

.view-game {
  display: flex;
  flex-direction: column;
  gap: 8px;
  animation: fadeIn 0.25s ease-out;
}

.view-entrance.hidden,
.view-game.hidden {
  display: none !important;
}

/* ヒーローエリア */
.entrance-hero {
  text-align: center;
  padding: 14px 10px 8px;
}

.hero-badge {
  display: inline-block;
  font-size: 0.68rem;
  font-weight: 900;
  letter-spacing: 0.16em;
  color: var(--evo-gold);
  background: rgba(245, 158, 11, 0.12);
  border: 1px solid rgba(245, 158, 11, 0.35);
  padding: 2px 10px;
  border-radius: 999px;
  margin-bottom: 8px;
  text-transform: uppercase;
}

.entrance-title {
  font-size: 2rem;
  font-weight: 900;
  letter-spacing: 0.04em;
  color: #fff;
  line-height: 1.15;
  margin-bottom: 4px;
  text-shadow: 0 4px 16px rgba(0, 0, 0, 0.6);
}

.entrance-sub {
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--evo-gold);
  letter-spacing: 0.1em;
  text-shadow: 0 0 12px var(--evo-glow);
}

.entrance-tagline {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-weight: 600;
  letter-spacing: 0.02em;
}

/* プレイヤーランク＆レートカード */
.player-rank-card {
  background: linear-gradient(135deg, rgba(30, 41, 59, 0.9) 0%, rgba(15, 23, 42, 0.95) 100%);
  border: 1px solid rgba(245, 158, 11, 0.3);
  border-radius: 14px;
  padding: 12px 14px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.rank-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.rank-badge-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
}

.rank-icon {
  font-size: 1.3rem;
}

.rank-title {
  font-size: 1.25rem;
  font-weight: 900;
  color: #fde68a;
  letter-spacing: 0.04em;
}

.rank-rating-box {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}

.rating-label {
  font-size: 0.62rem;
  font-weight: 800;
  color: #94a3b8;
  letter-spacing: 0.08em;
}

.rating-value {
  font-size: 1.3rem;
  font-weight: 900;
  color: #38bdf8;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.rank-progress-bar-bg {
  height: 6px;
  background: rgba(15, 23, 42, 0.8);
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 10px;
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.rank-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #38bdf8 0%, #f59e0b 100%);
  border-radius: 999px;
  transition: width 0.4s ease-out;
}

.rank-card-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  padding-top: 8px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  text-align: center;
}

.stat-col {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.stat-num {
  font-size: 1.05rem;
  font-weight: 800;
  color: #f1f5f9;
  font-variant-numeric: tabular-nums;
}

.stat-lbl {
  font-size: 0.65rem;
  font-weight: 600;
  color: #94a3b8;
}

/* モード選択カード群 */
.entrance-modes {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.mode-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 14px;
  background: var(--bg-card);
  border: 1.5px solid var(--border-color);
  border-radius: 14px;
  cursor: pointer;
  text-align: left;
  transition: transform 0.12s ease, border-color 0.15s ease, box-shadow 0.15s ease;
  user-select: none;
  touch-action: manipulation;
  width: 100%;
}

.mode-card:active {
  transform: translateY(2px) scale(0.99);
}

.mode-icon-box {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  flex-shrink: 0;
  background: rgba(255, 255, 255, 0.05);
}

.mode-info {
  flex: 1;
  min-width: 0;
}

.mode-heading {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 3px;
  flex-wrap: wrap;
}

.mode-name {
  font-size: 1.05rem;
  font-weight: 900;
  color: #fff;
  letter-spacing: 0.02em;
}

.mode-tag {
  font-size: 0.65rem;
  font-weight: 800;
  padding: 1px 6px;
  border-radius: 4px;
  text-transform: uppercase;
}

.mode-desc {
  font-size: 0.74rem;
  color: var(--text-muted);
  line-height: 1.35;
}

.mode-arrow {
  color: #64748b;
  font-size: 0.9rem;
  font-weight: 900;
  transition: transform 0.15s ease, color 0.15s ease;
}

/* ランクマッチ特別装飾 */
.mode-rank {
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.12) 0%, rgba(30, 41, 59, 0.85) 75%);
  border-color: rgba(245, 158, 11, 0.45);
  box-shadow: 0 4px 16px rgba(245, 158, 11, 0.12);
}
.mode-rank .mode-icon-box {
  background: rgba(245, 158, 11, 0.2);
  border: 1px solid rgba(245, 158, 11, 0.4);
}
.tag-rank {
  background: #f59e0b;
  color: #1e1b4b;
}
.mode-rank:hover {
  border-color: #f59e0b;
}

/* COM対戦特別装飾 */
.mode-com {
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.12) 0%, rgba(30, 41, 59, 0.85) 75%);
  border-color: rgba(59, 130, 246, 0.35);
}
.mode-com .mode-icon-box {
  background: rgba(59, 130, 246, 0.2);
  border: 1px solid rgba(59, 130, 246, 0.4);
}
.tag-com {
  background: #3b82f6;
  color: #fff;
}
.mode-com:hover {
  border-color: #3b82f6;
}

/* フリーマッチ特別装飾 */
.mode-free {
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.12) 0%, rgba(30, 41, 59, 0.85) 75%);
  border-color: rgba(16, 185, 129, 0.35);
}
.mode-free .mode-icon-box {
  background: rgba(16, 185, 129, 0.2);
  border: 1px solid rgba(16, 185, 129, 0.4);
}
.tag-free {
  background: #10b981;
  color: #fff;
}
.mode-free:hover {
  border-color: #10b981;
}

/* エントランス下部アクション */
.entrance-footer-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 4px;
}

.btn-resume {
  width: 100%;
  padding: 12px;
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  color: #fff;
  border-radius: 10px;
  font-size: 0.95rem;
  font-weight: 800;
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
  border: none;
}
.btn-resume:active {
  transform: translateY(2px);
}

.entrance-aux-btns {
  display: flex;
  gap: 8px;
}

.btn-aux {
  flex: 1;
  padding: 9px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  color: #cbd5e1;
  border-radius: 8px;
  font-size: 0.78rem;
  font-weight: 700;
}
.btn-aux:hover {
  background: #243048;
  color: #fff;
}

.btn-header-back {
  background: #1e293b;
  color: #f1f5f9;
  border: 1px solid #334155;
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 0.72rem;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}
.btn-header-back:active {
  transform: translateY(1px);
}

/* ピルボタングリッド（COM・手番選択用） */
.pills-grid {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 6px;
}

.pills-grid-half {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-top: 6px;
}

.pill-btn {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  padding: 10px 12px;
  background: #1e293b;
  border: 1.5px solid #334155;
  border-radius: 8px;
  cursor: pointer;
  text-align: left;
  user-select: none;
  touch-action: manipulation;
  transition: all 0.12s ease;
}

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

.pill-btn.active {
  background: rgba(59, 130, 246, 0.18);
  border-color: #3b82f6;
  box-shadow: 0 0 10px rgba(59, 130, 246, 0.25);
}

.pill-title {
  font-size: 0.88rem;
  font-weight: 800;
  color: #fff;
}

.pill-sub {
  font-size: 0.68rem;
  color: #94a3b8;
  margin-top: 2px;
}

/* ランクマッチ確認カード */
.rank-matchup-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #0f172a;
  border: 1.5px solid rgba(245, 158, 11, 0.4);
  border-radius: 12px;
  padding: 14px 12px;
  margin: 12px 0;
  box-shadow: inset 0 0 16px rgba(0, 0, 0, 0.5);
}

.matchup-side {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  flex: 1;
}

.matchup-tag {
  font-size: 0.62rem;
  font-weight: 800;
  color: #94a3b8;
  background: rgba(255, 255, 255, 0.08);
  padding: 1px 6px;
  border-radius: 4px;
}

.matchup-name {
  font-size: 0.95rem;
  font-weight: 900;
  color: #fff;
  margin-top: 2px;
}

.matchup-rank {
  font-size: 0.8rem;
  font-weight: 800;
  color: #fde68a;
}

.matchup-rate {
  font-size: 0.72rem;
  font-weight: 700;
  color: #38bdf8;
  font-variant-numeric: tabular-nums;
}

.matchup-vs {
  font-size: 1.1rem;
  font-weight: 900;
  font-style: italic;
  color: #ef4444;
  padding: 0 8px;
}

.rank-match-rule-hint {
  font-size: 0.72rem;
  color: #94a3b8;
  text-align: center;
  margin-bottom: 12px;
}

.btn-gold {
  background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
  color: #0f172a;
  font-weight: 900;
  border: none;
  box-shadow: 0 4px 14px rgba(245, 158, 11, 0.35);
}
.btn-gold:hover {
  background: linear-gradient(135deg, #fbbf24 0%, #f59e0b 100%);
}

.btn-lg {
  padding: 12px;
  font-size: 0.95rem;
  border-radius: 10px;
}

/* 決着モーダル内のランク変動ボックス */
.gameover-rank-box {
  background: #0f172a;
  border: 1px solid rgba(245, 158, 11, 0.4);
  border-radius: 10px;
  padding: 10px;
  margin: 10px 0 14px;
  text-align: center;
}

.rank-result-badge {
  font-size: 0.68rem;
  font-weight: 800;
  color: #f59e0b;
  letter-spacing: 0.05em;
  margin-bottom: 2px;
}

.rank-result-diff {
  font-size: 1.5rem;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
}

.rank-result-diff.plus {
  color: #10b981;
}

.rank-result-diff.minus {
  color: #ef4444;
}

.rank-result-current {
  font-size: 0.76rem;
  color: #cbd5e1;
  margin-top: 2px;
}

.rank-up-banner {
  margin-top: 8px;
  padding: 6px;
  background: rgba(245, 158, 11, 0.2);
  border: 1px solid #f59e0b;
  border-radius: 6px;
  font-size: 0.85rem;
  font-weight: 900;
  color: #fde68a;
  animation: pulse 1s infinite;
}

/* ==========================================
   ① 週間シーズン ＆ ランキングボード
   ========================================== */
.season-banner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(30, 41, 59, 0.6);
  border: 1px solid rgba(148, 163, 184, 0.2);
  border-radius: 8px;
  padding: 5px 10px;
  font-size: 0.72rem;
}

.season-badge {
  font-weight: 800;
  color: #38bdf8;
  letter-spacing: 0.03em;
}

.season-timer {
  color: #fbbf24;
  font-weight: 700;
  background: rgba(251, 191, 36, 0.12);
  padding: 1px 6px;
  border-radius: 4px;
}

/* 称号バッジ */
.player-title-badge {
  font-size: 0.65rem;
  font-weight: 800;
  color: #0f172a;
  background: linear-gradient(135deg, #fde68a 0%, #f59e0b 100%);
  padding: 2px 7px;
  border-radius: 999px;
  letter-spacing: 0.02em;
  white-space: nowrap;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
}

.btn-change-title {
  background: #334155;
  color: #94a3b8;
  border: none;
  font-size: 0.62rem;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 4px;
  cursor: pointer;
}
.btn-change-title:hover {
  background: #475569;
  color: #fff;
}

/* 連勝ハイライト */
.stat-streak-num {
  color: #f97316 !important;
  text-shadow: 0 0 8px rgba(249, 115, 22, 0.4);
}

/* 戦績カード発行ボタン */
.rank-card-actions {
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.btn-cert-card {
  width: 100%;
  padding: 8px 12px;
  background: linear-gradient(135deg, #0284c7 0%, #0369a1 100%);
  color: #fff;
  border: 1px solid #38bdf8;
  border-radius: 8px;
  font-size: 0.8rem;
  font-weight: 800;
  box-shadow: 0 2px 8px rgba(2, 132, 199, 0.3);
  cursor: pointer;
  transition: transform 0.12s ease;
}
.btn-cert-card:active {
  transform: translateY(2px);
}

/* 週間ランキングカード */
.season-ranking-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 14px;
  padding: 12px 14px;
}

.ranking-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
  padding-bottom: 6px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.ranking-title-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
}

.ranking-title {
  font-size: 0.88rem;
  font-weight: 900;
  color: #fff;
}

.player-rank-pos {
  font-size: 0.72rem;
  font-weight: 800;
  color: #38bdf8;
  background: rgba(56, 189, 248, 0.12);
  padding: 2px 8px;
  border-radius: 6px;
}

.ranking-list {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.ranking-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 10px;
  background: #0f172a;
  border-radius: 8px;
  font-size: 0.76rem;
  border: 1px solid transparent;
}

.ranking-row.is-player {
  background: rgba(56, 189, 248, 0.12);
  border-color: rgba(56, 189, 248, 0.4);
  font-weight: 800;
}

.ranking-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.rank-pos-num {
  font-size: 0.78rem;
  font-weight: 900;
  min-width: 20px;
  text-align: center;
  color: #94a3b8;
}

.rank-pos-num.gold {
  color: #fbbf24;
}

.rank-pos-num.silver {
  color: #cbd5e1;
}

.rank-pos-num.bronze {
  color: #d97706;
}

.ranking-player-name {
  color: #f1f5f9;
}

.ranking-player-title {
  font-size: 0.62rem;
  color: #94a3b8;
  margin-left: 4px;
}

.ranking-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.ranking-tier-badge {
  font-size: 0.65rem;
  font-weight: 800;
  color: #fde68a;
}

.ranking-rate-val {
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  color: #38bdf8;
}

/* ==========================================
   ③ 賞金首（Bounty）システム
   ========================================== */
.tag-bounty-chance {
  background: #dc2626;
  color: #fff;
  animation: pulse 1.2s infinite;
}

.bounty-match-banner {
  background: linear-gradient(135deg, rgba(220, 38, 38, 0.25) 0%, rgba(185, 28, 28, 0.1) 100%);
  border: 1.5px solid #ef4444;
  border-radius: 8px;
  padding: 8px 10px;
  margin-bottom: 10px;
  text-align: center;
  animation: pulse 1.5s infinite;
}

.bounty-badge {
  display: inline-block;
  font-size: 0.65rem;
  font-weight: 900;
  letter-spacing: 0.1em;
  color: #fff;
  background: #ef4444;
  padding: 1px 8px;
  border-radius: 999px;
  margin-bottom: 3px;
}

.bounty-title {
  font-size: 0.8rem;
  font-weight: 800;
  color: #fca5a5;
}

.rank-bounty-bonus-desc {
  font-size: 0.8rem;
  font-weight: 900;
  color: #fbbf24;
  margin-top: 4px;
  animation: pulse 1s infinite;
}

/* ==========================================
   ⑤ 戦績カードCanvasプレビュー＆称号モーダル
   ========================================== */
.cert-modal-card {
  max-width: 520px;
}

.cert-canvas-wrap {
  width: 100%;
  border-radius: 12px;
  overflow: hidden;
  border: 2px solid rgba(56, 189, 248, 0.4);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.6);
  margin-bottom: 12px;
  background: #0b0f17;
}

#cert-canvas {
  width: 100%;
  height: auto;
  display: block;
}

.cert-modal-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* 称号一覧 */
.title-list-container {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 50vh;
  overflow-y: auto;
  padding-right: 4px;
}

.title-card-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  background: #1e293b;
  border: 1px solid #334155;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.12s ease;
}

.title-card-item.active {
  background: rgba(245, 158, 11, 0.15);
  border-color: #f59e0b;
}

.title-card-item.locked {
  opacity: 0.5;
  cursor: not-allowed;
  background: #0f172a;
}

.title-card-name {
  font-size: 0.85rem;
  font-weight: 800;
  color: #fff;
}

.title-card-cond {
  font-size: 0.68rem;
  color: #94a3b8;
}

.title-card-status {
  font-size: 0.68rem;
  font-weight: 800;
  padding: 2px 6px;
  border-radius: 4px;
}

.title-card-status.equipped {
  background: #f59e0b;
  color: #1e1b4b;
}

.title-card-status.unlocked {
  background: #3b82f6;
  color: #fff;
}

.title-card-status.locked-badge {
  background: #334155;
  color: #64748b;
}

/* ==========================================
   オンライン対戦（Firebase）関連スタイル
   ========================================== */
.mode-online {
  background: linear-gradient(135deg, rgba(14, 165, 233, 0.18) 0%, rgba(30, 41, 59, 0.9) 75%);
  border-color: rgba(14, 165, 233, 0.5);
  box-shadow: 0 4px 18px rgba(14, 165, 233, 0.18);
}
.mode-online .mode-icon-box {
  background: rgba(14, 165, 233, 0.25);
  border: 1px solid rgba(14, 165, 233, 0.5);
}
.tag-online {
  background: #0ea5e9;
  color: #0f172a;
}
.mode-online:hover {
  border-color: #38bdf8;
}

.online-modes-grid {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 12px 0;
}

.online-choice-btn {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  padding: 12px 14px;
  border-radius: 10px;
  cursor: pointer;
  border: none;
  text-align: left;
  user-select: none;
  touch-action: manipulation;
  transition: transform 0.12s ease;
}
.online-choice-btn:active {
  transform: translateY(2px);
}

.choice-icon {
  font-size: 1.3rem;
  margin-bottom: 2px;
}

.choice-title {
  font-size: 0.95rem;
  font-weight: 900;
  color: #fff;
}

.choice-sub {
  font-size: 0.72rem;
  color: #cbd5e1;
  margin-top: 2px;
}

.join-room-box {
  background: #0f172a;
  border: 1px solid #334155;
  border-radius: 10px;
  padding: 10px 12px;
}

.join-label {
  display: block;
  font-size: 0.74rem;
  font-weight: 800;
  color: #94a3b8;
  margin-bottom: 6px;
}

.join-input-wrap {
  display: flex;
  gap: 8px;
}

.styled-input {
  flex: 1;
  background: #1e293b;
  border: 1.5px solid #334155;
  color: #fff;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 700;
  outline: none;
  transition: border-color 0.15s ease;
}
.styled-input:focus {
  border-color: #38bdf8;
}

.online-footer-setting {
  text-align: center;
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.btn-text-setting {
  background: none;
  border: none;
  color: #64748b;
  font-size: 0.72rem;
  font-weight: 700;
  cursor: pointer;
  text-decoration: underline;
}
.btn-text-setting:hover {
  color: #94a3b8;
}

/* マッチング待機オーバーレイ */
.matchmaking-card {
  text-align: center;
  padding: 24px 20px;
}

.matchmaking-spinner {
  width: 44px;
  height: 44px;
  margin: 0 auto 14px;
  border: 4px solid rgba(56, 189, 248, 0.2);
  border-top-color: #38bdf8;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.matchmaking-timer {
  font-size: 0.8rem;
  color: #94a3b8;
  margin: 6px 0 16px;
}

.friend-room-code-badge {
  font-size: 2.2rem;
  font-weight: 900;
  color: #fde68a;
  letter-spacing: 0.2em;
  background: #0f172a;
  border: 2px dashed #f59e0b;
  padding: 8px 16px;
  border-radius: 10px;
  margin: 12px auto;
  width: fit-content;
  font-variant-numeric: tabular-nums;
}

.friend-code-desc {
  font-size: 0.78rem;
  color: #cbd5e1;
}


/* ==========================================
   後手番プレイヤー視点の自動盤面反転 (180deg)
   常に手前が自陣、奥が敵陣で直感的に操作可能！
   ========================================== */
#shogi-board.flip-board {
  transform: rotate(180deg);
}

/* プレイヤーバーの上下反転（手前が自分＝後手、奥が相手＝先手） */
.main-layout.flip-players {
  display: flex;
  flex-direction: column;
}

.main-layout.flip-players #card-sente {
  order: 1; /* 相手（先手）を上部に配置 */
}
.main-layout.flip-players .status-banner {
  order: 2;
}
.main-layout.flip-players .enemy-evo-toast {
  order: 3;
}
.main-layout.flip-players .board-section {
  order: 4;
}
.main-layout.flip-players #card-gote {
  order: 5; /* 自分（後手）を手前に配置 */
}
.main-layout.flip-players .evolution-dock {
  order: 6;
}
.main-layout.flip-players .log-ticker-bar {
  order: 7;
}


/* ユーザーネーム表示バー */
.player-profile-name-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 8px;
  margin-bottom: 12px;
  border: 1px solid rgba(255, 215, 0, 0.2);
}

.player-name-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  overflow: hidden;
}

.name-badge-icon {
  font-size: 1.1rem;
}

.player-display-name {
  font-size: 1.1rem;
  font-weight: 700;
  color: #f6ad55;
  text-shadow: 0 0 8px rgba(246, 173, 85, 0.4);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.btn-change-name {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #e2e8f0;
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 0.8rem;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s ease;
  touch-action: manipulation;
  user-select: none;
}

.btn-change-name:hover {
  background: rgba(255, 215, 0, 0.2);
  border-color: #ffd700;
  color: #fff;
}

.btn-change-name:active {
  transform: translateY(2px);
}

/* ユーザーネーム入力エラーメッセージ */
.name-error-msg {
  color: #ff4d4f;
  background: rgba(255, 77, 79, 0.12);
  border: 1px solid rgba(255, 77, 79, 0.3);
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 0.85rem;
  margin-top: 8px;
  text-align: left;
  line-height: 1.4;
  animation: shake 0.3s ease-in-out;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-4px); }
  75% { transform: translateX(4px); }
}
