:root {
  --bg: #15121c;
  --panel: #211c2b;
  --panel2: #2b2538;
  --line: #3a3349;
  --text: #f3eff8;
  --muted: #a99fbb;
  --accent: #ff5fa2;
  --accent2: #ffb84d;
  --ok: #3ddc97;
  --ng: #ff6b6b;
  --radius: 14px;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: "Hiragino Sans", "Noto Sans JP", "Yu Gothic UI", "Meiryo", system-ui, sans-serif;
  line-height: 1.6;
  min-height: 100vh;
}
[hidden] { display: none !important; }
button, input, select { font: inherit; color: inherit; }

.topbar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 16px; border-bottom: 1px solid var(--line);
}
.brand { font-weight: 700; letter-spacing: .02em; }
.room { color: var(--muted); font-size: .9em; }
.room b { color: var(--accent2); letter-spacing: .15em; }

main { max-width: 1100px; margin: 0 auto; padding: 16px; }
.card {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 18px;
}
.narrow { max-width: 460px; margin: 24px auto; }
h1 { font-size: 1.4em; margin: 0 0 4px; }
h2 { font-size: 1.05em; margin: 0 0 12px; }
h2 small, .label small { color: var(--muted); font-weight: 400; }
.sub { color: var(--muted); margin: 0 0 18px; font-size: .92em; }

.field { display: block; margin-bottom: 12px; }
.field span { display: block; font-size: .9em; color: var(--muted); margin-bottom: 4px; }
input, select {
  width: 100%; background: var(--panel2); border: 1px solid var(--line);
  border-radius: 10px; padding: 10px 12px; outline: none;
}
input:focus, select:focus { border-color: var(--accent); }
.row { display: flex; gap: 8px; align-items: center; }
.row input { flex: 1; min-width: 0; }
.row.end { justify-content: flex-end; }
.row.center { justify-content: center; flex-wrap: wrap; }

.btn {
  background: var(--panel2); border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 16px; cursor: pointer; white-space: nowrap;
}
.btn:hover:not(:disabled) { border-color: var(--accent); }
.btn:disabled { opacity: .45; cursor: default; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 700; }
.btn.big { width: 100%; padding: 13px; font-size: 1.05em; }
.btn.small { padding: 6px 10px; font-size: .88em; }
.btn.ghost { background: transparent; }
.or { text-align: center; color: var(--muted); margin: 14px 0; font-size: .85em; }
.error { color: var(--ng); min-height: 1.4em; margin: 10px 0 0; }

.grid2 { display: grid; grid-template-columns: 1fr 1.3fr; gap: 16px; }
.players { list-style: none; padding: 0; margin: 0 0 14px; display: flex; flex-direction: column; gap: 6px; }
.players li {
  background: var(--panel2); border-radius: 10px; padding: 8px 12px;
  display: flex; justify-content: space-between; align-items: center;
}
.players .off { opacity: .45; }
.tag { font-size: .78em; color: var(--accent2); }
.invite { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; font-size: .88em; color: var(--muted); }
.invite code { background: var(--panel2); padding: 4px 8px; border-radius: 8px; color: var(--text); word-break: break-all; }

