/* =========================================================
 * ゲーム画面の共通スタイル（common.css の次に読み込む）
 * ヘッダー・設定画面・オンラインのロビー・掛け声・結果画面
 * ========================================================= */

.topbar {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  margin-bottom: 12px;
}
.topbar h1 {
  margin: 0;
  font-size: 1.8rem;
  font-weight: 900;
  text-shadow: 2px 2px 0 var(--yellow);
}
.icon-btn {
  justify-self: end;
  font-size: 1.4rem;
  background: #fff;
  border: 3px solid var(--ink);
  border-radius: 50%;
  width: 44px; height: 44px;
  cursor: pointer;
}

.btn.big { font-size: 1.25rem; padding: 12px 36px; }
.btn.small { font-size: 0.85rem; padding: 4px 14px; }

/* ---------- 設定画面 ---------- */
.setup { max-width: 520px; margin: 0 auto; text-align: center; }
.setup h2 { margin-top: 0; }
fieldset { border: none; margin: 0 0 16px; padding: 0; }
legend { font-weight: 700; margin: 0 auto 8px; }
.choices { display: flex; justify-content: center; gap: 8px; flex-wrap: wrap; }
.choices input { position: absolute; opacity: 0; pointer-events: none; }
.choices span {
  display: inline-block;
  min-width: 84px;
  padding: 8px 14px;
  border: 3px solid var(--ink);
  border-radius: 12px;
  background: var(--paper);
  font-weight: 700;
  cursor: pointer;
}
.choices input:checked + span { background: var(--yellow); box-shadow: var(--shadow); }
.choices input:focus-visible + span { outline: 3px solid var(--blue); outline-offset: 2px; }
.stats { color: var(--ink-soft); font-weight: 700; }
.rules { text-align: left; margin-top: 8px; }
.rules summary { cursor: pointer; font-weight: 700; text-align: center; }
.hint { font-size: 0.85rem; color: var(--ink-soft); }
kbd {
  border: 2px solid var(--ink-soft);
  border-radius: 4px;
  padding: 0 4px;
  font-family: inherit;
  background: var(--paper);
}

/* ---------- キャラ選択（assets/js/chara.js） ---------- */
.chara-list { display: flex; justify-content: center; flex-wrap: wrap; gap: 6px; }
.chara {
  display: grid; justify-items: center; gap: 2px;
  width: 78px;
  padding: 6px 2px 4px;
  font-family: inherit;
  font-size: 0.78rem; font-weight: 700;
  color: var(--ink);
  background: var(--paper);
  border: 3px solid var(--ink);
  border-radius: 12px;
  cursor: pointer;
}
.chara .art { width: 48px; height: 48px; }
.chara.on { background: var(--yellow); box-shadow: var(--shadow); }
.chara:focus-visible { outline: 3px solid var(--blue); outline-offset: 2px; }

/* ---------- モード切替タブ ---------- */
.mode-tabs { display: flex; justify-content: center; margin-bottom: 20px; }
.mode-tab {
  font-family: inherit; font-size: 1rem; font-weight: 700;
  padding: 8px 16px;
  border: 3px solid var(--ink);
  background: var(--paper);
  color: var(--ink);
  cursor: pointer;
}
.mode-tab:first-child { border-radius: 12px 0 0 12px; border-right-width: 0; }
.mode-tab:last-child { border-radius: 0 12px 12px 0; }
.mode-tab.active { background: var(--yellow); }

