@font-face {
  font-family: 'Oswald';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url('./fonts/oswald-cyrillic-600-normal.woff2') format('woff2');
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: 'Oswald';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url('./fonts/oswald-latin-600-normal.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Oswald';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url('./fonts/oswald-cyrillic-700-normal.woff2') format('woff2');
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: 'Oswald';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url('./fonts/oswald-latin-700-normal.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  --bg1: #0b1024;
  --bg2: #151d3b;
  --ink: #f2f6ff;
  --muted: #93a2c4;
  --accent: #ff7a45;
  --accent-2: #ffb066;
  --teal: #2ee6d6;
  --green: #3ddc84;
  --card: #f4f7ff;
  --card-ink: #0d1430;
  --glass: rgba(12, 19, 40, 0.72);
  --line: rgba(255, 255, 255, 0.13);
  --p1: #ff7a45;
  --p2: #2ee6d6;
  --p3: #ffd166;
  --p4: #b28dff;
  --font: 'Oswald', 'Arial Narrow', system-ui, sans-serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; padding: 0; height: 100%;
  background: var(--bg1); color: var(--ink);
  font-family: var(--font); overflow: hidden;
  touch-action: manipulation; user-select: none; -webkit-user-select: none;
  overscroll-behavior: none;
}
body::before {
  content: ''; position: fixed; inset: 0; pointer-events: none; z-index: 0;
  background:
    radial-gradient(70% 45% at 50% 0%, rgba(64, 92, 200, 0.35), transparent 70%),
    radial-gradient(60% 45% at 100% 100%, rgba(255, 122, 69, 0.13), transparent 70%),
    repeating-linear-gradient(0deg, rgba(255,255,255,0.022) 0 1px, transparent 1px 44px),
    repeating-linear-gradient(90deg, rgba(255,255,255,0.022) 0 1px, transparent 1px 44px),
    linear-gradient(165deg, var(--bg1), var(--bg2) 62%, #080c1b);
}

#app {
  position: relative; z-index: 1; height: 100dvh; height: 100vh;
  display: flex; flex-direction: column;
  padding: calc(8px + env(safe-area-inset-top)) calc(12px + env(safe-area-inset-right)) calc(10px + env(safe-area-inset-bottom)) calc(12px + env(safe-area-inset-left));
}
.hide { display: none !important; }
button { font-family: var(--font); color: var(--ink); border: 0; background: none; cursor: pointer; }
button:active { transform: scale(0.97); }

/* ---------- верхняя панель ---------- */
.hud { display: flex; align-items: center; gap: 10px; min-height: 46px; }
.round { font-size: 12px; letter-spacing: 1.4px; color: var(--muted); white-space: nowrap; }
.round b { color: var(--ink); font-size: 16px; }
.round i { font-style: normal; color: rgba(255,255,255,.3); margin: 0 1px; }
.scorebar { flex: 1; display: flex; gap: 6px; justify-content: center; flex-wrap: nowrap; overflow: hidden; }
.chip {
  display: flex; align-items: baseline; gap: 6px; padding: 5px 10px; border-radius: 12px;
  background: rgba(255,255,255,0.06); border: 1px solid var(--line); min-width: 0;
  max-width: 34vw; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.chip .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--c, var(--accent)); box-shadow: 0 0 8px var(--c, var(--accent)); flex: 0 0 auto; align-self: center; }
.chip .nm { font-size: 12px; letter-spacing: .5px; color: #cfd9f2; overflow: hidden; text-overflow: ellipsis; }
.chip .sc { font-size: 18px; font-weight: 700; color: var(--c, #fff); }
.chip.me { border-color: var(--c, var(--accent)); box-shadow: 0 0 0 1px var(--c, var(--accent)), 0 6px 18px rgba(0,0,0,.25); }
.chip.lead { background: rgba(255,255,255,.12); }
.iconbtn {
  width: 36px; height: 36px; flex: 0 0 auto; border-radius: 10px; border: 1px solid var(--line);
  background: var(--glass); color: #dfe7ff; font-size: 14px;
}
.iconbtn.off { color: #55617d; }

/* ---------- экраны ---------- */
#main { flex: 1; display: flex; min-height: 0; }
.screen { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; min-height: 0; width: 100%; max-width: 640px; margin: 0 auto; }

.join .logo { display: flex; align-items: baseline; gap: 8px; }
.join .logo b {
  font-size: clamp(38px, 9vw, 58px); font-weight: 700; letter-spacing: 2px; line-height: 1;
  background: linear-gradient(180deg, #fff 15%, #ffc39b 65%, #ff7a45 100%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 6px 18px rgba(255, 110, 50, 0.35));
}
.join .logo em { font-style: normal; font-size: clamp(22px, 5vw, 34px); font-weight: 700; color: var(--teal); letter-spacing: 1px; }
.tag { margin: 0; color: #c6d2ec; font-size: 15px; letter-spacing: .6px; text-align: center; }
.field { width: min(360px, 88vw); display: block; }
.field span { display: block; font-size: 11px; letter-spacing: 1.6px; color: var(--muted); margin-bottom: 5px; }
input {
  width: 100%; height: 52px; border-radius: 14px; border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.3); color: var(--ink); font-family: var(--font);
  font-size: 20px; letter-spacing: .8px; padding: 0 14px; outline: none;
}
input:focus { border-color: rgba(255, 140, 80, .7); box-shadow: 0 0 0 3px rgba(255, 122, 69, .16); }
.primary {
  width: min(360px, 88vw); min-height: 58px; border-radius: 16px; margin-top: 4px;
  background: linear-gradient(180deg, #ff9a5e, #f05a1f); color: #1a0c04;
  font-size: 22px; font-weight: 700; letter-spacing: 1.6px;
  box-shadow: 0 10px 26px rgba(255, 90, 32, 0.32), inset 0 2px 0 rgba(255, 235, 220, 0.55);
}
.primary:disabled { opacity: .45; box-shadow: none; transform: none; }
.ghost {
  width: min(360px, 88vw); min-height: 40px; border-radius: 12px; margin-top: 2px;
  background: rgba(255,255,255,.05); border: 1px solid var(--line);
  color: #cfd9f2; font-size: 12px; letter-spacing: 1.2px;
}
.note { margin: 0; text-align: center; font-size: 12px; line-height: 1.55; color: var(--muted); letter-spacing: .3px; max-width: 92vw; }

h2 { margin: 0 0 4px; font-size: 24px; letter-spacing: 3px; color: var(--ink); font-weight: 700; }
.lobbyList { width: min(420px, 92vw); display: flex; flex-direction: column; gap: 8px; }
.lrow {
  display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-radius: 14px;
  background: rgba(255, 255, 255, 0.05); border: 1px solid var(--line);
}
.lrow .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--c); box-shadow: 0 0 10px var(--c); }
.lrow .nm { flex: 1; font-size: 17px; letter-spacing: .5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lrow .st { font-size: 11px; letter-spacing: 1.2px; color: var(--muted); }
.lrow.ready .st { color: var(--green); }
.lrow.me { border-color: rgba(255, 122, 69, .55); }
.lrow.empty .nm { color: rgba(200, 210, 235, .3); font-style: italic; }

/* ---------- игра ---------- */
.game {
  justify-content: center; gap: clamp(14px, 3.2vh, 34px);
  padding: 1vh 0 0;
}
.qwrap { width: 100%; display: flex; flex-direction: column; align-items: center; gap: 12px; }
.qline {
  display: flex; align-items: center; justify-content: center; gap: 4px;
  background: var(--card); color: var(--card-ink); border-radius: 24px;
  padding: 14px 20px; min-width: min(460px, 92vw); min-height: clamp(110px, 20vh, 170px);
  box-shadow: 0 22px 60px rgba(0, 0, 0, 0.45), inset 0 -4px 0 rgba(13, 20, 48, 0.08);
  transition: transform .18s ease, box-shadow .2s ease;
}
.qline.good { box-shadow: 0 0 0 4px var(--green), 0 22px 60px rgba(0,0,0,.45); transform: scale(1.02); }
.qline.bad { animation: shake .35s; box-shadow: 0 0 0 4px #ff5b5b, 0 22px 60px rgba(0,0,0,.45); }
@keyframes shake { 20% { transform: translateX(-9px); } 40% { transform: translateX(8px); } 60% { transform: translateX(-5px); } 80% { transform: translateX(3px); } }
.question { font-size: clamp(44px, 10vw, 84px); font-weight: 700; letter-spacing: 1px; white-space: nowrap; }
.answer {
  min-width: 1.1em; margin-left: 10px; padding-left: 14px; border-left: 4px dashed rgba(13, 20, 48, .14);
  font-size: clamp(44px, 10vw, 84px); font-weight: 700; color: var(--accent);
  text-align: center; line-height: 1;
}
.answer.empty { color: rgba(13, 20, 48, .22); }
.timer { width: min(460px, 92vw); height: 8px; border-radius: 6px; background: rgba(255, 255, 255, 0.1); overflow: hidden; }
.timer i { display: block; height: 100%; width: 100%; background: linear-gradient(90deg, var(--teal), var(--accent)); border-radius: 6px; }
@keyframes shrink { from { width: 100%; } to { width: 0%; } }

.confetti {
  position: fixed; top: -14px; width: 8px; height: 13px; z-index: 60; pointer-events: none;
  border-radius: 2px; animation: fall linear forwards;
}
@keyframes fall {
  to { transform: translateY(108vh) rotate(720deg); opacity: .85; }
}

.keypad {
  width: min(430px, 94vw); display: grid; grid-template-columns: repeat(3, 1fr); gap: 9px;
  margin: 0 auto;
}
.keypad button {
  height: clamp(52px, 9.4vh, 82px); border-radius: 16px; font-size: clamp(24px, 5vw, 32px); font-weight: 600;
  background: linear-gradient(180deg, rgba(255,255,255,.14), rgba(255,255,255,.055));
  border: 1px solid rgba(255, 255, 255, 0.18);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.25);
}
.keypad button:active { background: rgba(255,255,255,.22); }
.keypad button.key-ok {
  background: linear-gradient(180deg, #55ea95, #22b566); color: #06210f; font-weight: 700;
  border-color: rgba(120, 255, 180, .6); font-size: 22px; letter-spacing: 1px;
  box-shadow: 0 8px 22px rgba(40, 200, 110, .35), inset 0 2px 0 rgba(220, 255, 235, .5);
}
.keypad button.key-back { color: #ffb4a0; font-size: 22px; }
.keypad.locked { pointer-events: none; opacity: .38; }
.keypad.frozen { pointer-events: none; opacity: .55; }

.feedback {
  position: absolute; left: 50%; top: 17%; transform: translate(-50%, -50%);
  font-size: clamp(26px, 6.2vw, 44px); font-weight: 700; letter-spacing: 2px;
  pointer-events: none; opacity: 0; z-index: 6; text-align: center; white-space: nowrap;
  padding: 4px 18px; border-radius: 999px; background: rgba(8, 12, 26, 0.86);
  border: 1px solid rgba(255, 255, 255, 0.12);
}
.feedback.show { animation: fb 1.1s ease-out; }
.feedback.good { color: var(--green); text-shadow: 0 0 30px rgba(61, 220, 132, .6); }
.feedback.bad { color: #ff6b6b; text-shadow: 0 0 30px rgba(255, 80, 80, .5); }
@keyframes fb { 0% { opacity: 0; transform: translate(-50%, -50%) scale(.6); } 20% { opacity: 1; transform: translate(-50%, -50%) scale(1.05); } 70% { opacity: 1; } 100% { opacity: 0; transform: translate(-50%, -60%) scale(1); } }

.spectator {
  position: absolute; left: 50%; bottom: calc(150px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: rgba(10, 16, 32, .8); border: 1px solid var(--line); border-radius: 999px;
  padding: 8px 16px; font-size: 12px; letter-spacing: .6px; color: var(--muted); white-space: nowrap;
}

/* ---------- конец матча ---------- */
.over { gap: 8px; }
.overTitle { font-size: clamp(34px, 8vw, 54px); font-weight: 700; letter-spacing: 3px; color: var(--accent); text-align: center; text-shadow: 0 0 40px rgba(255, 110, 40, .45); }
.overTitle.lose { color: var(--teal); text-shadow: 0 0 40px rgba(46, 230, 214, .35); }
.overSub { color: var(--muted); font-size: 13px; letter-spacing: 1px; }
.overList { width: min(420px, 92vw); display: flex; flex-direction: column; gap: 7px; margin: 6px 0; }
.orow { display: flex; align-items: center; gap: 10px; padding: 9px 14px; border-radius: 12px; background: rgba(255,255,255,.05); border: 1px solid var(--line); }
.orow .pos { width: 22px; color: var(--muted); font-size: 13px; }
.orow .nm { flex: 1; font-size: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.orow .sc { font-size: 20px; font-weight: 700; color: var(--c, #fff); }
.orow.first { background: rgba(255, 122, 69, .16); border-color: rgba(255, 122, 69, .55); }

/* ---------- оверлеи ---------- */
.countdown {
  position: fixed; inset: 0; z-index: 30; display: flex; align-items: center; justify-content: center;
  background: rgba(6, 10, 22, .72); backdrop-filter: blur(6px);
}
.countdown span {
  font-size: clamp(110px, 30vw, 220px); font-weight: 700; color: var(--accent);
  text-shadow: 0 0 60px rgba(255, 120, 50, .6); animation: pop .9s ease-out;
}
@keyframes pop { 0% { transform: scale(.3); opacity: 0; } 30% { transform: scale(1.15); opacity: 1; } 100% { transform: scale(1); } }

.toast {
  position: fixed; left: 50%; top: calc(14px + env(safe-area-inset-top)); transform: translateX(-50%);
  z-index: 40; background: rgba(120, 24, 24, .94); border: 1px solid rgba(255, 130, 130, .5);
  color: #ffe1e1; padding: 10px 18px; border-radius: 12px; font-size: 13px; letter-spacing: .5px;
  max-width: 90vw; text-align: center;
}

/* ---------- ландшафт ---------- */
@media (orientation: landscape) and (min-width: 720px) {
  .game {
    display: grid; grid-template-columns: 1.1fr 0.9fr; align-items: center; gap: 18px;
    width: 100%; max-width: 1100px; justify-content: stretch;
  }
  .qwrap { height: 100%; justify-content: center; }
  .keypad { width: min(400px, 42vw); margin: 0; }
  .keypad button { height: clamp(46px, 9.5vh, 66px); }
  .question, .answer { font-size: clamp(40px, 6.2vw, 76px); }
  .qline { min-height: clamp(96px, 22vh, 150px); }
  .spectator { bottom: 24px; }
}

@media (orientation: landscape) and (max-height: 430px) {
  .question, .answer { font-size: clamp(36px, 7vh, 58px); }
  .qline { min-height: 84px; padding: 8px 18px; }
  .keypad button { height: clamp(38px, 9.6vh, 52px); font-size: 20px; border-radius: 12px; }
  .keypad button.key-ok { font-size: 16px; }
  .hud { min-height: 38px; }
  .chip .nm { font-size: 10px; }
  .chip .sc { font-size: 15px; }
  .join .logo b { font-size: 34px; }
  .join .tag { font-size: 12px; }
  .field { display: flex; align-items: center; gap: 10px; width: min(460px, 92vw); }
  .field span { display: none; }
  input { height: 44px; font-size: 17px; }
  .primary { min-height: 46px; font-size: 18px; width: min(460px, 92vw); }
  .note { font-size: 10px; }
  h2 { font-size: 18px; }
  .lrow { padding: 7px 12px; }
  .lrow .nm { font-size: 14px; }
  .overList { gap: 5px; }
  .orow { padding: 6px 12px; }
  .orow .nm { font-size: 14px; }
  .orow .sc { font-size: 16px; }
  .overTitle { font-size: 30px; }
}
