/* =========================================================
   Bilard 8-Ball - Midnight Violet & Gold Theme
   Inspired by Luxury Casual Mobile Game UI
   ========================================================= */

/* Local Poppins font files - 100% self-contained for Klyo Games */
@font-face {
  font-family: 'Poppins';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url('fonts/poppins-600.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Poppins';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url('fonts/poppins-600-ext.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'Poppins';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url('fonts/poppins-700.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Poppins';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url('fonts/poppins-700-ext.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'Poppins';
  font-style: normal;
  font-weight: 800;
  font-display: swap;
  src: url('fonts/poppins-800.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Poppins';
  font-style: normal;
  font-weight: 800;
  font-display: swap;
  src: url('fonts/poppins-800-ext.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'Poppins';
  font-style: normal;
  font-weight: 900;
  font-display: swap;
  src: url('fonts/poppins-900.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Poppins';
  font-style: normal;
  font-weight: 900;
  font-display: swap;
  src: url('fonts/poppins-900-ext.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

:root {
  /* Unified Bold Typography */
  --app-font: 'Poppins', 'Segoe UI', system-ui, -apple-system, BlinkMacSystemFont, Roboto, sans-serif;

  /* Midnight Violet Palette */
  --bg-deep: #09071a;
  --bg-violet-glow: #241a54;
  --panel-bg: rgba(24, 19, 58, 0.85);
  --panel-border: rgba(138, 126, 212, 0.32);
  --panel-glow: rgba(13, 9, 36, 0.6);

  /* Card Inset & Regular */
  --card-bg: rgba(32, 25, 75, 0.75);
  --card-border: rgba(142, 128, 222, 0.32);
  --card-inset-bg: rgba(20, 16, 50, 0.85);

  /* Gold Offer Accent (NAJLEPSZA OFERTA & $2.99 style) */
  --gold-grad: linear-gradient(180deg, #ffd752 0%, #f7a823 100%);
  --gold-border: #fcd55c;
  --gold-glow: rgba(247, 168, 35, 0.45);
  --gold-badge-bg: linear-gradient(180deg, #fff3b8 0%, #fcd55c 100%);
  --gold-dark-text: #3b1d00;

  /* Purple Button Gradient (Wróć / Przywróć zakupy style) */
  --purple-btn-grad: linear-gradient(180deg, #3c346f 0%, #282153 100%);
  --purple-btn-border: rgba(145, 133, 224, 0.4);

  /* Cyan Diamond Accent */
  --accent-cyan: #48dbfb;
  --accent-cyan-glow: rgba(72, 219, 251, 0.6);

  /* Typography */
  --text-primary: #ffffff;
  --text-secondary: #b8b2e0;
  --text-muted: #7971aa;
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: var(--app-font);
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}

html, body, button, input, select, textarea {
  font-family: var(--app-font);
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: var(--bg-deep);
  background-image: radial-gradient(circle at 50% 8%, #271d5c 0%, #130f36 50%, #070617 100%);
  color: var(--text-primary);
  touch-action: manipulation;
}

body {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

/* =========================================================
   1. Header Bar
   ========================================================= */
.game-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 18px;
  background: var(--panel-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1.5px solid var(--panel-border);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
  z-index: 20;
  flex-shrink: 0;
  gap: 10px;
}

.logo-section {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.logo-ball {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #444455, #0f0c24);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.7), 0 0 10px rgba(138, 126, 212, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.logo-inner {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #ffffff;
  color: #111111;
  font-weight: 900;
  font-size: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.game-title {
  font-size: 1.15rem;
  font-weight: 900;
  letter-spacing: 1px;
  white-space: nowrap;
  background: linear-gradient(180deg, #ffffff 0%, #b8caff 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 2px 10px rgba(100, 140, 255, 0.5));
}

.header-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.mode-selector {
  display: flex;
  background: var(--card-inset-bg);
  padding: 3px;
  border-radius: 12px;
  border: 1px solid var(--panel-border);
}

.mode-btn {
  background: transparent;
  color: var(--text-secondary);
  border: none;
  padding: 6px 12px;
  font-size: 0.82rem;
  font-weight: 700;
  border-radius: 9px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 5px;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.mode-btn:hover {
  color: #ffffff;
}

.mode-btn.active {
  background: var(--gold-grad);
  color: var(--gold-dark-text);
  box-shadow: 0 3px 10px var(--gold-glow);
  font-weight: 900;
}

.difficulty-group {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.difficulty-select {
  background: var(--purple-btn-grad);
  color: #ffffff;
  border: 1.5px solid var(--purple-btn-border);
  padding: 5px 8px;
  border-radius: 10px;
  font-size: 0.82rem;
  font-weight: 700;
  outline: none;
  cursor: pointer;
}

.quick-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.diamond-badge {
  display: flex;
  align-items: center;
  gap: 5px;
  background: var(--card-inset-bg);
  border: 1.5px solid rgba(72, 219, 251, 0.4);
  padding: 5px 10px;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}

.diamond-badge.clickable-badge {
  cursor: pointer;
  transition: all 0.2s ease;
}

.diamond-badge.clickable-badge:hover {
  border-color: #48dbfb;
  box-shadow: 0 0 14px rgba(72, 219, 251, 0.5), 0 2px 8px rgba(0, 0, 0, 0.4);
  transform: translateY(-1px);
}

.diamond-badge.clickable-badge:active {
  transform: translateY(1px);
}

.diamond-icon {
  font-size: 0.95rem;
  filter: drop-shadow(0 0 6px var(--accent-cyan-glow));
}

.diamond-count {
  font-weight: 800;
  font-size: 0.85rem;
  color: #ffffff;
  letter-spacing: 0.3px;
}

.lang-selector-group {
  display: flex;
  align-items: center;
}

.lang-select {
  background: var(--purple-btn-grad);
  color: #ffffff;
  border: 1.5px solid var(--purple-btn-border);
  padding: 6px 10px;
  border-radius: 11px;
  font-size: 0.82rem;
  font-weight: 800;
  cursor: pointer;
  outline: none;
  font-family: inherit;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.35);
  transition: all 0.15s ease;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml;charset=UTF-8,%3Csvg%20width%3D%2210%22%20height%3D%226%22%20viewBox%3D%220%200%2010%206%22%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%3E%3Cpath%20d%3D%22M1%201l4%204%204-4%22%20stroke%3D%22%23ffd752%22%20stroke-width%3D%221.8%22%20fill%3D%22none%22%20stroke-linecap%3D%22round%22%20stroke-linejoin%3D%22round%22%2F%3E%3C%2Fsvg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  padding-right: 24px;
}

.lang-select:hover {
  border-color: var(--gold-border);
  box-shadow: 0 0 10px rgba(255, 215, 82, 0.3);
}

.lang-select option {
  background: #191240;
  color: #ffffff;
  font-weight: 700;
}

.shop-action-btn {
  background: linear-gradient(180deg, #4f3b8c 0%, #30245d 100%) !important;
  border: 1.5px solid #a38cf5 !important;
  color: #ffd752 !important;
  box-shadow: 0 2px 10px rgba(163, 140, 245, 0.3) !important;
}

.shop-action-btn:hover {
  border-color: #fcd55c !important;
  box-shadow: 0 0 14px rgba(247, 168, 35, 0.4) !important;
}

.action-btn {
  background: var(--purple-btn-grad);
  border: 1.5px solid var(--purple-btn-border);
  color: #ffffff;
  padding: 6px 11px;
  border-radius: 11px;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 5px;
  transition: all 0.15s ease;
  white-space: nowrap;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.35);
}

.action-btn:hover {
  filter: brightness(1.15);
}

.action-btn:active {
  transform: scale(0.96);
}

.action-btn.muted {
  color: var(--accent-red);
  border-color: rgba(231, 76, 60, 0.6);
}

/* =========================================================
   2. Scoreboard & Players HUD (Offer Cards Style)
   ========================================================= */
.scoreboard {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 14px;
  padding: 8px 18px;
  max-width: 1240px;
  margin: 0 auto;
  width: 100%;
  flex-shrink: 0;
  z-index: 15;
}

.player-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 14px;
  background: var(--card-bg);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1.5px solid var(--card-border);
  border-radius: 20px;
  box-shadow: 0 6px 20px var(--panel-glow);
  transition: all 0.25s ease;
  min-width: 0;
  position: relative;
}

/* Floating "TWÓJ RUCH" Badge (exact replica of "NAJLEPSZA OFERTA") */
.turn-badge {
  display: none;
  position: absolute;
  top: -11px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--gold-badge-bg);
  color: var(--gold-dark-text);
  font-size: 0.65rem;
  font-weight: 900;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  padding: 2px 14px;
  border-radius: 12px;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.7);
  white-space: nowrap;
  z-index: 5;
}

.player-card.active-turn {
  border: 2px solid var(--gold-border);
  box-shadow: 0 0 22px var(--gold-glow), 0 8px 24px rgba(0, 0, 0, 0.6);
  background: rgba(38, 30, 84, 0.85);
}

.player-card.active-turn .turn-badge {
  display: block;
}

.player-avatar {
  font-size: 1.35rem;
  background: var(--card-inset-bg);
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  border: 1.5px solid var(--card-border);
  box-shadow: inset 0 2px 5px rgba(0, 0, 0, 0.5);
  transition: transform 0.2s;
}

.active-turn .player-avatar {
  border-color: var(--gold-border);
  box-shadow: 0 0 12px var(--gold-glow);
  transform: scale(1.05);
}

.player-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  flex: 1;
}

.player-name-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.player-name {
  font-size: 0.92rem;
  font-weight: 800;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: #ffffff;
}

.group-row {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  margin: 2px 0;
}

.group-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 8px;
  font-size: 0.74rem;
  font-weight: 800;
  letter-spacing: 0.3px;
}

.group-pill.open-group {
  background: rgba(140, 130, 200, 0.16);
  color: var(--text-secondary);
  border: 1px solid rgba(140, 130, 200, 0.3);
}

.group-pill.solid-group {
  background: rgba(241, 196, 15, 0.18);
  color: #ffd752;
  border: 1px solid rgba(241, 196, 15, 0.45);
  box-shadow: 0 0 8px rgba(241, 196, 15, 0.2);
}

.group-pill.stripe-group {
  background: rgba(41, 128, 185, 0.22);
  color: #48dbfb;
  border: 1px solid rgba(72, 219, 251, 0.45);
  box-shadow: 0 0 8px rgba(72, 219, 251, 0.2);
}

.count-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--card-inset-bg);
  padding: 2px 8px;
  border-radius: 8px;
  border: 1px solid var(--panel-border);
  font-size: 0.74rem;
  font-weight: 700;
  color: var(--text-secondary);
}

.count-pill .count-highlight {
  color: #ffd752;
  font-weight: 900;
  font-size: 0.84rem;
}

.count-pill .count-total {
  color: var(--text-muted);
  font-size: 0.72rem;
}

.count-pill .count-noun {
  color: var(--text-secondary);
  font-size: 0.72rem;
}

.count-pill.target-eight-badge {
  background: linear-gradient(180deg, #ffd752 0%, #f7a823 100%);
  color: #3b1d00;
  font-weight: 900;
  font-size: 0.72rem;
  letter-spacing: 0.6px;
  border: 1px solid #ffe98a;
  box-shadow: 0 0 12px var(--gold-glow);
  animation: pulse-eight-badge 1s infinite alternate ease-in-out;
}

@keyframes pulse-eight-badge {
  from { transform: scale(1); box-shadow: 0 0 6px rgba(247, 168, 35, 0.5); }
  to { transform: scale(1.04); box-shadow: 0 0 16px rgba(247, 168, 35, 0.9); }
}

.remaining-balls {
  min-height: 24px;
  display: flex;
  align-items: center;
}

.ball-tray {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-wrap: nowrap;
  padding: 2px 0;
}

.ball-dot {
  width: 21px;
  height: 21px;
  border-radius: 50%;
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 3px 6px rgba(0, 0, 0, 0.65), inset -1px -2px 3px rgba(0, 0, 0, 0.45), inset 1px 2px 2px rgba(255, 255, 255, 0.6);
  flex-shrink: 0;
  transition: transform 0.25s, opacity 0.25s, filter 0.25s;
  overflow: hidden;
  user-select: none;
}

/* 3D sphere top-left shine */
.ball-dot::before {
  content: '';
  position: absolute;
  top: 1px;
  left: 3px;
  width: 7px;
  height: 5px;
  border-radius: 50%;
  background: radial-gradient(ellipse at center, rgba(255, 255, 255, 0.85) 0%, rgba(255, 255, 255, 0) 100%);
  pointer-events: none;
  z-index: 3;
}

/* White center circle with black number */
.ball-dot .ball-inner-num {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: #ffffff;
  color: #111111;
  font-size: 7.5px;
  font-weight: 900;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
  line-height: 1;
}

/* Stripe ball band */
.ball-dot.stripe {
  background-color: #f7f9fa !important;
}

.ball-dot.stripe .stripe-band {
  position: absolute;
  top: 3.5px;
  bottom: 3.5px;
  left: 0;
  right: 0;
  z-index: 1;
}

/* Potted ball (dimmed & crossed/checked) */
.ball-dot.potted {
  opacity: 0.2;
  filter: grayscale(100%);
  transform: scale(0.85);
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.9);
}

.ball-dot.potted::after {
  content: '✓';
  position: absolute;
  font-size: 10px;
  font-weight: 900;
  color: #ffffff;
  z-index: 4;
  text-shadow: 0 1px 2px #000000;
}

/* 8-Ball Target */
.ball-dot.eight-target {
  background-color: #151515 !important;
  border: 1.5px solid #ffd752;
  box-shadow: 0 0 12px rgba(255, 215, 82, 0.7);
  animation: pulse-eight 1s infinite alternate ease-in-out;
}

@keyframes pulse-eight {
  from { transform: scale(1); box-shadow: 0 0 4px var(--gold-border); }
  to { transform: scale(1.15); box-shadow: 0 0 14px var(--gold-glow); }
}

/* Open table prompt */
.open-table-tray {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.72rem;
  color: var(--text-secondary);
}

.mini-preview-group {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.ball-dot.mini-sample {
  width: 17px;
  height: 17px;
}

.ball-dot.mini-sample .ball-inner-num {
  width: 9px;
  height: 9px;
  font-size: 6.5px;
}

.mini-sample-text {
  font-size: 0.68rem;
  color: var(--text-muted);
  font-weight: 700;
}

/* Toast Message */
.toast-container {
  display: flex;
  justify-content: center;
  align-items: center;
  min-width: 0;
}

.game-toast {
  padding: 6px 16px;
  border-radius: 20px;
  font-size: 0.82rem;
  font-weight: 700;
  background: rgba(14, 10, 38, 0.92);
  border: 1.5px solid var(--panel-border);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.7);
  color: var(--text-primary);
  opacity: 0;
  transform: translateY(-4px);
  transition: all 0.25s ease;
  pointer-events: none;
  white-space: nowrap;
  max-width: 280px;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: center;
}

.game-toast.show {
  opacity: 1;
  transform: translateY(0);
}

.game-toast.warning {
  border-color: var(--gold-border);
  color: #ffd752;
}

.game-toast.error {
  border-color: var(--accent-red);
  color: #ff7675;
  background: rgba(120, 18, 24, 0.9);
}

/* Orientation Tip */
.orientation-tip {
  display: none;
  align-items: center;
  justify-content: space-between;
  background: linear-gradient(90deg, #2b2368, #1c154a);
  border-bottom: 1.5px solid var(--panel-border);
  color: #ffffff;
  padding: 6px 14px;
  font-size: 0.8rem;
  font-weight: 700;
  z-index: 14;
}

.btn-dismiss {
  background: transparent;
  border: none;
  color: #ffffff;
  font-size: 1rem;
  cursor: pointer;
  padding: 0 6px;
}

/* =========================================================
   3. Table Canvas Container
   ========================================================= */
.canvas-container {
  flex: 1;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4px;
  overflow: hidden;
  min-height: 0;
}

#poolCanvas {
  display: block;
  border-radius: 22px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.9), 0 0 50px rgba(37, 26, 84, 0.4);
  cursor: crosshair;
  touch-action: none;
}

/* =========================================================
   4. Bottom Controls Bar (Price Tag Pill Button Style)
   ========================================================= */
.bottom-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 22px;
  background: var(--panel-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-top: 1.5px solid var(--panel-border);
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.4);
  gap: 14px;
  flex-shrink: 0;
  z-index: 20;
}

.power-controls {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
  min-width: 0;
}

.power-label-group {
  display: flex;
  align-items: baseline;
  gap: 5px;
  flex-shrink: 0;
}

.power-label {
  font-size: 0.82rem;
  font-weight: 800;
  color: var(--text-secondary);
  letter-spacing: 0.5px;
}

.power-percent {
  font-size: 0.85rem;
  font-weight: 900;
  color: #ffd752;
  min-width: 38px;
}

.power-meter-wrapper {
  width: 120px;
  height: 10px;
  background: var(--card-inset-bg);
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid var(--panel-border);
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.6);
  flex-shrink: 0;
}

.power-meter-fill {
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, #48dbfb, #ffd752, #ff6b6b);
  transition: width 0.04s ease;
}

.power-slider {
  flex: 1;
  max-width: 180px;
  min-width: 60px;
  accent-color: #ffd752;
  cursor: pointer;
  touch-action: none;
  flex-shrink: 1;
}

/* Big Golden "UDERZ" Button (Replica of $2.99 / $0.99 Pill Buttons) */
.btn-shoot {
  background: var(--gold-grad);
  color: var(--gold-dark-text);
  border: 1.5px solid #ffe98a;
  padding: 9px 24px;
  font-size: 0.95rem;
  font-weight: 900;
  letter-spacing: 0.5px;
  border-radius: 16px;
  cursor: pointer;
  box-shadow: 0 4px 16px var(--gold-glow), inset 0 1px 2px rgba(255, 255, 255, 0.7);
  transition: transform 0.1s, box-shadow 0.1s;
  flex-shrink: 0;
  min-height: 42px;
}

.btn-shoot:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px var(--gold-glow);
}

.btn-shoot:active {
  transform: translateY(1px);
  box-shadow: 0 2px 8px var(--gold-glow);
}

.hint-text {
  font-size: 0.78rem;
  color: var(--text-secondary);
  text-align: center;
  flex: 1;
}

/* =========================================================
   5. Modal Overlay (Shop Modal Window Style)
   ========================================================= */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(6, 4, 18, 0.94);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 16px;
}

.modal-overlay.active {
  display: flex;
}

.modal-card {
  background: #191240;
  background-image: radial-gradient(circle at 50% 0%, #2b1f69 0%, #150f34 100%);
  border: 2px solid var(--panel-border);
  border-radius: 24px;
  padding: 30px 36px;
  text-align: center;
  max-width: 420px;
  width: 100%;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.95), 0 0 40px rgba(138, 126, 212, 0.3);
  animation: modal-pop 0.18s ease-out;
}

@keyframes modal-pop {
  from { transform: scale(0.94); }
  to { transform: scale(1); }
}

.modal-trophy {
  font-size: 3.2rem;
  margin-bottom: 8px;
}

.modal-title {
  font-size: 1.5rem;
  font-weight: 900;
  color: #ffd752;
  margin-bottom: 8px;
  filter: drop-shadow(0 2px 10px var(--gold-glow));
}

.modal-desc {
  font-size: 0.92rem;
  color: var(--text-secondary);
  margin-bottom: 24px;
  line-height: 1.4;
}

.btn-primary {
  background: var(--gold-grad);
  color: var(--gold-dark-text);
  border: 1.5px solid #ffe98a;
  padding: 12px 28px;
  font-size: 1rem;
  font-weight: 900;
  border-radius: 16px;
  cursor: pointer;
  box-shadow: 0 4px 18px var(--gold-glow);
  transition: transform 0.1s;
}

.btn-primary:hover {
  transform: translateY(-2px);
}

.modal-reward-info {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: rgba(247, 168, 35, 0.15);
  border: 1.5px solid var(--gold-border);
  color: #ffd752;
  font-weight: 800;
  font-size: 0.95rem;
  padding: 8px 18px;
  border-radius: 14px;
  margin-bottom: 20px;
  box-shadow: 0 0 16px rgba(247, 168, 35, 0.25);
}

.modal-buttons-group {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
}

.reward-ad-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: linear-gradient(135deg, #10ac84, #00b894);
  color: #042e22;
  font-family: inherit;
  font-weight: 800;
  font-size: 0.88rem;
  padding: 10px 18px;
  border-radius: 14px;
  border: 1.5px solid #55efc4;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(16, 172, 132, 0.4);
  transition: all 0.15s ease;
}

.reward-ad-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(16, 172, 132, 0.6);
  background: linear-gradient(135deg, #1dd1a1, #10ac84);
}

.reward-ad-btn:active {
  transform: translateY(1px);
}

.shop-reward-btn {
  padding: 6px 12px;
  font-size: 0.78rem;
  border-radius: 10px;
}

/* =========================================================
   5b. Table Skins Shop Modal
   ========================================================= */
.shop-modal-card {
  max-width: 760px;
  width: 95%;
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  padding: 24px 28px;
  text-align: left;
  overflow: hidden;
}

.shop-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1.5px solid var(--panel-border);
  padding-bottom: 16px;
  margin-bottom: 18px;
  gap: 14px;
  flex-shrink: 0;
}

.shop-title-group {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.shop-header-icon {
  font-size: 2rem;
  flex-shrink: 0;
  filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.5));
}

.shop-title {
  font-size: 1.25rem;
  font-weight: 900;
  letter-spacing: 0.5px;
  background: var(--gold-grad);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 2px 10px var(--gold-glow));
  margin-bottom: 2px;
}

.shop-subtitle {
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin: 0;
}

.shop-header-right {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.btn-close-modal {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--card-inset-bg);
  border: 1.5px solid var(--panel-border);
  color: var(--text-secondary);
  font-size: 1.1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-close-modal:hover {
  background: #e74c3c;
  color: #ffffff;
  border-color: #e74c3c;
  transform: scale(1.08);
}

.shop-items-container {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(215px, 1fr));
  gap: 16px;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 8px 4px 14px 4px;
  max-height: calc(88vh - 120px);
}

.shop-items-container::-webkit-scrollbar {
  width: 7px;
}

.shop-items-container::-webkit-scrollbar-track {
  background: rgba(15, 12, 40, 0.5);
  border-radius: 4px;
}

.shop-items-container::-webkit-scrollbar-thumb {
  background: rgba(138, 126, 212, 0.4);
  border-radius: 4px;
}

.shop-items-container::-webkit-scrollbar-thumb:hover {
  background: rgba(247, 168, 35, 0.6);
}

.shop-item-card {
  position: relative;
  background: #20194b;
  border: 1.5px solid var(--card-border);
  border-radius: 20px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.shop-item-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.5);
  border-color: rgba(162, 145, 255, 0.6);
}