.setting { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.setting.col { flex-direction: column; align-items: stretch; }
.setting .label { min-width: 72px; color: var(--muted); font-size: .92em; }
.setting select { flex: 1; }
.seg { display: inline-flex; background: var(--panel2); border-radius: 10px; padding: 3px; gap: 3px; flex-wrap: wrap; }
.seg button { background: transparent; border: 0; border-radius: 8px; padding: 6px 14px; cursor: pointer; }
.seg button.on { background: var(--accent); color: #fff; font-weight: 700; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips button {
  background: var(--panel2); border: 1px solid var(--line); border-radius: 999px;
  padding: 5px 12px; cursor: pointer; font-size: .9em;
}
.chips button.on { background: rgba(255, 95, 162, .18); border-color: var(--accent); color: #ffd1e5; }
.locked .seg button, .locked .chips button, .locked select { pointer-events: none; }
.status { color: var(--muted); min-height: 1.5em; margin: 10px 0; }

/* 問題 */
.grid-game { display: grid; grid-template-columns: 1fr 260px; gap: 16px; align-items: start; }
.stagecol { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.qhead { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; padding: 12px 18px; }
.qnum { font-weight: 700; font-size: 1.15em; }
.qmode { color: var(--muted); }
.lastbanner { color: var(--accent2); font-weight: 700; }
.stages { display: flex; gap: 6px; }
.stages span {
  flex: 1; text-align: center; font-size: .78em; padding: 4px 0; border-radius: 8px;
  background: var(--panel); border: 1px solid var(--line); color: var(--muted);
}
.stages span.done { opacity: .45; }
.stages span.now { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 700; }
.stage-info { display: flex; justify-content: space-between; font-weight: 700; }
.points { color: var(--accent2); }
.timer { height: 6px; background: var(--panel2); border-radius: 3px; overflow: hidden; margin: 8px 0 12px; }
.timer div { height: 100%; width: 0; background: var(--accent); }
.display {
  height: clamp(170px, 34vh, 300px); background: #0e0b13; border-radius: 12px; display: flex;
  align-items: center; justify-content: center; overflow: hidden; position: relative;
}
.display video { max-width: 100%; max-height: 100%; }
.wave { display: flex; gap: 6px; align-items: center; height: 80px; }
.wave i { width: 10px; height: 16px; background: var(--line); border-radius: 5px; }
.wave.on i { background: var(--accent); animation: wave .9s ease-in-out infinite; }
.wave.on i:nth-child(2) { animation-delay: .15s; }
.wave.on i:nth-child(3) { animation-delay: .3s; }
.wave.on i:nth-child(4) { animation-delay: .45s; }
.wave.on i:nth-child(5) { animation-delay: .6s; }
@keyframes wave { 0%, 100% { height: 16px; } 50% { height: 72px; } }
.lyrics { padding: 12px 18px; font-size: 1.25em; line-height: 1.9; text-align: center; overflow-y: auto; max-height: 100%; }
.lyrics p { margin: 0; }
/* テロップは枚数に合わせて縮めて、表示する場所に収める（スクロールさせない） */
.lyrics.telops {
  display: grid; grid-template-columns: repeat(var(--cols, 1), minmax(0, 1fr));
  grid-template-rows: repeat(var(--rows, 1), minmax(0, 1fr));
  gap: 6px; width: 100%; height: 100%; max-height: none; overflow: hidden; padding: 8px;
}
.lyrics.telops img.telop { width: 100%; height: 100%; min-height: 0; object-fit: contain; }
.ngrow { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; margin: 6px 0 4px; }
.ngitem { position: relative; background: #0e0b13; border-radius: 8px; padding: 4px; }
.ngitem img { width: 100%; height: 44px; object-fit: contain; display: block; }
.ngitem.removed { opacity: .3; }
.ngbtn {
  position: absolute; top: 2px; right: 2px; width: 22px; height: 22px; border-radius: 50%;
  border: 0; background: rgba(0, 0, 0, .65); color: #fff; font-size: 12px; line-height: 22px; padding: 0; cursor: pointer;
}
.ngbtn:disabled { cursor: default; }
.lyrics .q { color: var(--accent2); font-weight: 700; margin-top: 8px; }
.hint { background: rgba(255, 184, 77, .12); border: 1px solid rgba(255, 184, 77, .4); border-radius: 10px; padding: 8px 12px; margin: 12px 0 0; }

.answer { background: var(--panel2); border-radius: 12px; padding: 12px; margin: 8px 0 12px; border: 1px solid var(--accent); }
.answer-head { display: flex; justify-content: space-between; color: var(--muted); font-size: .88em; margin-bottom: 8px; }
.choices { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.choices button {
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
  padding: 12px; cursor: pointer; text-align: left;
}
.choices button:hover { border-color: var(--accent); }
.choices b { color: var(--accent2); margin-right: 6px; }

.buzz {
  width: 100%; margin-top: 4px; border: 0; border-radius: 16px; padding: 22px 12px; cursor: pointer;
  background: var(--accent); color: #fff; display: flex; flex-direction: column; align-items: center;
  box-shadow: 0 6px 0 #b8336f; transition: transform .05s, box-shadow .05s;
  touch-action: manipulation; user-select: none;
}
.buzz:active:not(:disabled) { transform: translateY(4px); box-shadow: 0 2px 0 #b8336f; }
.buzz:disabled { background: var(--panel2); color: var(--muted); box-shadow: 0 6px 0 #1a1622; cursor: default; }
.buzz-main { font-size: 1.6em; font-weight: 800; letter-spacing: .1em; }
.buzz-sub { font-size: .78em; opacity: .85; }
#giveupBtn { margin-top: 10px; }

.reveal h2 { font-size: 1.3em; margin-bottom: 4px; }
.reveal .meta { color: var(--muted); font-size: .92em; }
.reveal .top { display: flex; gap: 14px; align-items: center; }
.reveal img.thumb { width: 96px; border-radius: 8px; }
.reveal video { width: 100%; border-radius: 10px; margin-top: 10px; background: #000; }
.reveal .winner { margin: 12px 0 6px; font-weight: 700; }
.reveal .presses { font-size: .88em; color: var(--muted); }
.reveal .presses div { margin: 2px 0; }
.reveal .presses b { color: var(--text); }
.reveal a { color: var(--accent2); }

.scores h2 { margin-bottom: 8px; }
.scorelist { list-style: none; margin: 0 0 12px; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.scorelist li { display: flex; justify-content: space-between; padding: 6px 10px; border-radius: 8px; background: var(--panel2); }
.scorelist li.me { outline: 1px solid var(--accent); }
.scorelist li.off { opacity: .45; }
.scorelist .pt { font-weight: 700; font-variant-numeric: tabular-nums; }
.scorelist li.flash-ok { animation: flashok 1s; }
.scorelist li.flash-ng { animation: flashng 1s; }
@keyframes flashok { from { background: rgba(61, 220, 151, .45); } }
@keyframes flashng { from { background: rgba(255, 107, 107, .45); } }

.ranking { list-style: none; padding: 0; margin: 16px 0; display: flex; flex-direction: column; gap: 8px; }
.ranking li { background: var(--panel2); border-radius: 12px; padding: 12px 14px; display: flex; gap: 12px; align-items: center; }
.ranking .rk { font-size: 1.4em; width: 2em; text-align: center; }
.ranking .nm { flex: 1; font-weight: 700; }
.ranking .nm small { display: block; font-weight: 400; color: var(--muted); }
.ranking .pt { font-size: 1.2em; font-weight: 800; color: var(--accent2); }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  background: var(--panel2); border: 1px solid var(--accent); border-radius: 12px;
  padding: 10px 16px; max-width: calc(100% - 32px); z-index: 10;
}

@media (max-width: 800px) {
  .grid2, .grid-game { grid-template-columns: 1fr; }
  .scores { order: -1; padding: 10px 12px; }
  .scorelist { flex-direction: row; flex-wrap: wrap; }
  .scorelist li { gap: 8px; }
  .display { height: 200px; }
  .choices { grid-template-columns: 1fr; }
  .stages span { font-size: .7em; }
}

/* MC当て: 正解発表で、伏せる前の文 */
.mcquote { margin: 8px 0; padding: 6px 10px; border-left: 3px solid var(--accent, #e85a8a); font-size: .9em; opacity: .9; max-height: 8em; overflow: auto; }
