/* Ev Quiz phone controller. Designed at 375px, touch targets >= 44px. */
:root {
  --bg: #0D1219; --card: #151C26; --line: #232D3A; --text: #E3EAF2; --muted: #8592A3; --track: #1C2531;
  --bad: #FF8E7E; --bad-bg: #3A2023; --sage: #A7BCBB; --amber: #E3A55E;
  --head: "Space Grotesk", "Segoe UI", system-ui, sans-serif;
  --body: Inter, "Segoe UI", system-ui, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, Consolas, monospace;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body { font-family: var(--body); -webkit-font-smoothing: antialiased; overscroll-behavior: none; }
#app { max-width: 520px; margin: 0 auto; min-height: 100vh; min-height: 100dvh; padding: max(20px, env(safe-area-inset-top)) 20px max(20px, env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 18px; }
button { font: inherit; color: inherit; cursor: pointer; touch-action: manipulation; }
button:disabled { cursor: default; }
.label { font-family: var(--mono); font-weight: 500; font-size: 14px; letter-spacing: 1.5px; color: var(--muted); }
h1 { margin: 0; font-family: var(--head); font-weight: 600; font-size: 34px; line-height: 1.08; }
.muted { color: var(--muted); }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; }
.avatar { border-radius: 50%; display: flex; align-items: center; justify-content: center; font-family: var(--head); font-weight: 700; flex: none; width: 44px; height: 44px; font-size: 22px; }
.avatar.sm { width: 32px; height: 32px; font-size: 16px; }

