/* ============ GD Boardroom — ビジネス調テーマ ============ */
:root {
  --navy: #12263f;
  --navy-deep: #0c1a2c;
  --navy-line: #1f3a5c;
  --gold: #b08d3e;
  --gold-light: #d3b271;
  --bg: #f2f4f7;
  --card: #ffffff;
  --line: #dde3ec;
  --text: #24303e;
  --muted: #6b7887;
  --danger: #c0392b;
  --ok: #2e7d55;
  --room-bg: #0d141f;
  --tile-bg: #17222f;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body { height: 100%; }

body {
  font-family: "Noto Sans JP", "Hiragino Kaku Gothic ProN", "Yu Gothic", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.7;
}

body[data-screen="room"] { background: var(--room-bg); }

.hidden { display: none !important; }
.muted { color: var(--muted); font-size: 13px; }

/* ============ スプラッシュ（起動画面） ============ */
#splash {
  position: fixed; inset: 0; z-index: 1000;
  background: linear-gradient(135deg, #0c1a2c 0%, #12263f 60%, #1b3a5f 100%);
  display: flex; align-items: center; justify-content: center;
  transition: opacity .55s ease;
}
#splash.hide { opacity: 0; pointer-events: none; }
.sp-inner { text-align: center; animation: spIn .7s ease; }
@keyframes spIn {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: none; }
}
.sp-gd { font-size: 68px; font-weight: 900; color: #d3b271; letter-spacing: 8px; text-indent: 8px; line-height: 1; }
.sp-dj { font-size: 46px; font-weight: 900; color: #ffffff; letter-spacing: 16px; text-indent: 16px; margin-top: 8px; line-height: 1; }
.sp-bar { width: 130px; height: 5px; background: #b08d3e; border-radius: 3px; margin: 24px auto 16px; }
.sp-sub { font-size: 12px; letter-spacing: 3px; color: #8fa2b8; font-weight: 700; }

/* ============ ヘッダー ============ */
#appHeader {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 22px;
  background: linear-gradient(90deg, var(--navy-deep), var(--navy));
  border-bottom: 2px solid var(--gold);
  color: #fff;
}
.brand { font-weight: 900; font-size: 19px; letter-spacing: 1px; }
.brand span { color: var(--gold-light); }
.brand small { display: block; font-size: 10px; font-weight: 500; letter-spacing: 2.5px; color: #9db1c7; }
.header-right { display: flex; align-items: center; gap: 10px; }

#phaseChip, #roomCodeChip {
  font-size: 12px; font-weight: 700; letter-spacing: 1px;
  padding: 4px 12px; border-radius: 3px;
  background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.18);
}
#phaseChip { color: var(--gold-light); border-color: rgba(211,178,113,.45); }

#timerPill {
  font-size: 18px; font-weight: 900; letter-spacing: 1px;
  padding: 6px 16px; border-radius: 4px;
  background: var(--gold); color: var(--navy-deep);
  font-variant-numeric: tabular-nums;
  box-shadow: 0 2px 10px rgba(0,0,0,.35);
}
#timerPill.urgent { background: var(--danger); color: #fff; animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: .6; } }

#jsErr {
  background: #fde8e6; color: var(--danger);
  padding: 8px 20px; font-size: 13px; font-weight: 700;
}

/* ============ ロビー ============ */
#scr-lobby { max-width: 1080px; margin: 0 auto; padding: 36px 20px 60px; }

.hero { text-align: center; margin-bottom: 34px; }
.hero h1 {
  font-size: 32px; font-weight: 900; color: var(--navy); line-height: 1.4;
  margin-bottom: 12px;
}
.hero p { color: var(--muted); font-size: 14px; }

.lobby-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 16px; }

/* フリーマッチのルーム一覧 */
.match-row {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  border: 1px solid var(--line); border-radius: 6px;
  padding: 8px 12px; margin-top: 8px;
}
.match-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 13px; }
.match-meta .chip { margin-left: 0; }
.match-host { font-weight: 700; }
.match-cnt { color: var(--muted); font-variant-numeric: tabular-nums; }
.match-row .btn { flex: none; }

.card {
  background: var(--card); border: 1px solid var(--line); border-radius: 8px;
  padding: 20px; box-shadow: 0 1px 4px rgba(18,38,63,.06);
}
.card-head {
  font-weight: 900; font-size: 15px; color: var(--navy);
  margin-bottom: 14px; padding-bottom: 10px; border-bottom: 2px solid var(--gold);
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
}
.card-head small { font-weight: 500; font-size: 11px; color: var(--muted); }
.card-head .num {
  display: inline-flex; align-items: center; justify-content: center;
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--navy); color: var(--gold-light); font-size: 12px; flex: none;
}