.shop-item-card.active-offer {
  border: 2px solid var(--gold-border);
  box-shadow: 0 0 24px var(--gold-glow), 0 8px 24px rgba(0, 0, 0, 0.6);
}

.shop-active-badge {
  position: absolute;
  top: -11px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--gold-badge-bg);
  color: var(--gold-dark-text);
  font-size: 0.7rem;
  font-weight: 900;
  letter-spacing: 0.8px;
  padding: 3px 14px;
  border-radius: 999px;
  box-shadow: 0 4px 12px var(--gold-glow);
  white-space: nowrap;
  z-index: 2;
}

.skin-preview-swatch {
  width: 100%;
  height: 68px;
  border-radius: 12px;
  border-width: 5px;
  border-style: solid;
  position: relative;
  overflow: hidden;
  box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.7), 0 4px 12px rgba(0, 0, 0, 0.3);
}

.swatch-felt {
  width: 100%;
  height: 100%;
  position: relative;
}

.swatch-line {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 28%;
  width: 1px;
  background: rgba(255, 255, 255, 0.2);
}

.swatch-spot {
  position: absolute;
  top: 50%;
  right: 25%;
  transform: translateY(-50%);
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.35);
}

.swatch-pocket {
  position: absolute;
  width: 11px;
  height: 11px;
  background: #000000;
  border-radius: 50%;
  border: 1.5px solid;
  z-index: 2;
}

