/* Player1 UI: global wait overlay, header user menu, modals */

:root {
  --p1-ui-green: #127311;
  --p1-ui-green-hover: #0e5a0d;
  --p1-ui-green-50: #effcef;
  --p1-ui-green-100: #dcf7dc;
  --p1-ui-gold: #fbbf24;
  --p1-ui-ink: #18181b;
  --p1-ui-muted: #52525b;
  --p1-ui-border: #e4e4e7;
  --p1-ui-danger: #dc2626;
}

@keyframes p1-ui-spin {
  to { transform: rotate(360deg); }
}

/* Global Please Wait overlay */
.p1-wait-backdrop {
  position: fixed;
  inset: 0;
  z-index: 2002;
  background-color: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.p1-wait-backdrop.is-open {
  display: flex;
}

#global-loader.is-open {
  display: flex !important;
  pointer-events: auto !important;
  z-index: 2002;
}

#global-loader.hidden,
#loading-screen.hidden {
  display: none !important;
  pointer-events: none !important;
}

.p1-wait-box {
  width: 100%;
  max-width: 22rem;
  background-color: #ffffff;
  border: 1px solid var(--p1-ui-border);
  border-radius: 1rem;
  padding: 1.75rem 1.5rem;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.35);
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 0.75rem;
}

.p1-wait-spinner {
  width: 2.5rem;
  height: 2.5rem;
  border: 3px solid var(--p1-ui-green-100);
  border-top-color: var(--p1-ui-green);
  border-radius: 9999px;
  animation: p1-ui-spin 0.75s linear infinite;
}

.p1-wait-title {
  font-family: "Space Grotesk", ui-sans-serif, system-ui, sans-serif;
  font-size: 1.125rem;
  font-weight: 800;
  color: var(--p1-ui-ink);
  margin: 0;
}

.p1-wait-sub {
  font-size: 0.875rem;
  color: var(--p1-ui-muted);
  line-height: 1.45;
  margin: 0;
}

.p1-wait-sub:empty,
.p1-wait-sub[hidden],
.p1-wait-sub.hidden {
  display: none;
}

/* Header user dropdown */
.p1-user-dropdown {
  position: absolute;
  top: calc(100% + 0.5rem);
  right: 0;
  width: 18rem;
  background-color: #ffffff;
  border: 1px solid var(--p1-ui-border);
  border-radius: 0.875rem;
  box-shadow: 0 20px 35px -10px rgba(0, 0, 0, 0.26);
  z-index: 60;
  color: var(--p1-ui-ink);
  overflow: hidden;
}

.p1-dropdown-deposit-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 36px;
  margin-top: 0.75rem;
  padding: 0.45rem 0.75rem;
  border-radius: 0.55rem;
  background-color: var(--p1-ui-gold);
  color: #451a03;
  font-size: 0.8125rem;
  font-weight: 800;
  text-decoration: none;
  transition: filter 150ms ease;
}

.p1-dropdown-deposit-btn:hover {
  filter: brightness(1.06);
}

.p1-user-trigger {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  min-height: 40px;
  max-width: 14rem;
  padding: 0.25rem 0.625rem 0.25rem 0.3rem;
  border-radius: 0.75rem;
  background-color: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.22);
  color: #ffffff;
  cursor: pointer;
  white-space: nowrap;
  transition: background-color 160ms ease, border-color 160ms ease;
}

.p1-user-trigger:hover {
  background-color: rgba(255, 255, 255, 0.2);
  border-color: rgba(255, 255, 255, 0.35);
}

.p1-user-avatar {
  position: relative;
  width: 2rem;
  height: 2rem;
  border-radius: 9999px;
  background-color: var(--p1-ui-gold);
  color: #451a03;
  font-family: "Space Grotesk", ui-sans-serif, system-ui, sans-serif;
  font-size: 0.75rem;
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  overflow: hidden;
  border: 1.5px solid rgba(255, 255, 255, 0.75);
}

.p1-user-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  line-height: 1.15;
  min-width: 0;
}

.p1-user-name {
  font-size: 0.8125rem;
  font-weight: 700;
  color: #ffffff;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 8rem;
}

.p1-user-type {
  font-size: 0.625rem;
  font-weight: 600;
  color: var(--p1-ui-green-100);
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}

.p1-status-dot {
  width: 0.375rem;
  height: 0.375rem;
  border-radius: 9999px;
  background-color: #4ade80;
  display: inline-block;
  flex-shrink: 0;
}

