/* ===== GAMES PANEL (Social Area) ===== */
#games-panel {
  position: fixed;
  bottom: 80px;
  right: 260px;
  width: 300px;
  background: rgba(14, 22, 42, 0.98);
  border: 1px solid rgba(255,255,255,0.14);
  border-radius: 16px;
  box-shadow: 0 12px 40px rgba(0,0,0,0.6);
  z-index: 140;
  display: flex;
  flex-direction: column;
  backdrop-filter: blur(16px);
  overflow: hidden;
}
#games-panel.hidden { display: none; }

#games-panel-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.09);
  font-size: 0.9rem; font-weight: 700; color: #fff;
}
#games-panel-close {
  background: none; border: none; color: rgba(255,255,255,0.4);
  cursor: pointer; font-size: 1rem; line-height: 1;
  transition: color 0.15s;
}
#games-panel-close:hover { color: #fff; }

#games-player-list {
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  max-height: 420px;
  overflow-y: auto;
}

/* ── Step layout ── */
.games-step { display: flex; flex-direction: column; gap: 8px; }

.games-step-label {
  font-size: 0.75rem;
  font-weight: 700;
  color: rgba(255,255,255,0.45);
  text-transform: uppercase;
  letter-spacing: 0.07em;
}

.games-empty {
  font-size: 0.85rem;
  color: rgba(255,255,255,0.35);
  text-align: center;
  padding: 16px 0;
  font-style: italic;
}

/* ── Player selection ── */
.games-player-grid {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.games-player-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(255,255,255,0.05);
  border: 1.5px solid rgba(255,255,255,0.08);
  border-radius: 10px;
  padding: 9px 12px;
  cursor: pointer;
  text-align: left;
  transition: background 0.15s, border-color 0.15s;
  width: 100%;
}
.games-player-btn:hover {
  background: rgba(79,142,247,0.15);
  border-color: rgba(79,142,247,0.4);
}
.games-player-btn.selected {
  background: rgba(79,142,247,0.22);
  border-color: #4f8ef7;
}
.games-player-avatar {
  width: 32px; height: 32px;
  background: rgba(79,142,247,0.3);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.9rem; font-weight: 800; color: #fff;
  flex-shrink: 0;
}
.games-player-btn-name {
  font-size: 0.9rem;
  font-weight: 600;
  color: #fff;
}