.swatch-pocket.sp-tl { top: -3px; left: -3px; }
.swatch-pocket.sp-tr { top: -3px; right: -3px; }
.swatch-pocket.sp-bl { bottom: -3px; left: -3px; }
.swatch-pocket.sp-br { bottom: -3px; right: -3px; }
.swatch-pocket.sp-tm { top: -4px; left: 50%; transform: translateX(-50%); }
.swatch-pocket.sp-bm { bottom: -4px; left: 50%; transform: translateX(-50%); }

.shop-item-details {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.shop-item-title {
  font-size: 0.98rem;
  font-weight: 800;
  color: #ffffff;
  letter-spacing: 0.2px;
}

.shop-item-desc {
  font-size: 0.74rem;
  color: var(--text-secondary);
  line-height: 1.35;
  min-height: 36px;
}

.shop-item-action {
  margin-top: auto;
  padding-top: 4px;
}

.shop-btn-buy {
  width: 100%;
  background: var(--gold-grad);
  color: var(--gold-dark-text);
  border: 1.5px solid #ffe98a;
  padding: 9px 14px;
  font-size: 0.92rem;
  font-weight: 900;
  border-radius: 14px;
  cursor: pointer;
  box-shadow: 0 4px 14px var(--gold-glow);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: transform 0.1s, box-shadow 0.1s;
}

.shop-btn-buy:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 18px var(--gold-glow);
}

