/* ==========================================
   21ゲーム CSS
   プレフィックス: g21-
   Version: 2.0.0（ヘッダー＋フルスクリーン＋右下ツールバー＋一本道ステップ構成）
   ========================================== */

.g21-root, .g21-root * { box-sizing: border-box; }

.g21-root {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: "BIZ UDGothic", "M PLUS Rounded 1c", "Hiragino Kaku Gothic ProN", "Meiryo", sans-serif;
  background: #f5f7fa;
  color: #1a2a40;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
  z-index: 9999;
}

/* ===== ヘッダー ===== */
.g21-root .g21-header {
  position: fixed; top: 0; left: 0; right: 0;
  height: 52px;
  background: #1e3a5f;
  color: #fff;
  display: flex; align-items: center;
  padding: 0 16px;
  gap: 12px;
  z-index: 20;
}
.g21-root .g21-header h1 { font-size: 17px; font-weight: bold; flex: 1; margin: 0; }
.g21-root .g21-score {
  font-size: 13px; font-weight: bold;
  background: rgba(255,255,255,0.15);
  padding: 6px 14px; border-radius: 999px;
  white-space: nowrap;
}

/* ===== メインエリア ===== */
.g21-root #g21-main {
  position: fixed;
  top: 52px; left: 0; width: 100vw; height: calc(100vh - 52px);
  overflow-y: auto;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 20px 16px;
  gap: 16px;
}