/* ---------- オンラインのロビー（assets/js/room.js が組み立てる） ---------- */
.name-row { display: block; font-weight: 700; margin-bottom: 16px; }
.name-row input, .join-row input {
  font-family: inherit; font-size: 1.1rem; font-weight: 700;
  padding: 8px 12px;
  border: 3px solid var(--ink);
  border-radius: 10px;
  width: 11em;
  margin-left: 8px;
  text-align: center;
}
.join-row { display: flex; justify-content: center; gap: 8px; align-items: center; flex-wrap: wrap; }
.join-row input { margin-left: 0; width: 8em; text-transform: uppercase; letter-spacing: 0.15em; }
.or { color: var(--ink-soft); font-size: 0.85rem; margin: 10px 0; }
.room-code-box { font-weight: 700; display: grid; justify-items: center; gap: 6px; }
.room-code {
  font-size: 2.2rem; font-weight: 900; letter-spacing: 0.25em;
  background: #2f5d46; color: #fff;
  padding: 2px 8px 2px 16px;
  border-radius: 8px;
  border: 4px solid #a8743f;
}
.lobby-members { list-style: none; padding: 0; margin: 16px auto; max-width: 260px; text-align: left; }
.lobby-members li {
  border: 2px solid var(--ink);
  border-radius: 10px;
  background: var(--paper);
  padding: 4px 12px;
  margin-bottom: 6px;
  font-weight: 700;
}
.lobby-members li.empty { opacity: 0.4; }
.lobby-actions { display: grid; justify-items: center; gap: 8px; }
.online-msg { color: var(--red-dark); font-weight: 700; min-height: 1.4em; }
.ready-badge {
  display: inline-block;
  font-size: 0.75rem; font-weight: 900;
  color: #fff; background: var(--green);
  border: 2px solid var(--ink);
  border-radius: 999px;
  padding: 0 8px;
}

/* ---------- 掛け声（ステージ） ---------- */
.stage-sub { color: var(--ink-soft); font-weight: 700; min-height: 1.5em; font-size: 0.9rem; }
.stage-main {
  font-size: clamp(1.3rem, 4.2vw, 2.2rem);
  font-weight: 900;
  min-height: 1.4em;
  line-height: 1.3;
  text-shadow: 2px 2px 0 rgba(255, 255, 255, 0.8);
}
.stage-main.hit { color: var(--green); animation: pop 0.4s ease-out; }
.stage-main.miss { color: var(--ink-soft); }
.stage-main.shout { color: var(--red); font-size: clamp(2rem, 8vw, 3.4rem); animation: pop 0.3s ease-out; }
.stage-next { font-weight: 700; color: var(--blue); min-height: 1.5em; font-size: 0.9rem; margin-bottom: 8px; }

.badge {
  display: inline-block;
  background: var(--red);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 900;
  padding: 0 8px;
  margin-right: 4px;
  border: 2px solid var(--ink);
  border-radius: 999px;
  vertical-align: middle;
}
.speech {
  position: absolute;
  left: 50%; top: -30px;
  transform: translateX(-50%);
  white-space: nowrap;
  background: #fff;
  border: 3px solid var(--ink);
  border-radius: 14px;
  padding: 0 12px;
  font-weight: 900;
  font-size: 1.2rem;
  animation: pop 0.3s ease-out;
}
.speech::after {
  content: "";
  position: absolute;
  left: 50%; bottom: -10px;
  width: 14px; height: 14px;
  background: #fff;
  border-right: 3px solid var(--ink);
  border-bottom: 3px solid var(--ink);
  transform: translateX(-50%) rotate(45deg);
}

/* ---------- ログ ---------- */
.log-wrap { margin-top: 12px; }
.log-wrap summary { cursor: pointer; font-weight: 700; color: var(--ink-soft); }
.log { margin: 8px 0 0; padding-left: 1.5em; font-size: 0.9rem; max-height: 220px; overflow-y: auto; }
.log li.hit { color: var(--green); font-weight: 700; }

/* ---------- 結果 ---------- */
.overlay {
  position: fixed; inset: 0;
  background: rgba(59, 42, 30, 0.55);
  display: grid; place-items: center;
  padding: 16px;
  z-index: 10;
}
.result-box { text-align: center; max-width: 380px; width: 100%; animation: pop 0.4s ease-out; }
.result-icon { width: 96px; height: 96px; margin: 0 auto 6px; }
.result-icon .art-svg { width: 100%; height: 100%; }
.icon-btn { display: grid; place-items: center; padding: 6px; }
.icon-btn .art-svg { width: 100%; height: 100%; }
.mode-tab .art { width: 1.4em; height: 1.4em; margin-right: 2px; }
.lobby-members .art { width: 1.6em; height: 1.6em; vertical-align: middle; }
.result-box h2 { margin: 0; font-size: 2rem; }
.result-actions { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }

@keyframes pop {
  0% { scale: 0.6; }
  70% { scale: 1.2; }
  100% { scale: 1; }
}

@media (max-width: 560px) {
  .topbar h1 { font-size: 1.4rem; }
  .back-link { font-size: 0.85rem; }
  .btn.big { font-size: 1.1rem; padding: 10px 26px; }
}