.shop-btn-buy:active {
  transform: translateY(1px);
}

.shop-btn-buy.disabled {
  opacity: 0.45;
  cursor: not-allowed;
  filter: grayscale(50%);
  transform: none !important;
  box-shadow: none !important;
}

.shop-btn-equip {
  width: 100%;
  background: var(--purple-btn-grad);
  color: #ffffff;
  border: 1.5px solid var(--purple-btn-border);
  padding: 9px 14px;
  font-size: 0.9rem;
  font-weight: 800;
  border-radius: 14px;
  cursor: pointer;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.35);
  transition: all 0.15s ease;
}

.shop-btn-equip:hover {
  border-color: #a291ff;
  transform: translateY(-1px);
}

.shop-btn-equipped {
  width: 100%;
  background: rgba(30, 24, 60, 0.6);
  color: var(--text-muted);
  border: 1.5px solid rgba(255, 255, 255, 0.1);
  padding: 9px 14px;
  font-size: 0.88rem;
  font-weight: 800;
  border-radius: 14px;
  cursor: default;
}

.shop-btn-diamond {
  font-size: 0.95rem;
  filter: drop-shadow(0 0 4px rgba(0, 0, 0, 0.5));
}

/* =========================================================
   6. Responsive Layouts: Tablets & Mobile
   ========================================================= */

