:root {
  --bg: #0b1220; --panel: #131c30; --line: #24304d; --text: #e9eefb; --mute: #8d9abb;
  --gold: #ffcf4a; --green: #1f9d62; --red: #e2504a; --blue: #3b82f6;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; margin: 0; overflow: hidden; overscroll-behavior: none; }
body { background: var(--bg); color: var(--text); font: 14px/1.3 -apple-system, "Segoe UI", Roboto, sans-serif; user-select: none; -webkit-user-select: none; }
[hidden] { display: none !important; }
button, input { font: inherit; color: inherit; }
button { border: 1px solid var(--line); background: var(--panel); border-radius: 12px; padding: 10px 12px; cursor: pointer; font-weight: 600; }
button:active { transform: scale(.97); }
button:disabled { opacity: .45; }
button.primary { background: linear-gradient(#2bb673, #17804f); border-color: #2bb673; }
button.danger { background: #3a1b22; border-color: #6d2a33; color: #ff9c96; }
input { background: #0d1526; border: 1px solid var(--line); border-radius: 10px; padding: 9px 10px; min-width: 0; user-select: text; -webkit-user-select: text; }
a { color: #8fb4ff; cursor: pointer; text-decoration: underline; }

#app { height: 100%; max-width: 540px; margin: 0 auto; display: flex; flex-direction: column; padding-bottom: env(safe-area-inset-bottom); }

/* верхняя панель */
#top { display: flex; justify-content: space-between; align-items: center; padding: 8px 10px; gap: 8px; }
.room b { letter-spacing: 2px; font-size: 15px; }
.room span { display: block; color: var(--mute); font-size: 11px; }
.top-btns { display: flex; gap: 6px; }
.top-btns button { padding: 7px 10px; font-size: 12px; position: relative; }
#reqDot { position: absolute; top: -3px; right: -3px; width: 10px; height: 10px; border-radius: 50%; background: var(--red); }

/* стол */
#table { flex: 1; position: relative; min-height: 0; margin: 20px 6px 0; }
.rim { position: absolute; inset: 7% 9%; border-radius: 46% / 34%; padding: 9px; background: linear-gradient(160deg, #5b3b1e, #2c1a0b); box-shadow: 0 12px 30px rgba(0,0,0,.6), inset 0 1px 0 rgba(255,255,255,.15); }
.felt { width: 100%; height: 100%; border-radius: inherit; background: radial-gradient(ellipse at 50% 40%, #23915d 0%, #14653f 55%, #0b4129 100%); box-shadow: inset 0 0 0 2px rgba(255,255,255,.08), inset 0 0 40px rgba(0,0,0,.55); }
#center { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); width: 62%; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; }
#pot { min-height: 22px; font-weight: 700; color: var(--gold); display: flex; align-items: center; gap: 6px; }
#pot:not(:empty) { background: rgba(0,0,0,.35); padding: 3px 12px; border-radius: 20px; }
#pot i, .bet i { width: 13px; height: 13px; border-radius: 50%; background: radial-gradient(circle, #fff 28%, var(--red) 30% 58%, #fff 60% 68%, var(--red) 70%); box-shadow: 0 1px 2px rgba(0,0,0,.5); flex: none; }
#board { display: flex; gap: 4px; justify-content: center; min-height: 58px; }
#msg { font-size: 12.5px; color: #e8f5ee; min-height: 32px; text-shadow: 0 1px 2px rgba(0,0,0,.7); }
#msg b { color: var(--gold); }

/* карты */
.card { width: 40px; height: 56px; border-radius: 6px; background: linear-gradient(#fff, #e9e9ef); color: #15171c; display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1; box-shadow: 0 2px 5px rgba(0,0,0,.45); flex: none; }
.card b { font-size: 20px; font-weight: 800; letter-spacing: -1px; }
.card i { font-size: 18px; font-style: normal; margin-top: 1px; }
.card.s-h { color: #d5232b; } .card.s-d { color: #1c5fd6; } .card.s-c { color: #17853f; }
.card.back { background: repeating-linear-gradient(45deg, #27408f 0 4px, #1c2f6d 4px 8px); border: 2px solid #f1f1f5; }
.card.mini { width: 22px; height: 30px; border-radius: 4px; }
.card.mini b { font-size: 12px; } .card.mini i { font-size: 11px; margin: 0; }
.card.mini.back { border-width: 1.5px; }
.card.big { width: 58px; height: 82px; border-radius: 8px; }
.card.big b { font-size: 30px; } .card.big i { font-size: 26px; }
.card.dim { opacity: .4; }
.card.deal { animation: deal .35s ease-out both; }
@keyframes deal { from { transform: translateY(-26px) scale(.7); opacity: 0; } }

/* места */
.seat { position: absolute; width: 66px; transform: translate(-50%, -50%); display: flex; flex-direction: column; align-items: center; transition: left .45s, top .45s; z-index: 2; }
.ava { width: 46px; height: 46px; border-radius: 50%; padding: 3px; background: #26324f; position: relative; }
.ava img, .ava span { width: 100%; height: 100%; border-radius: 50%; display: flex; align-items: center; justify-content: center; object-fit: cover; background: linear-gradient(135deg, #46558a, #2a3559); font-weight: 700; font-size: 18px; }
.seat.me .ava span, .seat.me .ava img { box-shadow: 0 0 0 1.5px var(--blue); }
.seat.acting .ava { background: conic-gradient(var(--gold) calc(var(--p, 1) * 1turn), #4a3c12 0); box-shadow: 0 0 14px rgba(255, 207, 74, .55); }
.seat.winner .ava { background: var(--gold); box-shadow: 0 0 18px 4px rgba(255, 207, 74, .75); animation: pulse .9s ease-in-out infinite alternate; }
@keyframes pulse { to { box-shadow: 0 0 6px 1px rgba(255, 207, 74, .4); } }
.seat.folded .ava, .seat.out .ava, .seat.folded .plate, .seat.out .plate { opacity: .45; }
.seat.off .ava::after { content: ""; position: absolute; right: 0; bottom: 0; width: 12px; height: 12px; border-radius: 50%; background: #7b8499; border: 2px solid var(--bg); }
.plate { margin-top: -6px; background: rgba(8, 13, 25, .92); border: 1px solid var(--line); border-radius: 9px; padding: 2px 6px 3px; width: 100%; text-align: center; position: relative; }
.nm { font-size: 10.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: #cfd8ee; }
.st { font-size: 11.5px; font-weight: 700; color: var(--gold); }
.hole { position: absolute; top: -22px; left: 50%; transform: translateX(-50%); display: flex; gap: 2px; z-index: 3; }
.dealer { position: absolute; top: 20px; right: 0; width: 17px; height: 17px; border-radius: 50%; background: #fff; color: #111; font-size: 10px; font-weight: 800; display: flex; align-items: center; justify-content: center; box-shadow: 0 1px 3px rgba(0,0,0,.6); z-index: 4; }
.badge { position: absolute; top: 28px; left: 50%; transform: translateX(-50%); font-size: 9.5px; font-weight: 700; padding: 1px 6px; border-radius: 8px; background: #33415f; white-space: nowrap; z-index: 5; }
.b-fold { background: #4a2b31; color: #ffaaa5; } .b-raise, .b-allin { background: #b8651b; } .b-call { background: #1f6f4a; } .b-check { background: #36507f; }
.b-win { background: var(--gold); color: #1d1500; } .b-out { background: #444c61; }
.sit { width: 40px; height: 40px; border-radius: 50%; padding: 0; font-size: 20px; background: rgba(8,13,25,.7); border: 1.5px dashed #6f7fa8; color: #b8c5e6; }
.sit.off { opacity: .35; }
.bet { position: absolute; transform: translate(-50%, -50%); display: flex; align-items: center; gap: 4px; font-size: 11.5px; font-weight: 700; background: rgba(0,0,0,.45); padding: 2px 7px 2px 3px; border-radius: 12px; transition: left .45s, top .45s; z-index: 1; white-space: nowrap; }

/* мои карты и кнопки */
#mine { display: flex; align-items: center; gap: 12px; padding: 4px 12px; min-height: 90px; }
#myCards { display: flex; gap: 6px; min-width: 122px; min-height: 82px; }
#myInfo { flex: 1; display: flex; flex-direction: column; gap: 8px; color: var(--mute); font-size: 13px; }
#myInfo b { color: var(--gold); font-size: 15px; }
.links { display: flex; gap: 14px; font-size: 12px; }
#actions { position: relative; padding: 10px 10px 12px; min-height: 76px; border-top: 1px solid var(--line); background: var(--panel); display: flex; flex-direction: column; justify-content: center; gap: 8px; }
#actions.myturn::before { content: ""; position: absolute; left: 0; top: -1px; height: 3px; width: calc(var(--p, 0) * 100%); background: var(--gold); }
.btns { display: flex; gap: 8px; }
.btns button { flex: 1; padding: 15px 6px; font-size: 15px; border-radius: 14px; }
.btns button.wide { flex: 2; }
.status { text-align: center; color: var(--mute); font-size: 13px; }
.req { display: flex; gap: 8px; }
.req input { flex: 1; } .req button { flex: 1.4; }
.presets { display: flex; gap: 5px; }
.presets button { flex: 1; padding: 8px 2px; font-size: 12px; }
.slider { display: flex; gap: 8px; align-items: center; }
.slider button { width: 42px; padding: 7px 0; font-size: 18px; }
.slider input { flex: 1; padding: 0; height: 30px; accent-color: var(--gold); }

/* лобби */
#lobby { height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; padding: 24px; text-align: center; background: radial-gradient(ellipse at 50% 30%, #14653f, var(--bg) 70%); }
.logo { font-size: 26px; letter-spacing: 3px; color: var(--gold); } .logo span { color: #fff; font-weight: 800; }
.sub { color: var(--mute); margin: 0; max-width: 300px; }
.big { width: 100%; max-width: 300px; padding: 14px; font-size: 16px; border-radius: 14px; }
.join { display: flex; gap: 8px; width: 100%; max-width: 300px; }
.join input { flex: 1; text-transform: uppercase; text-align: center; letter-spacing: 3px; } .join .big { width: auto; }

/* шторка */
#sheet { position: fixed; inset: 0; background: rgba(0,0,0,.6); z-index: 20; display: flex; align-items: flex-end; justify-content: center; }
.sheet-box { width: 100%; max-width: 540px; max-height: 88%; background: var(--panel); border-radius: 18px 18px 0 0; display: flex; flex-direction: column; padding-bottom: env(safe-area-inset-bottom); }
.sheet-head { display: flex; justify-content: space-between; align-items: center; padding: 12px 14px; border-bottom: 1px solid var(--line); font-size: 16px; }
.sheet-head button { padding: 4px 10px; }
#sheetBody { overflow-y: auto; padding: 12px 14px 20px; -webkit-overflow-scrolling: touch; }
.block { margin-bottom: 18px; } .block h4 { margin: 0 0 8px; color: var(--mute); font-size: 12px; text-transform: uppercase; letter-spacing: 1px; }
.block .big { max-width: none; }
.row { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 4px 0; }
.row button { padding: 7px 10px; font-size: 12.5px; margin-left: 4px; }
.pl { border: 1px solid var(--line); border-radius: 12px; padding: 8px 10px; margin-bottom: 8px; }
.ctl { justify-content: flex-start; } .ctl input { flex: 1; padding: 7px 8px; } .ctl button { margin: 0; flex: none; }
.ctl.small { justify-content: space-between; font-size: 12px; padding-bottom: 0; }
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 10px; }
.grid label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--mute); }
.log { font-size: 12.5px; border-bottom: 1px solid var(--line); } .log small { color: var(--mute); }
.tbl { width: 100%; border-collapse: collapse; } .tbl th { text-align: right; color: var(--mute); font-size: 11px; font-weight: 500; padding: 4px; }
.tbl th:first-child, .tbl td:first-child { text-align: left; } .tbl td { text-align: right; padding: 8px 4px; border-top: 1px solid var(--line); }
.plus { color: #49d18b; } .minus { color: #ff8a84; }
.dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: #56607a; margin-right: 6px; } .dot.on { background: #49d18b; }
.hint { color: var(--mute); font-size: 12px; }

/* графика из public/img — включается классами has-* из app.js, только если файл загрузился */
html.has-bg body { background: var(--bg) url(img/bg.jpg) center top / cover no-repeat; }
html.has-bg #lobby { background: radial-gradient(ellipse at 50% 30%, rgba(20, 101, 63, .25), transparent 70%), url(img/bg.jpg) center top / cover no-repeat; }
html.has-table .rim { background: url(img/table.png) center / 100% 100% no-repeat; border-radius: 0; padding: 0; box-shadow: none; filter: drop-shadow(0 12px 22px rgba(0, 0, 0, .55)); }
html.has-table .felt { background: none; box-shadow: none; }
html.has-back .card.back { background: #1c2f6d url(img/card-back.png) center / 100% 100% no-repeat; border: none; }
html.has-chip #pot i, html.has-chip .bet i { background: url(img/chip.png) center / contain no-repeat; }

#toast { position: fixed; left: 50%; top: 56px; transform: translate(-50%, -20px); background: #f3f5fb; color: #111; padding: 9px 14px; border-radius: 12px; font-weight: 600; font-size: 13px; opacity: 0; pointer-events: none; transition: .25s; z-index: 40; max-width: 88%; text-align: center; }
#toast.on { opacity: 1; transform: translate(-50%, 0); }
#conn { position: fixed; top: 0; left: 0; right: 0; background: var(--red); text-align: center; padding: 5px; font-size: 12px; font-weight: 600; z-index: 50; }
