/* ===================================================== 8 BALL POOL — styles ===================================================== */
:root {
  --bg: #07030d; --bg2: #120a1d; --panel: rgba(28, 14, 44, .72); --line: rgba(255, 255, 255, .09);
  --txt: #f4f4f6; --mut: #a1a1aa; --gold: #fbbf24; --vio: #8b5cf6; --vio2: #a855f7; --red: #ef4444; --green: #22c55e;
  --tc: 26, 163, 240;          /* table colour (r,g,b) — set from JS */
  --hud-h: 72px;
  --top-room: clamp(16px, 13vh, 150px);   /* room above the table for the shelf + hanging lamps */
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--txt); font-family: 'Inter', system-ui, sans-serif; -webkit-tap-highlight-color: transparent; overflow: hidden; }
button { font-family: inherit; }
.hidden { display: none !important; }
.muted { color: var(--mut); }
.small { font-size: 12px; }

#app { position: fixed; inset: 0; }
.screen { position: absolute; inset: 0; display: none; }
.screen.active { display: flex; }

.glass { background: var(--panel); border: 1px solid var(--line); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); box-shadow: 0 24px 60px rgba(0, 0, 0, .55); }

/* ---------- background orbs (auth / lobby) ---------- */
.bg-orbs { position: absolute; inset: 0; overflow: hidden; pointer-events: none; background: radial-gradient(ellipse 80% 60% at 50% 0%, #2a1145 0%, #0d0616 55%, #05020a 100%); }
.bg-orbs i { position: absolute; border-radius: 50%; filter: blur(70px); opacity: .5; animation: orb 18s ease-in-out infinite alternate; }
.bg-orbs i:nth-child(1) { width: 520px; height: 520px; left: -120px; top: 10%; background: rgba(var(--tc), .45); }
.bg-orbs i:nth-child(2) { width: 420px; height: 420px; right: -100px; top: 40%; background: rgba(168, 85, 247, .45); animation-delay: -6s; }
.bg-orbs i:nth-child(3) { width: 300px; height: 300px; left: 40%; bottom: -120px; background: rgba(251, 191, 36, .25); animation-delay: -11s; }
@keyframes orb { to { transform: translate(60px, -40px) scale(1.15); } }

/* ---------- brand ---------- */
.brand { display: flex; align-items: center; gap: 14px; }
.brand h1 { margin: 0; font-size: 30px; font-weight: 900; letter-spacing: .08em; line-height: 1; }
.brand p { margin: 4px 0 0; font-size: 11px; letter-spacing: .3em; color: var(--mut); font-weight: 700; }
.brand.small h1 { font-size: 20px; } .brand.small p { font-size: 9px; }
.brand-ball { width: 54px; height: 54px; border-radius: 50%; display: grid; place-items: center; background: radial-gradient(circle at 32% 28%, #555 0%, #161616 45%, #000 100%); box-shadow: inset -6px -8px 14px rgba(0,0,0,.6), 0 8px 24px rgba(0,0,0,.6), 0 0 30px rgba(var(--tc), .35); flex: none; }
.brand.small .brand-ball { width: 38px; height: 38px; }
.brand-ball b { width: 46%; height: 46%; border-radius: 50%; background: #fbfaf6; color: #111; display: grid; place-items: center; font-weight: 900; font-size: 15px; }
.brand.small .brand-ball b { font-size: 11px; }

/* ---------- buttons ---------- */
.btn { border: none; border-radius: 12px; padding: 10px 16px; font-weight: 800; font-size: 14px; cursor: pointer; color: #fff; transition: transform .12s, filter .15s, background .15s; }
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.big { width: 100%; padding: 14px 18px; font-size: 15px; }
.btn.tiny { padding: 6px 10px; font-size: 11px; border-radius: 8px; }
.btn.primary { background: linear-gradient(135deg, #8b5cf6, #6d28d9); box-shadow: 0 8px 22px rgba(109, 40, 217, .45); }
.btn.primary:hover { filter: brightness(1.12); }
.btn.gold { background: linear-gradient(135deg, #fcd34d, #f59e0b); color: #1a0f00; box-shadow: 0 8px 22px rgba(245, 158, 11, .35); }
.btn.gold:hover { filter: brightness(1.08); }
.btn.ghost { background: rgba(255, 255, 255, .07); border: 1px solid rgba(255, 255, 255, .14); }
.btn.ghost:hover { background: rgba(255, 255, 255, .12); }
.btn.danger { background: linear-gradient(135deg, #f87171, #dc2626); }

/* ---------- auth ---------- */
#scr-auth { align-items: center; justify-content: center; padding: 20px; }
.auth-card { position: relative; width: min(420px, 100%); border-radius: 22px; padding: 28px; display: flex; flex-direction: column; gap: 16px; }
.tabs { display: grid; grid-template-columns: 1fr 1fr; background: rgba(0, 0, 0, .3); border-radius: 12px; padding: 4px; gap: 4px; }
.tab { background: transparent; border: none; color: var(--mut); padding: 9px; border-radius: 9px; font-weight: 800; cursor: pointer; }
.tab.active { background: rgba(139, 92, 246, .3); color: #fff; }
#auth-form { display: flex; flex-direction: column; gap: 12px; }
label { display: flex; flex-direction: column; gap: 6px; font-size: 12px; font-weight: 700; color: var(--mut); }
input[type=text], input[type=password], input[type=email], input:not([type]) { background: rgba(0, 0, 0, .35); border: 1px solid rgba(255, 255, 255, .12); border-radius: 10px; padding: 12px 14px; color: #fff; font: 600 15px 'Inter', sans-serif; outline: none; transition: border-color .15s, box-shadow .15s; }
input:focus { border-color: var(--vio); box-shadow: 0 0 0 3px rgba(139, 92, 246, .25); }
.err { margin: 0; min-height: 16px; color: #fca5a5; font-size: 12.5px; font-weight: 600; }
.sep { display: flex; align-items: center; gap: 10px; color: var(--mut); font-size: 12px; }
.sep::before, .sep::after { content: ''; flex: 1; height: 1px; background: var(--line); }
.net-line { margin: 0; display: flex; align-items: center; justify-content: center; gap: 8px; font-size: 12px; color: var(--mut); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: #f59e0b; box-shadow: 0 0 8px currentColor; }
.dot.on { background: var(--green); } .dot.off { background: var(--red); }

/* ---------- lobby ---------- */
#scr-lobby { flex-direction: column; overflow-y: auto; }
.lobby-top { position: relative; display: flex; align-items: center; justify-content: space-between; padding: 18px 26px; gap: 12px; flex-wrap: wrap; }
.me-chip { display: flex; align-items: center; gap: 12px; padding: 8px 10px 8px 8px; border-radius: 16px; }
.me-chip b { display: block; font-size: 14px; } .me-chip small { color: var(--gold); font-weight: 800; font-size: 12px; }
.avatar { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; font-weight: 900; font-size: 16px; color: #fff; background: linear-gradient(135deg, #8b5cf6, #ec4899); flex: none; text-transform: uppercase; }
.avatar.big { width: 72px; height: 72px; border-radius: 18px; font-size: 28px; }
.lobby-grid { position: relative; display: grid; grid-template-columns: repeat(12, 1fr); gap: 18px; padding: 8px 26px 30px; max-width: 1180px; width: 100%; margin: 0 auto; }
.card { border-radius: 20px; padding: 22px; position: relative; overflow: hidden; }
.card h2 { margin: 6px 0 8px; font-size: 24px; font-weight: 900; } .card h3 { margin: 0 0 12px; font-size: 16px; }
.card p { margin: 0 0 14px; font-size: 13.5px; line-height: 1.5; color: #c9c9d1; }
.card-tag { display: inline-block; font-size: 10px; letter-spacing: .2em; font-weight: 900; padding: 4px 8px; border-radius: 6px; background: rgba(34, 197, 94, .18); color: #86efac; }
.card-tag.cpu { background: rgba(251, 191, 36, .16); color: #fcd34d; }
.play-online { grid-column: span 6; background: linear-gradient(160deg, rgba(109, 40, 217, .45), rgba(28, 14, 44, .75)); }
.play-ai { grid-column: span 6; background: linear-gradient(160deg, rgba(245, 158, 11, .22), rgba(28, 14, 44, .75)); }
.stats { grid-column: span 4; } .board { grid-column: span 4; } .theme { grid-column: span 4; }
.live-line { display: flex; align-items: center; gap: 8px; font-size: 13px; color: #d4d4d8; margin-bottom: 16px; }
.pulse { width: 9px; height: 9px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 0 rgba(34, 197, 94, .7); animation: pulse 1.6s infinite; }
@keyframes pulse { 70% { box-shadow: 0 0 0 10px rgba(34, 197, 94, 0); } 100% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0); } }
.levels { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 8px 0 16px; }
.levels button { background: rgba(0, 0, 0, .3); border: 1.5px solid rgba(255, 255, 255, .1); border-radius: 12px; padding: 12px 6px; color: #fff; cursor: pointer; display: flex; flex-direction: column; gap: 3px; align-items: center; transition: all .15s; }
.levels button small { color: var(--mut); font-size: 10.5px; }
.levels button.active { border-color: var(--gold); background: rgba(251, 191, 36, .14); box-shadow: 0 0 18px rgba(251, 191, 36, .2); }
.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.stat-grid div { background: rgba(0, 0, 0, .28); border-radius: 12px; padding: 12px; display: flex; flex-direction: column; gap: 2px; }
.stat-grid b { font-size: 22px; font-weight: 900; } .stat-grid small { color: var(--mut); font-size: 11px; }
#leaderboard { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 6px; counter-reset: lb; max-height: 260px; overflow-y: auto; }
#leaderboard li { display: flex; align-items: center; gap: 10px; background: rgba(0, 0, 0, .25); padding: 8px 10px; border-radius: 10px; font-size: 13px; counter-increment: lb; }
#leaderboard li:not(.muted)::before { content: counter(lb); width: 20px; font-weight: 900; color: var(--mut); }
#leaderboard li:nth-child(1)::before { color: #fcd34d; } #leaderboard li:nth-child(2)::before { color: #d4d4d8; } #leaderboard li:nth-child(3)::before { color: #f59e0b; }
#leaderboard li.me { outline: 1.5px solid var(--vio); }
#leaderboard .lb-name { flex: 1; font-weight: 700; } #leaderboard .lb-r { color: var(--gold); font-weight: 800; } #leaderboard .lb-wl { color: var(--mut); font-size: 11px; }
.swatches { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }
.swatches button { width: 42px; height: 42px; border-radius: 12px; border: 2px solid transparent; cursor: pointer; box-shadow: inset 0 -6px 12px rgba(0, 0, 0, .35); }
.swatches button.active { border-color: #fff; box-shadow: 0 0 16px rgba(255, 255, 255, .35), inset 0 -6px 12px rgba(0, 0, 0, .35); }
.switch { flex-direction: row; align-items: center; gap: 10px; cursor: pointer; color: #d4d4d8; font-size: 13px; }
.switch input { width: 18px; height: 18px; accent-color: var(--vio); }

@media (max-width: 900px) {
  .play-online, .play-ai { grid-column: span 12; }
  .stats, .board, .theme { grid-column: span 12; }
  .levels { grid-template-columns: repeat(2, 1fr); }
}

/* ================================================== GAME ================================================== */
#scr-game { flex-direction: column; background: #04020a; user-select: none; -webkit-user-select: none; }
.hud { height: var(--hud-h); flex: none; display: flex; align-items: center; justify-content: space-between; padding: 0 14px; background: #06030c; border-bottom: 1px solid rgba(255, 255, 255, .05); position: relative; z-index: 5; }
.hud-left, .hud-right { display: flex; align-items: center; gap: 8px; min-width: 170px; }
.hud-right { justify-content: flex-end; }
.icon-btn { background: transparent; border: none; color: #fff; cursor: pointer; padding: 7px; border-radius: 9px; display: grid; place-items: center; opacity: .9; }
.icon-btn:hover { background: rgba(255, 255, 255, .08); opacity: 1; }
.pill { display: flex; align-items: center; gap: 7px; background: #fff; color: #09060f; border: none; border-radius: 999px; padding: 5px 12px 5px 5px; font-weight: 900; font-size: 11.5px; letter-spacing: .05em; cursor: pointer; }
.pill-dot { width: 20px; height: 20px; border-radius: 50%; background: #6d4aff; color: #fff; display: grid; place-items: center; font-size: 11px; }
.mode-chip { font-size: 11px; font-weight: 800; letter-spacing: .12em; padding: 6px 10px; border-radius: 8px; background: rgba(255, 255, 255, .06); color: var(--mut); }

.hud-players { display: flex; align-items: center; gap: 14px; }
.player { display: flex; align-items: center; gap: 10px; transition: opacity .2s; opacity: .62; }
.player.turn { opacity: 1; }
.p-info { display: flex; flex-direction: column; gap: 3px; }
.p1 .p-info { align-items: flex-end; } .p2 .p-info { align-items: flex-start; }
.p-name { font-size: 13.5px; font-weight: 800; max-width: 160px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.p-sub { font-size: 10.5px; color: var(--gold); font-weight: 800; letter-spacing: .04em; }
.p-balls { display: flex; gap: 4px; }
.pip { width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center; position: relative; overflow: hidden; box-shadow: inset 0 -2px 4px rgba(0, 0, 0, .45), inset 0 1px 2px rgba(255, 255, 255, .5); }
.pip.empty { background: #3b1a5e !important; box-shadow: inset 0 2px 4px rgba(0, 0, 0, .5); }
.pip.gone { opacity: .22; filter: grayscale(.6); }
.pip b { position: relative; z-index: 2; width: 11px; height: 11px; border-radius: 50%; background: rgba(255, 255, 255, .9); color: #111; font-size: 7.5px; font-weight: 900; display: grid; place-items: center; }
.pip.stripe { background: #f5f2ea !important; }
.pip.stripe::before, .tray-ball.stripe::before { content: ''; position: absolute; inset: 0; background: var(--c); clip-path: inset(26% 0 26% 0); }
.ava { width: 50px; height: 50px; border-radius: 12px; padding: 2px; border: 2px solid rgba(255, 255, 255, .16); position: relative; transition: border-color .2s, box-shadow .2s; }
.ava span { width: 100%; height: 100%; border-radius: 9px; display: grid; place-items: center; font-weight: 900; font-size: 18px; background: linear-gradient(135deg, #8b5cf6, #ec4899); }
.player.turn .ava { border-color: #fff; box-shadow: 0 0 14px rgba(255, 255, 255, .45); }
.player.winner .ava { border-color: var(--gold); box-shadow: 0 0 18px rgba(251, 191, 36, .6); }
.ava svg { position: absolute; inset: -4px; width: calc(100% + 8px); height: calc(100% + 8px); transform: rotate(-90deg); pointer-events: none; }
.ava svg circle { fill: none; stroke: #fff; stroke-width: 3; stroke-linecap: round; transition: stroke .3s; }
.ava.low svg circle { stroke: var(--red); }
.vs { width: 50px; height: 50px; border-radius: 10px; background: #140a21; border: 1px solid rgba(255, 255, 255, .08); display: grid; place-items: center; font-weight: 900; font-size: 13px; font-variant-numeric: tabular-nums; }
.vs.urgent { color: var(--red); animation: urgent .5s infinite alternate; }
.vs.gg { color: var(--gold); }
@keyframes urgent { to { transform: scale(1.08); } }

.stage { flex: 1; display: flex; min-height: 0; position: relative; overflow: hidden; }

/* ---------- left controls ---------- */
.controls { position: relative; z-index: 2; width: 66px; flex: none; background: rgba(21, 10, 33, .92); border-right: 1px solid rgba(255, 255, 255, .05); display: flex; flex-direction: column; align-items: center; padding: 12px 0 14px; gap: 16px; }
.spin { width: 52px; height: 52px; border-radius: 50%; position: relative; display: grid; place-items: center; cursor: pointer; touch-action: none; flex: none; background: radial-gradient(circle at 32% 30%, #fff, #e6e2d8 68%, #b8b2a6); box-shadow: 0 4px 12px rgba(0, 0, 0, .6), inset 0 -3px 6px rgba(0, 0, 0, .25); }
.spin::after { content: ''; position: absolute; inset: 9px; border-radius: 50%; border: 1px dashed rgba(0, 0, 0, .18); pointer-events: none; }
.spin-dot { width: 11px; height: 11px; border-radius: 50%; border: 2.5px solid #dc2626; background: rgba(220, 38, 38, .25); pointer-events: none; transition: transform .05s linear; }
.spin-reset { position: absolute; right: -4px; bottom: -4px; width: 19px; height: 19px; border-radius: 6px; background: #6d3ab2; color: #fff; font-size: 10px; font-weight: 900; border: 1px solid rgba(255, 255, 255, .25); cursor: pointer; display: grid; place-items: center; padding: 0; }
.power { flex: 1; width: 26px; max-height: 420px; background: #09040e; border: 1.5px solid #27153b; border-radius: 7px; position: relative; overflow: hidden; display: flex; justify-content: center; cursor: ns-resize; touch-action: none; box-shadow: inset 0 3px 10px rgba(0, 0, 0, .85); }
.power-scale { position: absolute; inset: 0; background: linear-gradient(180deg, #e5c338 0%, #e59324 52%, #d13b27 100%); opacity: .18; transition: opacity .15s; }
.power.charging .power-scale { opacity: .95; }
.power-scale i { position: absolute; left: 3px; right: 3px; height: 2px; background: rgba(0, 0, 0, .7); }
.power-mask { position: absolute; top: 0; left: 0; right: 0; height: 100%; background: rgba(9, 4, 14, .82); pointer-events: none; }
.power-cue { width: 7px; height: 92%; margin-top: 8px; display: flex; flex-direction: column; align-items: center; pointer-events: none; z-index: 2; }
.power-cue i { display: block; }
.power-cue .tip { width: 5px; height: 5px; background: #e2e8f0; border-top: 2px solid #38bdf8; border-radius: 1px 1px 0 0; }
.power-cue .shaft { width: 5.5px; flex: 1.5; background: linear-gradient(90deg, #9c5720, #f3b271 50%, #874817); }
.power-cue .ring { width: 6px; height: 3px; background: #cbd5e1; }
.power-cue .butt { width: 6.5px; flex: 1; background: linear-gradient(90deg, #2e1305, #6e3414 50%, #240e03); }
.power-val { font-size: 11px; font-weight: 900; color: var(--mut); font-variant-numeric: tabular-nums; }
.controls.off .spin, .controls.off .power { opacity: .4; pointer-events: none; }

/* ---------- table ---------- */
.table-zone { position: relative; z-index: 1; flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: var(--top-room) 16px 6px; }
.table-and-return { position: relative; display: flex; align-items: stretch; justify-content: center; max-width: 100%; }
.table-wrap { position: relative; width: min(calc(100vw - 150px), calc((100vh - var(--hud-h) - var(--top-room) - 60px) * 1.8993)); aspect-ratio: 1056 / 556; isolation: isolate; }
#cv { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; cursor: crosshair; }
.table-glow { position: absolute; z-index: -1; inset: 6% 3%; border-radius: 40px; box-shadow: 0 0 110px 24px rgba(var(--tc), .3), 0 0 28px 2px rgba(var(--tc), .35); pointer-events: none; }
.under { width: min(calc(100vw - 150px), calc((100vh - var(--hud-h) - var(--top-room) - 60px) * 1.8993)); display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 34px; margin-top: 6px; }
.tray { display: none; gap: 3px; min-height: 26px; padding: 3px 8px; border-radius: 999px; background: rgba(0, 0, 0, .35); border: 1px solid rgba(255, 255, 255, .06); }
.tray-ball { width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center; position: relative; overflow: hidden; box-shadow: inset 0 -3px 5px rgba(0, 0, 0, .55), inset 0 2px 3px rgba(255, 255, 255, .55); animation: drop .45s cubic-bezier(.3, 1.6, .5, 1); }
.tray-ball.stripe { background: #f5f2ea !important; }
.tray-ball b { position: relative; z-index: 2; width: 10px; height: 10px; border-radius: 50%; background: rgba(255, 255, 255, .92); color: #111; font-size: 7px; font-weight: 900; display: grid; place-items: center; }
@keyframes drop { from { transform: translateY(-14px) scale(.6); opacity: 0; } }
.hint { margin: 0; font-size: 12.5px; color: var(--mut); text-align: right; }
.hint.warn { color: var(--gold); font-weight: 700; }

.banner { position: absolute; left: 50%; top: 50%; z-index: 20; transform: translate(-50%, -50%); padding: 12px 28px; border-radius: 999px; font-weight: 900; font-size: clamp(15px, 2.2vw, 22px); white-space: nowrap; background: rgba(10, 6, 18, .85); border: 2px solid rgba(255, 255, 255, .18); box-shadow: 0 6px 28px rgba(0, 0, 0, .45); pointer-events: none; opacity: 0; }
.banner.show { animation: banner 2.4s ease both; }
.banner.good { border-color: var(--gold); color: var(--gold); } .banner.foul { border-color: var(--red); color: #fecaca; } .banner.info { border-color: #60a5fa; color: #bfdbfe; }
@keyframes banner { 0% { opacity: 0; transform: translate(-50%, -50%) scale(.82); } 10% { opacity: 1; transform: translate(-50%, -50%) scale(1.06); } 18% { transform: translate(-50%, -50%) scale(1); } 80% { opacity: 1; } 100% { opacity: 0; transform: translate(-50%, -56%); } }
.thinking { position: absolute; left: 50%; bottom: 9%; transform: translateX(-50%); z-index: 15; display: flex; align-items: center; gap: 10px; padding: 8px 16px; border-radius: 999px; background: rgba(10, 6, 18, .8); border: 1px solid rgba(255, 255, 255, .14); font-size: 13px; font-weight: 700; pointer-events: none; }
.dots { display: flex; gap: 4px; } .dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--gold); animation: dots 1s infinite; }
.dots i:nth-child(2) { animation-delay: .15s; } .dots i:nth-child(3) { animation-delay: .3s; }
@keyframes dots { 50% { transform: translateY(-5px); opacity: .5; } }
.think-bar { width: 60px; height: 4px; border-radius: 4px; background: rgba(255, 255, 255, .12); overflow: hidden; }
.think-bar i { display: block; height: 100%; width: 0; background: var(--gold); transition: width .1s; }
.opp-off { position: absolute; left: 50%; top: 10%; transform: translateX(-50%); z-index: 15; padding: 8px 16px; border-radius: 999px; background: rgba(127, 29, 29, .85); border: 1px solid #f87171; font-size: 13px; font-weight: 700; }

/* ---------- chat ---------- */
.chat { position: fixed; right: 16px; bottom: 16px; z-index: 30; display: flex; flex-direction: column; align-items: flex-end; gap: 10px; }
.chat-panel { width: min(320px, 88vw); max-height: min(60vh, 430px); display: flex; flex-direction: column; border-radius: 14px; background: #1c0c2b; border: 1px solid rgba(168, 85, 247, .35); box-shadow: 0 18px 40px rgba(0, 0, 0, .65); overflow: hidden; }
.chat-head { display: flex; justify-content: space-between; align-items: center; padding: 10px 14px; background: rgba(168, 85, 247, .15); font-weight: 800; font-size: 13px; }
.chat-head button { background: transparent; border: none; color: #d4d4d8; cursor: pointer; }
.chat-quick { display: flex; gap: 5px; padding: 8px 10px 0; flex-wrap: wrap; }
.chat-quick button { background: rgba(255, 255, 255, .07); border: 1px solid rgba(255, 255, 255, .1); color: #e4e4e7; border-radius: 999px; padding: 4px 9px; font-size: 11.5px; cursor: pointer; }
.chat-msgs { flex: 1; overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 8px; min-height: 140px; }
.chat-row { display: flex; flex-direction: column; gap: 2px; align-items: flex-start; }
.chat-row.mine { align-items: flex-end; }
.chat-row small { font-size: 10px; color: var(--mut); }
.chat-row div { background: rgba(255, 255, 255, .08); padding: 7px 11px; border-radius: 11px; font-size: 12.5px; word-break: break-word; max-width: 240px; }
.chat-row.mine div { background: rgba(147, 51, 234, .4); }
.chat-empty { color: var(--mut); font-size: 12px; text-align: center; margin: auto; }
.chat-form { display: flex; gap: 6px; padding: 9px; border-top: 1px solid rgba(255, 255, 255, .08); }
.chat-form input { flex: 1; min-width: 0; padding: 8px 10px; font-size: 13px; }
.chat-form button { background: var(--vio2); color: #fff; border: none; border-radius: 8px; padding: 7px 12px; font-weight: 800; cursor: pointer; }
.chat-toggle { position: relative; background: #2b1244; color: #fff; border: 1px solid rgba(168, 85, 247, .45); border-radius: 999px; padding: 9px 15px; font-weight: 800; font-size: 13px; cursor: pointer; }
.badge { position: absolute; top: -6px; right: -6px; background: var(--red); color: #fff; font-size: 10px; min-width: 18px; height: 18px; border-radius: 999px; display: grid; place-items: center; padding: 0 4px; }

/* ---------- overlays ---------- */
.overlay { position: fixed; inset: 0; z-index: 80; display: grid; place-items: center; background: rgba(5, 2, 10, .78); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); padding: 20px; animation: fade .2s ease; }
@keyframes fade { from { opacity: 0; } }
.ov-card { border-radius: 22px; padding: 30px 34px; display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center; max-width: 460px; width: 100%; animation: pop .3s cubic-bezier(.3, 1.4, .5, 1); }
@keyframes pop { from { transform: scale(.88); opacity: 0; } }
.ov-card h2 { margin: 4px 0; font-size: 24px; font-weight: 900; }
.ov-card p { margin: 0; }
.ov-card .row { display: flex; gap: 10px; margin-top: 10px; flex-wrap: wrap; justify-content: center; }
.radar { position: relative; width: 120px; height: 120px; display: grid; place-items: center; margin-bottom: 8px; }
.radar i { position: absolute; inset: 0; border-radius: 50%; border: 2px solid rgba(var(--tc), .7); animation: radar 2.2s ease-out infinite; }
.radar i:nth-child(2) { animation-delay: .73s; } .radar i:nth-child(3) { animation-delay: 1.46s; }
@keyframes radar { from { transform: scale(.4); opacity: 1; } to { transform: scale(1.3); opacity: 0; } }
.found-row { display: flex; align-items: center; gap: 22px; margin-top: 8px; }
.found-p { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.found-p small { color: var(--gold); font-weight: 800; }
.found-vs { font-size: 26px; font-weight: 900; color: var(--gold); text-shadow: 0 0 20px rgba(251, 191, 36, .6); }
.result-icon { font-size: 58px; }
.result.win { border-color: var(--gold); } .result.lose { border-color: var(--red); }
.rating-delta { font-size: 18px; font-weight: 900; }
.rating-delta.up { color: var(--green); } .rating-delta.down { color: #f87171; }
.help ul { text-align: left; margin: 6px 0 10px; padding-left: 18px; font-size: 13.5px; line-height: 1.6; color: #d4d4d8; }

#toasts { position: fixed; top: 14px; left: 50%; transform: translateX(-50%); z-index: 100; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast { background: rgba(20, 10, 32, .95); border: 1px solid rgba(255, 255, 255, .14); padding: 10px 16px; border-radius: 12px; font-size: 13px; font-weight: 700; box-shadow: 0 10px 30px rgba(0, 0, 0, .5); animation: toast 3.2s ease both; }
.toast.err { border-color: var(--red); } .toast.ok { border-color: var(--green); }
@keyframes toast { 0% { opacity: 0; transform: translateY(-10px); } 8%, 85% { opacity: 1; transform: none; } 100% { opacity: 0; } }

@media (max-width: 760px) {
  :root { --hud-h: 62px; }
  .hud-left, .hud-right { min-width: 0; } .hud-right { display: none; } .pill { display: none; }
  .p-name { max-width: 80px; font-size: 12px; } .pip { width: 14px; height: 14px; } .pip b { display: none; } .ava { width: 38px; height: 38px; } .vs { width: 40px; height: 40px; }
  .controls { width: 54px; } .spin { width: 44px; height: 44px; }
  .table-zone { padding: 6px; }
  .hint { display: none; }
}
@media (max-width: 700px) { .ball-return, .chute-svg, .chute-layer { display: none; } .tray { display: flex; } }
@media (orientation: portrait) and (max-width: 760px) {
  .stage { flex-direction: column-reverse; }
  .controls { width: 100%; height: 70px; flex-direction: row; padding: 8px 14px; border-right: none; border-top: 1px solid rgba(255, 255, 255, .05); }
  .power { height: 26px; width: auto; flex: 1; max-height: none; cursor: ew-resize; }
  .power-cue { display: none; }
  .power-mask { height: 100%; }
  .table-wrap, .under { width: 100%; }
}
@media (max-height: 520px) {
  :root { --hud-h: 56px; --top-room: 4px; }
  .table-wrap, .under { width: min(calc(100vw - 80px), calc((100vh - var(--hud-h) - 22px) * 1.8993)); }
  .bar-lamps { display: none; }
  .under { position: absolute; bottom: 4px; left: 50%; transform: translateX(-50%); margin: 0; pointer-events: none; }
  .table-zone { padding: 4px 8px; }
  .hint { display: none; }
}
@media (prefers-reduced-motion: reduce) { .bg-orbs i, .pulse, .radar i { animation: none; } }

/* ================= BAR AMBIENCE + LAMPS (taken from the original component) ================= */
.bar-bg {
  position: absolute; inset: 0; z-index: 0; overflow: hidden; pointer-events: none;
  background:
    radial-gradient(ellipse 64% 60% at 50% 55%, rgba(var(--tc), .22), rgba(var(--tc), .06) 52%, transparent 76%),
    radial-gradient(ellipse 120% 70% at 50% -12%, rgba(255, 170, 90, .12), transparent 62%),
    linear-gradient(180deg, #190d29 0%, #0c0714 36%, #030106 100%);
}
.bar-static { position: absolute; inset: 0; }
.bar-wall {
  position: absolute; inset: 0;
  background: repeating-linear-gradient(90deg, rgba(255,255,255,.028) 0 1px, transparent 1px 46px);
  -webkit-mask-image: linear-gradient(180deg, #000, transparent 72%); mask-image: linear-gradient(180deg, #000, transparent 72%);
}
.bar-shelf {
  position: absolute; left: 0; right: 0; top: 4px; height: 92px; opacity: .45;
  background: url('data:image/svg+xml;base64,PHN2ZyB4bWxucz0naHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmcnIHdpZHRoPSc0MjAnIGhlaWdodD0nOTInIHZpZXdCb3g9JzAgMCA0MjAgOTInPjxkZWZzPjxsaW5lYXJHcmFkaWVudCBpZD0nZycgeDE9JzAnIHgyPScxJz48c3RvcCBvZmZzZXQ9JzAnIHN0b3AtY29sb3I9JyNmZmMyN2EnIHN0b3Atb3BhY2l0eT0nLjQyJy8+PHN0b3Agb2Zmc2V0PScxJyBzdG9wLWNvbG9yPScjZmZjMjdhJyBzdG9wLW9wYWNpdHk9Jy4wNycvPjwvbGluZWFyR3JhZGllbnQ+PC9kZWZzPjxnIGZpbGw9J3VybCgjZyknPjxyZWN0IHg9JzE0JyB5PSczMCcgd2lkdGg9JzIwJyBoZWlnaHQ9JzU0JyByeD0nNCcvPjxyZWN0IHg9JzIwJyB5PScxMicgd2lkdGg9JzgnIGhlaWdodD0nMjInIHJ4PScyJy8+PHJlY3QgeD0nNTQnIHk9JzE4JyB3aWR0aD0nMjQnIGhlaWdodD0nNjYnIHJ4PSc1Jy8+PHJlY3QgeD0nNjInIHk9JzQnIHdpZHRoPSc4JyBoZWlnaHQ9JzE4JyByeD0nMicvPjxwYXRoIGQ9J00xMDAgODRWNTBRMTAwIDQwIDEwOCAzNlYxNkgxMThWMzZRMTI2IDQwIDEyNiA1MFY4NFonLz48cmVjdCB4PScxNDYnIHk9JzQ2JyB3aWR0aD0nMzAnIGhlaWdodD0nMzgnIHJ4PSc0Jy8+PHJlY3QgeD0nMTk2JyB5PScyNCcgd2lkdGg9JzE4JyBoZWlnaHQ9JzYwJyByeD0nNCcvPjxyZWN0IHg9JzIwMScgeT0nMTAnIHdpZHRoPSc4JyBoZWlnaHQ9JzE2JyByeD0nMicvPjxwYXRoIGQ9J00yMzIgODRMMjM4IDUySDI2MkwyNjggODRaJy8+PHJlY3QgeD0nMjg2JyB5PSczNCcgd2lkdGg9JzIyJyBoZWlnaHQ9JzUwJyByeD0nNScvPjxyZWN0IHg9JzI5MScgeT0nMTYnIHdpZHRoPScxMicgaGVpZ2h0PScyMCcgcng9JzInLz48cGF0aCBkPSdNMzMwIDg0VjQ4UTMzMCAzOCAzMzggMzRWMTJIMzQ4VjM0UTM1NiAzOCAzNTYgNDhWODRaJy8+PHJlY3QgeD0nMzc2JyB5PScyNicgd2lkdGg9JzI2JyBoZWlnaHQ9JzU4JyByeD0nNScvPjxyZWN0IHg9JzM4MycgeT0nOCcgd2lkdGg9JzEyJyBoZWlnaHQ9JzIwJyByeD0nMicvPjwvZz48cmVjdCB4PScwJyB5PSc4NCcgd2lkdGg9JzQyMCcgaGVpZ2h0PSczJyBmaWxsPScjZmZjMjdhJyBmaWxsLW9wYWNpdHk9Jy4zMCcvPjwvc3ZnPg==') repeat-x center bottom / auto 92px;
}
.bar-shelf::after {
  content: ''; position: absolute; left: 0; right: 0; bottom: -4px; height: 4px;
  background: linear-gradient(90deg, transparent, rgba(255,176,80,.65) 18%, rgba(255,176,80,.65) 82%, transparent); filter: blur(2.5px);
}
.bar-floor { position: absolute; left: 0; right: 0; bottom: 0; height: 24%; background: linear-gradient(0deg, rgba(var(--tc), .12), transparent); }
.bar-bokeh {
  position: absolute; border-radius: 50%; opacity: var(--ba, .4); filter: blur(var(--bl, 6px));
  animation: barBokeh var(--bd, 12s) ease-in-out var(--bdl, 0s) infinite alternate; will-change: transform, opacity;
}
@keyframes barBokeh { from { transform: translate(0, 0) scale(1); } to { transform: translate(12px, -16px) scale(1.14); opacity: calc(var(--ba, .4) * .5); } }

.bar-neon {
  position: absolute; top: 12px; padding: 3px 14px 2px; border: 2px solid rgba(var(--tc), .95); border-radius: 10px;
  font: 900 20px/1.2 'Inter', sans-serif; letter-spacing: .22em; color: #fff; white-space: nowrap;
  text-shadow: 0 0 3px #fff, 0 0 9px rgba(var(--tc), 1), 0 0 20px rgba(var(--tc), .9), 0 0 38px rgba(var(--tc), .7);
  box-shadow: 0 0 8px rgba(var(--tc), .85), inset 0 0 9px rgba(var(--tc), .55), 0 0 30px rgba(var(--tc), .4);
  animation: barNeon 7s linear infinite; opacity: .95;
}
.bar-neon.left { left: 96px; }
.bar-neon.right { right: 28px; --tc: 255, 150, 60; animation-delay: -3.1s; }
@keyframes barNeon { 0%, 17%, 22%, 58%, 100% { opacity: .95; } 19% { opacity: .45; } 60% { opacity: .65; } 62% { opacity: .95; } 63.5% { opacity: .5; } 65% { opacity: .95; } }
@media (max-width: 1100px), (max-height: 700px) { .bar-neon { display: none; } }

.table-light {
  position: absolute; inset: 0; pointer-events: none; border-radius: 3% / 5.5%;
  background:
    radial-gradient(ellipse 25% 64% at 20% 52%, rgba(255, 244, 214, .10), transparent 72%),
    radial-gradient(ellipse 25% 64% at 50% 52%, rgba(255, 244, 214, .12), transparent 72%),
    radial-gradient(ellipse 25% 64% at 80% 52%, rgba(255, 244, 214, .10), transparent 72%),
    radial-gradient(ellipse 82% 92% at 50% 50%, transparent 54%, rgba(0, 0, 14, .34) 100%);
}
.bar-lamps { position: absolute; inset: 0; pointer-events: none; }
.bar-lamp {
  position: absolute; top: 0; width: 46%; height: 100%; transform-origin: 50% -230px;
  animation: barSway 7.5s ease-in-out var(--ld, 0s) infinite alternate; will-change: transform;
}
@keyframes barSway { from { transform: rotate(-.4deg); } to { transform: rotate(.4deg); } }
.lamp-cord { position: absolute; left: 50%; top: -230px; width: 2px; height: 196px; margin-left: -1px; background: linear-gradient(180deg, #050308, #41345a 70%, #62507d); }
.lamp-halo { position: absolute; left: 50%; top: -92px; width: 250px; height: 96px; margin-left: -125px; background: radial-gradient(ellipse at 50% 58%, rgba(255, 226, 160, .55), rgba(255, 200, 120, .16) 45%, transparent 70%); }
.lamp-shade { position: absolute; left: 50%; top: -38px; width: 86px; height: 28px; margin-left: -43px; clip-path: polygon(33% 0, 67% 0, 100% 100%, 0 100%); background: linear-gradient(180deg, #62507d, #2c1f40 55%, #140c21); }
.lamp-bulb { position: absolute; left: 50%; top: -15px; width: 50px; height: 11px; margin-left: -25px; border-radius: 50%; background: radial-gradient(ellipse at 50% 40%, #fffaf0 0%, #ffe6a8 45%, rgba(255, 200, 110, 0) 76%); filter: blur(.8px); }
.lamp-cone { position: absolute; left: 0; right: 0; top: -8px; bottom: 0; filter: blur(13px); }
.lamp-cone b { position: absolute; inset: 0; clip-path: polygon(41% 0, 59% 0, 100% 100%, 0 100%); background: linear-gradient(180deg, rgba(255, 238, 200, .22) 0%, rgba(255, 232, 190, .075) 38%, rgba(255, 226, 180, .015) 100%); }
.lamp-mote {
  position: absolute; left: var(--ml, 50%); top: 4px; width: 3px; height: 3px; border-radius: 50%; background: rgba(255, 244, 214, .9); opacity: 0;
  animation: barMote var(--mt, 12s) linear var(--md, 0s) infinite; will-change: transform, opacity;
}
@keyframes barMote { 0% { transform: translate(0, 0); opacity: 0; } 12% { opacity: .6; } 78% { opacity: .35; } 100% { transform: translate(var(--dx, 20px), 340px); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .bar-lamp, .bar-bokeh, .lamp-mote, .bar-neon { animation: none; } }
.bar-bokeh-wrap, #bar-bokeh { position: absolute; inset: 0; }

/* ================= ball-return chute (track drawn by chute.js) ================= */
.table-wrap { z-index: 1; }
.ball-return { position: relative; width: 52px; align-self: stretch; margin-left: 10px; pointer-events: none; }
.chute-svg { position: absolute; left: 0; top: 0; z-index: 0; pointer-events: none; overflow: visible; }
.chute-layer { position: absolute; inset: 0; z-index: 6; pointer-events: none; }
.chute-ball { width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; box-shadow: inset -3px -4px 6px rgba(0,0,0,.5), inset 2px 2px 3px rgba(255,255,255,.55), 0 2px 4px rgba(0,0,0,.6); position: relative; overflow: hidden; }
.chute-ball.chute-abs { position: absolute; left: 0; top: 0; will-change: transform; }
.chute-ball.stripe { background: #f5f2ea !important; }
.chute-ball.stripe::before { content: ''; position: absolute; inset: 0; background: var(--c); clip-path: inset(25% 0 25% 0); }
.chute-ball b { position: relative; z-index: 2; width: 12px; height: 12px; border-radius: 50%; background: rgba(255,255,255,.92); color: #111; font-size: 8.5px; font-weight: 900; display: grid; place-items: center; }

/* ================= history ================= */
.history { grid-column: span 12; }
#history { margin: 0; padding: 0; list-style: none; display: grid; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); gap: 8px; }
#history li { display: grid; grid-template-columns: 28px 1fr auto; column-gap: 10px; align-items: center; background: rgba(0, 0, 0, .25); padding: 8px 12px; border-radius: 10px; font-size: 13px; border-left: 3px solid transparent; }
#history li.muted { display: block; }
#history li.win { border-left-color: var(--green); } #history li.loss { border-left-color: var(--red); }
#history .h-res { grid-row: span 2; width: 26px; height: 26px; border-radius: 8px; display: grid; place-items: center; font-weight: 900; }
#history li.win .h-res { background: rgba(34, 197, 94, .2); color: #86efac; } #history li.loss .h-res { background: rgba(239, 68, 68, .2); color: #fca5a5; }
#history .h-opp { font-weight: 800; } #history .h-opp small { color: var(--gold); font-weight: 700; }
#history .h-why { color: var(--mut); font-size: 11.5px; grid-column: 2; }
#history .h-d { font-weight: 900; text-align: right; } #history .h-d.up { color: var(--green); } #history .h-d.down { color: #f87171; }
#history .h-d { grid-column: 3; grid-row: 1; }
#history time { color: var(--mut); font-size: 11px; text-align: right; grid-column: 3; grid-row: 2; }
.sw-auto { background: conic-gradient(#1aa3f0, #22c55e, #f59e0b, #ef4444, #a855f7, #1aa3f0) !important; color: #fff; font-size: 9px; font-weight: 900; text-shadow: 0 1px 2px #000; }
