/* はやおしクイズ（party/quiz） 独自スタイル。共通は ../common/party.css。
   テーマ色は青系（共通CSS変数を上書き）。
   選択肢の4色（赤▲・青◆・黄●・緑■）はテーマとは独立の固定色。
   色だけでなく形（▲◆●■）もつけているので、色が見分けにくい子でも
   「三角を押して」と声で伝えあえる。 */

:root {
  --party-accent: #1e6fdb;
  --party-accent-dark: #14509f;
  --party-accent-soft: #e3efff;
  --party-bg: #eef5ff;
  --party-card: #ffffff;
  --party-text: #10243d;
  --party-muted: #5d7590;
  --party-line: #d6e4f7;

  --qz-a: #e3453f; /* ▲ 赤 */
  --qz-b: #2f6fd0; /* ◆ 青 */
  --qz-c: #e8a300; /* ● 黄 */
  --qz-d: #2e9e57; /* ■ 緑 */
  --qz-ok: #2e9e57;
  --qz-ng: #e3453f;
}

.qz {
  position: fixed;
  inset: 0;
  background: var(--party-bg);
  overflow: hidden;
}

.qz-screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
  padding: calc(env(safe-area-inset-top) + 10px) calc(env(safe-area-inset-right) + 12px)
    calc(env(safe-area-inset-bottom) + 12px) calc(env(safe-area-inset-left) + 12px);
  max-width: 560px;
  margin: 0 auto;
}

/* ───── 出題画面 ───── */

.qz-top {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 700;
  color: var(--party-muted);
  flex-shrink: 0;
}
.qz-top__cat {
  flex: 1;
  text-align: center;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.qz-top__n b,
.qz-top__pt b {
  font-size: 17px;
  color: var(--party-accent-dark);
}

.qz-timebar {
  height: 12px;
  margin: 8px 0 10px;
  border-radius: 999px;
  background: rgba(16, 36, 61, 0.1);
  overflow: hidden;
  flex-shrink: 0;
}
.qz-timebar__fill {
  height: 100%;
  width: 100%;
  border-radius: 999px;
  background: var(--party-accent);
}
/* のこり3秒で色が変わる（数字が読めなくても急ぎが伝わる） */
.qz-timebar__fill.is-hurry {
  background: var(--qz-ng);
}

.qz-question {
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  margin: 0 0 10px;
  padding: 14px 12px;
  background: var(--party-card);
  border-radius: var(--party-radius);
  box-shadow: var(--party-shadow);
  font-size: 24px;
  font-weight: 800;
  line-height: 1.45;
  /* 国旗の絵文字は大きく見せたい。長文の問題では自動で縮む */
  overflow-wrap: anywhere;
}

.qz-choices {
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.qz-choice {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 78px;
  padding: 10px 12px;
  border: none;
  border-radius: 16px;
  color: #fff;
  font-family: inherit;
  font-size: 17px;
  font-weight: 800;
  line-height: 1.3;
  text-align: left;
  cursor: pointer;
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.22);
  transition: transform 0.06s ease, box-shadow 0.06s ease, opacity 0.2s ease;
}
.qz-choice:active:not(:disabled) {
  transform: translateY(3px);
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.22);
}
.qz-choice--a { background: var(--qz-a); }
.qz-choice--b { background: var(--qz-b); }
.qz-choice--c { background: var(--qz-c); }
.qz-choice--d { background: var(--qz-d); }

.qz-choice__mark {
  font-size: 22px;
  line-height: 1;
  flex-shrink: 0;
}
.qz-choice__label {
  flex: 1;
  overflow-wrap: anywhere;
}

/* 自分がえらんだ選択肢 */
.qz-choice.is-picked {
  outline: 4px solid var(--party-text);
  outline-offset: -4px;
}
/* 発表: 正解は残して、それ以外は沈める */
.qz-choice.is-correct {
  outline: 5px solid var(--qz-ok);
  outline-offset: -5px;
  opacity: 1;
}
.qz-choice.is-wrong {
  outline: 5px solid var(--party-text);
  outline-offset: -5px;
  opacity: 0.85;
}
.qz-choice.is-dim {
  opacity: 0.35;
}
.qz-choice:disabled {
  cursor: default;
}

