/* ========================================================
   Speed Quiz - battle / ranking 共通デザイン
   最終整理版（2025）
======================================================== */

/* --------------------------------------------------------
   0. 全体ベース
-------------------------------------------------------- */
body {
  background: #1a1a2e; /* 統一ダーク背景 */
  color: #fff;
  font-family: sans-serif;
  margin: 0;
}

/* --------------------------------------------------------
   1. トップバー
-------------------------------------------------------- */
#topBar {
  background: #16213e;
}

/* --------------------------------------------------------
   2. 出題画面（start.php）
-------------------------------------------------------- */

/* 問題番号（Q.3 など） */
#category {
  text-align: center;
  margin-top: 10px;
  font-size: 2.1em;
  color: #ffcc00;
}

/* メッセージ領域（エラー・警告など） */
#msgArea {
  text-align: center;
  margin-top: 8px;
  font-size: 1.8em;
  color: #ff6666;
  min-height: 1.3em;
}

/* 問題文ボックス */
#question-box {
  margin: 10px auto;
  padding: 20px;
  background: #0f3460;
  border-radius: 10px;
  width: 92%;
  max-width: var(--pc-content-max-width);
  font-size: 2.5em;
}

/* 選択肢グリッド */
.grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
  width: 92%;
  max-width: var(--pc-content-max-width);
  margin: 20px auto;
}
.grid.choices-2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
.grid.choices-3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}
.grid.choices-4 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

/* 選択肢ボタン */
.choice-button {
  position: relative;
  display: flex;
  align-items: center;
  background: #e9e9e9;
  color: #000;
  padding: 18px;
  border-radius: 10px;
  font-size: 1.8em;
  cursor: pointer;
  border: 3px solid transparent;
  transition: 0.1s ease;
}
.choice-button.is-hidden {
  display: none;
}

/* 選択されたとき */
.choice-button.selected {
  border-color: #ff9800 !important;
  border-width: 5px;
  box-shadow: 0 0 0 3px rgba(255, 152, 0, 0.25);
}

/* 正解 */
.choice-button.correct {
  background: #ffd84d !important;
  color: #1f2937 !important;
  font-weight: 500;
  font-size: 2.16em;
}

/* 不正解 */
.choice-button.wrong {
  background: #27354d !important;
  color: #eef2ff !important;
}

/* A〜D ラベル丸 */
.choice-label {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  color: #fff;
  font-family: Arial, "Helvetica Neue", sans-serif;
  font-weight: 800;
  font-size: 1.25em;
  line-height: 1;
  letter-spacing: 0;
  margin-right: 15px;
  display: flex;
  justify-content: center;
  align-items: center;
}

.label-A {
  background: #d32f2f;
}
.label-B {
  background: #1976d2;
}
.label-C {
  background: #388e3c;
}
.label-D {
  background: #fbc02d;
  color: #000;
}

/* 回答人数バッジ（A:○人 / B:○人） */
.badge {
  position: absolute;
  right: 0;
  bottom: 0;
  background: #1565c0;
  color: #fff;
  padding: 3px 8px;
  font-size: 0.8em;
  border-radius: 6px;
  display: none;
}

/* 結果表示エリア（正解発表後） */
#resultArea {
  width: 92%;
  max-width: var(--pc-content-max-width);
  margin: 20px auto;
  padding: 15px;
  background: #16213e;
  border-radius: 6px;
  font-size: 1.6em;
  display: none;
}

/* ボタン揺れアニメ（回答不可時） */
@keyframes choiceShake {
  25% {
    transform: translateX(-5px);
  }
  50% {
    transform: translateX(5px);
  }
  75% {
    transform: translateX(-3px);
  }
}

.choice-button.shake {
  animation: choiceShake 0.25s ease;
}

/* --------------------------------------------------------
   3. ランキング画面（ranking.php）
   start とデザイン統一
-------------------------------------------------------- */

#maincontents {
  width: 92%;
  max-width: var(--pc-content-max-width);
  margin: 20px auto;
  color: #fff;
}

.subhead {
  text-align: center;
  font-size: 1.2em;
  color: #ffcc00;
  margin-top: 10px;
}

