/* UI polish pass — July 2026 (additive fixes only, no redesign) */

/* ── Focus-visible (keyboard) ── */
.social-hub-tab:focus-visible,
.social-avatar-option:focus-visible,
.social-frame-option:focus-visible,
.social-friend-row--link:focus-visible,
.retention-activity-tab:focus-visible,
.companion-hub-tabs button:focus-visible,
.cat-room-claim-btn:focus-visible,
.cat-room-open-btn:focus-visible,
.auth-portal-close:focus-visible,
.slot-modal-close:focus-visible,
.game-embed-fullscreen-btn:focus-visible,
.hub-quest-claim:focus-visible,
.retention-profile-collect-hint:focus-visible,
.asset-workshop-tabs .btn:focus-visible,
.admin-tab-nav .btn:focus-visible,
.social-field input:focus-visible,
.social-field textarea:focus-visible,
.social-field select:focus-visible,
.retention-filter input:focus-visible,
.companion-hub-chat-input:focus-visible,
.companion-hub-gacha-card:focus-visible {
  outline: 2px solid #818cf8;
  outline-offset: 2px;
}

.social-field input:focus,
.social-field textarea:focus,
.social-field select:focus,
.retention-filter input:focus,
.companion-hub-chat-input:focus {
  border-color: rgba(129, 140, 248, 0.55);
}

