:root {
  --bg: #0f1726;
  --panel: #16223a;
  --panel-2: #1d2c49;
  --line: #2a3a5c;
  --text: #eaf0fb;
  --muted: #9fb0cf;
  --accent: #4f8cff;
  --accent-2: #36d399;
  --warn: #ffb340;
  --bad: #ff6b6b;
  --good: #36d399;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: radial-gradient(1200px 600px at 70% -10%, #1c2c4d 0%, var(--bg) 60%);
  color: var(--text);
  font-family: "Segoe UI", "Hiragino Kaku Gothic ProN", "Yu Gothic UI", Meiryo, sans-serif;
  min-height: 100%;
}

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 22px; border-bottom: 1px solid var(--line);
  background: rgba(15,23,38,0.7); backdrop-filter: blur(6px);
  position: sticky; top: 0; z-index: 20;
}
.brand { font-weight: 700; font-size: 19px; letter-spacing: .3px; }

.screen { max-width: 1100px; margin: 0 auto; padding: 26px 22px 60px; }
.hidden { display: none !important; }

/* ---------- ボタン ---------- */
button { font-family: inherit; cursor: pointer; border: none; border-radius: 10px; font-size: 15px; }
.primary-btn { background: var(--accent); color: #fff; padding: 11px 18px; font-weight: 600; }
.primary-btn:hover { background: #3f7af0; }
.ghost-btn { background: transparent; color: var(--text); border: 1px solid var(--line); padding: 9px 14px; }
.ghost-btn:hover { background: var(--panel-2); }

/* ---------- シナリオ選択 ---------- */
.intro h1 { font-size: 26px; margin: 6px 0 8px; }
.intro p { color: var(--muted); line-height: 1.7; margin: 0 0 22px; }
.scenario-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.scenario-card {
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px;
  padding: 18px; cursor: pointer; transition: transform .12s, border-color .12s, background .12s;
}
.scenario-card:hover { transform: translateY(-3px); border-color: var(--accent); background: var(--panel-2); }
.scenario-card .cat { font-size: 12px; color: var(--accent); font-weight: 700; letter-spacing: .5px; }
.scenario-card h3 { margin: 8px 0 10px; font-size: 18px; }
.scenario-card .sit { color: var(--muted); font-size: 13.5px; line-height: 1.6; min-height: 60px; }
.diff { margin-top: 12px; font-size: 13px; }
.diff .star { color: var(--warn); }
.diff .star.off { color: #44557a; }

/* ---------- 会話画面 ---------- */
.talk-layout { display: grid; grid-template-columns: 1fr 280px; gap: 20px; }
@media (max-width: 860px) { .talk-layout { grid-template-columns: 1fr; } }

.scenario-banner { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; margin-bottom: 14px; }
.talk-title { font-weight: 700; font-size: 17px; }
.badge { margin-left: 10px; font-size: 12px; color: var(--warn); }
.talk-situation { color: var(--muted); font-size: 13.5px; margin-top: 6px; line-height: 1.6; }

.chat-log {
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  padding: 16px; height: 46vh; min-height: 300px; overflow-y: auto;
  display: flex; flex-direction: column; gap: 12px;
}
.bubble { max-width: 80%; padding: 11px 14px; border-radius: 14px; line-height: 1.6; font-size: 15px; white-space: pre-wrap; }
.bubble.customer { align-self: flex-start; background: var(--panel-2); border-top-left-radius: 4px; }
.bubble.staff { align-self: flex-end; background: var(--accent); color: #fff; border-top-right-radius: 4px; }
.bubble .who { font-size: 11px; opacity: .7; margin-bottom: 3px; }

.input-row { display: flex; gap: 8px; margin-top: 14px; }
.text-input { flex: 1; background: var(--panel); border: 1px solid var(--line); color: var(--text); border-radius: 10px; padding: 11px 13px; font-size: 15px; }
.text-input:focus { outline: none; border-color: var(--accent); }
.mic-btn { background: var(--panel-2); color: var(--text); border: 1px solid var(--line); padding: 11px 16px; font-weight: 600; white-space: nowrap; }
.mic-btn.recording { background: var(--bad); border-color: var(--bad); color: #fff; animation: pulse 1.1s infinite; }
@keyframes pulse { 0%,100% { box-shadow: 0 0 0 0 rgba(255,107,107,.5);} 50% { box-shadow: 0 0 0 8px rgba(255,107,107,0);} }
.interim { color: var(--muted); font-size: 13px; min-height: 18px; margin-top: 6px; font-style: italic; }

.talk-actions { display: flex; gap: 10px; margin-top: 14px; flex-wrap: wrap; }
.hint-btn { background: transparent; border: 1px solid var(--warn); color: var(--warn); padding: 10px 14px; font-weight: 600; }
.hint-btn:hover { background: rgba(255,179,64,.12); }
.end-btn { background: transparent; border: 1px solid var(--line); color: var(--muted); padding: 10px 14px; margin-left: auto; }
.end-btn:hover { color: var(--text); border-color: var(--text); }

/* ---------- サイド: ゲージ ---------- */
.gauge-card, .tip-card, .hint-panel { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 16px; margin-bottom: 14px; }
.gauge-label { font-size: 13px; color: var(--muted); margin-bottom: 10px; }
.gauge-track { height: 16px; background: #0e1626; border-radius: 10px; overflow: hidden; border: 1px solid var(--line); }
.gauge-fill { height: 100%; width: 50%; border-radius: 10px; background: linear-gradient(90deg, var(--bad), var(--warn) 50%, var(--good)); transition: width .6s ease; }
.gauge-readout { text-align: right; margin-top: 8px; font-size: 24px; font-weight: 800; }
.gauge-readout small { font-size: 13px; color: var(--muted); font-weight: 400; }
.mood-chip { margin-top: 8px; text-align: center; font-size: 13px; padding: 5px; border-radius: 8px; background: var(--panel-2); }
.turn-readout { margin-top: 12px; text-align: center; font-size: 14px; color: var(--text); }
.turn-readout b { color: var(--accent); font-size: 16px; }
.rule-note { margin-top: 8px; font-size: 11.5px; color: var(--muted); line-height: 1.6; text-align: center; }
.rule-note b { color: var(--good); }

.hint-panel { border-color: var(--warn); }
.hint-head { color: var(--warn); font-weight: 700; margin-bottom: 8px; }
.hint-body { font-size: 14px; line-height: 1.7; white-space: pre-wrap; }

.tip-card .tip-head { font-weight: 700; margin-bottom: 8px; font-size: 14px; }
.tip-card ul { margin: 0; padding-left: 18px; color: var(--muted); font-size: 13.5px; line-height: 1.9; }
.tip-card b { color: var(--text); }

/* ---------- 結果画面 ---------- */
.result-wrap { max-width: 760px; margin: 0 auto; }
.score-ring {
  width: 180px; height: 180px; border-radius: 50%; margin: 10px auto 4px;
  display: grid; place-items: center;
  background: conic-gradient(var(--accent) calc(var(--p,0)*1%), #233453 0);
  position: relative;
}
.score-ring::after { content: ""; position: absolute; inset: 14px; border-radius: 50%; background: var(--bg); }
.score-num { position: relative; z-index: 2; font-size: 52px; font-weight: 800; }
.score-num small { font-size: 18px; color: var(--muted); }
.pass-banner { text-align: center; font-size: 20px; font-weight: 800; margin: 6px 0 24px; }
.pass-banner.pass { color: var(--good); }
.pass-banner.fail { color: var(--warn); }
.pass-banner.over { color: var(--bad); }

.category-list { display: flex; flex-direction: column; gap: 12px; margin: 14px 0 26px; }
.cat-row { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; }
.cat-row .cat-top { display: flex; justify-content: space-between; align-items: baseline; }
.cat-row .cat-name { font-weight: 600; }
.cat-row .cat-score { font-weight: 800; }
.cat-bar { height: 8px; background: #0e1626; border-radius: 6px; margin: 8px 0; overflow: hidden; }
.cat-bar > div { height: 100%; background: var(--accent); border-radius: 6px; }
.cat-row .cat-comment { color: var(--muted); font-size: 13px; line-height: 1.6; }

.feedback-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 700px) { .feedback-cols { grid-template-columns: 1fr; } }
.fb-card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 16px; }
.fb-card h3 { margin: 0 0 10px; font-size: 16px; }
.fb-card.good { border-color: rgba(54,211,153,.4); }
.fb-card.improve { border-color: rgba(255,179,64,.4); }
.fb-card ul { margin: 0; padding-left: 20px; line-height: 1.8; font-size: 14px; }
.overall-comment { background: var(--panel-2); border-radius: 12px; padding: 16px; margin: 20px 0; line-height: 1.8; font-size: 15px; }
.result-actions { display: flex; gap: 12px; justify-content: center; margin-top: 10px; }

/* ---------- モーダル / 共通 ---------- */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.6); display: grid; place-items: center; z-index: 50; }
.modal-card { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 24px; width: min(440px, 92vw); }
.modal-card h2 { margin: 0 0 16px; }
.field { display: block; margin-bottom: 16px; }
.field > span { display: block; font-size: 14px; margin-bottom: 6px; }
.field input, .field select { width: 100%; background: var(--bg); border: 1px solid var(--line); color: var(--text); border-radius: 9px; padding: 10px 12px; font-size: 15px; }
.field small { display: block; color: var(--muted); font-size: 12px; margin-top: 5px; line-height: 1.5; }
.check { display: flex; align-items: center; gap: 9px; font-size: 14px; margin-bottom: 16px; }
.check input { width: 18px; height: 18px; }
.modal-actions { text-align: right; }

.loading { position: fixed; inset: 0; background: rgba(0,0,0,.45); display: flex; align-items: center; justify-content: center; gap: 14px; z-index: 60; color: #fff; font-size: 15px; }
.spinner { width: 30px; height: 30px; border: 3px solid rgba(255,255,255,.25); border-top-color: #fff; border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: var(--panel-2); border: 1px solid var(--line); color: var(--text); padding: 12px 18px; border-radius: 10px; z-index: 70; font-size: 14px; box-shadow: 0 8px 30px rgba(0,0,0,.4); max-width: 80vw; }

/* ---- realtime additions ---- */
.brand-tag { font-size: 11px; background: var(--accent); color: #fff; padding: 2px 8px; border-radius: 8px; vertical-align: middle; margin-left: 6px; font-weight: 600; }
.status-pill { margin-left: 10px; font-size: 12px; padding: 3px 10px; border-radius: 20px; background: #3a3030; color: var(--muted); border: 1px solid var(--line); }
.status-pill.connecting { background: rgba(255,179,64,.15); color: var(--warn); border-color: var(--warn); }
.status-pill.live { background: rgba(54,211,153,.15); color: var(--good); border-color: var(--good); }
.status-pill.live::before { content: "● "; }
.status-pill.ended { background: rgba(255,107,107,.12); color: var(--bad); border-color: var(--bad); }
.note-box { background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; font-size: 13px; line-height: 1.7; color: var(--muted); margin-bottom: 16px; }
.note-box code { background: #0e1626; padding: 2px 6px; border-radius: 5px; color: var(--text); }
.turn-readout { margin-top: 10px; text-align: center; font-size: 13px; color: var(--muted); }
.mic-btn.muted { background: var(--bad); border-color: var(--bad); color: #fff; }