.qz-status {
  flex-shrink: 0;
  margin: 8px 0 0;
  min-height: 1.5em;
  text-align: center;
  font-weight: 700;
  font-size: 15px;
  color: var(--party-muted);
}

/* ───── ○×の全画面フラッシュ ───── */

.qz-flash {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: #fff;
  animation: qz-flash-in 0.25s ease-out;
}
.qz-flash.is-ok { background: var(--qz-ok); }
.qz-flash.is-ng { background: var(--qz-ng); }

.qz-flash__mark {
  font-size: 40vmin;
  line-height: 1;
  font-weight: 800;
  animation: qz-pop 0.4s ease-out;
}
.qz-flash__sub {
  font-size: 22px;
  font-weight: 800;
  text-align: center;
  padding: 0 20px;
}

@keyframes qz-flash-in {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes qz-pop {
  0% { transform: scale(0.4); opacity: 0; }
  60% { transform: scale(1.12); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}

/* ───── 順位表 ───── */

.qz-screen--rank {
  justify-content: center;
  gap: 6px;
}
.qz-rank__label {
  margin: 0;
  text-align: center;
  font-size: 14px;
  font-weight: 700;
  color: var(--party-muted);
}
.qz-rank__ans {
  margin: 0;
  text-align: center;
  font-size: 26px;
  font-weight: 800;
  color: var(--party-accent-dark);
  overflow-wrap: anywhere;
}
.qz-rank__gain {
  margin: 4px 0 12px;
  text-align: center;
  font-size: 20px;
  font-weight: 800;
}
.qz-rank__gain.is-ok { color: var(--qz-ok); }
.qz-rank__gain.is-ng { color: var(--party-muted); }

.qz-rank__list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.qz-rank__row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 12px;
  background: var(--party-card);
  font-size: 14px;
  font-weight: 700;
}
.qz-rank__row.is-me {
  outline: 3px solid var(--party-accent);
}
.qz-rank__no {
  width: 1.4em;
  flex-shrink: 0;
  text-align: center;
  color: var(--party-muted);
}
.qz-rank__name {
  width: 5.5rem;
  flex-shrink: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.qz-rank__barwrap {
  flex: 1;
  height: 12px;
  border-radius: 999px;
  background: rgba(16, 36, 61, 0.08);
  overflow: hidden;
}
.qz-rank__bar {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: var(--party-accent);
}
.qz-rank__pt {
  width: 5.5rem;
  flex-shrink: 0;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* ───── 表彰台 ───── */

.qz-screen--final {
  justify-content: center;
  align-items: center;
  gap: 8px;
  overflow-y: auto;
}
.qz-final__title {
  margin: 0;
  font-size: 24px;
  font-weight: 800;
  color: var(--party-accent-dark);
}
.qz-podium {
  width: 100%;
  max-width: 340px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.qz-podium__item {
  padding: 10px 14px;
  border-radius: 14px;
  background: var(--party-card);
  font-size: 18px;
  font-weight: 800;
  text-align: center;
}
.qz-podium__item--1 {
  background: #fff3c4;
  font-size: 22px;
}
.qz-podium__item--2 { background: #eef1f4; }
.qz-podium__item--3 { background: #ffe6cc; }

/* 4位以下だけの補足リスト（1〜3位は表彰台に出ているので重ねて出さない）。
   主役は表彰台なので、こちらは小さく地味にする */
.qz-final__list {
  list-style: none;
  margin: 10px 0 0;
  padding: 0;
  width: 100%;
  max-width: 340px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 14px;
  font-weight: 700;
  color: var(--party-muted);
  text-align: center;
}
.qz-final__actions {
  display: flex;
  gap: 10px;
  margin-top: 12px;
}
.qz-final__actions button {
  min-height: 56px;
  padding: 0 20px;
  border: none;
  border-radius: 14px;
  font-family: inherit;
  font-size: 17px;
  font-weight: 800;
  cursor: pointer;
}
#btn-again {
  background: var(--party-accent);
  color: #fff;
  box-shadow: 0 4px 0 var(--party-accent-dark);
}
#btn-back-lobby {
  background: var(--party-card);
  color: var(--party-accent-dark);
  box-shadow: 0 4px 0 var(--party-line);
}
.qz-final__wait {
  margin: 12px 0 0;
  font-weight: 700;
  color: var(--party-muted);
}

/* ───── ロビーのホスト設定（ジャンル・小学生モード） ───── */

.qz-opt__grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}
.qz-opt__cat {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-height: 68px;
  padding: 6px 4px;
  border: 3px solid transparent;
  border-radius: 14px;
  background: var(--party-accent-soft);
  color: var(--party-text);
  font-family: inherit;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.2;
  text-align: center;
  cursor: pointer;
}
.qz-opt__cat[aria-pressed='true'] {
  border-color: var(--party-accent);
  background: #fff;
}
.qz-opt__emoji {
  font-size: 24px;
  line-height: 1;
}

.qz-opt__kids {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: 14px;
  background: var(--party-accent-soft);
  font-size: 15px;
  cursor: pointer;
}
.qz-opt__kids input {
  width: 26px;
  height: 26px;
  flex-shrink: 0;
  accent-color: var(--party-accent);
}
.qz-opt__kids small {
  color: var(--party-muted);
}

/* 横向き・背の低い画面では問題文を小さくして選択肢を守る */
@media (max-height: 620px) {
  .qz-question {
    font-size: 19px;
    padding: 10px;
  }
  .qz-choice {
    min-height: 62px;
    font-size: 15px;
  }
}

/* ───── チーム戦 🔴vs🔵（docs/party-team-spec.md） ─────
   チーム戦OFFのときは帯もチーム欄も出ないので、従来の画面と同じ見た目のまま。 */

.qz-team__row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 6px 2px;
  cursor: pointer;
}
.qz-team__row input {
  width: 26px;
  height: 26px;
  flex-shrink: 0;
  accent-color: var(--party-accent);
}
.qz-team__row small {
  color: var(--party-muted);
}
.qz-team__note {
  margin: 6px 0 0;
  font-size: 14px;
  color: var(--party-muted);
}
.qz-team__chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}
.qz-team__chip {
  padding: 4px 10px;
  border-radius: 999px;
  color: #fff;
  font-size: 14px;
  font-weight: 700;
}
.qz-team__shuffle {
  margin-top: 10px;
  width: 100%;
  min-height: 44px;
  border: 0;
  border-radius: 14px;
  background: var(--party-accent-soft);
  color: var(--party-accent-dark);
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
}

/* 自分のチーム色の帯（画面上部に常時） */
.qz-teambadge {
  position: absolute;
  top: calc(env(safe-area-inset-top) + 4px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 30;
  margin: 0;
  padding: 3px 14px;
  border-radius: 999px;
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  white-space: nowrap;
  pointer-events: none;
}
.qz-teambadge.is-note {
  background: var(--party-card);
  color: var(--party-muted);
  border: 1px solid var(--party-line);
  font-size: 13px;
}
/* 帯のぶんだけ各画面の上を空ける（チーム戦のときだけ） */
.qz.is-team .qz-screen {
  padding-top: calc(env(safe-area-inset-top) + 38px);
}

/* チーム成績（途中経過＝個人順位の上／最終＝表彰台の上）。
   最終画面は align-items:center の縦フレックスなので、幅を指定しないとバーが縮む */
.qz-teamzone {
  width: 100%;
}
.qz-teamzone:empty {
  display: none;
}
.qz-teamsum {
  margin: 0 0 10px;
  padding: 8px 10px;
  border-radius: 14px;
  background: var(--party-card);
  border: 1px solid var(--party-line);
}
.qz-teamsum__title {
  margin: 0 0 6px;
  text-align: center;
  font-size: 20px;
  font-weight: 800;
}
.qz-teamsum__row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 3px 0;
}
.qz-teamsum__name {
  flex-shrink: 0;
  font-size: 14px;
  font-weight: 700;
}
.qz-teamsum__barwrap {
  flex: 1;
  height: 12px;
  border-radius: 999px;
  background: var(--party-line);
  overflow: hidden;
}
.qz-teamsum__bar {
  display: block;
  height: 100%;
  border-radius: 999px;
}
.qz-teamsum__pt {
  flex-shrink: 0;
  min-width: 92px;
  text-align: right;
  font-size: 14px;
  font-weight: 700;
}
.qz-teamsum__pt small {
  display: block;
  font-size: 11px;
  font-weight: 500;
  color: var(--party-muted);
}