/* ── Touch targets (min 44px) ── */
.social-avatar-option,
.social-frame-option {
  min-width: 2.75rem;
  min-height: 2.75rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.retention-activity-tab,
.social-hub-tab.game-lobby-tab {
  min-height: 2.75rem;
}

.hub-quest-claim {
  min-height: 2.75rem;
  padding: 0.45rem 0.85rem !important;
}

.cat-room-claim-btn,
.cat-room-open-btn {
  min-height: 2.75rem;
}

.auth-portal-close {
  min-width: 2.75rem;
  min-height: 2.75rem;
}

/* ── Scroll & overflow ── */
.retention-reward-list,
.retention-activity-list,
.farm-hub-body,
.beta-auth-body,
.companion-hub-chat-log,
.companion-hub-list,
.companion-hub-modal .cat-room-shop-list,
.social-search-results,
.game-lobby-panel--social {
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.social-search-results:not([hidden]) {
  max-height: min(40vh, 320px);
  overflow-y: auto;
  margin-top: 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.companion-hub-body {
  overflow: hidden;
}

/* ── Layout stability (loading / empty) ── */
.retention-empty,
.social-hub-loading,
.social-hub-empty {
  min-height: 4rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.social-hub-panel.is-active {
  min-height: 10rem;
}

.retention-inline-rewards .retention-reward-list {
  min-height: 6rem;
}

.beta-auth-error:not(.hidden) {
  margin: 0.35rem 0 0;
  padding: 0.45rem 0.6rem;
  border-radius: 8px;
  background: rgba(127, 29, 29, 0.25);
  border: 1px solid rgba(248, 113, 113, 0.35);
}

/* ── Transitions & hover (match existing timing) ── */
.beta-ui-btn {
  transition: filter 0.18s ease, transform 0.18s ease, box-shadow 0.18s ease;
}

.beta-ui-btn:hover:not(:disabled) {
  filter: brightness(1.05);
}

.beta-ui-btn:active:not(:disabled) {
  transform: translateY(1px);
}

.social-avatar-option,
.social-frame-option,
.social-friend-row--link,
.retention-activity-tab,
.social-leaderboard-row {
  transition: border-color 0.18s ease, background 0.18s ease, box-shadow 0.18s ease;
}

.social-friend-row--link:hover {
  border-color: rgba(129, 140, 248, 0.35);
  background: rgba(99, 102, 241, 0.08);
}

.social-avatar-option:hover,
.social-frame-option:hover {
  border-color: rgba(129, 140, 248, 0.4);
}

.retention-activity-tab:hover:not(.is-active) {
  background: rgba(148, 163, 184, 0.08);
}

/* ── Social hub tabs scroll (mobile) ── */
@media (max-width: 720px) {
  .social-hub-tabs {
    overflow-x: auto;
    flex-wrap: nowrap;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding-bottom: 0.15rem;
  }

  .social-hub-tabs::-webkit-scrollbar {
    display: none;
  }

  .social-hub-tab {
    flex: 0 0 auto;
    white-space: nowrap;
  }

  .retention-profile-stat-grid {
    grid-template-columns: 1fr;
  }

  .social-profile-form,
  .social-search-form {
    gap: 0.85rem;
  }

  .companion-hub-body {
    grid-template-columns: 1fr !important;
  }

  .companion-hub-list,
  .companion-hub-modal .cat-room-shop-list {
    max-height: min(38vh, 360px);
  }
}

/* ── Retention toast stacking ── */
.retention-toast-host {
  pointer-events: none;
}

.overlay-host:has(.slot-modal:not([hidden])) ~ .retention-toast-host,
.showcase-shell:has(.slot-modal:not([hidden])) .retention-toast-host {
  z-index: 11900;
}

/* ── Z-index: hub menu above lobby content ── */
.showcase-hub-menu-panel {
  z-index: 250;
}

/* ── Font consistency in retention profile ── */
.retention-profile-companion-name,
.retention-profile-balance-value strong,
.retention-reward-amount {
  font-variant-numeric: tabular-nums;
}

.retention-profile-stat-grid strong {
  font-size: 0.95rem;
  color: #f1f5f9;
}

/* ── Empty / error text alignment ── */
.social-hub-empty-hint {
  line-height: 1.45;
}

.social-achievement-grid:empty::after {
  content: none;
}

/* ── Admin workshop panel scroll ── */
.playground-admin-workshop .asset-workshop-panel-section {
  overflow-y: auto;
  max-height: calc(100vh - 8rem);
  overscroll-behavior: contain;
}

/* ── Cat room sidebar touch polish ── */
.cat-room-sidebar-actions .beta-ui-btn {
  min-height: 2.75rem;
}

/* ── Loading screen busy state ── */
.game-loading-screen[aria-busy='true'] .game-loading-status {
  min-height: 1.25rem;
}

/* ── Farm hub modal spacing ── */
.farm-hub-grid {
  padding-bottom: 0.25rem;
}

.farm-hub-card:last-child {
  margin-bottom: 0.15rem;
}

/* ── Companion hub chat form alignment ── */
.companion-hub-chat-form .beta-ui-btn {
  flex-shrink: 0;
  min-height: 2.75rem;
}

/* ── Social hub error state ── */
.social-hub-error {
  margin: 0;
  padding: 0.85rem 1rem;
  border-radius: 12px;
  text-align: center;
  color: #fecaca;
  background: rgba(127, 29, 29, 0.28);
  border: 1px solid rgba(248, 113, 113, 0.38);
  line-height: 1.45;
}

/* ── Retention profile companion visuals ── */
.retention-profile-companion-visual {
  width: 64px;
  height: 64px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(148, 163, 184, 0.2);
  flex-shrink: 0;
  overflow: hidden;
}

.retention-profile-companion-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.retention-profile-companion-placeholder {
  font-size: 1.75rem;
  line-height: 1;
}

.retention-profile-companion-copy {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  min-width: 0;
}

.retention-profile-companion-room,
.retention-profile-companion-idle {
  font-size: 0.78rem;
  color: rgba(148, 163, 184, 0.9);
}

.retention-profile-collect-hint {
  align-self: flex-start;
  margin-top: 0.25rem;
}

.retention-profile-balance,
.retention-profile-stats {
  margin-bottom: 1rem;
}

/* ── Reward history modal scroll ── */
.retention-panel-body {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  min-height: 0;
  max-height: min(72vh, 640px);
  overflow: hidden;
}

.retention-panel-body .retention-reward-list {
  flex: 1;
  min-height: 8rem;
}

/* ── Daily quest hint spacing ── */
.hub-quest-hint {
  margin: 0 0 0.85rem;
  line-height: 1.45;
}

/* ── Social friends action buttons ── */
.social-friend-actions .beta-ui-btn {
  min-height: 2.75rem;
  padding: 0.4rem 0.75rem;
}

.social-friend-actions {
  flex-wrap: wrap;
}

/* ── Leaderboard row hover ── */
.social-leaderboard-row {
  border-radius: 10px;
  transition: background 0.18s ease, border-color 0.18s ease;
}

.social-leaderboard-row:hover {
  background: rgba(99, 102, 241, 0.08);
}

.social-lb-rank {
  font-variant-numeric: tabular-nums;
  color: #94a3b8;
}

/* ── Embedded game chrome ── */
.game-embed-toolbar {
  flex-shrink: 0;
}

.game-embed-fullscreen-btn {
  min-height: 2.75rem;
  min-width: 8.5rem;
}

.game-embed-view {
  position: relative;
}

.game-embed-loading {
  position: absolute;
  inset: 2.75rem 0 0;
  z-index: 2;
  display: grid;
  place-items: center;
  gap: 0.65rem;
  background: rgba(15, 23, 42, 0.72);
  color: #cbd5e1;
  font-size: 0.88rem;
  pointer-events: none;
}

.game-embed-loading[hidden] {
  display: none !important;
}

.game-embed-loading::before {
  content: '';
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 3px solid rgba(148, 163, 184, 0.25);
  border-top-color: #818cf8;
  animation: ui-polish-spin 0.8s linear infinite;
}

@keyframes ui-polish-spin {
  to {
    transform: rotate(360deg);
  }
}

.game-embed-frame {
  transition: opacity 0.22s ease;
}

.game-embed-view.is-loading .game-embed-frame {
  opacity: 0.35;
}

/* ── Live-Ops admin polish ── */
.liveops-nav-item,
.liveops-tab,
.liveops-sort,
.liveops-link-btn,
.liveops-drawer-close,
.liveops-filter input,
.liveops-login-card input {
  transition: background 0.18s ease, border-color 0.18s ease, color 0.18s ease;
}

.liveops-nav-item:focus-visible,
.liveops-tab:focus-visible,
.liveops-sort:focus-visible,
.liveops-link-btn:focus-visible,
.liveops-drawer-close:focus-visible,
.liveops-filter input:focus-visible,
.liveops-login-card input:focus-visible,
.liveops-filter-actions .btn:focus-visible,
.liveops-sidebar-foot .btn:focus-visible,
.liveops-login-card button:focus-visible {
  outline: 2px solid #38bdf8;
  outline-offset: 2px;
}

.liveops-nav-item {
  min-height: 2.75rem;
}

.liveops-table-wrap,
.liveops-drawer-body,
.liveops-pre {
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.liveops-state {
  min-height: 10rem;
}

.liveops-state--error p {
  text-align: center;
  color: #fca5a5;
  max-width: 36ch;
  line-height: 1.45;
}

.liveops-state--loading p {
  margin: 0;
}

.liveops-drawer-close {
  min-width: 2.75rem;
  min-height: 2.75rem;
}

/* ── Companion hub gacha card hover ── */
.companion-hub-gacha-card:not(:disabled):hover {
  border-color: rgba(251, 191, 36, 0.45);
  background: rgba(15, 23, 42, 0.92);
}

.companion-hub-gacha-card:not(:disabled):active {
  transform: translateY(1px);
}

/* ── Cat room sidebar scroll on small screens ── */
@media (max-width: 720px) {
  .cat-room-full-overlay .cat-room-full-body,
  .companion-hub-modal .companion-hub-body {
    overflow-y: auto;
    overscroll-behavior: contain;
  }

  .retention-toast-host {
    top: auto;
    bottom: 1rem;
    right: 0.75rem;
    left: 0.75rem;
    max-width: none;
  }

  .game-lobby-panel--social {
    padding-bottom: 0.5rem;
  }
}

/* ── Reduced motion ── */
@media (prefers-reduced-motion: reduce) {
  .hub-quest-card,
  .game-lobby-card,
  .beta-ui-btn,
  .retention-toast,
  .hub-daily-board--pulse,
  .game-embed-loading::before,
  .liveops-spinner {
    transition: none !important;
    animation: none !important;
  }

  .hub-quest-card:hover:not(.is-claimed),
  .game-lobby-card:hover:not([disabled]),
  .companion-hub-gacha-card:not(:disabled):active {
    transform: none;
  }
}
