/* Omega Billiard – Moderne Neon-Lounge (Dunkler Schiefer & feine Lichtakzente) */
:root {
  --bg-dark: #080c14;
  --bg-panel: rgba(15, 23, 38, 0.88);
  --bg-panel-solid: #101828;
  --bg-card: rgba(20, 31, 50, 0.84);
  --border: rgba(125, 211, 252, 0.16);
  --border-strong: rgba(56, 189, 248, 0.48);
  --gold: #f5c518;
  --gold-soft: #e6bf67;
  --emerald: #22c55e;
  --neon-cyan: #38bdf8;
  --neon-violet: #a855f7;
  --danger: #f87171;
  --text: #f1f5f9;
  --muted: #94a3b8;
  --radius: 14px;
  --shadow: 0 18px 42px rgba(0, 0, 0, 0.56);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: radial-gradient(circle at 50% 0%, #131d33 0%, #0a101d 55%, #060911 100%);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
}

.bar-ambient {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(ellipse 46% 34% at 0% 10%, rgba(56, 189, 248, 0.11), transparent 72%),
    radial-gradient(ellipse 42% 36% at 100% 12%, rgba(168, 85, 247, 0.1), transparent 72%),
    radial-gradient(ellipse 45% 32% at 8% 96%, rgba(34, 197, 94, 0.08), transparent 70%),
    radial-gradient(ellipse 44% 34% at 96% 94%, rgba(56, 189, 248, 0.09), transparent 72%),
    radial-gradient(circle at 50% 48%, rgba(255, 255, 255, 0.025), transparent 60%);
  z-index: 0;
}

.hidden {
  display: none !important;
}

/* TOPBAR */
.topbar {
  position: relative;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 20px;
  background: rgba(8, 12, 20, 0.88);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(12px);
}

.brand {
  display: inline-flex;
  align-items: center;
  cursor: pointer;
  user-select: none;
  border-radius: 9999px;
}

.brand:focus-visible {
  outline: 2px solid #8cb3ff;
  outline-offset: 4px;
}

.brand-emblem {
  --brand-stroke: 3px;
  position: relative;
  display: inline-flex;
  align-items: center;
  padding-inline-end: 14px;
  border: var(--brand-stroke) solid transparent;
  border-radius: 9999px;
  transition: transform 200ms cubic-bezier(0.23, 1, 0.32, 1);
}

.brand:hover .brand-emblem {
  transform: scale(1.02);
}

.brand:active .brand-emblem {
  transform: scale(0.98);
}

.brand-emblem-circle {
  position: relative;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: var(--brand-stroke) solid transparent;
  margin-block: calc(-1 * var(--brand-stroke));
  margin-inline-start: calc(-1 * var(--brand-stroke));
  margin-inline-end: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2;
  flex-shrink: 0;
}

.brand-emblem,
.brand-emblem-circle {
  background:
    linear-gradient(#05050d, #05050d) padding-box,
    linear-gradient(90deg, #ff004c 0%, #ffaa00 16.667%, #00ff66 33.333%, #00eaff 50%, #355cff 66.667%, #a600ff 83.333%, #ff004c 100%) border-box;
  background-size: 100% 100%, 300px 100%;
  background-repeat: no-repeat, repeat-x;
  background-position: 0 0, 0px 50%;
  animation: rainbowEmblemFlow 7.5s linear infinite;
  filter: drop-shadow(0 0 3px rgba(140, 179, 255, 0.4));
}

.brand-emblem-img-wrap {
  position: relative;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  overflow: hidden;
  background: #05050d;
}

.brand-logo {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
  display: block;
}

.brand-emblem-frame {
  position: relative;
  min-height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1;
  flex-shrink: 0;
}

.brand-emblem-title {
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: #f4f6fb;
  white-space: nowrap;
}

.brand-emblem-sub {
  font-weight: 400;
  color: var(--muted);
}

@keyframes rainbowEmblemFlow {
  0% {
    background-position: 0 0, 0px 50%;
  }
  100% {
    background-position: 0 0, 300px 50%;
  }
}

@media (prefers-reduced-motion: reduce) {
  .brand-emblem,
  .brand-emblem-circle {
    animation: none;
    background-position: 0 0, 0% 50%;
  }
  .brand-emblem {
    transform: none;
    transition: none;
  }
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.conn-pill {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 5px 11px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.09);
  font-size: 0.78rem;
  color: var(--muted);
}

.conn-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #f59e0b;
}

.conn-pill.online .conn-dot {
  background: #4ade80;
  box-shadow: 0 0 8px #4ade80;
}

.conn-pill.offline .conn-dot {
  background: #f87171;
}

/* BUTTONS & INPUTS */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: none;
  border-radius: 10px;
  padding: 10px 16px;
  font-size: 0.92rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.12s ease, filter 0.15s ease, background 0.15s ease;
  color: var(--text);
  white-space: nowrap;
}

.btn:hover:not(:disabled) {
  filter: brightness(1.08);
  transform: translateY(-1px);
}

.btn:active:not(:disabled) {
  transform: translateY(0);
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-gold {
  background: linear-gradient(135deg, #f7d154, #c98f22);
  color: #1f1107;
  box-shadow: 0 4px 16px rgba(245, 197, 24, 0.25);
}

.btn-emerald {
  background: linear-gradient(135deg, #22c55e, #15803d);
  color: #062110;
}

.btn-ghost {
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid var(--border);
  color: var(--text);
}

.btn-dark {
  background: rgba(15, 9, 6, 0.75);
  border: 1px solid rgba(255, 255, 255, 0.13);
  color: var(--text);
}

.btn-dark.active-lock {
  background: rgba(245, 197, 24, 0.22);
  border-color: var(--gold);
  color: #fde68a;
}

.btn-sm {
  padding: 7px 12px;
  font-size: 0.84rem;
}

.btn-xs {
  padding: 5px 9px;
  font-size: 0.78rem;
  border-radius: 8px;
}

.icon-btn {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  cursor: pointer;
  font-size: 1rem;
  display: grid;
  place-items: center;
}

.link-btn {
  background: none;
  border: none;
  color: var(--gold-soft);
  font-size: 0.74rem;
  cursor: pointer;
  text-decoration: underline;
}

input[type="text"],
select {
  background: rgba(12, 7, 5, 0.78);
  border: 1px solid rgba(218, 175, 86, 0.3);
  color: var(--text);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 0.92rem;
  outline: none;
  width: 100%;
}

input[type="text"]:focus,
select:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(245, 197, 24, 0.15);
}

.muted {
  color: var(--muted);
  font-size: 0.85rem;
}

/* ==================== LOBBY HUB ==================== */
.lobby-view {
  position: relative;
  z-index: 2;
  max-width: 1220px;
  margin: 0 auto;
  padding: 24px 20px 44px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.lobby-hero {
  display: grid;
  grid-template-columns: 1.35fr 1fr;
  gap: 16px;
}

.player-identity-card,
.join-code-card,
.panel {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(8px);
}

.player-identity-card label,
.join-code-card label {
  display: block;
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--gold-soft);
  margin-bottom: 8px;
}

.identity-row {
  display: flex;
  gap: 10px;
}

.code-input {
  text-transform: uppercase;
  letter-spacing: 3px;
  font-weight: 800;
  text-align: center;
}

.lobby-grid {
  display: grid;
  grid-template-columns: 1.5fr 1fr;
  gap: 20px;
  align-items: start;
}

.panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.panel-header h2 {
  font-size: 1.12rem;
  color: #fbe6b0;
  margin-bottom: 3px;
}

.rooms-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 220px;
}

.empty-state {
  text-align: center;
  padding: 40px 20px;
  border: 1px dashed rgba(218, 175, 86, 0.25);
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.empty-icon {
  font-size: 2.2rem;
}

.room-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px 16px;
  background: var(--bg-card);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  transition: border-color 0.15s ease;
}

.room-row:hover {
  border-color: var(--border-strong);
}

.room-info {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.room-title-line {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.room-name {
  font-weight: 700;
  font-size: 1rem;
}

.room-status-pill {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
}

.room-status-pill.waiting {
  background: rgba(34, 197, 94, 0.18);
  color: #86efac;
  border: 1px solid rgba(34, 197, 94, 0.4);
}

.room-status-pill.playing {
  background: rgba(245, 197, 24, 0.16);
  color: #fde68a;
  border: 1px solid rgba(245, 197, 24, 0.35);
}

.room-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tag {
  font-size: 0.74rem;
  padding: 2px 8px;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.35);
  color: var(--muted);
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.quickplay-cards {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.qp-card {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  text-align: left;
  padding: 13px 14px;
  border-radius: 12px;
  background: var(--bg-card);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--text);
  cursor: pointer;
  transition: all 0.15s ease;
}

.qp-card:hover {
  border-color: var(--gold);
  background: rgba(66, 40, 26, 0.9);
  transform: translateX(3px);
}

.qp-icon {
  font-size: 1.7rem;
  width: 42px;
  height: 42px;
  border-radius: 10px;
  background: rgba(245, 197, 24, 0.12);
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.qp-card strong {
  display: block;
  font-size: 0.96rem;
  margin-bottom: 2px;
}

.qp-card span {
  font-size: 0.8rem;
  color: var(--muted);
}

.tip-box {
  margin-top: 16px;
  padding: 12px 14px;
  border-radius: 10px;
  background: rgba(245, 197, 24, 0.07);
  border: 1px solid rgba(245, 197, 24, 0.2);
  font-size: 0.82rem;
  line-height: 1.5;
}

.tip-box ul {
  margin-top: 6px;
  padding-left: 18px;
  color: var(--muted);
}

/* ==================== GAME VIEW ==================== */
.game-view {
  position: relative;
  z-index: 2;
  max-width: 1680px;
  width: 100%;
  height: calc(100dvh - 65px);
  margin: 0 auto;
  padding: 10px 14px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow: hidden;
}

.waiting-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  padding: 7px 14px;
  border-radius: 12px;
  background: linear-gradient(90deg, rgba(16, 185, 129, 0.2), rgba(15, 23, 38, 0.92));
  border: 1px solid rgba(52, 211, 153, 0.36);
  flex-shrink: 0;
}

.waiting-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.waiting-left strong {
  display: block;
  color: #bbf7d0;
  font-size: 0.95rem;
}

.waiting-left span {
  font-size: 0.82rem;
  color: #d6e4da;
}

.pulse-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #4ade80;
  box-shadow: 0 0 0 0 rgba(74, 222, 128, 0.7);
  animation: pulseRing 1.7s infinite;
  flex-shrink: 0;
}

@keyframes pulseRing {
  0% { box-shadow: 0 0 0 0 rgba(74, 222, 128, 0.7); }
  70% { box-shadow: 0 0 0 11px rgba(74, 222, 128, 0); }
  100% { box-shadow: 0 0 0 0 rgba(74, 222, 128, 0); }
}

.waiting-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.code-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.45);
  border: 1px solid var(--gold);
  font-size: 0.8rem;
}

.code-badge strong {
  letter-spacing: 2.5px;
  color: var(--gold);
  font-size: 0.98rem;
}

.mini-select {
  width: auto !important;
  padding: 6px 10px !important;
  font-size: 0.8rem !important;
}

.game-layout {
  display: grid;
  grid-template-columns: 248px minmax(0, 1fr) 290px;
  gap: 12px;
  align-items: stretch;
  flex: 1;
  min-height: 0;
}

.game-layout.no-chat {
  grid-template-columns: 248px minmax(0, 1fr);
  max-width: 1520px;
  margin: 0 auto;
  width: 100%;
}

.table-column {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
  min-height: 0;
  height: 100%;
}

/* SCOREBOARD */
.scoreboard {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 10px;
  align-items: center;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 6px 12px;
  flex-shrink: 0;
}

.player-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 10px;
  background: rgba(5, 10, 20, 0.42);
  border: 1.5px solid transparent;
  transition: all 0.2s ease;
}