.field { width: 100%; height: 58px; border-radius: 14px; border: 1px solid var(--line); background: var(--card); color: var(--text); font: 600 22px var(--body); padding: 0 18px; outline: none; }
.field:focus { border-color: var(--sage); }
.field.code { font-family: var(--head); font-weight: 700; font-size: 34px; letter-spacing: 10px; text-align: center; }
.btn { min-height: 56px; border-radius: 14px; border: 1px solid var(--line); background: var(--card); font-weight: 600; font-size: 19px; padding: 0 20px; display: flex; align-items: center; justify-content: center; gap: 10px; }
.btn.primary { background: var(--text); color: var(--bg); border-color: var(--text); }
.btn.ghost { background: transparent; min-height: 44px; font-size: 16px; color: var(--muted); }
.btn.danger { border-color: var(--bad); color: var(--bad); background: var(--bad-bg); }
.btn:active:not(:disabled) { transform: scale(.98); }
.err { color: var(--bad); font-size: 16px; min-height: 22px; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.grow { flex-grow: 1; }
.center-msg { flex-grow: 1; display: flex; flex-direction: column; justify-content: center; gap: 14px; }

/* header */
.top { display: flex; align-items: center; gap: 12px; min-height: 44px; }
.top .nm { font-size: 18px; font-weight: 600; flex-grow: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top .tag { font-family: var(--mono); font-size: 13px; letter-spacing: 1px; color: var(--muted); white-space: nowrap; }
.top .exit { min-width: 44px; min-height: 44px; border-radius: 12px; border: 1px solid var(--line); background: transparent; color: var(--muted); font-size: 15px; padding: 0 12px; }
.confirm { display: flex; gap: 10px; align-items: center; padding: 12px 14px; }
.confirm .q { flex-grow: 1; font-size: 15px; }
.confirm .btn { min-height: 44px; font-size: 15px; padding: 0 14px; }

.view { flex-grow: 1; display: flex; flex-direction: column; gap: 16px; min-height: 0; }
.view.fresh { animation: rise .35s ease backwards; }

/* lobby */
.modebtn { text-align: left; padding: 20px; display: flex; flex-direction: column; gap: 6px; border-radius: 16px; min-height: 110px; }
.modebtn .mt { font-family: var(--head); font-weight: 700; font-size: 30px; }
.modebtn .md { font-size: 15px; color: #C5CFDB; line-height: 1.4; font-weight: 400; }
.modebtn.quiz .mt { color: var(--sage); } .modebtn.pick .mt { color: var(--amber); }
.players { display: flex; flex-wrap: wrap; gap: 10px; }
.pchip { display: flex; align-items: center; gap: 8px; padding: 6px 12px 6px 6px; border-radius: 999px; background: var(--card); border: 1px solid var(--line); font-size: 15px; font-weight: 600; }
.pchip.off { opacity: .45; }
.foot { display: flex; gap: 8px; flex-wrap: wrap; justify-content: space-between; align-items: center; }
.source { font-size: 12px; color: var(--muted); min-height: 44px; display: flex; align-items: center; text-decoration: underline; text-underline-offset: 3px; }

/* choose tiles */
.ctiles { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.ctile { position: relative; overflow: hidden; height: 84px; border-radius: 14px; border: 1px solid var(--line); background: var(--card); padding: 10px 12px; display: flex; align-items: flex-end; text-align: left; animation: rise .35s ease backwards; }
.ctile img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.ctile::after { content: ""; position: absolute; inset: 0; background: linear-gradient(0deg, rgba(13,18,25,.95) 0%, rgba(13,18,25,.55) 55%, rgba(13,18,25,.15) 100%); }
.ctile span { position: relative; z-index: 1; font-family: var(--head); font-weight: 600; font-size: 17px; line-height: 1.15; }
.ctile.busy { opacity: .5; }

/* timer */
.timer { display: flex; align-items: center; gap: 14px; }
.bar { flex-grow: 1; height: 10px; border-radius: 5px; background: var(--track); position: relative; overflow: hidden; }
.bar .fill, .bar .warn { position: absolute; inset: 0; border-radius: 5px; transform-origin: 0 50%; }
.bar .fill { background: var(--text); }
.bar .warn { background: var(--bad); opacity: 0; }
.timer .secs { width: 30px; text-align: right; font-family: var(--head); font-weight: 700; font-size: 26px; }
.bar.urgent + .secs { color: var(--bad); }
.qsmall { font-size: 15px; line-height: 1.4; color: var(--muted); }

/* answers */
.answers { flex-grow: 1; display: flex; flex-direction: column; gap: 12px; min-height: 300px; }
.ans { flex: 1 1 0; min-height: 64px; display: flex; align-items: center; gap: 14px; text-align: left; padding: 10px 18px; border-radius: 14px; border: 1px solid var(--line); background: var(--card); transition: opacity .25s, transform .25s, background-color .25s, border-color .25s; }
.ans .k { font-family: var(--mono); font-size: 17px; color: var(--muted); flex: none; width: 18px; }
.ans .t { font-size: 22px; font-weight: 600; line-height: 1.2; overflow-wrap: anywhere; }
.answers.long .ans .t { font-size: 18px; }
.answers.wait .ans { opacity: .35; }
.answers.open .ans { animation: rise .3s ease backwards; }
.answers.open .ans:nth-child(2) { animation-delay: .06s; } .answers.open .ans:nth-child(3) { animation-delay: .12s; } .answers.open .ans:nth-child(4) { animation-delay: .18s; }
.ans.mine { border-color: var(--text); background: #1F2834; }
.answers.done .ans:not(.mine) { opacity: .4; }
.ans.correct { background: var(--text); color: var(--bg); border-color: var(--text); opacity: 1 !important; }
.ans.correct .k { color: var(--bg); }
.ans.wrong { background: var(--bad-bg); border-color: var(--bad); opacity: 1 !important; }
.verdict { font-family: var(--head); font-weight: 700; font-size: 34px; display: flex; align-items: baseline; gap: 12px; animation: pop .45s cubic-bezier(.2,.9,.3,1.5) backwards; }
.verdict .pts { font-size: 26px; }

/* secmece */
.votes { flex-grow: 1; display: flex; flex-direction: column; gap: 12px; min-height: 300px; }
.vbtn { flex: 1 1 0; min-height: 96px; position: relative; overflow: hidden; border-radius: 16px; border: 2px solid var(--line); background: var(--card); display: flex; align-items: flex-end; padding: 16px 18px; text-align: left; transition: opacity .3s, transform .3s, border-color .3s; }
.vbtn img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.vbtn.cover img { opacity: .3; }
.vbtn::after { content: ""; position: absolute; inset: 0; background: linear-gradient(0deg, rgba(21,28,38,.96) 0%, rgba(21,28,38,.5) 50%, rgba(21,28,38,0) 100%); }
.vbtn .t { position: relative; z-index: 1; font-family: var(--head); font-weight: 700; font-size: 28px; line-height: 1.1; }
.vbtn.noimg { align-items: center; justify-content: center; text-align: center; }
.vbtn.noimg::after { display: none; }
.vbtn.a { animation: fromLeft .45s ease backwards; } .vbtn.b { animation: fromRight .45s ease backwards; }
.vbtn .who { position: absolute; z-index: 1; right: 12px; top: 12px; display: flex; gap: 6px; }
.votes.done .vbtn:not(.mine) { opacity: .4; }
.vbtn.mine { border-color: var(--text); }
.vbtn.win { border-color: var(--text); }
.vbtn.lose { opacity: .3; transform: scale(.97); }
.big-num { font-family: var(--head); font-weight: 700; font-size: 64px; line-height: 1; }
.champ-name { font-family: var(--head); font-weight: 700; font-size: 44px; line-height: 1.05; color: var(--amber); animation: pop .6s cubic-bezier(.2,.9,.3,1.4) backwards; overflow-wrap: anywhere; }
.champ-img { width: 100%; aspect-ratio: 3 / 2; border-radius: 16px; overflow: hidden; border: 2px solid var(--amber); }
.champ-img img { width: 100%; height: 100%; object-fit: cover; display: block; }
.rows { display: flex; flex-direction: column; gap: 8px; }
.srow { display: flex; align-items: center; gap: 12px; padding: 10px 14px; }
.srow .n { flex-grow: 1; font-weight: 600; font-size: 17px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.srow .s { font-family: var(--head); font-weight: 700; font-size: 24px; }

.net { position: fixed; left: 50%; bottom: 16px; transform: translateX(-50%) translateY(80px); background: var(--bad-bg); border: 1px solid var(--bad); color: var(--bad); border-radius: 12px; padding: 10px 14px; font-size: 14px; transition: transform .3s; z-index: 10; white-space: nowrap; }
.net.on { transform: translateX(-50%) translateY(0); }

@keyframes rise { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
@keyframes pop { 0% { transform: scale(.7); opacity: 0; } 60% { transform: scale(1.08); opacity: 1; } 100% { transform: scale(1); } }
@keyframes fromLeft { from { opacity: 0; transform: translateX(-60px); } to { opacity: 1; transform: none; } }
@keyframes fromRight { from { opacity: 0; transform: translateX(60px); } to { opacity: 1; transform: none; } }
@keyframes shake { 0%, 100% { transform: none; } 25% { transform: translateX(-8px); } 50% { transform: translateX(6px); } 75% { transform: translateX(-3px); } }
.shake { animation: shake .45s ease; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; }
  *:not(.fill):not(.warn) { transition: none !important; }
}