/* ── Game selection ── */
.games-game-grid {
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.games-game-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(255,255,255,0.04);
  border: 1.5px solid rgba(255,255,255,0.08);
  border-radius: 10px;
  padding: 8px 12px;
  cursor: pointer;
  text-align: left;
  transition: background 0.15s, border-color 0.15s;
  width: 100%;
}
.games-game-btn:hover {
  background: rgba(79,142,247,0.15);
  border-color: rgba(79,142,247,0.35);
}
.games-game-btn.selected {
  background: rgba(79,142,247,0.22);
  border-color: #4f8ef7;
}
.games-game-emoji { font-size: 1.25rem; width: 28px; text-align: center; flex-shrink: 0; }
.games-game-label { font-size: 0.88rem; font-weight: 600; color: #fff; }

/* ── Challenge send button ── */
.games-challenge-send {
  width: 100%;
  background: linear-gradient(135deg, #4f8ef7, #7c5ef7);
  border: none;
  border-radius: 10px;
  color: #fff;
  font-size: 0.9rem;
  padding: 11px 14px;
  cursor: pointer;
  font-weight: 600;
  transition: filter 0.15s, transform 0.1s;
  text-align: center;
  line-height: 1.4;
}
.games-challenge-send:hover {
  filter: brightness(1.12);
  transform: translateY(-1px);
}
.games-challenge-send:active { transform: translateY(0); }

/* ===== GAME MODAL ===== */
.game-modal-box {
  min-width: 360px;
  max-width: 420px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}
.game-modal-header {
  display: flex; width: 100%; align-items: center; justify-content: space-between;
}
.game-modal-header span { font-size: 1.1rem; font-weight: 700; }
#game-modal-close { background: none; border: none; color: var(--text2); cursor: pointer; font-size: 1rem; }
#game-turn-label { font-size: 0.9rem; font-weight: 600; min-height: 20px; }
#game-board { display: flex; flex-direction: column; align-items: center; gap: 6px; width: 100%; }

/* ── Tic Tac Toe ── */
.ttt-grid {
  display: grid; grid-template-columns: repeat(3, 90px);
  gap: 6px;
}
.ttt-cell {
  width: 90px; height: 90px;
  background: rgba(255,255,255,0.07); border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 2.2rem; font-weight: 900; cursor: default;
  transition: background 0.15s;
}
.ttt-cell.clickable { cursor: pointer; }
.ttt-cell.clickable:hover { background: rgba(79,142,247,0.2); }
.ttt-cell.p0 { color: #4f8ef7; }
.ttt-cell.p1 { color: #f06464; }

/* ── Connect 4 ── */
.c4-drop-row {
  display: grid; grid-template-columns: repeat(7, 46px);
  gap: 4px; margin-bottom: 2px;
}
.c4-drop-btn {
  background: rgba(255,255,255,0.08); border: none;
  border-radius: 6px; color: var(--accent); cursor: pointer;
  padding: 4px; font-size: 0.8rem; transition: background 0.15s;
}
.c4-drop-btn:hover { background: rgba(79,142,247,0.25); }

.c4-grid {
  display: grid; grid-template-columns: repeat(7, 46px);
  gap: 4px;
  background: rgba(20,50,120,0.5);
  border-radius: 10px; padding: 8px;
}
.c4-cell {
  width: 46px; height: 46px; border-radius: 50%;
  background: rgba(255,255,255,0.07);
  transition: background 0.2s;
}
.c4-cell.p0 { background: #f7a94f; box-shadow: 0 0 8px rgba(247,169,79,0.5); }
.c4-cell.p1 { background: #e05c5c; box-shadow: 0 0 8px rgba(224,92,92,0.5); }

/* ── Battleship ── */
.game-modal-box.bs-modal { min-width: 580px; max-width: 640px; }

.bs-wrapper {
  display: flex; gap: 18px; align-items: flex-start;
}
.bs-section {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
}
.bs-section h4, .bs-grid-label {
  font-size: 0.8rem; font-weight: 700; color: var(--text2);
  text-transform: uppercase; letter-spacing: 0.06em; margin: 0;
}

.bs-grid {
  display: grid;
  grid-template-columns: repeat(10, 34px);
  gap: 2px;
}
.bs-cell {
  width: 34px; height: 34px; border-radius: 4px;
  background: rgba(30,60,120,0.55);
  border: 1px solid rgba(255,255,255,0.07);
  display: flex; align-items: center; justify-content: center;
  font-size: 0.9rem; cursor: default;
  transition: background 0.12s;
}
.bs-cell.ship        { background: rgba(79,142,247,0.35); border-color: rgba(79,142,247,0.5); }
.bs-cell.hit         { background: rgba(240,100,100,0.8); border-color: #f06464; color: #fff; }
.bs-cell.miss        { background: rgba(255,255,255,0.12); color: rgba(255,255,255,0.35); }
.bs-cell.sunk        { background: rgba(180,30,30,0.75); border-color: #c0392b; }
.bs-cell.targetable  { cursor: crosshair; }
.bs-cell.targetable:hover { background: rgba(247,169,79,0.4); border-color: #f7a94f; }

/* placement grid overlays */
.bs-cell.preview         { background: rgba(79,142,247,0.3); border-color: #4f8ef7; }
.bs-cell.preview-invalid { background: rgba(240,100,100,0.35); border-color: #f06464; }

.bs-place-info {
  font-size: 0.8rem; color: var(--text2); text-align: center; line-height: 1.5;
}
.bs-ship-list {
  display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; max-width: 380px;
}
.bs-ship-chip {
  background: rgba(79,142,247,0.18); border: 1px solid rgba(79,142,247,0.4);
  border-radius: 5px; padding: 3px 8px; font-size: 0.75rem; color: var(--text);
  white-space: nowrap;
}
.bs-ship-chip.placed { opacity: 0.4; text-decoration: line-through; }

.bs-btn-sm {
  background: rgba(255,255,255,0.09); border: 1px solid rgba(255,255,255,0.15);
  border-radius: 6px; color: var(--text); font-size: 0.78rem;
  padding: 5px 12px; cursor: pointer; transition: background 0.15s;
}
.bs-btn-sm:hover { background: rgba(255,255,255,0.16); }
.bs-btn-confirm {
  background: var(--accent); border: none; border-radius: 6px;
  color: #fff; font-size: 0.85rem; font-weight: 700;
  padding: 7px 18px; cursor: pointer; transition: filter 0.15s;
}
.bs-btn-confirm:hover { filter: brightness(1.12); }
.bs-btn-confirm:disabled { opacity: 0.4; cursor: not-allowed; filter: none; }

.bs-placement-controls {
  display: flex; gap: 8px; align-items: center; flex-wrap: wrap; justify-content: center;
}
.bs-sunk-summary {
  display: flex; flex-wrap: wrap; gap: 5px; justify-content: center;
  max-width: 360px;
}
.bs-ship-chip.sunk {
  background: rgba(180,30,30,0.35); border-color: #c0392b;
  text-decoration: line-through; opacity: 0.7;
}
.bs-waiting {
  font-size: 0.85rem; color: var(--text2); font-style: italic;
  text-align: center; padding: 20px 0;
}

/* ── Memory Match ── */
.game-modal-box.mem-modal { min-width: 400px; max-width: 450px; }

.mem-scores {
  display: flex; gap: 24px; justify-content: center; width: 100%;
}
.mem-score {
  font-size: 0.9rem; color: var(--text2); font-weight: 600;
}
.mem-score.me { color: #4f8ef7; }

.mem-status {
  font-size: 0.82rem; color: var(--text2); font-style: italic; min-height: 18px;
}

.mem-grid {
  display: grid;
  grid-template-columns: repeat(4, 82px);
  gap: 8px;
}
.mem-card {
  width: 82px; height: 82px; border-radius: 10px;
  background: rgba(79,142,247,0.18);
  border: 1.5px solid rgba(79,142,247,0.35);
  display: flex; align-items: center; justify-content: center;
  font-size: 2rem; cursor: default;
  transition: background 0.18s, transform 0.18s;
  user-select: none;
}
.mem-card.clickable {
  cursor: pointer;
}
.mem-card.clickable:hover {
  background: rgba(79,142,247,0.32); transform: scale(1.06);
}
.mem-card.flipped {
  background: rgba(255,255,255,0.12);
  border-color: rgba(255,255,255,0.25);
}
.mem-card.matched {
  background: rgba(72,199,142,0.25);
  border-color: rgba(72,199,142,0.6);
  cursor: default;
}
.mem-card.matched:hover { transform: none; }

/* ── Rock Paper Scissors ── */
.game-modal-box.rps-modal { min-width: 360px; max-width: 420px; }

.rps-header {
  display: flex; gap: 30px; justify-content: center;
  width: 100%; margin-bottom: 4px;
}
.rps-score {
  font-size: 1rem; font-weight: 700; color: var(--text);
}

.rps-round {
  font-size: 0.78rem; color: var(--text2);
}

.rps-choices {
  display: flex; gap: 14px; justify-content: center; flex-wrap: wrap;
}
.rps-choice-btn {
  width: 88px; height: 88px; border-radius: 16px;
  background: rgba(255,255,255,0.07);
  border: 2px solid rgba(255,255,255,0.12);
  font-size: 2.4rem; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 4px; transition: background 0.15s, border-color 0.15s, transform 0.12s;
  color: var(--text);
}
.rps-choice-btn span {
  font-size: 0.65rem; font-weight: 700; letter-spacing: 0.04em; color: var(--text2);
  text-transform: capitalize;
}
.rps-choice-btn:hover:not(:disabled) {
  background: rgba(79,142,247,0.25); border-color: #4f8ef7; transform: scale(1.07);
}
.rps-choice-btn.chosen {
  background: rgba(79,142,247,0.3); border-color: #4f8ef7;
}
.rps-choice-btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }

.rps-waiting {
  font-size: 0.85rem; color: var(--text2); font-style: italic;
  text-align: center; padding: 6px 0;
}

.rps-history {
  width: 100%; display: flex; flex-direction: column; gap: 5px;
  max-height: 160px; overflow-y: auto;
}
.rps-hist-item {
  display: block;
  background: rgba(255,255,255,0.04); border-radius: 7px;
  padding: 5px 10px; font-size: 0.82rem;
}
.rps-hist-item .rps-hist-round { color: var(--text2); font-size: 0.75rem; min-width: 52px; }
.rps-hist-item .rps-hist-choices { flex: 1; text-align: center; font-size: 1.05rem; letter-spacing: 0.1em; }
.rps-hist-item .rps-hist-result { font-weight: 700; min-width: 46px; text-align: right; }
.rps-hist-item .rps-hist-result.win  { color: #48c78e; }
.rps-hist-item .rps-hist-result.lose { color: #f06464; }
.rps-hist-item .rps-hist-result.draw { color: var(--text2); }

/* ── Challenge Popup ── */
#game-challenge-popup {
  position: fixed;
  top: 80px;
  right: 24px;
  z-index: 500;
  background: rgba(18,28,52,0.98);
  border: 2px solid rgba(79,142,247,0.6);
  border-radius: 16px;
  box-shadow: 0 8px 40px rgba(0,0,0,0.6), 0 0 0 1px rgba(79,142,247,0.2);
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 260px;
  max-width: 300px;
  backdrop-filter: blur(16px);
  opacity: 0;
  transform: translateX(40px);
  transition: opacity 0.25s ease, transform 0.25s ease;
}
#game-challenge-popup.challenge-popup-in {
  opacity: 1;
  transform: translateX(0);
}
#game-challenge-popup.challenge-popup-out {
  opacity: 0;
  transform: translateX(40px);
}
.challenge-popup-icon {
  font-size: 2rem;
  text-align: center;
}
.challenge-popup-body {
  text-align: center;
}
.challenge-popup-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 4px;
}
.challenge-popup-game {
  font-size: 0.82rem;
  color: #4f8ef7;
  font-weight: 600;
}
.challenge-popup-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
}
.challenge-popup-accept {
  background: #4f8ef7;
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 8px 20px;
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  transition: filter 0.15s;
  flex: 1;
}
.challenge-popup-accept:hover { filter: brightness(1.15); }
.challenge-popup-decline {
  background: rgba(255,255,255,0.08);
  color: var(--text2);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 8px;
  padding: 8px 20px;
  font-size: 0.85rem;
  cursor: pointer;
  transition: background 0.15s;
  flex: 1;
}
.challenge-popup-decline:hover { background: rgba(255,255,255,0.14); }