.player-card.active-turn {
  border-color: var(--gold);
  background: rgba(245, 197, 24, 0.11);
  box-shadow: 0 0 18px rgba(245, 197, 24, 0.16);
}

.player-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.turn-indicator {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.18);
  flex-shrink: 0;
}

.player-card.active-turn .turn-indicator {
  background: var(--gold);
  box-shadow: 0 0 10px var(--gold);
}

.player-name {
  font-weight: 700;
  font-size: 1.05rem;
  color: #f8fafc;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.group-badge {
  font-size: 0.84rem;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.1);
  color: #fde68a;
  white-space: nowrap;
}

.player-balls {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
}

.mini-ball {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  font-size: 10px;
  font-weight: 800;
  display: grid;
  place-items: center;
  color: #111;
  border: 1px solid rgba(0, 0, 0, 0.5);
  box-shadow: inset -2px -2px 3px rgba(0,0,0,0.3);
}

.mini-ball.potted {
  opacity: 0.22;
  filter: grayscale(1);
}

.player-score {
  font-size: 1.55rem;
  font-weight: 800;
  color: var(--gold);
  min-width: 26px;
  text-align: center;
}

.match-center {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 0 8px;
}

.match-mode-tag {
  font-size: 0.82rem;
  letter-spacing: 1.2px;
  font-weight: 800;
  color: #fde68a;
}

