/* Всё в rem — масштабируется под любой экран 16:9 (ТВ, ноутбук, iPhone горизонтально) */
html { font-size: min(1.5vw, 2.67vh); }
body { overflow: hidden; }
#app { height: 100vh; height: 100dvh; position: relative; }
.scene { position: absolute; inset: 0; padding: 2rem 2.6rem; display: none; }
.scene.active { display: flex; }
.scene.center { flex-direction: column; align-items: center; justify-content: center; text-align: center; }
.small { font-size: 1rem; padding: 0.5em 1em; }

/* Старт */
.start { position: fixed; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2rem; text-align: center; z-index: 50; }
.logo { font-size: 4.5rem; font-weight: 900; }
.btn.big { font-size: 2.4rem; padding: 0.6em 1.6em; }
.hint { color: var(--muted); font-size: 1.2rem; line-height: 1.5; }

/* Лобби */
#lobby { gap: 2.5rem; }
.lobby-left { flex: 0 0 34%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1.4rem; }
.lobby-title { font-size: 2.4rem; font-weight: 900; text-align: center; line-height: 1.15; }
.qr-card { background: #fff; color: #1b1340; border-radius: 1.6rem; padding: 1.4rem; text-align: center; width: 100%; box-shadow: 0 1.2rem 3rem rgba(0,0,0,0.3); }
.qr-card img { width: 100%; aspect-ratio: 1; display: block; }
.join-url { font-size: 1.35rem; font-weight: 800; margin-top: 0.6rem; word-break: break-all; }
.code { font-size: 1.3rem; color: #5b4f8a; }
.code b { font-size: 2.2rem; letter-spacing: 0.15em; color: #1b1340; }
.lobby-right { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.lobby-head h2 { font-size: 2.2rem; margin: 0 0 1rem; }
.lobby-head span { color: var(--muted); font-size: 1.6rem; }
.lobby-players { display: grid; grid-template-columns: repeat(5, 1fr); gap: 1rem; align-content: start; flex: 1; }
.lp { display: flex; flex-direction: column; align-items: center; gap: 0.4rem; cursor: pointer; }
.lp .avatar { width: 5.2rem; font-size: 3rem; }
.lp .nm { font-size: 1.15rem; font-weight: 800; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lp.off { opacity: 0.35; }
.lobby-empty { flex: 1; display: flex; align-items: center; justify-content: center; font-size: 2rem; color: var(--muted); animation: pulse 2s infinite; }
.lobby-ctl { display: flex; flex-wrap: wrap; align-items: center; gap: 1rem; font-size: 1.2rem; padding-top: 1rem; }
.lobby-ctl #startGame { margin-left: auto; font-size: 1.7rem; }
.sel select { font: inherit; font-size: 1.1rem; padding: 0.35em 0.5em; border-radius: 10px; border: 0; max-width: 16rem; }
.toggle { display: flex; align-items: center; gap: 0.4rem; background: var(--panel); padding: 0.45em 0.8em; border-radius: 12px; cursor: pointer; }
.toggle input { width: 1.2rem; height: 1.2rem; }
.voice-info { color: var(--muted); font-size: 0.95rem; margin-top: 0.6rem; min-height: 1.2em; }

/* Раунд */
.round-num { font-size: 2rem; color: var(--accent); font-weight: 900; text-transform: uppercase; letter-spacing: 0.2em; }
.round-title { font-size: 5rem; font-weight: 900; margin: 1rem 0; line-height: 1.1; }
.round-desc { font-size: 2rem; color: var(--muted); max-width: 70%; }

/* Вопрос */
#question { flex-direction: column; gap: 1.1rem; }
.q-head { display: flex; align-items: center; gap: 1.2rem; font-size: 1.25rem; font-weight: 800; }
.q-progress { background: var(--panel-strong); padding: 0.3em 0.9em; border-radius: 99px; }
.q-round { color: var(--muted); }
.q-join { margin-left: auto; color: var(--muted); }
.q-text { background: #fff; color: #1b1340; border-radius: var(--radius); padding: 1rem 1.6rem; font-size: 2.4rem; font-weight: 900; text-align: center; line-height: 1.2; box-shadow: 0 0.6rem 0 rgba(0,0,0,0.15); }
#question.text-only .q-text { font-size: 3.4rem; padding: 2rem; }
.q-middle { flex: 1; display: flex; align-items: center; gap: 1.5rem; min-height: 0; }
.q-side { flex: 0 0 9rem; display: flex; justify-content: center; }
.q-media { flex: 1; height: 100%; display: flex; align-items: center; justify-content: center; position: relative; min-height: 0; }
.q-media img, .q-media video { max-width: 100%; max-height: 100%; border-radius: var(--radius); box-shadow: 0 1rem 2.5rem rgba(0,0,0,0.35); background: #000; }
#soundFix { position: absolute; font-size: 1.6rem; }
.timer { width: 8.5rem; height: 8.5rem; position: relative; }
.timer svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.timer circle { fill: none; stroke-width: 9; }
.timer .track { stroke: rgba(255,255,255,0.15); }
.timer .bar { stroke: var(--accent); stroke-linecap: round; stroke-dasharray: 276.5; transition: stroke 0.3s; }
.timer.low .bar { stroke: var(--bad); }
.timer span { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 3.2rem; font-weight: 900; }
.timer.low span { animation: pulse 0.5s infinite; }
.answered { display: flex; flex-direction: column; align-items: center; background: var(--panel); border-radius: var(--radius); padding: 0.8rem 1.2rem; }
.answered b { font-size: 3.4rem; line-height: 1; }
.answered span { font-size: 1.1rem; color: var(--muted); }
.answers { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.answers:empty { display: none; }
.ans { display: flex; align-items: center; gap: 1rem; border-radius: var(--radius); padding: 1rem 1.4rem; font-size: 2rem; font-weight: 900; min-height: 5.4rem; position: relative; overflow: hidden; box-shadow: 0 0.4rem 0 rgba(0,0,0,0.2); transition: opacity 0.4s, transform 0.4s; }
.ans .shape { font-size: 2.2rem; opacity: 0.9; flex: 0 0 auto; }
.ans .txt { flex: 1; line-height: 1.15; }
.ans .cnt { font-size: 1.6rem; background: rgba(0,0,0,0.25); border-radius: 99px; padding: 0.15em 0.7em; display: none; }
.ans .fill { position: absolute; left: 0; bottom: 0; height: 0.45rem; background: rgba(255,255,255,0.75); width: 0; transition: width 0.8s ease; }
.answers.revealed .ans .cnt { display: block; }
.answers.revealed .ans.wrong { opacity: 0.28; transform: scale(0.97); }
.answers.revealed .ans.right { transform: scale(1.03); outline: 0.35rem solid #fff; }
.answers.revealed .ans.right .txt::after { content: ' ✔'; }
.q-note { background: var(--panel-strong); border-radius: var(--radius); padding: 0.7rem 1.2rem; font-size: 1.5rem; text-align: center; }
/* Вопрос с картинкой/видео: всё компактнее, ответы в одну строку — медиа получает максимум места */
#question.has-media { gap: 0.8rem; padding-top: 1.4rem; padding-bottom: 1.2rem; }
#question.has-media .q-text { font-size: 2rem; padding: 0.6rem 1.4rem; }
#question.has-media .answers { grid-template-columns: repeat(var(--n, 4), 1fr); gap: 0.8rem; }
#question.has-media .ans { font-size: 1.6rem; min-height: 4.4rem; padding: 0.7rem 1rem; gap: 0.6rem; }
#question.has-media .ans .shape { font-size: 1.6rem; }
#question.has-media .answered-avatars { min-height: 2.6rem; }
#question.has-media .answered-avatars .avatar { width: 2.6rem; font-size: 1.5rem; }
#question.has-media .q-note { font-size: 1.25rem; padding: 0.5rem 1rem; }
.answered-avatars { display: flex; gap: 0.4rem; justify-content: center; min-height: 3rem; flex-wrap: wrap; }
.answered-avatars .avatar { width: 3rem; font-size: 1.7rem; }
.answered-avatars .who { display: flex; align-items: center; gap: 0.3rem; background: var(--panel); border-radius: 99px; padding: 0.15rem 0.8rem 0.15rem 0.15rem; font-weight: 800; font-size: 1.15rem; }

/* Таблица лидеров */
#leaderboard, #podium { flex-direction: column; align-items: center; }
.lb-title { font-size: 3rem; margin: 0 0 1.4rem; }
#podium .lb-title { margin-bottom: 0.4rem; }
.lb-list { width: 100%; display: grid; grid-auto-flow: column; grid-template-rows: repeat(10, auto); grid-template-columns: 1fr; column-gap: 1.6rem; row-gap: 0.55rem; }
.lb-list.two { grid-template-columns: 1fr 1fr; }
.lb-row { display: flex; align-items: center; gap: 0.9rem; background: var(--panel); border-radius: 14px; padding: 0.35rem 1rem 0.35rem 0.5rem; font-size: 1.5rem; font-weight: 800; }
.lb-row.top1 { background: rgba(255, 194, 51, 0.32); }
.lb-row .pl { width: 2.4rem; text-align: center; color: var(--muted); }
.lb-row .avatar { width: 2.9rem; font-size: 1.7rem; }
.lb-row .nm { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-row .mv { font-size: 1.1rem; width: 2.6rem; text-align: center; }
.lb-row .mv.up { color: var(--good); }
.lb-row .mv.down { color: var(--bad); }
.lb-row .delta { color: var(--good); font-size: 1.15rem; min-width: 4.5rem; text-align: right; }
.lb-row .sc { min-width: 5rem; text-align: right; }

/* Пьедестал */
.podium { display: flex; align-items: flex-end; justify-content: center; gap: 1.6rem; flex: 1; width: 100%; min-height: 0; }
.pd { display: flex; flex-direction: column; align-items: center; width: 15rem; }
.pd .avatar { width: 6rem; font-size: 3.6rem; margin-bottom: 0.4rem; }
.pd .nm { font-size: 1.8rem; font-weight: 900; text-align: center; }
.pd .sc { font-size: 1.3rem; color: var(--muted); margin-bottom: 0.5rem; }
.pd .block { width: 100%; border-radius: 1rem 1rem 0 0; display: flex; justify-content: center; padding-top: 0.6rem; font-size: 4rem; font-weight: 900; animation: rise 0.9s ease both; }
.pd.p1 .block { height: 11rem; background: linear-gradient(#ffd45c, #e3a400); }
.pd.p2 .block { height: 7.5rem; background: linear-gradient(#e6e9f0, #a9b0c2); color: #3a3f55; }
.pd.p3 .block { height: 5rem; background: linear-gradient(#ffb27a, #c86a2c); }
.pd.p1 { animation-delay: 1.2s; }
.pd.p1 .avatar { animation: pulse 1.2s 2s infinite; }
.podium-rest { display: flex; flex-wrap: wrap; justify-content: center; gap: 0.6rem; margin-top: 1.2rem; font-size: 1.15rem; }
.podium-rest .who { display: flex; align-items: center; gap: 0.4rem; background: var(--panel); border-radius: 99px; padding: 0.2rem 0.9rem 0.2rem 0.2rem; font-weight: 800; }
.podium-rest .avatar { width: 2.4rem; font-size: 1.4rem; }

.wait-host { position: absolute; top: 0.5rem; left: 50%; transform: translateX(-50%); color: var(--muted); font-size: 1rem; background: rgba(0,0,0,0.2); padding: 0.2em 0.9em; border-radius: 99px; }

/* Скрывающаяся панель управления */
.ctl { position: absolute; right: 1rem; bottom: 1rem; display: flex; gap: 0.5rem; opacity: 0; transition: opacity 0.3s; z-index: 20; }
.ctl.show { opacity: 1; }
#lobby.active ~ .ctl #ctlLobby { display: none; }

.modal { position: fixed; inset: 0; background: rgba(10, 5, 30, 0.75); display: flex; align-items: center; justify-content: center; z-index: 60; }
.modal-card { background: #fff; color: #1b1340; border-radius: 1.6rem; padding: 2rem; width: 30rem; text-align: center; }
.modal-card h2 { margin: 0 0 0.5rem; font-size: 2rem; }
.modal-card p { font-size: 1.15rem; }
.modal-card img { width: 16rem; display: block; margin: 0 auto 1.2rem; }