/* Tablet (max-width: 900px) */
@media (max-width: 900px) {
  .game-header {
    padding: 6px 14px;
  }
  .game-title {
    font-size: 1rem;
  }
  .scoreboard {
    padding: 6px 12px;
    gap: 8px;
  }
  .player-card {
    padding: 6px 10px;
    gap: 8px;
  }
  .player-avatar {
    width: 32px;
    height: 32px;
    font-size: 1.15rem;
  }
  .bottom-bar {
    padding: 6px 14px;
  }
  .hint-text {
    display: none;
  }
}

/* Mobile Screens (max-width: 650px) */
@media (max-width: 650px) {
  .game-header {
    padding: 6px 10px;
    gap: 6px;
  }

  /* Compact Logo: Show only 8-ball icon on narrow screens */
  .logo-section .game-title {
    display: none;
  }

  /* Mode & Action Buttons: icons only */
  .mode-btn .btn-text,
  .action-btn .btn-text {
    display: none;
  }
  .mode-btn,
  .action-btn {
    padding: 5px 8px;
    font-size: 0.95rem;
    min-height: 34px;
    min-width: 34px;
    justify-content: center;
    border-radius: 10px;
  }

  .diff-label {
    display: none;
  }
  .difficulty-select {
    padding: 3px 5px;
    font-size: 0.75rem;
    max-width: 72px;
  }

  /* Scoreboard: Two compact cards + toast below */
  .scoreboard {
    grid-template-columns: 1fr 1fr;
    grid-template-rows: auto auto;
    padding: 4px 8px;
    gap: 6px;
  }

  .toast-container {
    grid-column: 1 / -1;
    grid-row: 2;
    margin-top: -2px;
  }

  .game-toast {
    font-size: 0.74rem;
    padding: 3px 10px;
    max-width: 95%;
  }

  .player-card {
    padding: 6px 8px;
    gap: 6px;
    border-radius: 16px;
  }

  .turn-badge {
    top: -9px;
    font-size: 0.58rem;
    padding: 1px 10px;
  }

  .player-name {
    font-size: 0.8rem;
  }

  .group-pill, .count-pill {
    font-size: 0.65rem;
    padding: 1px 6px;
  }

  .ball-tray {
    gap: 3px;
  }

  .ball-dot {
    width: 16px;
    height: 16px;
  }

  .ball-dot .ball-inner-num {
    width: 9px;
    height: 9px;
    font-size: 6.5px;
  }

  .ball-dot::before {
    width: 5px;
    height: 3px;
    top: 1px;
    left: 2px;
  }

  .ball-dot.stripe .stripe-band {
    top: 2.5px;
    bottom: 2.5px;
  }

  /* Show portrait orientation tip */
  .orientation-tip {
    display: flex;
  }

  /* Bottom Controls: Space-efficient row */
  .bottom-bar {
    padding: 6px 10px;
    gap: 8px;
    display: flex;
    align-items: center;
    justify-content: space-between;
  }

  .power-controls {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
  }

  .power-meter-wrapper {
    display: none; /* Hide static wrapper on mobile to maximize slider */
  }

  .power-slider {
    flex: 1;
    width: 0;
    min-width: 50px;
  }

  .btn-shoot {
    padding: 7px 18px;
    font-size: 0.85rem;
    min-height: 36px;
    flex-shrink: 0;
    border-radius: 12px;
  }

  /* Responsive Shop Modal */
  .shop-modal-card {
    padding: 16px 14px;
    width: 96%;
    max-height: 90vh;
    border-radius: 18px;
  }

  .shop-modal-header {
    padding-bottom: 10px;
    margin-bottom: 12px;
  }

  .shop-title {
    font-size: 1.05rem;
  }

  .shop-subtitle {
    font-size: 0.72rem;
  }

  .shop-header-icon {
    font-size: 1.5rem;
  }

  .shop-items-container {
    grid-template-columns: 1fr;
    gap: 12px;
    max-height: calc(90vh - 90px);
  }

  .skin-preview-swatch {
    height: 56px;
  }
}