.p1-user-menu-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.625rem;
  padding: 0.55rem 0.75rem;
  border-radius: 0.5rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: #3f3f46;
  text-decoration: none;
  background: transparent;
  border: 0;
  cursor: pointer;
  transition: background-color 140ms ease, color 140ms ease;
  width: 100%;
  text-align: left;
}

.p1-user-menu-link:hover {
  background-color: var(--p1-ui-green-50);
  color: var(--p1-ui-green);
}

.p1-user-menu-link.is-current {
  background-color: var(--p1-ui-green-50);
  color: var(--p1-ui-green);
  font-weight: 700;
}

.p1-user-menu-link.text-red-600,
.p1-user-menu-link.p1-sign-out-link {
  color: #dc2626;
}

.p1-user-menu-link.p1-sign-out-link:hover {
  background-color: #fef2f2;
  color: #b91c1c;
}

/* Modals */
.p1-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 2001;
  background-color: rgba(24, 24, 27, 0.72);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.p1-modal-backdrop.is-open {
  display: flex;
}

.p1-modal-panel {
  width: 100%;
  max-width: 28rem;
  max-height: calc(100vh - 2rem);
  overflow-y: auto;
  background-color: #ffffff;
  border: 1px solid var(--p1-ui-border);
  border-radius: 1rem;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.35);
  color: var(--p1-ui-ink);
}

.p1-modal-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid #f4f4f5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.p1-modal-title {
  font-family: "Space Grotesk", ui-sans-serif, system-ui, sans-serif;
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--p1-ui-ink);
  margin: 0;
}

.p1-modal-close {
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 0.625rem;
  border: 1px solid var(--p1-ui-border);
  background-color: #ffffff;
  color: var(--p1-ui-muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background-color 150ms ease, color 150ms ease;
}

.p1-modal-close:hover {
  background-color: #f4f4f5;
  color: var(--p1-ui-ink);
}

.p1-modal-body {
  padding: 1.5rem;
}

.p1-modal-alert-icon {
  width: 3.25rem;
  height: 3.25rem;
  border-radius: 9999px;
  background-color: #fffbeb;
  border: 1px solid #fde68a;
  color: #b45309;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 1rem;
}

.p1-detail-list {
  border: 1px solid var(--p1-ui-border);
  border-radius: 0.75rem;
  overflow: hidden;
  background-color: #fafafa;
}

.p1-detail-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid #f4f4f5;
  font-size: 0.875rem;
}

.p1-detail-row:last-child {
  border-bottom: 0;
}

.p1-detail-label {
  color: var(--p1-ui-muted);
  font-weight: 500;
}

.p1-detail-val {
  font-family: "Space Grotesk", ui-sans-serif, system-ui, sans-serif;
  font-weight: 700;
  color: var(--p1-ui-ink);
  text-align: right;
}

.p1-detail-val.is-zero {
  color: var(--p1-ui-danger);
  font-size: 1.0625rem;
  font-weight: 800;
}

.p1-detail-val.is-win {
  color: var(--p1-ui-green);
}

.p1-modal-footer {
  padding-top: 1.25rem;
  margin-top: 1.25rem;
  border-top: 1px solid #f4f4f5;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 0.625rem;
}

.p1-btn-secondary {
  min-height: 44px;
  padding: 0.625rem 1.25rem;
  border-radius: 0.625rem;
  background-color: #ffffff;
  color: var(--p1-ui-ink);
  font-size: 0.875rem;
  font-weight: 600;
  border: 1px solid #d4d4d8;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  cursor: pointer;
  transition: background-color 150ms ease, border-color 150ms ease;
}

.p1-btn-secondary:hover {
  background-color: #f4f4f5;
  border-color: #a1a1aa;
}

.p1-btn-deposit-modal {
  min-height: 44px;
  padding: 0.625rem 1.5rem;
  border-radius: 0.625rem;
  background-color: var(--p1-ui-gold);
  color: #451a03;
  font-family: "Space Grotesk", ui-sans-serif, system-ui, sans-serif;
  font-size: 0.9375rem;
  font-weight: 800;
  text-decoration: none;
  border: 0;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  box-shadow: 0 4px 14px rgba(251, 191, 36, 0.32);
  transition: filter 150ms ease, transform 150ms ease, box-shadow 150ms ease;
}

.p1-btn-deposit-modal:hover {
  filter: brightness(1.06);
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(251, 191, 36, 0.48);
}

@media (prefers-reduced-motion: reduce) {
  .p1-wait-spinner {
    animation: none;
  }
}