:root {
  --bg: #161b27; --bg2: #1f2634; --card: #262f40; --line: rgba(255,255,255,.08);
  --text: #f1eee6; --muted: #9aa3b5; --amber: #f2a541; --green: #4e9b45; --red: #e15b4d;
  --tg-top: 0px; --tg-bottom: 0px;
  --sat: max(env(safe-area-inset-top, 0px), var(--tg-top)); --sab: max(env(safe-area-inset-bottom, 0px), var(--tg-bottom));
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font-family: 'Rubik', system-ui, sans-serif; overflow: hidden; overscroll-behavior: none; }
body { position: fixed; inset: 0; user-select: none; -webkit-user-select: none; }
.hidden { display: none !important; }
.scr { position: absolute; inset: 0; display: flex; flex-direction: column; }
#scr-home { overflow-y: auto; padding: calc(12px + var(--sat)) 16px calc(24px + var(--sab)); background: radial-gradient(120% 60% at 50% -10%, #2a3550 0%, var(--bg) 60%); }
.muted { color: var(--muted); font-size: 14px; }

/* шапка */
.hdr { display: flex; align-items: center; gap: 12px; padding: 6px 0 14px; }
.hdr-mid { flex: 1; min-width: 0; }
.nm { font-weight: 700; font-size: 17px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sub { color: var(--muted); font-size: 13px; margin-top: 2px; }
.ava-frame { flex: none; padding: 3px; border-radius: 50%; background: conic-gradient(from 200deg, #f2a541, #b56a1c, #f2a541, #8f5216, #f2a541); box-shadow: 0 4px 14px rgba(0,0,0,.4); }
.ava { width: 46px; height: 46px; border-radius: 50%; overflow: hidden; flex: none; background: #4a5568; display: flex; align-items: center; justify-content: center; font-family: 'Russo One', sans-serif; font-size: 19px; color: #fff; border: 2px solid #1a120c; }
.ava img { width: 100%; height: 100%; object-fit: cover; display: block; }
.elo-chip { padding: 6px 12px; border-radius: 999px; background: rgba(242,165,65,.14); border: 1px solid rgba(242,165,65,.5); color: var(--amber); font-family: 'Russo One', sans-serif; font-size: 15px; }

/* герой */
.hero { display: flex; align-items: center; gap: 14px; padding: 10px 6px 18px; }
.hero-bottle { width: 64px; height: 170px; flex: none; filter: drop-shadow(0 8px 12px rgba(0,0,0,.45)); transform: rotate(-12deg); }
.hero-t { flex: 1; }
.logo { font-family: 'Russo One', sans-serif; font-size: 44px; line-height: 1; letter-spacing: 1px; color: #f4d35e; text-shadow: 3px 3px 0 #1a120c, 0 10px 24px rgba(0,0,0,.5); }
.tag { margin-top: 8px; font-size: 16px; font-weight: 500; }
.tag2 { color: var(--muted); font-size: 13px; margin-top: 3px; }

/* кнопки */
.btns { display: flex; flex-direction: column; gap: 10px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.btn { display: flex; align-items: center; gap: 12px; width: 100%; padding: 14px 16px; border: 0; border-radius: 16px; background: var(--card); color: var(--text); font: inherit; text-align: left; cursor: pointer; box-shadow: 0 2px 0 rgba(0,0,0,.35), inset 0 1px 0 rgba(255,255,255,.06); transition: transform .08s; }
.btn:active { transform: translateY(2px); box-shadow: none; }
.btn .bi { font-size: 26px; flex: none; }
.btn b { display: block; font-size: 16px; }
.btn small { display: block; color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.btn.big { background: linear-gradient(180deg, #f6b552, #d98a22); color: #1a120c; box-shadow: 0 4px 0 #8f5216, 0 10px 20px rgba(0,0,0,.35); padding: 16px 18px; justify-content: center; }
.btn.big small { color: rgba(26,18,12,.7); }
.btn.big b { font-family: 'Russo One', sans-serif; font-size: 20px; letter-spacing: .5px; }
.btn.ghost { background: transparent; border: 1px solid var(--line); box-shadow: none; justify-content: center; color: var(--muted); }
.btn[disabled] { opacity: .5; pointer-events: none; }

/* вкладки: строго над содержимым, высота постоянная */
.tabs { display: flex; gap: 6px; margin: 20px 0 10px; padding: 4px; border-radius: 14px; background: var(--bg2); }
.tab { flex: 1; border: 0; background: transparent; color: var(--muted); font: inherit; font-weight: 500; padding: 9px 0; border-radius: 10px; cursor: pointer; }
.tab.on { background: var(--card); color: var(--text); }
.tabc { display: none; }
.tabc.on { display: block; }
.how { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.how li { display: flex; gap: 10px; padding: 10px 12px; background: var(--bg2); border-radius: 12px; font-size: 14px; line-height: 1.35; }
.how .hi { flex: none; font-size: 18px; }

.list { display: flex; flex-direction: column; gap: 6px; }
.rowi { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 12px; background: var(--bg2); }
.rowi.me { outline: 1px solid rgba(242,165,65,.55); }
.rowi .place { width: 26px; text-align: center; font-family: 'Russo One', sans-serif; color: var(--muted); font-size: 14px; }
.rowi .ava { width: 36px; height: 36px; font-size: 15px; }
.rowi .rn { flex: 1; min-width: 0; }
.rowi .rn b { display: block; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rowi .rn small { color: var(--muted); font-size: 12px; }
.rowi .re { font-family: 'Russo One', sans-serif; color: var(--amber); }
.rowi .re.win { color: var(--green); } .rowi .re.lose { color: var(--red); }

.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 14px; }
.stat { background: var(--bg2); border-radius: 12px; padding: 10px 12px; }
.stat b { display: block; font-family: 'Russo One', sans-serif; font-size: 20px; color: var(--amber); }
.stat span { color: var(--muted); font-size: 12px; }
h4 { margin: 12px 0 8px; font-weight: 500; color: var(--muted); font-size: 13px; text-transform: uppercase; letter-spacing: .5px; }

/* ожидание */
#scr-wait { align-items: center; justify-content: center; padding: calc(20px + var(--sat)) 20px calc(20px + var(--sab)); background: radial-gradient(120% 60% at 50% -10%, #2a3550 0%, var(--bg) 60%); }
.wait-box { width: 100%; max-width: 360px; display: flex; flex-direction: column; align-items: center; gap: 12px; text-align: center; }
.spin { width: 84px; height: 84px; border-radius: 50%; border: 4px solid rgba(255,255,255,.08); border-top-color: var(--amber); animation: spin 1s linear infinite; display: flex; align-items: center; justify-content: center; margin-bottom: 6px; }
.spin-b { width: 36px; height: 36px; border-radius: 8px 8px 12px 12px; background: var(--green); border: 3px solid #1a120c; }
@keyframes spin { to { transform: rotate(360deg); } }
.wait-t { font-family: 'Russo One', sans-serif; font-size: 22px; }
.wait-s { color: var(--muted); font-size: 14px; margin-bottom: 8px; }

/* бой */
#scr-game { background: #141a2a; }
#gl { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
.hud { position: absolute; inset: 0; pointer-events: none; }
.bars { position: absolute; left: 10px; right: 10px; top: calc(10px + var(--sat)); display: flex; align-items: center; gap: 6px; }
.bar { flex: 1; min-width: 0; display: flex; align-items: center; gap: 7px; padding: 6px 8px; border-radius: 14px; background: rgba(12,16,26,.62); border: 1px solid rgba(255,255,255,.08); }
.bar .ava { width: 34px; height: 34px; font-size: 14px; }
.bar-mid { flex: 1; min-width: 0; }
.bar-nm { display: flex; justify-content: space-between; align-items: center; gap: 6px; font-size: 12px; font-weight: 500; margin-bottom: 4px; white-space: nowrap; overflow: hidden; }
.bar-nm > span:not(.bottles) { overflow: hidden; text-overflow: ellipsis; }
.bar.opp .bar-nm { text-align: right; }
.hp { position: relative; height: 11px; border-radius: 999px; background: rgba(0,0,0,.45); overflow: hidden; border: 1px solid rgba(255,255,255,.1); }
.hp-f, .hp-d { position: absolute; left: 0; top: 0; bottom: 0; width: 100%; border-radius: 999px; transform-origin: left; }
.hp.rtl .hp-f, .hp.rtl .hp-d { transform-origin: right; }
.hp-f { background: linear-gradient(180deg, #ff7b6b, #d8433a); transition: transform .25s ease-out; z-index: 2; }
.hp-f.me { background: linear-gradient(180deg, #7ed36e, #3f8f38); }
.hp-d { background: rgba(255,255,255,.55); transition: transform .9s ease-out .25s; z-index: 1; }
.bottles { display: flex; gap: 2px; flex: none; }
.bottles i { display: block; width: 7px; height: 15px; border-radius: 2px 2px 3px 3px; background: #4e9b45; border: 1.5px solid #1a120c; position: relative; margin-top: 4px; }
.bottles i::before { content: ''; position: absolute; left: 0.5px; right: 0.5px; top: -5px; height: 5px; background: #4e9b45; border: 1.5px solid #1a120c; border-bottom: 0; border-radius: 2px 2px 0 0; }
.bottles i.vodka, .bottles i.vodka::before { background: #bfe3ee; }
.bottles i.champ, .bottles i.champ::before { background: #2f6f4e; }
.timer { flex: none; font-family: 'Russo One', sans-serif; font-size: 18px; padding: 6px 10px; border-radius: 12px; background: rgba(12,16,26,.62); border: 1px solid rgba(255,255,255,.08); min-width: 58px; text-align: center; }
.timer small { display: block; font-family: 'Rubik', sans-serif; font-size: 9px; color: var(--muted); line-height: 1; margin-top: 1px; min-height: 9px; }
.timer small.bad { color: var(--red); }
#timer.low { color: var(--red); }
.center-msg { position: absolute; left: 0; right: 0; top: 38%; text-align: center; font-family: 'Russo One', sans-serif; font-size: 64px; color: #f4d35e; text-shadow: 4px 4px 0 #1a120c, 0 12px 30px rgba(0,0,0,.6); opacity: 0; transform: scale(.6); }
.center-msg.pop { animation: pop .9s ease-out; }
.center-msg.small { font-size: 34px; }
@keyframes pop { 0% { opacity: 0; transform: scale(.4); } 20% { opacity: 1; transform: scale(1.1); } 70% { opacity: 1; transform: scale(1); } 100% { opacity: 0; transform: scale(1.05); } }
.zone { position: absolute; bottom: 0; width: 50%; height: 168px; pointer-events: auto; touch-action: none; display: flex; align-items: center; justify-content: center; }
.zone.left { left: 0; } .zone.right { right: 0; }
.zone .hint { position: absolute; bottom: calc(14px + var(--sab)); color: rgba(255,255,255,.35); font-size: 12px; letter-spacing: .5px; text-transform: uppercase; }
.stick { position: absolute; width: 110px; height: 110px; border-radius: 50%; background: rgba(255,255,255,.08); border: 2px solid rgba(255,255,255,.18); left: 50%; top: 50%; transform: translate(-50%, -50%); opacity: .55; }
.stick.on { opacity: 1; }
.knob { position: absolute; width: 50px; height: 50px; border-radius: 50%; background: rgba(255,255,255,.7); left: 50%; top: 50%; transform: translate(-50%, -50%); box-shadow: 0 3px 8px rgba(0,0,0,.4); }
.throw-btn { width: 96px; height: 96px; border-radius: 50%; background: radial-gradient(circle at 35% 30%, #ffd27a, #e08a1e 70%); border: 3px solid #1a120c; box-shadow: 0 6px 0 #8f5216, 0 10px 20px rgba(0,0,0,.45); display: flex; align-items: center; justify-content: center; font-size: 42px; transition: transform .08s; }
.throw-btn.press { transform: scale(.94); box-shadow: 0 2px 0 #8f5216; }
.throw-btn.empty { filter: grayscale(.9) brightness(.7); }
.flash { position: absolute; inset: 0; background: radial-gradient(circle, rgba(225,91,77,0) 40%, rgba(225,91,77,.75) 100%); opacity: 0; }
.flash.on { animation: flash .45s ease-out; }
@keyframes flash { 0% { opacity: 1; } 100% { opacity: 0; } }
#floaters { position: absolute; inset: 0; overflow: hidden; }
.fl { position: absolute; font-family: 'Russo One', sans-serif; font-size: 28px; color: #ffd23f; text-shadow: 2px 2px 0 #1a120c; transform: translate(-50%, -50%); animation: fl 1s ease-out forwards; }
.fl.big { font-size: 38px; color: #ff7b6b; }
@keyframes fl { 0% { opacity: 0; transform: translate(-50%, -30%) scale(.6); } 20% { opacity: 1; transform: translate(-50%, -60%) scale(1.15); } 100% { opacity: 0; transform: translate(-50%, -160%) scale(1); } }
.leave { position: absolute; right: 12px; top: calc(70px + var(--sat)); pointer-events: auto; width: 34px; height: 34px; border-radius: 50%; border: 1px solid rgba(255,255,255,.15); background: rgba(12,16,26,.62); color: var(--muted); font-size: 15px; }

/* итог */
.result { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; background: rgba(8,10,18,.72); padding: calc(20px + var(--sat)) 20px calc(20px + var(--sab)); }
.res-box { width: 100%; max-width: 360px; background: var(--card); border-radius: 22px; padding: 22px 18px; text-align: center; box-shadow: 0 20px 50px rgba(0,0,0,.6); animation: pop-in .35s ease-out; }
@keyframes pop-in { from { transform: scale(.85); opacity: 0; } to { transform: none; opacity: 1; } }
.res-title { font-family: 'Russo One', sans-serif; font-size: 40px; color: #f4d35e; text-shadow: 3px 3px 0 #1a120c; }
.res-title.lose { color: #ff7b6b; } .res-title.draw { color: var(--muted); }
.res-sub { color: var(--muted); margin: 6px 0 14px; font-size: 14px; }
.res-stats { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; margin-bottom: 16px; }
.res-stats .stat b { font-size: 18px; }
.res-btns { display: flex; flex-direction: column; gap: 8px; }

.toast { position: absolute; left: 50%; bottom: calc(30px + var(--sab)); transform: translateX(-50%); background: #2b3446; color: var(--text); padding: 10px 16px; border-radius: 12px; font-size: 14px; box-shadow: 0 8px 24px rgba(0,0,0,.5); max-width: 90%; text-align: center; z-index: 50; }