/* 戻るボタン（start と同じデザイン） */
.back-btn {
  display: inline-block;
  padding: 6px 12px;
  background: #ffffff;
  color: #000 !important;
  border-radius: 14px;
  text-decoration: none;
  font-weight: 700;
  font-size: 16px;
  border: 2px solid #fff;
}
.back-btn:hover {
  background: #e5e5e5;
}

/* start.php の画面遷移ボタン（一覧/解説/結果） */
.screen-nav-btn {
  color: #fff !important;
  background-color: #2563eb;
  position: relative;
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 10px 36px 10px 18px;
  font-size: 1.7rem;
  font-weight: 400;
  border: none;
}

.screen-nav-btn:hover {
  color: #fff !important;
  background-color: #1d4ed8;
}

.screen-nav-btn i.fa {
  margin-right: 10px;
  font-size: 1.6rem;
}

.screen-nav-btn::after {
  font-family: "Font Awesome 5 Free";
  font-weight: 900;
  font-size: 1.4rem;
  line-height: 1;
  position: absolute;
  top: calc(50% - 0.7rem);
  right: 12px;
  content: "\f054";
  color: #fff;
}

/* start.php のアクションボタン横並び・統一 */
.action-buttons {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}

/* ---------- テーブル ---------- */
#ranking,
.ranking-table {
  width: 100%;
  margin-top: 25px;
  border-collapse: collapse;
  background: #16213e; /* テーブル本体の背景 */
  color: #fff;
  border-radius: 8px;
  overflow: hidden;

  table-layout: fixed;
}

/* ▼ ヘッダ（黄色に変更） */
#ranking th,
.ranking-table th {
  background: #ffcc00; /* 明るい黄色 */
  color: #000; /* 黒字で読みやすく */
  padding: 12px;
  text-align: left;
  font-weight: bold;
}

/* データ行 */
#ranking td,
.ranking-table td {
  padding: 10px 12px;
  border-bottom: 1px solid #2c2c54;
}

/* ▼ 自分の行（紺色系ハイライト） */
#ranking tr.self,
.ranking-table tr.self {
  background: #264e8e !important; /* 濃い紺色 */
  color: #fff !important; /* 白字で視認性高く */
  font-weight: bold;
}

/* 最後の線を消す */
#ranking tr:last-child td,
.ranking-table tr:last-child td {
  border-bottom: none;
}

/* result.php 出題履歴（参考表示） */
.history-table {
  width: 100%;
  margin-top: 16px;
  border-collapse: separate;
  border-spacing: 0;
  background: rgba(22, 33, 62, 0.45);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  overflow: hidden;
}

.history-table th {
  background: rgba(15, 52, 96, 0.65);
  color: #c9d6ff;
  padding: 10px 12px;
  text-align: left;
  font-weight: 600;
  font-size: 0.95em;
}

.history-table td {
  color: #dfe6ff;
  padding: 9px 12px;
  border-top: 1px dashed rgba(255, 255, 255, 0.16);
  font-size: 0.92em;
  font-weight: 400;
}

/* PC（769px以上）ではグループ名を表示 */
#topBar .topbar-group {
  display: inline;
}

@media screen and (max-width: 768px) {
  /* 768px以下の画面サイズで適用されるスタイル */

  #topBar {
    font-size: 1.6em;
  }

  .topbar-group {
    display: none;
  }

  /* モバイル時は常に1列 */
  #choiceGrid,
  #choiceGrid.choices-2,
  #choiceGrid.choices-3,
  #choiceGrid.choices-4,
  .grid,
  .grid.choices-2,
  .grid.choices-3,
  .grid.choices-4 {
    grid-template-columns: 1fr !important;
  }

  #maincontents {
    width: 100% !important;
  }

  #ranking,
  .ranking-table {
    /* display: block; */
    overflow-x: auto;
    font-size: 0.9em;
  }

  #ranking th,
  #ranking td,
  .ranking-table th,
  .ranking-table td {
    padding: 8px 10px;
  }

  #ranking tr.self,
  .ranking-table tr.self {
    background: #264e8e !important;
  }

  .history-table {
    font-size: 0.9em;
  }

  .history-table th,
  .history-table td {
    padding: 8px 10px;
  }
}