.timer-display {
  font-size: 1.2rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  padding: 2px 12px;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.42);
  color: #f8fafc;
  min-width: 62px;
}

.timer-display.urgent {
  color: #fca5a5;
  background: rgba(220, 38, 38, 0.3);
  animation: blinkUrgent 0.8s infinite alternate;
}

@keyframes blinkUrgent {
  from { opacity: 1; }
  to { opacity: 0.55; }
}

.match-sub-tag {
  font-size: 0.84rem;
  color: #cbd5e1;
}

/* STATUS BAR */
.status-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 14px;
  border-radius: 10px;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  font-size: 0.95rem;
  font-weight: 500;
  color: #f8fafc;
  flex-shrink: 0;
}

.status-bar.foul {
  border-color: rgba(248, 113, 113, 0.55);
  background: rgba(127, 29, 29, 0.32);
  color: #fecaca;
}

.status-right-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

/* CANVAS */
.canvas-shell {
  position: relative;
  flex: 1;
  min-height: 0;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 18px;
  overflow: hidden;
  background: transparent;
  user-select: none;
  touch-action: none;
}

#poolCanvas {
  display: block;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 100%;
  aspect-ratio: 1016 / 556;
  border-radius: 16px;
  box-shadow: 0 22px 54px rgba(0, 0, 0, 0.68), 0 0 0 1px rgba(125, 211, 252, 0.14);
  cursor: crosshair;
}