.form-grid { display: grid; gap: 10px; margin-bottom: 14px; }
.form-grid label, .join-label { display: block; font-size: 12px; font-weight: 700; color: var(--muted); }
input[type="text"], input[type="password"], select {
  width: 100%; margin-top: 3px; padding: 8px 10px;
  border: 1px solid var(--line); border-radius: 5px;
  font: inherit; font-size: 14px; color: var(--text); background: #fbfcfe;
}
input:focus, select:focus { outline: 2px solid var(--gold-light); border-color: var(--gold); }

.code-input { font-size: 22px !important; font-weight: 900; letter-spacing: 8px; text-align: center; text-transform: uppercase; }
.join-label { margin-bottom: 14px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font: inherit; font-weight: 700; font-size: 14px;
  padding: 10px 18px; border-radius: 5px; border: 1px solid transparent;
  cursor: pointer; transition: filter .15s, transform .05s;
  text-decoration: none;
}
.btn:active { transform: translateY(1px); }
.btn:hover { filter: brightness(1.08); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.primary { background: var(--navy); color: #fff; }
.btn.gold { background: var(--gold); color: #fff; }
.btn.ghost { background: transparent; border-color: var(--line); color: var(--muted); }
.btn.small { padding: 6px 14px; font-size: 13px; }
.btn.wide { width: 100%; }

.note { font-size: 12px; color: var(--muted); margin-top: 10px; }

.card.slim { margin-bottom: 12px; padding: 0; }
.card.slim summary {
  padding: 14px 20px; font-weight: 700; font-size: 14px; color: var(--navy); cursor: pointer;
}
.card.slim .detail-body { padding: 0 20px 18px; font-size: 13px; color: var(--text); }
.api-row { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.api-row input { flex: 2 1 200px; margin-top: 0; }
.api-row select { flex: 1 1 180px; margin-top: 0; width: auto; }
.privacy-list { padding-left: 20px; display: grid; gap: 6px; }

.lobby-footer { text-align: center; color: var(--muted); font-size: 12px; margin-top: 26px; }

/* SEO・解説コンテンツ */
.seo-block {
  background: var(--card); border: 1px solid var(--line); border-radius: 8px;
  padding: 24px 26px; margin-bottom: 12px;
  box-shadow: 0 1px 4px rgba(18,38,63,.06);
}
.seo-block h2 {
  font-size: 17px; font-weight: 900; color: var(--navy);
  border-left: 4px solid var(--gold); padding-left: 12px;
  margin: 18px 0 10px;
}
.seo-block h2:first-child { margin-top: 0; }
.seo-block p { font-size: 14px; color: var(--text); margin-bottom: 6px; }

/* ============ ルーム ============ */
#scr-room { max-width: 1280px; margin: 0 auto; padding: 14px 16px 110px; }

#topicBar {
  display: flex; align-items: center; gap: 12px;
  background: var(--navy);
  border: 1px solid var(--navy-line); border-left: 4px solid var(--gold);
  color: #fff; border-radius: 6px;
  padding: 12px 16px; margin-bottom: 14px;
  font-size: 16px; font-weight: 700;
}
.topic-label {
  flex: none; font-size: 11px; font-weight: 900; letter-spacing: 2px;
  color: var(--navy-deep); background: var(--gold-light);
  padding: 2px 10px; border-radius: 3px;
}

.warn-banner {
  background: #4a3a12; color: #f0d9a0; border: 1px solid #8a6d2a;
  font-size: 12px; border-radius: 6px; padding: 8px 14px; margin-bottom: 12px;
}

#waitPanel { display: flex; justify-content: center; margin-bottom: 16px; }
.wait-box {
  background: var(--tile-bg); border: 1px solid var(--navy-line); border-radius: 10px;
  color: #dce5ef; text-align: center; padding: 22px 34px; min-width: 320px;
}
.wait-title { font-size: 12px; letter-spacing: 3px; color: #8fa2b8; font-weight: 700; }
#bigCode { font-size: 44px; font-weight: 900; letter-spacing: 10px; color: var(--gold-light); font-variant-numeric: tabular-nums; }
.wait-btns { display: flex; gap: 8px; justify-content: center; margin: 8px 0 14px; }
.wait-btns .btn { background: rgba(255,255,255,.09); color: #dce5ef; border: 1px solid var(--navy-line); }
.wait-summary { font-size: 13px; color: #a9bacd; }
.wait-count { font-size: 15px; font-weight: 700; color: #fff; margin: 6px 0 12px; }
.chk { display: block; font-size: 13px; color: #a9bacd; margin-bottom: 10px; cursor: pointer; }
.wait-note { color: #8fa2b8; font-size: 13px; }

/* ---- ビデオグリッド ---- */
#grid {
  display: grid; gap: 10px;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}
.tile {
  position: relative; background: var(--tile-bg);
  border: 1px solid var(--navy-line); border-radius: 8px;
  aspect-ratio: 16 / 9; overflow: hidden; cursor: pointer;
}
.tile video { width: 100%; height: 100%; object-fit: cover; display: block; }
.tile video.mirror { transform: scaleX(-1); }
.tile.cam-off video { visibility: hidden; }
.tile .avatar {
  display: none; position: absolute; inset: 0; margin: auto;
  width: 76px; height: 76px; border-radius: 50%;
  background: var(--navy); color: var(--gold-light);
  font-size: 34px; font-weight: 900;
  align-items: center; justify-content: center;
}
.tile.cam-off .avatar { display: flex; }
.tile .nametag {
  position: absolute; left: 8px; bottom: 8px;
  display: flex; align-items: center; gap: 6px;
  background: rgba(0,0,0,.58); color: #fff;
  font-size: 12px; font-weight: 700;
  padding: 3px 10px; border-radius: 4px; max-width: 85%;
}
.tile .nametag .host-badge {
  font-size: 10px; color: var(--navy-deep); background: var(--gold-light);
  padding: 0 6px; border-radius: 3px; flex: none;
}
.tile .badges { position: absolute; top: 8px; right: 8px; display: flex; gap: 6px; }
.tile .mic-badge {
  display: none; width: 24px; height: 24px; border-radius: 50%;
  background: var(--danger); color: #fff;
  align-items: center; justify-content: center;
}
.tile .mic-badge svg { width: 14px; height: 14px; fill: #fff; }
.tile.muted .mic-badge { display: flex; }
.tile .rec-badge {
  display: none; align-items: center; gap: 4px;
  background: rgba(0,0,0,.6); color: #ff5f4d;
  font-size: 10px; font-weight: 900; padding: 3px 8px; border-radius: 4px;
}
.tile .rec-badge::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: #ff5f4d; animation: pulse 1.2s infinite; }
.tile.recording .rec-badge { display: flex; }
.tile.presenter { border: 2px solid var(--gold); box-shadow: 0 0 18px rgba(176,141,62,.45); }
.tile.presenter::after {
  content: "発表者"; position: absolute; top: 0; left: 0;
  background: var(--gold); color: #fff; font-size: 11px; font-weight: 900;
  padding: 3px 12px; border-radius: 0 0 6px 0; letter-spacing: 2px;
}

/* ---- コントロールバー ---- */
#controls {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 60;
  display: flex; align-items: center; justify-content: center; gap: 14px;
  padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
  background: rgba(10, 17, 27, .96);
  border-top: 1px solid var(--navy-line);
}
.ctl {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  background: none; border: none; cursor: pointer;
  color: #cdd9e5; font: inherit; font-size: 11px;
  padding: 4px 10px; border-radius: 8px; min-width: 74px;
}
.ctl:hover { background: rgba(255,255,255,.08); }
.ctl svg { width: 24px; height: 24px; fill: currentColor; }
.ctl .ic-off { display: none; }
.ctl.off { color: #ff6b5b; }
.ctl.off .ic-on { display: none; }
.ctl.off .ic-off { display: block; }
.ctl.on { color: var(--gold-light); }
.ctl.rec-on { color: #ff5f4d; }
.ctl.rec-on svg { animation: pulse 1.2s infinite; }
.ctl.leave { color: #ff8a7a; }

/* ============ フィードバック ============ */
#scr-feedback { max-width: 860px; margin: 0 auto; padding: 28px 20px 130px; display: grid; gap: 14px; }
.fb-title {
  font-size: 24px; font-weight: 900; color: var(--navy); text-align: center;
  border-bottom: 3px double var(--gold); padding-bottom: 12px;
}
.sum-row { display: flex; gap: 14px; padding: 5px 0; border-bottom: 1px dashed var(--line); font-size: 14px; }
.sum-row .k { flex: none; width: 90px; font-weight: 700; color: var(--muted); }
.sum-row .v { font-weight: 500; }
.sum-comment { margin-top: 12px; font-size: 14px; background: #f6f2e8; border-left: 4px solid var(--gold); padding: 10px 14px; border-radius: 0 5px 5px 0; }

.bar-row { display: flex; align-items: center; gap: 10px; margin: 7px 0; }
.bar-name { flex: none; width: 110px; font-size: 13px; font-weight: 700; text-align: right; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-track { flex: 1; height: 18px; background: #e9edf3; border-radius: 3px; overflow: hidden; }
.bar-fill { height: 100%; background: linear-gradient(90deg, var(--navy), #2c4d77); border-radius: 3px; transition: width .6s ease; }
.bar-val { flex: none; width: 44px; font-size: 13px; font-weight: 700; color: var(--navy); font-variant-numeric: tabular-nums; }

.chip {
  display: inline-block; font-size: 11px; font-weight: 700;
  padding: 1px 9px; border-radius: 10px; margin-left: 6px;
  background: #e9edf3; color: var(--muted); vertical-align: middle;
}
.chip.gold { background: #f3e8cf; color: #8a6d2a; }
.chip.good { background: #e0f0e8; color: var(--ok); }
.chip.warn { background: #fdecd8; color: #b06210; }

.stat-card { border: 1px solid var(--line); border-radius: 7px; padding: 12px 16px; margin-bottom: 10px; }
.stat-card.me { border-color: var(--gold); background: #fdfaf3; }
.stat-name { font-weight: 900; font-size: 15px; color: var(--navy); margin-bottom: 6px; }
.stat-nums { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 6px; }
.stat-nums div { display: flex; flex-direction: column; font-size: 12px; color: var(--muted); }
.stat-nums strong { font-size: 17px; color: var(--text); font-variant-numeric: tabular-nums; }

.ai-overall { background: #f6f2e8; border-radius: 7px; padding: 14px 16px; margin-bottom: 12px; }
.ai-overall h4, .ai-member h4 { font-size: 14px; color: var(--navy); margin-bottom: 6px; }
.ai-member { border-top: 1px solid var(--line); padding: 12px 4px 4px; margin-top: 10px; }
.ai-member.me h4::after { content: "  ★"; color: var(--gold); }
.ai-member p { font-size: 14px; margin: 5px 0; }
#genAiBtn { margin-top: 14px; }

.tr-line { font-size: 13px; padding: 4px 0; border-bottom: 1px dotted var(--line); }
.tr-line .chip { margin: 0 6px 0 0; }
#fbTranscript { max-height: 320px; overflow-y: auto; }

.rec-item { margin-bottom: 16px; }
.rec-item video { width: 100%; border-radius: 7px; background: #000; margin-bottom: 8px; }

.fb-actions { display: flex; gap: 12px; justify-content: center; margin-top: 8px; }

/* ============ モーダル・オーバーレイ ============ */
.overlay {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(8, 14, 22, .72);
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.modal {
  background: var(--card); border-radius: 10px; border-top: 4px solid var(--gold);
  padding: 26px 28px; max-width: 460px; width: 100%;
  max-height: 86vh; overflow-y: auto;
  box-shadow: 0 18px 60px rgba(0,0,0,.4);
}
.modal h3 { color: var(--navy); font-size: 18px; margin-bottom: 6px; }
.modal-btns { display: flex; gap: 10px; margin-top: 16px; }
.modal-btns .btn { flex: 1; }

#presenterList { display: grid; gap: 6px; margin-top: 14px; }
#presenterList label {
  display: flex; align-items: center; gap: 10px;
  border: 1px solid var(--line); border-radius: 6px; padding: 10px 14px;
  cursor: pointer; font-weight: 700;
}
#presenterList label:has(input:checked) { border-color: var(--gold); background: #fdfaf3; }

#profileBody h3 { border-bottom: 2px solid var(--gold); padding-bottom: 8px; margin-bottom: 10px; }
.pf-row { display: flex; gap: 12px; padding: 6px 0; border-bottom: 1px dashed var(--line); font-size: 14px; }
.pf-row .k { flex: none; width: 92px; color: var(--muted); font-weight: 700; }
#profileClose { margin-top: 16px; }

.ad-modal { text-align: center; }
.ad-label { font-size: 11px; letter-spacing: 3px; color: var(--muted); font-weight: 700; margin-bottom: 10px; }
.ad-slot { margin-bottom: 16px; }
.ad-ph {
  border: 2px dashed var(--line); border-radius: 8px; padding: 40px 20px;
  color: var(--muted); font-size: 13px;
}
.ad-ph span {
  display: inline-block; background: var(--navy); color: #fff;
  font-size: 11px; font-weight: 900; letter-spacing: 2px;
  padding: 2px 10px; border-radius: 3px; margin-bottom: 10px;
}

/* ============ トースト ============ */
#toast {
  position: fixed; left: 50%; bottom: 96px; transform: translateX(-50%) translateY(20px);
  z-index: 200; background: var(--navy-deep); color: #fff;
  font-size: 13px; font-weight: 700;
  padding: 10px 22px; border-radius: 6px; border-left: 4px solid var(--gold);
  opacity: 0; pointer-events: none; transition: opacity .25s, transform .25s;
  max-width: 90vw; box-shadow: 0 6px 24px rgba(0,0,0,.35);
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ============ レスポンシブ ============ */
@media (max-width: 900px) {
  .lobby-grid { grid-template-columns: 1fr; }
  .hero h1 { font-size: 24px; }
  .pc-only { display: none; }
  #grid { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
  .brand small { display: none; }
  #timerPill { font-size: 15px; padding: 5px 10px; }
  .ctl { min-width: 56px; padding: 4px 4px; }
  #controls { gap: 4px; }
}