/* =========================================================
   7. Mobile Landscape (max-height: 520px)
   ========================================================= */
@media (max-height: 520px) {
  .game-header {
    padding: 3px 12px;
  }

  .logo-ball {
    width: 22px;
    height: 22px;
  }
  .logo-inner {
    width: 10px;
    height: 10px;
    font-size: 6.5px;
  }
  .game-title {
    font-size: 0.85rem;
  }

  .mode-btn, .action-btn {
    padding: 2px 7px;
    font-size: 0.74rem;
    min-height: 28px;
  }

  .scoreboard {
    padding: 2px 12px;
    gap: 6px;
  }

  .player-card {
    padding: 3px 10px;
    gap: 6px;
    border-radius: 12px;
  }

  .turn-badge {
    top: -8px;
    font-size: 0.52rem;
    padding: 1px 8px;
  }

  .player-avatar {
    width: 26px;
    height: 26px;
    font-size: 0.95rem;
  }

  .player-name {
    font-size: 0.78rem;
  }

  .ball-tray {
    gap: 2px;
  }

  .ball-dot {
    width: 14px;
    height: 14px;
  }

  .ball-dot .ball-inner-num {
    width: 8px;
    height: 8px;
    font-size: 5.5px;
  }

  .ball-dot::before {
    width: 4px;
    height: 3px;
    top: 1px;
    left: 1px;
  }

  .ball-dot.stripe .stripe-band {
    top: 2px;
    bottom: 2px;
  }

  .toast-container {
    max-height: 20px;
  }

  .game-toast {
    font-size: 0.7rem;
    padding: 1px 8px;
  }

  .orientation-tip {
    display: none !important;
  }

  .canvas-container {
    padding: 2px;
  }

  .bottom-bar {
    padding: 4px 14px;
  }

  .hint-text {
    display: none;
  }

  .btn-shoot {
    padding: 5px 16px;
    font-size: 0.82rem;
    min-height: 30px;
    border-radius: 12px;
  }

  .power-meter-wrapper {
    height: 8px;
    width: 80px;
  }

  .power-slider {
    width: 90px;
  }

  .shop-modal-card {
    padding: 12px 18px;
    max-height: 94vh;
  }
  .shop-items-container {
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 10px;
    max-height: calc(94vh - 65px);
  }
  .skin-preview-swatch {
    height: 48px;
  }
}