/* OVERLAY */
.match-overlay {
  position: absolute;
  inset: 0;
  background: rgba(6, 9, 17, 0.8);
  backdrop-filter: blur(6px);
  display: grid;
  place-items: center;
  z-index: 20;
}

.overlay-card {
  background: var(--bg-panel-solid);
  border: 1.5px solid var(--gold);
  border-radius: 18px;
  padding: 28px 34px;
  text-align: center;
  max-width: 390px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.7);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.overlay-trophy {
  font-size: 3rem;
}

.overlay-btns {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin-top: 8px;
}

/* CONTROLS SIDEBAR (LINKS NEBEN DEM TISCH) */
.controls-dock {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 10px;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  height: 100%;
  min-height: 0;
  overflow-y: auto;
  backdrop-filter: blur(10px);
}

.ctrl-group {
  display: flex;
  flex-direction: column;
  gap: 7px;
  padding-bottom: 10px;
  border-bottom: 1px solid rgba(125, 211, 252, 0.1);
}

.ctrl-group:last-child {
  padding-bottom: 0;
  border-bottom: none;
}

.ctrl-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 0.86rem;
  font-weight: 700;
  color: #cbd5e1;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.ctrl-hint {
  font-size: 0.82rem;
  color: #cbd5e1;
  text-align: center;
  line-height: 1.3;
}

.full-btn {
  width: 100%;
  font-size: 0.92rem;
  padding: 9px 12px;
}

.angle-readout,
.power-readout {
  font-size: 0.98rem;
  color: var(--gold);
  font-variant-numeric: tabular-nums;
}

.aim-buttons-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}

.aim-buttons-row .btn-xs {
  font-size: 0.86rem;
  padding: 7px 4px;
}

.power-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

#powerSlider {
  width: 100%;
  accent-color: var(--gold);
  height: 10px;
  cursor: pointer;
}

.shoot-btn {
  min-width: 98px;
  font-size: 0.95rem;
  letter-spacing: 0.8px;
}

.spin-widget-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
}

.spin-ball {
  position: relative;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 32%, #ffffff, #dcd7cc 70%, #aba292);
  border: 2px solid rgba(245, 197, 24, 0.65);
  cursor: crosshair;
  flex-shrink: 0;
}

.spin-label {
  font-size: 0.92rem;
  font-weight: 600;
  color: #f1f5f9;
}

.spin-cross-h,
.spin-cross-v {
  position: absolute;
  background: rgba(0, 0, 0, 0.16);
  pointer-events: none;
}

.spin-cross-h {
  left: 6px;
  right: 6px;
  top: 50%;
  height: 1px;
}

.spin-cross-v {
  top: 6px;
  bottom: 6px;
  left: 50%;
  width: 1px;
}

.spin-dot {
  position: absolute;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #dc2626;
  border: 1.5px solid #fff;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
}

.spin-label {
  font-size: 0.76rem;
  color: var(--muted);
  min-width: 58px;
}

.felt-dots {
  display: flex;
  align-items: center;
  gap: 7px;
}

.felt-dot {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.25);
  cursor: pointer;
}

.felt-dot.active {
  border-color: var(--gold);
  box-shadow: 0 0 10px rgba(245, 197, 24, 0.55);
}

