:root {
  --bg: #0e1828;
  --bg2: #13223a;
  --panel: #182b47;
  --panel2: #21395c;
  --line: #2c4670;
  --text: #f1f5fc;
  --muted: #8ea4c4;
  --gold: #f6bd3f;
  --gold2: #ffda7a;
  --green: #2bd07a;
  --red: #ff5a64;
  --blue: #3d8bff;
  --felt1: #1f8a59;
  --felt2: #0d4f33;
  --rail: #3a2414;
  --radius: 16px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font-family: Manrope, system-ui, -apple-system, sans-serif; overscroll-behavior: none; }
body { background: radial-gradient(120% 60% at 50% 0%, #1d3558 0%, var(--bg) 60%); }
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; }
input { font: inherit; color: var(--text); }
.hidden { display: none !important; }
.muted { color: var(--muted); }
#app { max-width: 480px; margin: 0 auto; min-height: 100%; position: relative; }

/* загрузка */
.loading { position: fixed; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px; z-index: 50; background: var(--bg); }
.logo-big { font-weight: 800; font-size: 40px; letter-spacing: 4px; background: linear-gradient(180deg, var(--gold2), var(--gold)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.bar { width: 200px; height: 6px; background: var(--panel); border-radius: 6px; overflow: hidden; }
.bar i { display: block; width: 40%; height: 100%; background: var(--gold); border-radius: 6px; animation: load 1.1s infinite ease-in-out; }
@keyframes load { 0% { transform: translateX(-100%); } 100% { transform: translateX(260%); } }

#screen { padding: 14px 16px 96px; }

/* шапка */
.top { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.ava { width: 44px; height: 44px; border-radius: 50%; background: linear-gradient(135deg, var(--blue), #7b5cff); display: grid; place-items: center; font-weight: 800; font-size: 18px; flex: none; border: 2px solid rgba(255,255,255,.15); }
.who { flex: 1; min-width: 0; }
.who b { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.who small { color: var(--muted); }
.bal { display: flex; align-items: center; gap: 6px; background: var(--panel); border: 1px solid var(--line); padding: 7px 8px 7px 10px; border-radius: 999px; font-weight: 800; }
.chip { width: 18px; height: 18px; border-radius: 50%; background: radial-gradient(circle at 35% 35%, var(--gold2), var(--gold) 55%, #b9811b); box-shadow: inset 0 0 0 2px rgba(255,255,255,.35); flex: none; display: inline-block; }
.bal .plus { width: 24px; height: 24px; border-radius: 50%; background: var(--gold); color: #2a1a00; font-weight: 800; display: grid; place-items: center; line-height: 1; }

.pills { display: flex; gap: 8px; margin-bottom: 14px; overflow-x: auto; scrollbar-width: none; }
.pills button { white-space: nowrap; background: var(--panel); border: 1px solid var(--line); padding: 7px 12px; border-radius: 999px; font-size: 13px; color: var(--muted); font-weight: 600; }

.btn { display: block; width: 100%; padding: 15px; border-radius: 14px; font-weight: 800; font-size: 16px; text-align: center; }
.btn-gold { background: linear-gradient(180deg, var(--gold2), var(--gold)); color: #2a1a00; box-shadow: 0 6px 20px rgba(246,189,63,.25); }
.btn-blue { background: var(--blue); color: #fff; }
.btn-dark { background: var(--panel2); border: 1px solid var(--line); }
.btn-red { background: var(--red); color: #fff; }
.btn:active { transform: translateY(1px); filter: brightness(.95); }
.btn[disabled] { opacity: .45; }

.tabs { display: flex; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 4px; margin: 14px 0; }
.tabs button { flex: 1; padding: 10px 0; border-radius: 10px; font-weight: 700; color: var(--muted); }
.tabs button.on { background: var(--panel2); color: var(--text); }

.create { display: flex; align-items: center; justify-content: center; gap: 10px; width: 100%; padding: 22px; border-radius: var(--radius); border: 1.5px dashed var(--line); background: linear-gradient(135deg, rgba(61,139,255,.12), rgba(61,139,255,.02)); font-weight: 800; font-size: 17px; margin-bottom: 12px; }
.create span { font-size: 26px; color: var(--gold); line-height: 1; }

.list { display: flex; flex-direction: column; gap: 10px; }
.tcard { display: flex; gap: 12px; align-items: center; padding: 12px; border-radius: var(--radius); background: linear-gradient(135deg, var(--panel2), var(--panel)); border: 1px solid var(--line); text-align: left; width: 100%; }
.tcard .badge { width: 62px; height: 62px; border-radius: 14px; flex: none; display: grid; place-items: center; font-size: 30px; background: radial-gradient(circle at 50% 30%, var(--felt1), var(--felt2)); box-shadow: inset 0 0 0 2px rgba(255,255,255,.1); }
.tcard .info { flex: 1; min-width: 0; }
.tcard .row1 { display: flex; align-items: center; gap: 6px; font-weight: 800; font-size: 17px; }
.tcard .tags { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 6px; }
.tag { font-size: 11px; font-weight: 700; padding: 3px 7px; border-radius: 6px; background: rgba(255,255,255,.07); color: var(--muted); }
.tag.g { color: var(--green); background: rgba(43,208,122,.12); }
.tcard .seats { text-align: right; font-weight: 800; }
.tcard .seats small { display: block; color: var(--muted); font-weight: 600; font-size: 11px; }

.tour { position: relative; overflow: hidden; padding: 16px; border-radius: var(--radius); background: linear-gradient(120deg, #4a1d6b, #8a1f4a); border: 1px solid rgba(255,255,255,.12); }
.tour h3 { margin: 0 0 4px; font-size: 19px; letter-spacing: .5px; }
.tour .prize { color: var(--gold2); font-weight: 800; font-size: 22px; }
.tour .soon { position: absolute; top: 12px; right: 12px; font-size: 11px; font-weight: 800; background: rgba(0,0,0,.3); padding: 4px 8px; border-radius: 6px; }
.tour .cup { position: absolute; right: -6px; bottom: -14px; font-size: 76px; opacity: .25; }
.empty { text-align: center; color: var(--muted); padding: 22px 10px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--bg2); }
.h { font-size: 26px; font-weight: 800; margin: 6px 0 16px; }
.sub { color: var(--muted); margin: -8px 0 16px; font-size: 14px; }

/* нижнее меню */
.nav { position: fixed; bottom: 0; left: 50%; transform: translateX(-50%); width: 100%; max-width: 480px; display: flex; background: rgba(14,24,40,.96); backdrop-filter: blur(10px); border-top: 1px solid var(--line); padding: 6px 6px calc(6px + env(safe-area-inset-bottom)); z-index: 10; }
.nav button { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 0; border-radius: 12px; font-size: 11px; font-weight: 700; color: var(--muted); }
.nav .ic { font-size: 20px; line-height: 22px; }
.nav button.on { color: var(--gold); background: rgba(246,189,63,.08); }

/* магазин, карьера, меню */
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.pack { padding: 16px 12px; border-radius: var(--radius); background: var(--panel); border: 1px solid var(--line); text-align: center; }
.pack .coin { width: 54px; height: 54px; margin: 4px auto 10px; border-radius: 50%; background: radial-gradient(circle at 35% 35%, var(--gold2), var(--gold) 55%, #a66f12); box-shadow: 0 6px 18px rgba(246,189,63,.3), inset 0 0 0 4px rgba(255,255,255,.3); }
.pack b { display: block; font-size: 18px; margin-bottom: 10px; }
.stat { padding: 16px; border-radius: var(--radius); background: var(--panel); border: 1px solid var(--line); }
.stat b { display: block; font-size: 26px; }
.stat small { color: var(--muted); }
.rows { border-radius: var(--radius); overflow: hidden; border: 1px solid var(--line); }
.rows button, .rows .r { display: flex; align-items: center; gap: 12px; width: 100%; padding: 15px 14px; background: var(--panel); border-bottom: 1px solid var(--line); text-align: left; font-weight: 700; }
.rows > :last-child { border-bottom: 0; }
.rows .ri { width: 22px; text-align: center; color: var(--gold); }
.rows .rt { flex: 1; }
.rows .chev { color: var(--muted); }
.sw { width: 46px; height: 28px; border-radius: 999px; background: var(--line); position: relative; transition: .2s; flex: none; }
.sw::after { content: ''; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; transition: .2s; }
.sw.on { background: var(--green); }
.sw.on::after { left: 21px; }
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; color: var(--muted); font-weight: 700; margin-bottom: 7px; }
.inp { width: 100%; padding: 13px 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--bg2); outline: none; font-weight: 700; }
.inp:focus { border-color: var(--blue); }

/* модальные окна */
.modal { position: fixed; inset: 0; z-index: 40; background: rgba(4,10,20,.7); display: flex; align-items: flex-end; justify-content: center; }
.sheet { width: 100%; max-width: 480px; max-height: 92vh; overflow-y: auto; background: var(--bg2); border-radius: 22px 22px 0 0; padding: 10px 16px calc(18px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); animation: up .22s ease-out; }
@keyframes up { from { transform: translateY(40px); opacity: 0; } }
.grab { width: 40px; height: 5px; border-radius: 5px; background: var(--line); margin: 0 auto 10px; }
.sheet-h { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.sheet-h h2 { margin: 0; font-size: 21px; }
.x { width: 34px; height: 34px; border-radius: 50%; background: var(--panel); font-size: 18px; color: var(--muted); }
.seg { display: flex; flex-wrap: wrap; gap: 6px; }
.seg button { flex: 1 0 auto; min-width: 48px; padding: 11px 10px; border-radius: 11px; background: var(--panel); border: 1px solid var(--line); font-weight: 700; font-size: 14px; color: var(--muted); }
.seg button.on { background: rgba(61,139,255,.18); border-color: var(--blue); color: var(--text); }
.seg button[disabled] { opacity: .35; }
.check { display: flex; align-items: center; gap: 10px; font-weight: 700; margin: 6px 0 16px; }
.faq details { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; margin-bottom: 8px; padding: 0 14px; }
.faq summary { padding: 14px 0; font-weight: 700; cursor: pointer; }
.faq p { margin: 0 0 14px; color: var(--muted); line-height: 1.45; }

.toast { position: fixed; left: 50%; top: 16px; transform: translate(-50%, -120px); background: #2b1520; border: 1px solid var(--red); color: #ffd7da; padding: 10px 16px; border-radius: 12px; font-weight: 700; font-size: 14px; z-index: 60; transition: transform .25s; max-width: 90%; text-align: center; }
.toast.ok { background: #0f2c1d; border-color: var(--green); color: #c9f5dc; }
.toast.show { transform: translate(-50%, 0); }

/* ---------- игровой стол ---------- */
.table-screen { position: fixed; inset: 0; z-index: 30; display: flex; justify-content: center; background: radial-gradient(120% 80% at 50% 40%, #1a2d49, #0a1220); }
.tbl { position: relative; width: 100%; max-width: 480px; height: 100%; overflow: hidden; display: flex; flex-direction: column; }
.tbar { display: flex; align-items: center; gap: 8px; padding: 10px 12px; z-index: 3; }
.tbar .ib { width: 38px; height: 38px; border-radius: 12px; background: rgba(255,255,255,.08); font-size: 18px; flex: none; }
.tbar .tinfo { flex: 1; text-align: center; font-size: 12px; color: var(--muted); font-weight: 700; }
.tbar .tinfo b { color: var(--gold2); font-size: 15px; display: block; }
.felt-wrap { position: relative; flex: 1; min-height: 0; }
.felt { position: absolute; left: 7%; right: 7%; top: 12%; bottom: 3%; border-radius: 200px; background: radial-gradient(ellipse at 50% 45%, var(--felt1), var(--felt2) 75%); box-shadow: 0 0 0 10px var(--rail), 0 0 0 12px rgba(255,214,140,.25), 0 20px 50px rgba(0,0,0,.6), inset 0 0 60px rgba(0,0,0,.45); }
.felt::after { content: 'КОЗЫРЬ'; position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); font-weight: 800; letter-spacing: 6px; font-size: 22px; color: rgba(255,255,255,.06); pointer-events: none; }

.seat { position: absolute; transform: translate(-50%, -50%); display: flex; flex-direction: column; align-items: center; width: 84px; z-index: 4; }
.seat .sav { width: 52px; height: 52px; border-radius: 50%; display: grid; place-items: center; font-weight: 800; font-size: 20px; background: linear-gradient(135deg, #5a6f92, #34486a); border: 3px solid rgba(255,255,255,.2); position: relative; }
.seat.empty .sav { background: rgba(0,0,0,.25); border-style: dashed; color: var(--muted); font-size: 22px; }
.seat .nm { margin-top: 4px; font-size: 12px; font-weight: 800; max-width: 84px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; background: rgba(0,0,0,.45); padding: 2px 8px; border-radius: 8px; }
.seat .role { font-size: 10px; font-weight: 800; margin-top: 3px; padding: 2px 6px; border-radius: 6px; }
.role.att { background: var(--gold); color: #2a1a00; }
.role.def { background: var(--blue); color: #fff; }
.role.done { background: var(--green); color: #00210f; }
.role.pas { background: rgba(255,255,255,.15); }
.seat .cnt { position: absolute; right: -10px; top: -6px; min-width: 24px; height: 24px; border-radius: 12px; padding: 0 6px; background: #fff; color: #111; font-size: 13px; font-weight: 800; display: grid; place-items: center; }
.seat .fan { display: flex; margin-top: -10px; height: 26px; }
.seat .fan i { width: 16px; height: 24px; border-radius: 3px; margin-left: -9px; background: repeating-linear-gradient(45deg, #b8323b 0 3px, #8e1f28 3px 6px); border: 1.5px solid #fff; }
.seat .fan i:first-child { margin-left: 0; }
.ring { position: absolute; inset: -6px; border-radius: 50%; }
.seat.turn .sav { border-color: var(--gold); box-shadow: 0 0 18px rgba(246,189,63,.6); }

.center { position: absolute; left: 14%; right: 14%; top: 28%; bottom: 24%; display: flex; flex-wrap: wrap; align-content: center; justify-content: center; gap: 8px 4px; z-index: 2; }
.pair { position: relative; width: 58px; height: 98px; }
.pair .card { position: absolute; left: 0; top: 0; }
.pair .card.d { left: 12px; top: 22px; transform: rotate(8deg); }
.pair.target .card.a { box-shadow: 0 0 0 3px var(--gold), 0 0 16px rgba(246,189,63,.7); }
.pair.can .card.a { box-shadow: 0 0 0 2px rgba(246,189,63,.7); cursor: pointer; }

.deck { position: absolute; left: 4%; bottom: 3%; width: 110px; height: 90px; z-index: 3; }
.deck .trumpc { position: absolute; left: 34px; top: 12px; transform: rotate(90deg); }
.deck .back { position: absolute; left: 0; top: 14px; }
.deck .dn { position: absolute; left: 2px; top: 24px; width: 46px; text-align: center; font-weight: 800; font-size: 18px; z-index: 2; text-shadow: 0 1px 3px #000; }
.deck .tsuit { position: absolute; left: 6px; top: 40px; font-size: 34px; opacity: .9; }
.disc { position: absolute; right: 5%; bottom: 4%; z-index: 3; text-align: center; font-size: 11px; font-weight: 800; color: var(--muted); }
.disc .back { margin: 0 auto 4px; transform: rotate(-12deg); }

.status { text-align: center; font-weight: 800; font-size: 15px; padding: 6px 12px 4px; min-height: 30px; z-index: 3; }
.status.me { color: var(--gold2); }
.timer { height: 4px; margin: 0 20px 6px; background: rgba(255,255,255,.1); border-radius: 4px; overflow: hidden; }
.timer i { display: block; height: 100%; background: var(--gold); border-radius: 4px; transition: width .25s linear; }
.timer i.low { background: var(--red); }
.acts { display: flex; gap: 8px; padding: 0 12px 6px; min-height: 52px; }
.acts .btn { padding: 13px 8px; }
.hand { position: relative; height: 138px; padding-bottom: env(safe-area-inset-bottom); display: flex; justify-content: center; align-items: flex-end; padding-left: 10px; padding-right: 10px; }
.hand .card { width: 66px; height: 98px; flex: none; transition: transform .15s, margin .15s; transform-origin: bottom center; cursor: pointer; }
.hand .card .cr { font-size: 17px; }
.hand .card .cbig { font-size: 34px; }
.hand .card.play { box-shadow: 0 0 0 2px var(--gold), 0 4px 12px rgba(0,0,0,.4); }
.hand .card.dim { filter: brightness(.6); }
.hand .card.sel { transform: translateY(-26px) !important; box-shadow: 0 0 0 3px var(--gold2), 0 0 20px rgba(246,189,63,.7); }

/* карты */
.card { width: 50px; height: 74px; border-radius: 7px; background: linear-gradient(180deg, #fff, #eef1f6); color: #17202e; position: relative; box-shadow: 0 2px 6px rgba(0,0,0,.45); user-select: none; }
.card.red { color: #d3263a; }
.card .cr { position: absolute; left: 5px; top: 3px; font-weight: 800; font-size: 15px; line-height: 1; }
.card .cs { position: absolute; left: 5px; top: 20px; font-size: 13px; line-height: 1; }
.card .cbig { position: absolute; right: 5px; bottom: 3px; font-size: 26px; line-height: 1; }
.card.trump::before { content: ''; position: absolute; inset: 0; border-radius: 7px; box-shadow: inset 0 0 0 2px rgba(246,189,63,.8); }
.back { width: 50px; height: 74px; border-radius: 7px; background: repeating-linear-gradient(45deg, #b8323b 0 5px, #8e1f28 5px 10px); border: 3px solid #fff; box-shadow: 0 2px 6px rgba(0,0,0,.45); }
.pair .card, .deck .card, .deck .back, .disc .back { width: 50px; height: 74px; }

/* ожидание и итог */
.wait { position: absolute; left: 50%; top: 52%; transform: translate(-50%, -50%); text-align: center; z-index: 5; width: 70%; }
.wait b { display: block; font-size: 18px; margin-bottom: 4px; }
.wait .btn { margin-top: 12px; }
.spin { width: 30px; height: 30px; border: 3px solid rgba(255,255,255,.2); border-top-color: var(--gold); border-radius: 50%; margin: 0 auto 10px; animation: sp 1s linear infinite; }
@keyframes sp { to { transform: rotate(360deg); } }
.result { position: absolute; inset: 0; z-index: 20; background: rgba(4,10,20,.82); display: flex; align-items: center; justify-content: center; padding: 20px; }
.rbox { width: 100%; max-width: 380px; background: var(--bg2); border: 1px solid var(--line); border-radius: 22px; padding: 22px 18px; text-align: center; animation: up .25s ease-out; }
.rbox .big { font-size: 46px; }
.rbox h2 { margin: 6px 0; font-size: 26px; }
.rbox .sum { font-size: 22px; font-weight: 800; margin-bottom: 14px; }
.rbox .sum.plus { color: var(--green); }
.rbox .sum.minus { color: var(--red); }
.rlist { text-align: left; margin-bottom: 16px; }
.rlist div { display: flex; justify-content: space-between; padding: 8px 4px; border-bottom: 1px solid var(--line); font-weight: 700; }
.rlist .l { color: var(--red); }
.rbox .btn + .btn { margin-top: 8px; }

/* темы стола */
body.th-blue { --felt1: #2d6fb8; --felt2: #123764; }
body.th-red { --felt1: #9b2a3a; --felt2: #4e1119; }
body.th-black { --felt1: #3b4352; --felt2: #151a23; --rail: #1b1b1b; }

@media (max-height: 700px) {
  .hand { height: 116px; }
  .hand .card { width: 58px; height: 86px; }
  .seat .sav { width: 44px; height: 44px; font-size: 17px; }
}
