:root {
  --bg: #14122b;
  --bg2: #1f1b3d;
  --panel: #2a2550;
  --panel-2: #332c63;
  --accent: #ffd23f;
  --accent-2: #ff5d8f;
  --good: #3ddc84;
  --bad: #ff5252;
  --text: #f5f3ff;
  --muted: #b3aede;
  --radius: 18px;
  --radius-sm: 12px;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 20px 55px rgba(0, 0, 0, 0.5);
  --ring: 0 0 0 3px rgba(255, 210, 63, 0.55);
  --t: 0.15s ease;
}

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

/* アクセシビリティ：キーボード操作時のフォーカスを明示 */
:focus-visible { outline: none; box-shadow: var(--ring); border-radius: 10px; }
::selection { background: var(--accent); color: #2a1a00; }

/* スクロールバー（ダークテーマに馴染ませる） */
* { scrollbar-width: thin; scrollbar-color: var(--panel-2) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--panel-2); border-radius: 8px; }
::-webkit-scrollbar-thumb:hover { background: #41397a; }
::-webkit-scrollbar-track { background: transparent; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  font-family: "Hiragino Kaku Gothic ProN", "Yu Gothic", "Meiryo", system-ui, sans-serif;
  color: var(--text);
}
body {
  background: var(--bg) url("/shared/assets/bg.webp") center center / cover no-repeat fixed;
}
@media (max-width: 760px) {
  body { background-image: url("/shared/assets/bg-mobile.webp"); }
}

body.center {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

button { font-family: inherit; cursor: pointer; }

/* ---------- ブランドロゴ（マーク＋ワードマーク） ---------- */
.brand-logo { display: flex; flex-direction: column; align-items: center; gap: 8px; margin: 0 0 8px; }
.brand-logo .mark { width: clamp(92px, 12vw, 140px); height: auto; filter: drop-shadow(0 12px 26px rgba(0, 0, 0, 0.55)); }
.brand-logo .name {
  font-size: clamp(34px, 6vw, 60px); font-weight: 900; letter-spacing: 3px; line-height: 1;
  background: linear-gradient(180deg, #ffffff 8%, #ffe6a0 58%, #ffc24a 100%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.4));
}
.brand-logo-sm .mark { width: clamp(68px, 18vw, 92px); }
.brand-logo-sm .name { font-size: clamp(26px, 7vw, 34px); letter-spacing: 2px; }
.brand-logo-lg .mark { width: clamp(120px, 16vw, 200px); }
.brand-logo-lg .name { font-size: clamp(46px, 8vw, 92px); }

/* ---------- Landing ---------- */
.landing { text-align: center; max-width: 780px; width: 100%; }
.logo {
  font-size: clamp(42px, 9vw, 86px); margin: 0 0 10px; letter-spacing: 1px; font-weight: 900;
  text-shadow: 0 4px 30px rgba(255, 210, 63, 0.25);
}
.tagline { color: var(--muted); font-size: clamp(15px, 3vw, 20px); margin: 0 0 44px; }

.card-group { display: flex; gap: 20px; justify-content: center; flex-wrap: wrap; }
.big-btn {
  position: relative; overflow: hidden;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  text-decoration: none; color: var(--text);
  background: linear-gradient(160deg, var(--panel), var(--bg2));
  border: 2px solid rgba(255, 255, 255, 0.06);
  border-radius: var(--radius); padding: 34px 30px; min-width: 240px; cursor: pointer;
  box-shadow: var(--shadow); transition: transform var(--t), border-color var(--t), box-shadow var(--t);
}
.big-btn:hover { transform: translateY(-5px); box-shadow: var(--shadow-lg); }
.big-btn.host:hover { border-color: var(--accent); }
.big-btn.join:hover { border-color: var(--accent-2); }
.big-btn.editor:hover { border-color: #7be0c0; }
.big-btn .emoji {
  font-size: 40px; width: 84px; height: 84px; display: flex; align-items: center; justify-content: center;
  background: rgba(255, 255, 255, 0.06); border-radius: 22px; margin-bottom: 4px;
}
.big-btn .label { font-size: 26px; font-weight: 800; }
.big-btn .sub { color: var(--muted); font-size: 14px; }
.big-btn-icon { width: 92px; height: 92px; object-fit: contain; margin-bottom: 6px; filter: drop-shadow(0 8px 18px rgba(0, 0, 0, 0.45)); }
.btn-icon { display: inline-flex; align-items: center; gap: 8px; }
.btn-icon img { width: 26px; height: 26px; object-fit: contain; }
.footer-note { color: var(--muted); margin-top: 44px; font-size: 13px; line-height: 1.7; }

/* ---------- Shared ---------- */
.wrap { max-width: 1100px; margin: 0 auto; padding: 20px; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.brand { font-weight: 800; font-size: 20px; }
.pill { background: var(--panel); border-radius: 999px; padding: 8px 16px; font-weight: 700; }
.pill .code { color: var(--accent); letter-spacing: 4px; font-size: 22px; }

.panel { background: var(--panel); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
.muted { color: var(--muted); }
.row { display: flex; gap: 12px; flex-wrap: wrap; }
.grow { flex: 1; }

input[type="text"], input[type="number"], input[type="password"], textarea, select {
  background: var(--bg2); border: 2px solid var(--panel-2); color: var(--text);
  border-radius: 12px; padding: 14px 16px; font-size: 18px; width: 100%; outline: none;
  font-family: inherit; transition: border-color var(--t), box-shadow var(--t);
}
textarea { resize: vertical; line-height: 1.4; }
input:focus, textarea:focus, select:focus { border-color: var(--accent); box-shadow: var(--ring); }
::placeholder { color: #7d77ad; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: none; border-radius: 12px; padding: 13px 22px; min-height: 48px;
  font-size: 16px; font-weight: 800; line-height: 1;
  background: var(--panel-2); color: var(--text);
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.25);
  transition: transform .08s ease, filter var(--t), box-shadow var(--t);
}
.btn:active { transform: translateY(2px); box-shadow: none; }
.btn:hover { filter: brightness(1.12); }
.btn.primary { background: linear-gradient(135deg, var(--accent), #ffb03f); color: #2a1a00; box-shadow: 0 4px 14px rgba(255, 178, 63, 0.35); }
.btn.pink { background: linear-gradient(135deg, var(--accent-2), #ff8a5d); color: #3a0018; box-shadow: 0 4px 14px rgba(255, 93, 143, 0.35); }
.btn.good { background: var(--good); color: #06301a; }
.btn.bad  { background: var(--bad);  color: #3a0000; }
.btn.ghost { background: transparent; border: 2px solid var(--panel-2); box-shadow: none; }
.btn.ghost:hover { border-color: var(--muted); filter: none; background: rgba(255, 255, 255, 0.04); }
.btn:disabled { opacity: .4; cursor: not-allowed; filter: grayscale(.3); box-shadow: none; }
.btn:disabled:active { transform: none; }
.btn.block { width: 100%; }

.hidden { display: none !important; }

/* ---------- Host layout ---------- */
.host-grid { display: grid; grid-template-columns: 320px 1fr; gap: 20px; align-items: start; }
@media (max-width: 860px) { .host-grid { grid-template-columns: 1fr; } }

.qr-box { text-align: center; }
.collapse-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; width: 100%; background: none; border: none; color: inherit; cursor: pointer; padding: 0; margin-bottom: 12px; }
.collapse-chev { color: var(--muted); font-size: 12px; transition: transform var(--t); }
.qr-box.collapsed .collapse-head { margin-bottom: 0; }
.qr-box.collapsed .collapse-body { display: none; }
.qr-box.collapsed .collapse-chev { transform: rotate(180deg); }
.qr-box img { width: 100%; max-width: 260px; border-radius: 12px; background: #fff; padding: 8px; }
.join-url { word-break: break-all; font-size: 12px; color: var(--muted); margin-top: 8px; }
.big-code { font-size: 44px; font-weight: 900; letter-spacing: 10px; color: var(--accent); text-align: center; }

.section-title { font-size: 14px; text-transform: uppercase; letter-spacing: 2px; color: var(--muted); margin: 0 0 12px; }

.players { display: flex; flex-direction: column; gap: 8px; }
.player-chip {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  background: var(--bg2); border-radius: 12px; padding: 10px 14px;
}
.player-chip.off { opacity: .4; }
.player-chip .name { font-weight: 700; }
.player-chip .score { color: var(--accent); font-weight: 900; }

/* Buzz board */
.buzz-board { display: flex; flex-direction: column; gap: 12px; min-height: 120px; }
.buzz-item {
  display: flex; align-items: center; gap: 16px; padding: 16px 20px; border-radius: 14px;
  background: var(--bg2); animation: pop .2s ease;
}
.buzz-item.first { background: linear-gradient(135deg, rgba(255,210,63,.25), rgba(255,93,143,.2)); border: 2px solid var(--accent); }
.buzz-item .rank { font-size: 28px; font-weight: 900; width: 56px; }
.buzz-item.first .rank { color: var(--accent); }
.buzz-item .bname { font-size: 26px; font-weight: 800; flex: 1; }
.buzz-item .judge { display: flex; gap: 8px; }
@keyframes pop { from { transform: scale(.9); opacity: 0; } to { transform: scale(1); opacity: 1; } }

.scoreboard { display: flex; flex-direction: column; gap: 8px; }
.score-row { display: flex; align-items: center; gap: 12px; background: var(--bg2); border-radius: 12px; padding: 12px 16px; }
.score-row .medal { font-size: 22px; width: 32px; text-align: center; }
.score-row .sname { flex: 1; font-weight: 700; font-size: 18px; }
.score-row .spts { color: var(--accent); font-weight: 900; font-size: 22px; }

.question-display { font-size: clamp(20px, 3vw, 30px); font-weight: 800; line-height: 1.5; min-height: 1.5em; }

/* ---------- Player ---------- */
.player-screen { max-width: 560px; margin: 0 auto; padding: 16px; min-height: 100dvh; display: flex; flex-direction: column; gap: 16px; }
.player-head { display: flex; align-items: center; justify-content: space-between; }
.player-head .me { font-weight: 800; font-size: 18px; }
.player-head .my-score { color: var(--accent); font-weight: 900; }
.player-head-right { display: flex; align-items: center; gap: 12px; }
.leave-btn { background: transparent; border: 1.5px solid var(--panel-2); color: var(--muted); font-weight: 700; font-size: 13px; padding: 6px 12px; border-radius: 999px; cursor: pointer; }
.leave-btn:hover { border-color: var(--bad); color: var(--bad); }

.buzz-wrap { flex: 1; display: flex; align-items: center; justify-content: center; }
.buzz-btn {
  width: min(80vw, 360px); height: min(80vw, 360px); border-radius: 50%;
  border: none; font-size: 42px; font-weight: 900; color: #3a0018;
  background: radial-gradient(circle at 35% 30%, #ff8fb3, var(--accent-2));
  box-shadow: 0 16px 0 #c23a68, 0 22px 40px rgba(0,0,0,.5);
  transition: transform .06s, box-shadow .06s;
  touch-action: manipulation; user-select: none;
}
.buzz-btn:active:not(:disabled) { transform: translateY(12px); box-shadow: 0 4px 0 #c23a68, 0 8px 20px rgba(0,0,0,.5); }
.buzz-btn:disabled { background: var(--panel-2); color: var(--muted); box-shadow: 0 8px 0 #1a1636; }
.buzz-btn.locked-in { background: radial-gradient(circle at 35% 30%, #8effc0, var(--good)); color: #06301a; box-shadow: 0 12px 0 #1f8a55; }

.player-status { text-align: center; font-size: 20px; font-weight: 800; min-height: 1.4em; }
.player-status .rank-big { font-size: 64px; color: var(--accent); display: block; }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  background: var(--panel); padding: 12px 20px; border-radius: 12px; box-shadow: var(--shadow);
  font-weight: 700; opacity: 0; transition: opacity .2s, transform .2s; pointer-events: none; z-index: 50;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(-6px); }

/* ============================================================
 *  追加: 問題エディタ / 3画面（ホスト操作・大画面・参加者）
 * ============================================================ */
.big-btn.editor:hover { border-color: #7be0c0; }

/* ---------- エディタ ---------- */
.editor-grid { display: grid; grid-template-columns: 280px 1fr; gap: 20px; align-items: start; }
@media (max-width: 860px) { .editor-grid { grid-template-columns: 1fr; } }

.quiz-list { display: flex; flex-direction: column; gap: 8px; }
.quiz-list-item {
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px;
  background: var(--bg2); border: 2px solid transparent; color: var(--text);
  border-radius: 12px; padding: 12px 14px; text-align: left; width: 100%;
}
.quiz-list-item:hover { border-color: var(--panel-2); }
.quiz-list-item.active { border-color: var(--accent); }
.qli-title { font-weight: 800; font-size: 16px; }
.qli-meta { color: var(--muted); font-size: 12px; }

.q-card { background: var(--bg2); border-radius: 14px; padding: 16px; margin-bottom: 14px; }
.q-card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.q-num { font-weight: 900; font-size: 18px; color: var(--accent); }
.q-time-field { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); margin-left: auto; margin-right: 12px; }
.q-time-field .q-time { width: 64px; padding: 6px 8px; font-size: 14px; text-align: center; }
.q-del { padding: 6px 10px; }
.q-card input[type="text"] { font-size: 16px; padding: 10px 12px; }

.img-field { margin-top: 10px; }
.img-toggle { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.img-toggle input { width: auto; }
.img-upload { margin-top: 8px; display: flex; align-items: center; gap: 12px; }
.img-upload input[type="file"] { font-size: 12px; color: var(--muted); }
.img-upload img { max-width: 90px; max-height: 70px; border-radius: 8px; }
img:not([src]), img[src=""] { display: none; }
.choice-count { background: var(--bg); color: var(--text); border: 2px solid var(--panel-2); border-radius: 10px; padding: 8px; }

.choices-edit { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.choice-edit { display: flex; align-items: flex-start; gap: 10px; background: var(--bg); border-radius: 10px; padding: 10px; transition: background var(--t), box-shadow var(--t); }
.choice-edit .c-text { font-size: 15px; }

/* 正解ピック（ラベル付きラジオ） */
.correct-pick { display: flex; flex-direction: column; align-items: center; gap: 2px; margin-top: 2px; cursor: pointer; user-select: none; }
.correct-pick input.c-correct { width: 24px; height: 24px; margin: 0; accent-color: var(--good); cursor: pointer; }
.correct-pick span { font-size: 11px; letter-spacing: 1px; color: var(--muted); }
.choice-edit.correct-selected { background: rgba(61, 220, 132, .14); box-shadow: inset 0 0 0 2px var(--good); }
.choice-edit.correct-selected .correct-pick span { color: var(--good); font-weight: 700; }

/* 保存アクションバー（スクロールしても常に画面下部に見える） */
.editor-actions { position: sticky; bottom: 0; z-index: 5; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin: 20px -20px -20px; padding: 14px 20px; background: var(--panel); border-top: 1px solid var(--panel-2); border-radius: 0 0 var(--radius) var(--radius); box-shadow: 0 -10px 24px rgba(0, 0, 0, .3); }
.editor-actions #deleteBtn { margin-left: auto; }
.editor-actions .save-btn { font-size: 16px; padding: 12px 30px; }
.editor-actions .save-status { flex-basis: 100%; order: -1; margin: 0; font-size: 13px; color: var(--bad); text-align: left; }
.editor-actions .save-status:empty { display: none; }
.dirty-flag { font-size: 13px; font-weight: 700; color: var(--accent); }
.dirty-flag:empty { display: none; }

/* 保存後の次アクション */
.saved-actions { margin-top: 14px; padding: 16px; border-radius: 12px; background: rgba(61, 220, 132, .12); box-shadow: inset 0 0 0 1px rgba(61, 220, 132, .4); text-align: center; }
.saved-actions .sa-title { margin: 0 0 6px; font-weight: 700; color: var(--good); }
.saved-actions .sa-desc { margin: 0 0 12px; color: var(--muted); font-size: 14px; }

/* ホスト画面の注意バナー */
.host-notice { background: rgba(255, 93, 143, .12); box-shadow: inset 0 0 0 1px rgba(255, 93, 143, .45); border-radius: 12px; padding: 12px 16px; margin-bottom: 18px; }
.host-notice-main { margin: 0 0 6px; font-size: 15px; line-height: 1.5; }
.host-notice-steps { margin: 0; font-size: 13px; color: var(--muted); line-height: 1.5; }

/* メディアプレビュー（画像/動画） */
.media-preview { display: inline-block; }
.media-preview-el { max-width: 160px; max-height: 120px; border-radius: 8px; }
.img-upload .media-preview-el { max-width: 160px; max-height: 120px; } /* 共通imgルールより優先して大きく表示 */
.field-hint { font-size: 12px; color: var(--accent); margin: 8px 0 0; line-height: 1.4; }

/* モーダル & テンプレート選択 */
.modal { position: fixed; inset: 0; z-index: 200; display: flex; align-items: center; justify-content: center; background: rgba(0,0,0,.6); padding: 20px; }
.modal-card { background: var(--panel); border-radius: 18px; padding: 24px; width: 100%; max-width: 760px; max-height: 86vh; overflow: auto; box-shadow: var(--shadow); }
.modal-head { display: flex; align-items: center; justify-content: space-between; }
/* テンプレ選択モーダル（サイドバー＋カード） */
.template-modal-card { max-width: 1200px; height: 90vh; display: flex; padding: 0; overflow: hidden; }
.tpl-sidebar { width: 230px; flex: none; background: var(--bg2); padding: 20px 14px; display: flex; flex-direction: column; gap: 4px; overflow-y: auto; }
.tpl-cat { text-align: left; background: transparent; border: none; color: var(--text); padding: 12px 14px; border-radius: 10px; font-weight: 700; font-size: 15px; cursor: pointer; }
.tpl-cat:hover { background: var(--panel-2); }
.tpl-cat.active { background: var(--panel-2); color: var(--accent); }
.tpl-main { flex: 1; padding: 18px 22px; overflow-y: auto; }

.template-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 18px; margin-top: 16px; }
.tpl-card { display: flex; flex-direction: column; gap: 10px; }
.tpl-preview { background: linear-gradient(135deg, #2f6fd6, #16357e); border-radius: 14px; padding: 14px; box-shadow: var(--shadow); }
.tpl-q-head { display: flex; gap: 8px; align-items: stretch; margin-bottom: 10px; }
.tpl-q-no { background: #6a4bd0; color: #fff; padding: 6px 9px; border-radius: 7px; font-size: 12px; font-weight: 800; white-space: nowrap; display: flex; align-items: center; }
.tpl-q-text { background: #fff; color: #1a2233; border-radius: 7px; padding: 7px 11px; font-size: 13px; font-weight: 700; flex: 1; line-height: 1.3; }
.tpl-q-media { display: flex; justify-content: center; margin-bottom: 10px; }
.tpl-media-el { max-height: 130px; max-width: 100%; border-radius: 10px; }
.tpl-choices { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; }
.tpl-choice { display: flex; align-items: center; gap: 7px; background: rgba(255,255,255,.14); border-radius: 7px; padding: 7px 9px; color: #fff; font-size: 12px; font-weight: 700; min-height: 34px; }
.tpl-choice .tpl-cnum { width: 19px; height: 19px; border-radius: 50%; background: var(--c); color: #1a0010; display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 900; flex: none; }
.tpl-ctext { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tpl-choices.imgs .tpl-choice { flex-direction: column; align-items: stretch; gap: 4px; padding: 5px; position: relative; }
.tpl-choices.imgs .tpl-cnum { position: absolute; top: 6px; left: 6px; z-index: 1; }
.tpl-choices.imgs .tpl-choice img { width: 100%; height: 58px; object-fit: cover; border-radius: 5px; }
.tpl-add { width: 100%; }

/* ホストの編集モーダル（iframe埋め込み） */
.editor-modal-card { max-width: 1100px; height: 88vh; display: flex; flex-direction: column; }
.editor-frame { flex: 1; width: 100%; border: none; border-radius: 12px; background: var(--bg); margin-top: 12px; }

/* ---------- ホスト: 問題確認 ---------- */
.host-q-text { font-size: 20px; font-weight: 800; margin-bottom: 8px; white-space: pre-wrap; }
.host-q-img { max-height: 160px; border-radius: 10px; margin-bottom: 10px; display: block; }
.host-choices { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.host-choice { display: flex; align-items: center; gap: 8px; background: var(--bg2); border: 2px solid transparent; border-radius: 10px; padding: 10px 12px; }
.host-choice.correct { border-color: var(--good); background: rgba(61,220,132,.15); }
.host-choice .ck { font-weight: 900; color: var(--muted); }
.host-choice img { max-height: 40px; border-radius: 6px; }
.progress-line { color: var(--accent); font-weight: 800; font-size: 20px; margin: 4px 0 14px; }

/* パネル見出し＋フェーズバッジ */
.panel-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.phase-badge { font-size: 13px; font-weight: 800; padding: 5px 12px; border-radius: 999px; letter-spacing: 1px; background: var(--panel-2); color: var(--muted); }
.phase-badge.phase-question { background: rgba(255, 210, 63, .18); color: var(--accent); box-shadow: inset 0 0 0 1px rgba(255, 210, 63, .4); animation: badgepulse 1.4s ease-in-out infinite; }
.phase-badge.phase-reveal { background: rgba(61, 220, 132, .18); color: var(--good); box-shadow: inset 0 0 0 1px rgba(61, 220, 132, .4); }
.phase-badge.phase-scoreboard, .phase-badge.phase-end { background: rgba(255, 93, 143, .18); color: var(--accent-2); box-shadow: inset 0 0 0 1px rgba(255, 93, 143, .4); }
@keyframes badgepulse { 0%, 100% { opacity: 1; } 50% { opacity: .55; } }

/* 主要操作ボタンは一回り大きく */
.main-actions .btn { min-height: 58px; font-size: 18px; }

/* ============================================================
 *  大画面 (screen.html)
 * ============================================================ */
.screen-body { min-height: 100dvh; display: flex; align-items: center; justify-content: center; padding: 20px; overflow: hidden; }
.screen-join { text-align: center; }
.stage { width: 100%; max-width: 1400px; height: calc(100dvh - 40px); display: flex; flex-direction: column; }
.stage-view { flex: 1; min-height: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px; }
/* 出題・正解発表はメディアを大きく、選択肢は常に見える配置に */
#viewQuestion, #viewReveal { justify-content: flex-start; }
#viewQuestion .stage-media-box, #viewReveal .reveal-media { flex: 1 1 auto; min-height: 0; align-items: center; }
#viewQuestion .stage-choices, #viewReveal .stage-choices { flex: 0 0 auto; }

/* 動画問題：周辺を小さくして動画を最大化 */
#viewQuestion.video-mode { gap: 10px; }
#viewQuestion.video-mode .q-topbar { padding: 0; }
#viewQuestion.video-mode .timer-ring { width: clamp(56px, 6vw, 84px); height: clamp(56px, 6vw, 84px); font-size: clamp(26px, 3.5vw, 44px); border-width: 5px; }
#viewQuestion.video-mode .stage-question { font-size: clamp(20px, 2.6vw, 34px); }
#viewQuestion.video-mode .stage-media-box { flex: 1 1 auto; }
#viewQuestion.video-mode .stage-media { width: 100%; height: 100%; }
#viewQuestion.video-mode .stage-choices { gap: 10px; }
#viewQuestion.video-mode .stage-choice { padding: 10px 18px; font-size: clamp(18px, 2.3vw, 30px); }
#viewQuestion.video-mode .stage-choice .cl { width: clamp(36px, 3.6vw, 52px); height: clamp(36px, 3.6vw, 52px); }

.stage-title { font-size: clamp(40px, 7vw, 90px); margin: 0; display: inline-flex; align-items: center; gap: 14px; }
.title-trophy { height: clamp(48px, 8vw, 100px); width: auto; object-fit: contain; filter: drop-shadow(0 8px 18px rgba(0, 0, 0, 0.5)); }
.stage-sub { color: var(--muted); font-size: clamp(16px, 2.5vw, 26px); margin: 0; }
.join-card { background: var(--panel); border-radius: 24px; padding: 32px 56px; text-align: center; box-shadow: var(--shadow); }
.join-label { color: var(--muted); letter-spacing: 4px; }
.join-code { font-size: clamp(60px, 12vw, 140px); font-weight: 900; letter-spacing: 12px; color: var(--accent); line-height: 1.1; }
.join-url-big { color: var(--muted); font-size: 18px; }
.lobby-row { display: flex; align-items: center; gap: 48px; flex-wrap: wrap; justify-content: center; }
.lobby-qr { width: clamp(180px, 22vw, 300px); border-radius: 16px; background: #fff; padding: 12px; box-shadow: var(--shadow); }
.lobby-players { display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; max-width: 1000px; }
.lobby-chip { background: var(--panel-2); padding: 12px 22px; border-radius: 999px; font-size: clamp(16px, 2vw, 24px); font-weight: 700; animation: pop .25s ease; }
.lobby-chip.off { opacity: .4; }

/* 上部バーは画面隅にオーバーレイ（メディアを最大化するため流れから外す） */
.q-topbar { position: absolute; top: 6px; left: 14px; right: 14px; z-index: 25; display: flex; align-items: flex-start; justify-content: space-between; pointer-events: none; }
.q-topleft { display: flex; flex-direction: column; gap: 2px; }
.q-index { font-size: clamp(18px, 2.6vw, 32px); font-weight: 900; color: var(--accent); }
.q-answered { font-size: clamp(14px, 1.8vw, 22px); color: var(--muted); }
.timer-ring {
  width: clamp(70px, 8vw, 116px); height: clamp(70px, 8vw, 116px); border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: clamp(34px, 4.6vw, 60px); font-weight: 900;
  background: rgba(26, 18, 43, .85); border: 6px solid var(--accent); color: var(--text);
  box-shadow: var(--shadow);
}
.timer-ring.danger { border-color: var(--bad); color: var(--bad); animation: pulse .6s infinite alternate; }
@keyframes pulse { from { transform: scale(1); } to { transform: scale(1.08); } }

.stage-question { font-size: clamp(28px, 5vw, 64px); font-weight: 900; text-align: center; line-height: 1.35; white-space: pre-wrap; max-width: 80%; margin: 0 auto; padding-top: 4px; }
.stage-media-box { display: flex; justify-content: center; width: 100%; }
/* width/height 100% + contain で、空きスペースいっぱいまで拡大（アスペクト比維持） */
.stage-media { width: 100%; height: 100%; max-height: 100%; max-width: 100%; object-fit: contain; border-radius: 16px; }
.reveal-media { display: flex; justify-content: center; width: 100%; }
.reveal-media-el { width: 100%; height: 100%; max-height: 100%; max-width: 100%; object-fit: contain; border-radius: 14px; }

.stage-choices { width: 100%; display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.stage-choices:has(.stage-choice:nth-child(5)) { grid-template-columns: repeat(3, 1fr); }
.stage-choice {
  display: flex; align-items: center; gap: 18px; background: var(--panel);
  border-radius: 18px; padding: 22px 28px; font-size: clamp(22px, 3.2vw, 42px); font-weight: 800;
  border-left: 12px solid var(--c); box-shadow: var(--shadow); animation: pop .2s ease;
}
.stage-choice .cl {
  width: clamp(44px, 5vw, 70px); height: clamp(44px, 5vw, 70px); flex: none; border-radius: 12px;
  background: var(--c); color: #1a0010; display: flex; align-items: center; justify-content: center; font-weight: 900;
}
.stage-choice img, .stage-choice video { max-height: 16vh; border-radius: 10px; }
.stage-choice .ct { flex: 1; }
.stage-choice .count { color: var(--muted); font-size: .7em; }
.stage-choices.reveal .stage-choice.is-wrong { opacity: .4; }
.stage-choices.reveal .stage-choice.is-correct { outline: 4px solid var(--good); transform: scale(1.02); }

/* 自動再生がブロックされた時だけ出る再生オーバーレイ */
.video-play-overlay { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; background: rgba(0,0,0,.45); cursor: pointer; z-index: 30; }
.vpo-btn { background: var(--accent); color: #2a1a00; font-weight: 900; font-size: clamp(20px, 3vw, 34px); padding: 16px 32px; border-radius: 999px; box-shadow: var(--shadow); }
.stage-view { position: relative; }

.reveal-answer { display: flex; align-items: center; gap: 20px; font-size: clamp(30px, 5vw, 60px); font-weight: 900; }
.ra-label { background: var(--good); color: #06301a; padding: 6px 18px; border-radius: 12px; font-size: .6em; }
.ra-key { width: 1.4em; height: 1.4em; border-radius: 12px; display: inline-flex; align-items: center; justify-content: center; color: #1a0010; }

/* ランキング */
.podium { display: flex; align-items: flex-end; justify-content: center; gap: 24px; width: 100%; }
.podium-col { display: flex; flex-direction: column; align-items: center; gap: 6px; width: clamp(140px, 18vw, 240px); }
.podium-medal { line-height: 0; }
.podium-medal img { width: clamp(56px, 7vw, 100px); height: auto; object-fit: contain; filter: drop-shadow(0 6px 14px rgba(0, 0, 0, 0.45)); }
.podium-name { font-size: clamp(20px, 2.5vw, 34px); font-weight: 900; }
.podium-score { font-size: clamp(18px, 2vw, 28px); color: var(--accent); font-weight: 800; }
.podium-time { color: var(--muted); }
.podium-bar { width: 100%; border-radius: 14px 14px 0 0; background: linear-gradient(var(--panel-2), var(--panel)); }
.podium-col.rank1 .podium-bar { height: 220px; background: linear-gradient(var(--accent), #ffb03f); }
.podium-col.rank2 .podium-bar { height: 160px; }
.podium-col.rank3 .podium-bar { height: 120px; }

.rank-rest { width: 100%; max-width: 760px; display: flex; flex-direction: column; gap: 8px; margin-top: 20px; }
.rank-row { display: flex; align-items: center; gap: 16px; background: var(--panel); border-radius: 12px; padding: 12px 20px; font-size: 22px; }
.rank-row .rr-rank { font-weight: 900; color: var(--muted); width: 36px; }
.rank-row .rr-name { flex: 1; font-weight: 700; }
.rank-row .rr-score { color: var(--accent); font-weight: 800; }

/* ランキング: 溜め（ドラムロール中） */
.score-suspense { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 28px; height: 100%; }
.suspense-trophy { width: clamp(130px, 20vw, 260px); height: auto; filter: drop-shadow(0 14px 34px rgba(0, 0, 0, 0.55)); animation: trophyPulse 0.5s ease-in-out infinite alternate; }
@keyframes trophyPulse { from { transform: scale(1) rotate(-3deg); } to { transform: scale(1.14) rotate(3deg); } }
.suspense-text { font-size: clamp(40px, 8vw, 96px); font-weight: 900; letter-spacing: 2px; }
.suspense-dots { display: flex; gap: 16px; }
.suspense-dots span { width: 20px; height: 20px; border-radius: 50%; background: var(--accent); animation: dotBounce 0.6s infinite; }
.suspense-dots span:nth-child(2) { animation-delay: 0.15s; }
.suspense-dots span:nth-child(3) { animation-delay: 0.3s; }
@keyframes dotBounce { 0%, 100% { transform: translateY(0); opacity: 0.4; } 50% { transform: translateY(-16px); opacity: 1; } }

/* ランキング: 発表（せり上がり演出） */
.score-reveal { display: flex; flex-direction: column; align-items: center; gap: 18px; width: 100%; }
@keyframes barGrow { from { transform: scaleY(0); } to { transform: scaleY(1); } }
@keyframes popIn { from { transform: scale(0.3); opacity: 0; } to { transform: scale(1); opacity: 1; } }
#scoreReveal .podium-bar { animation: barGrow 0.5s cubic-bezier(0.2, 0.9, 0.3, 1.3) backwards; transform-origin: bottom; }
#scoreReveal .podium-medal, #scoreReveal .podium-name, #scoreReveal .podium-score, #scoreReveal .podium-time { animation: popIn 0.4s ease backwards; }
/* 3位→2位→1位の順にせり上げ */
#scoreReveal .rank3 .podium-bar { animation-delay: 0.1s; } #scoreReveal .rank3 .podium-medal, #scoreReveal .rank3 .podium-name, #scoreReveal .rank3 .podium-score, #scoreReveal .rank3 .podium-time { animation-delay: 0.45s; }
#scoreReveal .rank2 .podium-bar { animation-delay: 0.55s; } #scoreReveal .rank2 .podium-medal, #scoreReveal .rank2 .podium-name, #scoreReveal .rank2 .podium-score, #scoreReveal .rank2 .podium-time { animation-delay: 0.9s; }
#scoreReveal .rank1 .podium-bar { animation-delay: 1.0s; } #scoreReveal .rank1 .podium-medal, #scoreReveal .rank1 .podium-name, #scoreReveal .rank1 .podium-score, #scoreReveal .rank1 .podium-time { animation-delay: 1.35s; }
#scoreReveal .rank-rest { animation: popIn 0.4s ease backwards; animation-delay: 1.5s; }

/* ============================================================
 *  参加者の選択肢 (player.html)
 * ============================================================ */
.p-question { background: var(--panel); border-radius: 14px; padding: 18px; text-align: center; font-size: 20px; font-weight: 700; min-height: 1.5em; white-space: pre-wrap; }
.p-question img { max-width: 100%; border-radius: 10px; }
.p-choices { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.p-choice {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  min-height: 96px; border: none; border-radius: 16px; padding: 16px; color: #1a0010; font-weight: 800; font-size: 18px;
  background: var(--c); box-shadow: 0 6px 0 rgba(0,0,0,.35); transition: transform .06s;
}
.p-choice:active:not(:disabled) { transform: translateY(4px); box-shadow: 0 2px 0 rgba(0,0,0,.35); }
.p-choice .cl { font-size: 26px; font-weight: 900; }
.p-choice img, .p-choice video { max-height: 70px; border-radius: 8px; }
.p-count { font-size: 13px; opacity: .8; }
.p-choice:disabled { opacity: .5; }
.p-choice.picked { outline: 4px solid #fff; opacity: 1; }
.p-choice.is-correct { outline: 4px solid var(--good); opacity: 1; }
.p-choice.is-wrong { outline: 4px solid var(--bad); opacity: .9; }
.p-choice.dim { opacity: .35; }
.p-choice .mark { font-size: 22px; }

.status-ok { color: var(--good); }
.status-ng { color: var(--bad); }

/* 参加者: 上部バー・メディア・正解バナー・ランキング */
.p-topbar { display: flex; align-items: center; justify-content: space-between; }
.p-index { font-weight: 900; color: var(--accent); font-size: 18px; }
.p-timer { font-weight: 900; font-size: 28px; min-width: 1.6em; text-align: center; color: var(--text); }
.p-timer.danger { color: var(--bad); }
.p-media { display: flex; justify-content: center; }
.p-media-el { max-width: 100%; max-height: 38vh; border-radius: 12px; box-shadow: var(--shadow); }
.p-reveal-answer { display: flex; align-items: center; gap: 10px; justify-content: center; font-weight: 900; font-size: 22px; }
.pra-label { background: var(--good); color: #06301a; padding: 4px 12px; border-radius: 10px; font-size: 14px; }
.pra-key { width: 1.4em; height: 1.4em; border-radius: 8px; display: inline-flex; align-items: center; justify-content: center; color: #1a0010; }
.p-ranking { display: flex; flex-direction: column; gap: 6px; grid-column: 1 / -1; }
.p-rank-row { display: flex; align-items: center; gap: 10px; background: var(--panel); border-radius: 10px; padding: 10px 14px; }
.p-rank-row.is-me { outline: 2px solid var(--accent); }
.p-rank-row .prr-name { flex: 1; font-weight: 700; }
.p-rank-row .prr-rank { width: 32px; display: flex; align-items: center; justify-content: center; font-weight: 900; color: var(--muted); }
.p-rank-row .prr-medal { width: 30px; height: 30px; object-fit: contain; }

/* ---------- ホスト認証ゲート ---------- */
/* 料金プラン画面 */
.plans-title { text-align: center; margin: 24px 0 8px; }
.plans-lead { text-align: center; color: var(--muted); line-height: 1.7; margin: 0 0 28px; }
.plans-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 18px; }
.plan-card { background: var(--panel); border-radius: var(--radius); padding: 24px; box-shadow: var(--shadow); text-align: center;
  display: flex; flex-direction: column; gap: 6px; }
.plan-card.is-current { box-shadow: var(--shadow), inset 0 0 0 2px var(--good); }
.pc-name { margin: 0; font-size: 15px; font-weight: 700; letter-spacing: 1px; color: var(--muted); }
.pc-price { margin: 4px 0; font-size: 34px; font-weight: 900; color: var(--accent); }
.pc-cap { margin: 0; font-size: 15px; font-weight: 700; }
.pc-desc { margin: 8px 0 16px; font-size: 12.5px; color: var(--muted); line-height: 1.6; }
.pc-buy { margin-top: auto; }
.pc-current { margin: auto 0 0; font-size: 13px; font-weight: 700; color: var(--good); }
.plans-note { text-align: center; color: var(--muted); font-size: 13px; margin-top: 24px; }
.purchase-result { text-align: center; margin: 0 0 20px; padding: 12px 16px; border-radius: 10px; font-size: 13.5px;
  line-height: 1.6; background: var(--panel); color: var(--muted); }
.purchase-result:empty { display: none; }
.purchase-result.ok { background: rgba(61, 220, 132, .12); box-shadow: inset 0 0 0 1px rgba(61, 220, 132, .4); color: var(--good); }

/* ホスト画面: プランと参加人数の枠 */
.plan-info { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; padding: 10px 12px;
  border-radius: 10px; background: var(--bg); font-size: 13px; color: var(--muted); }
.plan-info:empty { display: none; }
.plan-info .plan-name { font-weight: 700; color: var(--text); }
.plan-info .plan-count { margin-left: auto; font-variant-numeric: tabular-nums; }
.plan-info .plan-msg { flex-basis: 100%; }
.plan-info .plan-upgrade { flex-basis: 100%; text-align: center; }
.plan-info.warn { background: rgba(255, 210, 63, .12); box-shadow: inset 0 0 0 1px rgba(255, 210, 63, .4); }
.plan-info.warn .plan-msg { color: var(--accent); font-weight: 700; }
.plan-info.full { background: rgba(255, 82, 82, .12); box-shadow: inset 0 0 0 1px rgba(255, 82, 82, .45); }
.plan-info.full .plan-msg { color: var(--bad); font-weight: 700; }

/* 保存期間の注意書き */
.retention-note { margin: 14px 0 0; padding: 10px 12px; border-radius: 10px; background: rgba(255, 210, 63, .1);
  box-shadow: inset 0 0 0 1px rgba(255, 210, 63, .3); color: var(--muted); font-size: 12px; line-height: 1.6; }
.retention-note b { color: var(--accent); }

/* トップのログイン状態表示 */
.auth-status { position: fixed; top: 14px; right: 16px; z-index: 50; display: flex; align-items: center; gap: 10px; }
.auth-who { font-size: 13px; color: var(--muted); max-width: 40vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.btn-sm { padding: 7px 14px; font-size: 13px; }

/* ログイン / 新規登録 */
.auth-wrap { width: 100%; max-width: 420px; display: flex; flex-direction: column; align-items: center; padding: 24px; }
.auth-card { width: 100%; margin-top: 20px; }
.auth-tabs { display: flex; gap: 8px; margin-bottom: 18px; }
.auth-tab { flex: 1; padding: 10px; border-radius: 10px; border: none; cursor: pointer; font-size: 15px; font-weight: 700;
  background: var(--bg); color: var(--muted); transition: background var(--t), color var(--t); }
.auth-tab.active { background: var(--accent); color: #3a2c00; }
.auth-lead { font-size: 13px; margin: 0 0 18px; line-height: 1.5; }
.auth-field { margin-bottom: 14px; }
.auth-field .section-title { margin-bottom: 6px; }
.auth-error { color: var(--bad); font-size: 13px; min-height: 1.3em; margin: 10px 0 0; text-align: center; }
.auth-divider { display: flex; align-items: center; gap: 12px; margin: 22px 0 14px; color: var(--muted); font-size: 12px; }
.auth-divider::before, .auth-divider::after { content: ""; flex: 1; height: 1px; background: var(--panel-2); }
.auth-divider[hidden] { display: none; }
.google-btn { display: flex; align-items: center; justify-content: center; gap: 10px; background: #fff; color: #1f1f1f;
  text-decoration: none; font-weight: 700; }
/* display を指定すると既定の [hidden] より優先されてしまうので、明示的に隠す */
.google-btn[hidden] { display: none; }
.google-btn:hover { background: #f1f1f1; }
.google-btn .g-logo { width: 18px; height: 18px; flex: none; }

.gate { position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center; padding: 24px;
  background: radial-gradient(1000px 700px at 50% -10%, #3a2a6b 0%, transparent 60%), linear-gradient(160deg, var(--bg), var(--bg2)); }
.gate-card { background: var(--panel); border-radius: var(--radius); padding: 32px; box-shadow: var(--shadow); width: 100%; max-width: 380px; text-align: center; }
.gate-card input { text-align: center; font-size: 20px; letter-spacing: 2px; }

/* キックボタン */
.player-chip .kick { background: transparent; border: none; color: var(--muted); font-size: 16px; cursor: pointer; padding: 2px 6px; border-radius: 8px; }
.player-chip .kick:hover { background: var(--bad); color: #fff; }
.player-chip .chip-right { display: flex; align-items: center; gap: 8px; }