.felt-green { background: #146c43; }
.felt-blue { background: #16557d; }
.felt-burgundy { background: #751d30; }

/* CHAT PANEL */
.chat-panel {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  backdrop-filter: blur(10px);
}

.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.25);
}

.chat-header h3 {
  font-size: 0.96rem;
  color: #fbe6b0;
}

.chat-room-meta {
  font-size: 0.74rem;
  color: var(--muted);
}

.chat-close-mobile {
  display: none;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.chat-msg {
  padding: 8px 10px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.06);
  font-size: 0.85rem;
  line-height: 1.35;
  word-break: break-word;
}

.chat-msg.mine {
  background: rgba(245, 197, 24, 0.14);
  border: 1px solid rgba(245, 197, 24, 0.25);
  align-self: flex-end;
  max-width: 90%;
}

.chat-msg.theirs {
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.08);
  align-self: flex-start;
  max-width: 90%;
}

.chat-msg.system {
  background: rgba(34, 197, 94, 0.11);
  border: 1px solid rgba(34, 197, 94, 0.24);
  color: #d1fae5;
  font-size: 0.79rem;
  text-align: center;
}

.chat-msg-head {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 0.72rem;
  color: var(--gold-soft);
  margin-bottom: 3px;
}

.chat-time {
  color: var(--muted);
}

.quick-chat-bar {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
  padding: 8px 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.07);
  background: rgba(0, 0, 0, 0.18);
}

.quick-chip {
  border: 1px solid rgba(218, 175, 86, 0.25);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  font-size: 0.73rem;
  padding: 4px 8px;
  border-radius: 999px;
  cursor: pointer;
}

.quick-chip:hover {
  border-color: var(--gold);
  background: rgba(245, 197, 24, 0.15);
}

.chat-form {
  display: flex;
  gap: 6px;
  padding: 10px;
  border-top: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.28);
}

.chat-form input {
  padding: 8px 10px;
  font-size: 0.85rem;
}

/* MODAL */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(5px);
  display: grid;
  place-items: center;
  padding: 16px;
  z-index: 50;
}

.modal-card {
  width: 100%;
  max-width: 610px;
  max-height: 92vh;
  overflow-y: auto;
  background: var(--bg-panel-solid);
  border: 1.5px solid var(--border-strong);
  border-radius: 18px;
  padding: 20px 22px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.78);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.modal-header h2 {
  font-size: 1.18rem;
  color: #fbe6b0;
}

.setup-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.form-section {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.form-row {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.form-row label {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--gold-soft);
}

.two-col,
.rules-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.seg-btn {
  padding: 9px 10px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(0, 0, 0, 0.35);
  color: var(--muted);
  font-weight: 700;
  font-size: 0.83rem;
  cursor: pointer;
}

.seg-btn.active {
  border-color: var(--gold);
  background: rgba(245, 197, 24, 0.18);
  color: #fde68a;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding-top: 8px;
}

/* TOAST */
.toast-container {
  position: fixed;
  bottom: 18px;
  right: 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 100;
}

.toast {
  padding: 10px 15px;
  border-radius: 10px;
  background: #241610;
  border: 1px solid var(--gold);
  color: var(--text);
  font-size: 0.86rem;
  font-weight: 600;
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.55);
  animation: toastIn 0.2s ease;
}

.toast.error {
  border-color: var(--danger);
  color: #fecaca;
}

@keyframes toastIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.badge-unread {
  background: #ef4444;
  color: #fff;
  font-size: 0.7rem;
  padding: 1px 6px;
  border-radius: 999px;
}

/* RESPONSIVE */
@media (max-width: 1180px) {
  .game-layout {
    grid-template-columns: 204px minmax(0, 1fr);
  }
  .chat-toggle-mobile {
    display: inline-flex !important;
  }
  .chat-panel {
    position: fixed;
    right: 12px;
    bottom: 12px;
    width: min(350px, calc(100vw - 24px));
    height: 460px;
    z-index: 40;
  }
  .chat-panel.mobile-collapsed {
    display: none !important;
  }
  .chat-close-mobile {
    display: grid;
  }
}

@media (max-width: 900px) {
  .game-view {
    height: auto;
    overflow: visible;
  }
  .game-layout,
  .game-layout.no-chat {
    grid-template-columns: 1fr;
  }
  .controls-dock {
    order: 2;
    height: auto;
    display: grid;
    grid-template-columns: 1fr 1fr;
  }
  .ctrl-group {
    border-bottom: none;
    padding-bottom: 0;
  }
  .table-column {
    order: 1;
    height: auto;
  }
  #poolCanvas {
    width: 100%;
    max-height: none;
  }
}

@media (max-width: 820px) {
  .lobby-hero,
  .lobby-grid,
  .rules-grid,
  .two-col {
    grid-template-columns: 1fr;
  }
  .scoreboard {
    grid-template-columns: 1fr;
  }
  .controls-dock {
    grid-template-columns: 1fr;
  }
  .topbar {
    padding: 8px 14px;
  }
}
