/* billiards.css — розмір канваса рахує JS (layout); тут лише розкладка навколо нього */

.custom-scrollbar::-webkit-scrollbar { width: 6px; }
.custom-scrollbar::-webkit-scrollbar-track { background: transparent; }
.custom-scrollbar::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.2); border-radius: 4px; }

body.in-game #site-header { display: none; }
#main-container, #screens-wrapper { min-height: 0; }
#screen-game *, #screen-game *:focus { -webkit-tap-highlight-color: transparent; outline: none; }
#screen-game { background: radial-gradient(ellipse at 50% 45%, #14321f 0%, #07140d 60%, #020604 100%); user-select: none; -webkit-user-select: none; }
#screen-game input { user-select: text; -webkit-user-select: text; }

.game-bar { height: 44px; flex-shrink: 0; display: flex; align-items: center; gap: 6px; padding: 0 10px; background: rgba(2, 6, 23, 0.88); border-bottom: 1px solid #1e293b; z-index: 20; }
.gb-btn { padding: 5px 10px; border-radius: 9px; background: #1e293b; color: #cbd5e1; font-size: 13px; font-weight: 700; border: 1px solid #334155; white-space: nowrap; }
.gb-btn:hover { background: #334155; color: white; }
.gb-btn.danger { color: #fca5a5; }
.turn-pill { font-size: 13px; font-weight: 800; padding: 4px 12px; border-radius: 999px; background: #1e293b; border: 1px solid #334155; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; color: #e2e8f0; }
.turn-pill.mine { background: #059669; border-color: #34d399; color: white; box-shadow: 0 0 12px rgba(16, 185, 129, 0.7); }
.target-wrap { display: flex; align-items: center; gap: 5px; font-size: 11px; color: #94a3b8; font-weight: 700; white-space: nowrap; }
.target-ball { width: 24px; height: 24px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 900; box-shadow: inset 0 0 0 5px rgba(255,255,255,0.0), 0 0 8px rgba(250, 204, 21, 0.5); border: 2px solid rgba(255,255,255,0.8); }
.target-ball.stripe { background: linear-gradient(#f8fafc 0 28%, #facc15 28% 72%, #f8fafc 72%) !important; }
.target-wrap .target-ball { font-style: normal; }
.target-wrap b { color: #e2e8f0; font-weight: 800; }
.target-wrap .tg-any { color: #fde68a; }
.bl-card .grp { margin-left: 4px; font-size: 10px; font-weight: 800; color: #93c5fd; text-transform: uppercase; letter-spacing: 0.03em; }
/* правила */
.rl-tabs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.rl-tab { padding: 6px 12px; border-radius: 999px; font-size: 13px; font-weight: 800; background: #0f172a; border: 1px solid #334155; color: #cbd5e1; }
.rl-tab.on { background: #059669; border-color: #34d399; color: #fff; }
.rl-now { font-size: 12px; color: #6ee7b7; margin-bottom: 6px; }
.rl-list { margin: 0 0 8px; padding-left: 18px; list-style: disc; display: flex; flex-direction: column; gap: 6px; font-size: 14px; line-height: 1.45; color: #e2e8f0; }
.rl-list b { color: #fde68a; }
.rl-h { margin: 8px 0 6px; font-size: 13px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.05em; color: #94a3b8; }
.chat-badge { position: absolute; top: -6px; right: -6px; min-width: 18px; height: 18px; padding: 0 4px; border-radius: 9px; background: #ef4444; color: white; font-size: 11px; line-height: 18px; text-align: center; }
@media (max-width: 760px) { .hide-sm { display: none; } }
@media (max-width: 480px) { .hide-xs { display: none; } .game-bar { gap: 5px; padding: 0 6px; } .gb-btn { padding: 5px 8px; } }

/* Сцена */
#bl-stage { flex: 1; min-height: 0; display: grid; gap: 6px 10px; padding: 8px; justify-content: center; align-content: center; justify-items: center; }
#bl-stage.portrait { grid-template-columns: minmax(0, min(100%, 520px)); grid-template-areas: "cards" "table" "hint" "ctrl"; }
#bl-stage.wide { grid-template-columns: var(--tw) 84px; grid-template-areas: "cards cards" "table ctrl" "hint hint"; }
#bl-cards { grid-area: cards; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; width: 100%; }
#bl-table { grid-area: table; width: var(--tw); height: var(--th); }
#pool-canvas { display: block; border-radius: 10px; box-shadow: 0 14px 40px rgba(0,0,0,0.6); cursor: crosshair; }
.table-hint { grid-area: hint; font-size: 12px; color: #94a3b8; text-align: center; min-height: 16px; line-height: 16px; max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.table-hint.warn { color: #fbbf24; font-weight: 800; }

/* Керування */
#bl-controls { grid-area: ctrl; display: flex; align-items: center; gap: 10px; transition: opacity 0.2s; }
#bl-controls.off { opacity: 0.35; pointer-events: none; }
#bl-stage.portrait #bl-controls { width: 100%; height: 56px; }
#bl-stage.wide #bl-controls { flex-direction: column; height: var(--th); width: 84px; justify-content: flex-start; }
.spin-pad { position: relative; width: 52px; height: 52px; flex-shrink: 0; border-radius: 50%; background: radial-gradient(circle at 38% 34%, #ffffff 0%, #e2e8f0 55%, #94a3b8 100%); box-shadow: 0 3px 10px rgba(0,0,0,0.5), inset 0 0 0 1px rgba(0,0,0,0.25); cursor: pointer; touch-action: none; }
.spin-pad::before, .spin-pad::after { content: ''; position: absolute; background: rgba(15, 23, 42, 0.18); }
.spin-pad::before { left: 50%; top: 10%; bottom: 10%; width: 1px; } .spin-pad::after { top: 50%; left: 10%; right: 10%; height: 1px; }
#spin-dot { position: absolute; width: 12px; height: 12px; margin: -6px 0 0 -6px; border-radius: 50%; background: #dc2626; box-shadow: 0 0 0 2px rgba(255,255,255,0.8); pointer-events: none; }
.fine { display: flex; gap: 6px; }
#bl-stage.wide .fine { width: 100%; }
.fb { flex: 1; min-width: 38px; height: 38px; border-radius: 10px; background: #1e293b; color: #e2e8f0; font-weight: 900; border: 1px solid #334155; touch-action: none; }
.fb:active { background: #334155; }
.power-track { position: relative; flex: 1; height: 40px; border-radius: 12px; background: linear-gradient(90deg, #0f172a, #1e293b); border: 1px solid #334155; overflow: hidden; cursor: pointer; touch-action: none; }
.power-fill { --pw: 0; position: absolute; left: 0; top: 0; bottom: 0; width: calc(var(--pw) * 100%); background: linear-gradient(90deg, #10b981, #facc15 60%, #ef4444); }
#bl-stage.wide .power-track { flex: 1; width: 44px; height: auto; min-height: 120px; background: linear-gradient(180deg, #0f172a, #1e293b); }
#bl-stage.wide .power-fill { right: 0; bottom: auto; width: auto; height: calc(var(--pw) * 100%); background: linear-gradient(180deg, #10b981, #facc15 60%, #ef4444); }
#power-label { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 900; color: #e2e8f0; text-shadow: 0 1px 2px #000; pointer-events: none; }
#bl-stage.wide #power-label { writing-mode: vertical-rl; }

/* Картки гравців */
.bl-card { --p: 0; display: flex; align-items: center; gap: 8px; padding: 5px 10px; border-radius: 12px; background: rgba(15, 23, 42, 0.88); border: 2px solid #334155; opacity: 0.85; position: relative; min-width: 0; height: 44px; }
.bl-card.active { opacity: 1; border-color: #34d399; box-shadow: 0 0 16px rgba(52, 211, 153, 0.35); }
.bl-card .tok { position: relative; width: 30px; height: 30px; flex-shrink: 0; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 17px; background: transparent; }
.bl-card .tok .ad-av { --fi: -2.2px; --fw: 2px; --as: 30px; }
.bl-card .tok[data-t]:not([data-t=""])::after { z-index: 3; }
.bl-card.active .tok::before { content: ''; position: absolute; inset: -6px; border-radius: 50%; background: conic-gradient(#34d399 calc(var(--p) * 1turn), rgba(255,255,255,0.1) 0); -webkit-mask: radial-gradient(circle, transparent 17px, #000 18px); mask: radial-gradient(circle, transparent 17px, #000 18px); }
.bl-card.low .tok::before { background: conic-gradient(#ef4444 calc(var(--p) * 1turn), rgba(255,255,255,0.1) 0); }
.bl-card .tok[data-t]:not([data-t=""])::after { content: attr(data-t); position: absolute; right: -8px; bottom: -6px; font-size: 10px; font-weight: 900; color: white; background: #047857; border-radius: 999px; padding: 0 4px; }
.bl-card.low .tok::after { background: #dc2626 !important; }
.bl-card .info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.bl-card .nm { font-size: 13px; font-weight: 800; color: white; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; line-height: 1.1; }
.bl-card .pot { display: flex; gap: 2px; flex-wrap: nowrap; overflow: hidden; }
.bl-card .pot .none { font-size: 10px; color: #64748b; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bl-card .mb { width: 14px; height: 14px; border-radius: 50%; font-size: 8px; font-style: normal; font-weight: 900; display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; box-shadow: inset 0 0 0 1px rgba(0,0,0,0.3); }
.bl-card .mb.stripe { background: linear-gradient(#f8fafc 0 28%, #facc15 28% 72%, #f8fafc 72%) !important; }
.bl-card .fouls { font-size: 11px; font-weight: 900; color: #fbbf24; background: rgba(120, 53, 15, 0.6); border-radius: 999px; padding: 1px 6px; flex-shrink: 0; }

/* Чат під час гри */
.game-chat { position: absolute; top: 44px; right: 0; bottom: 0; width: min(340px, 100%); z-index: 60; display: flex; flex-direction: column; background: rgba(15, 23, 42, 0.97); border-left: 1px solid #334155; box-shadow: -10px 0 30px rgba(0,0,0,0.5); }
.gc-head { display: flex; justify-content: space-between; align-items: center; padding: 8px 10px; border-bottom: 1px solid #334155; }
.gc-list { flex: 1; min-height: 0; overflow-y: auto; padding: 10px; display: flex; flex-direction: column; gap: 8px; font-size: 13px; }
.gc-form { display: flex; gap: 6px; padding: 8px; border-top: 1px solid #334155; }
.gc-form input { flex: 1; min-width: 0; background: #020617; border: 1px solid #475569; border-radius: 8px; padding: 7px 10px; color: white; outline: none; }
.gc-form button { padding: 0 14px; border-radius: 8px; background: #059669; color: white; font-weight: 800; }

#modal-create-room > div, #modal-leaderboard > div { max-height: calc(100% - 16px); overflow-y: auto; margin: 0 8px; }
@media (max-height: 560px) {
    #modal-create-room > div { padding: 12px 16px; }
    #modal-create-room h2 { font-size: 18px; margin-bottom: 8px; }
    #modal-create-room .mb-4, #modal-create-room .mb-6 { margin-bottom: 8px; }
    #modal-create-room input[type=text], #modal-create-room select { padding-top: 5px; padding-bottom: 5px; }
}