.g21-root .g21-turn-indicator {
  font-size: 15px; font-weight: bold; text-align: center;
  background: #fff; border-radius: 12px; padding: 10px 20px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
  /* 修正: 「あなたの番です」と「コンピューターの番です」でテキスト量が違っても
     箱のサイズが変わらないよう、幅・高さを固定して画面のガタつきを防ぐ */
  width: 280px;
  min-height: 56px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
}
.g21-root .g21-turn-indicator.player-turn { color: #1e3a5f; border: 2px solid #1e3a5f; }
.g21-root .g21-turn-indicator.computer-turn { color: #c0392b; border: 2px solid #c0392b; }
.g21-root .g21-turn-indicator small { display: block; font-weight: normal; font-size: 11px; color: #6b7e99; margin-top: 4px; }

.g21-root .g21-number-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(38px, 52px));
  gap: 8px;
  justify-content: center;
}
.g21-root .g21-number-cell {
  aspect-ratio: 1;
  display: flex; align-items: center; justify-content: center;
  border-radius: 10px;
  font-size: 16px; font-weight: bold;
  background: #fff; color: #b8c2d4;
  border: 2px solid #dde4ef;
  transition: transform .12s;
}
.g21-root .g21-number-cell.selectable {
  color: #1e3a5f; border-color: #d4af37; background: #fffdf5;
  cursor: pointer;
}
.g21-root .g21-number-cell.selectable:active { transform: scale(0.9); }
.g21-root .g21-number-cell.player { background: #3d8ef0; border-color: #3d8ef0; color: #fff; }
.g21-root .g21-number-cell.computer { background: #e8534a; border-color: #e8534a; color: #fff; }
.g21-root .g21-number-cell.game21-animate-select { transform: scale(1.18); }

.g21-root .g21-result {
  font-size: 16px; font-weight: bold; text-align: center;
  background: #fff; border-radius: 14px; padding: 16px 24px;
  box-shadow: 0 4px 14px rgba(0,0,0,0.12);
  display: none;
}
.g21-root .g21-result.show { display: block; }
.g21-root .g21-result.win { color: #2e9e5b; border: 2px solid #2e9e5b; }
.g21-root .g21-result.lose { color: #c0392b; border: 2px solid #c0392b; }

/* ===== 履歴パネル ===== */
.g21-root .g21-history-panel {
  position: fixed; top: 64px; right: 16px;
  width: min(80vw, 280px); max-height: 60vh; overflow-y: auto;
  background: #fff; border-radius: 14px; box-shadow: 0 6px 20px rgba(0,0,0,0.2);
  padding: 14px 16px; z-index: 19;
}
.g21-root .g21-history-panel.hidden { display: none; }
.g21-root .g21-history-title { font-size: 13px; font-weight: bold; color: #1e3a5f; margin-bottom: 8px; }
.g21-root .g21-history-item { font-size: 12px; color: #4a5a70; padding: 5px 0; border-bottom: 1px solid #eef2f6; }
.g21-root .g21-history-item:last-child { border-bottom: none; }
.g21-root .g21-history-turn { font-weight: bold; color: #1e3a5f; margin-right: 4px; }
.g21-root .g21-history-empty { font-size: 12px; color: #9aa8bc; }

/* ===== 右下ツールバー ===== */
.g21-root .g21-toolbar {
  position: fixed; right: 16px; bottom: 20px;
  display: flex; flex-direction: column; gap: 12px; z-index: 10;
}
.g21-root .g21-btn {
  width: 60px; height: 60px; border-radius: 999px; border: none;
  font-size: 24px; cursor: pointer; box-shadow: 0 3px 8px rgba(0,0,0,0.25);
  display: flex; align-items: center; justify-content: center;
  transition: transform .1s; -webkit-tap-highlight-color: transparent;
  background: #fff; color: #7F8C8D; border: 2px solid #dde4ef;
}
.g21-root .g21-btn:active { transform: scale(0.92); }
.g21-root .g21-btn-setting { background: #fff; color: #1e3a5f; border: 2px solid #1e3a5f; }
.g21-root .g21-btn.g21-on { background: #d4af37; color: #fff; border-color: #d4af37; }

/* ===== ステップ画面（オーバーレイ） ===== */
.g21-root .g21-overlay {
  position: fixed; inset: 0; background: rgba(30,58,95,0.55);
  display: flex; align-items: center; justify-content: center; z-index: 100;
  padding: 12px;
}
.g21-root .g21-overlay.hidden { display: none; }
.g21-root .g21-dialog {
  background: #fff; border-radius: 16px; padding: 26px 24px 22px;
  width: min(94vw, 460px); max-height: 92vh; overflow-y: auto;
  box-shadow: 0 8px 30px rgba(0,0,0,0.3); text-align: center;
}
.g21-root .g21-dialog h2 { color: #1e3a5f; font-size: 19px; margin: 0 0 6px; }
.g21-root .g21-step-label {
  display: inline-block; background: #d4af37; color: #fff; font-size: 12px; font-weight: bold;
  border-radius: 999px; padding: 3px 14px; margin-bottom: 10px;
}
.g21-root .g21-hint { font-size: 13px; color: #5a708a; margin: 0 0 16px; }

.g21-root .g21-section-title { font-size: 13px; font-weight: bold; color: #1e3a5f; text-align: left; margin: 16px 0 8px; }
.g21-root .g21-section-title:first-of-type { margin-top: 0; }

.g21-root .g21-rule-options { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.g21-root .g21-rule-btn {
  background: #fff; border: 2px solid #dde4ef; border-radius: 12px; padding: 12px 8px;
  cursor: pointer; font-family: inherit; -webkit-tap-highlight-color: transparent;
}
.g21-root .g21-rule-btn.selected { border-color: #1e3a5f; background: #eef2f8; }
.g21-root .g21-rule-title { font-size: 14px; font-weight: bold; color: #1e3a5f; }
.g21-root .g21-rule-desc { font-size: 11px; color: #6b7e99; margin-top: 3px; }

.g21-root .g21-difficulty-options { display: grid; grid-template-columns: repeat(3,1fr); gap: 8px; }
.g21-root .g21-difficulty-btn {
  background: #fff; border: 2px solid #dde4ef; border-radius: 12px; padding: 10px 4px;
  cursor: pointer; font-family: inherit; -webkit-tap-highlight-color: transparent;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
}
.g21-root .g21-difficulty-btn.selected { border-color: #d4af37; background: #fffdf5; }
.g21-root .g21-difficulty-name { font-size: 12px; font-weight: bold; color: #1e3a5f; }

.g21-root .g21-start-buttons { display: flex; flex-direction: column; gap: 10px; margin-top: 18px; }
.g21-root .g21-start-btn {
  width: 100%; padding: 14px 0; border-radius: 999px; border: none;
  background: #d4af37; color: #fff; font-size: 16px; font-weight: bold;
  cursor: pointer; -webkit-tap-highlight-color: transparent;
}
.g21-root .g21-start-btn:last-child { background: #1e3a5f; }
.g21-root .g21-start-btn:active { transform: scale(0.97); }

/* ===== トースト（無効な操作など） ===== */
.g21-root .g21-toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  background: #c0392b; color: #fff; font-size: 13px; font-weight: bold;
  padding: 10px 18px; border-radius: 999px; box-shadow: 0 4px 14px rgba(0,0,0,0.25);
  z-index: 200; opacity: 0; pointer-events: none; transition: opacity .2s;
}
.g21-root .g21-toast.show { opacity: 1; }

.g21-root .hidden { display: none !important; }
