/* Auth UI overlay — independent of game styles, scoped via .ages-auth-* */

.ages-auth-root,
.ages-auth-root * {
  box-sizing: border-box;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica,
    Arial, sans-serif;
}

.ages-auth-root {
  --ages-bg: rgba(20, 20, 28, 0.92);
  --ages-fg: #f4f4f8;
  --ages-muted: #9aa0b4;
  --ages-accent: #d4a25a;
  --ages-error: #ff7373;
  --ages-input-bg: #2a2c3b;
  --ages-input-border: #3b3e52;
  --ages-btn-bg: #3a3d52;
  --ages-btn-hover: #4a4e69;
  --ages-radius: 6px;
  color: var(--ages-fg);
}

.ages-auth-hidden {
  display: none !important;
}

#ages-auth-header {
  position: fixed;
  top: 8px;
  right: 8px;
  z-index: 9998;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 10px;
  background: var(--ages-bg);
  border-radius: var(--ages-radius);
  font-size: 13px;
  pointer-events: auto;
}

.ages-auth-locales {
  display: flex;
  gap: 4px;
}

.ages-auth-locale-btn {
  background: transparent;
  border: 0;
  color: var(--ages-muted);
  padding: 2px 6px;
  cursor: pointer;
  font-size: 13px;
  letter-spacing: 0.05em;
  font-weight: 600;
}

.ages-auth-locale-btn:hover {
  color: var(--ages-fg);
}

.ages-auth-locale-btn.ages-auth-active {
  color: var(--ages-accent);
  text-decoration: underline;
}

.ages-auth-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.ages-auth-user-email {
  color: var(--ages-fg);
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ages-auth-primary-btn {
  background: var(--ages-btn-bg);
  color: var(--ages-fg);
  border: 0;
  border-radius: var(--ages-radius);
  padding: 5px 12px;
  cursor: pointer;
  font-size: 13px;
}

.ages-auth-primary-btn:hover {
  background: var(--ages-btn-hover);
}

/* ---------- Modal ---------- */

#ages-auth-modal-root {
  position: fixed;
  inset: 0;
  z-index: 9999;
}

.ages-auth-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  pointer-events: auto;
}

.ages-auth-modal {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: var(--ages-bg);
  border-radius: var(--ages-radius);
  padding: 22px 22px 18px;
  width: min(360px, calc(100vw - 24px));
  max-height: calc(100vh - 24px);
  overflow: auto;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.55);
  outline: 0;
}

.ages-auth-close {
  position: absolute;
  top: 6px;
  right: 8px;
  background: transparent;
  border: 0;
  color: var(--ages-muted);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  padding: 4px 8px;
}

.ages-auth-close:hover {
  color: var(--ages-fg);
}

.ages-auth-title {
  margin: 0 0 14px;
  font-size: 18px;
  font-weight: 600;
  color: var(--ages-fg);
}

.ages-auth-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 14px;
  border-bottom: 1px solid var(--ages-input-border);
}

.ages-auth-tab {
  background: transparent;
  border: 0;
  color: var(--ages-muted);
  padding: 6px 10px 8px;
  cursor: pointer;
  font-size: 13px;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}

.ages-auth-tab:hover {
  color: var(--ages-fg);
}

.ages-auth-tab.ages-auth-active {
  color: var(--ages-fg);
  border-bottom-color: var(--ages-accent);
}

.ages-auth-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.ages-auth-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
}

.ages-auth-label {
  color: var(--ages-muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.ages-auth-field input {
  background: var(--ages-input-bg);
  color: var(--ages-fg);
  border: 1px solid var(--ages-input-border);
  border-radius: var(--ages-radius);
  padding: 8px 10px;
  font-size: 14px;
  outline: 0;
}

.ages-auth-field input:focus {
  border-color: var(--ages-accent);
}

.ages-auth-error {
  color: var(--ages-error);
  font-size: 13px;
  min-height: 1em;
}

.ages-auth-submit {
  background: var(--ages-accent);
  color: #1a1a22;
  border: 0;
  border-radius: var(--ages-radius);
  padding: 9px 12px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  margin-top: 4px;
}

.ages-auth-submit:hover {
  filter: brightness(1.05);
}

.ages-auth-submit:disabled {
  cursor: progress;
  opacity: 0.7;
}

.ages-auth-switch {
  background: transparent;
  border: 0;
  color: var(--ages-muted);
  cursor: pointer;
  font-size: 12px;
  padding: 4px 0;
  text-decoration: underline;
  align-self: center;
}

.ages-auth-switch:hover {
  color: var(--ages-fg);
}

/* ---------- Save conflict dialog ---------- */

.ages-conflict-modal {
  width: min(560px, calc(100vw - 24px));
}

.ages-conflict-subtitle {
  margin: 0 0 14px;
  color: var(--ages-muted);
  font-size: 13px;
  line-height: 1.4;
}

.ages-conflict-cards {
  display: flex;
  gap: 12px;
  margin-bottom: 16px;
}

.ages-conflict-card {
  flex: 1;
  background: var(--ages-input-bg);
  border: 1px solid var(--ages-input-border);
  border-radius: var(--ages-radius);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.ages-conflict-card-label {
  color: var(--ages-accent);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 600;
  margin-bottom: 4px;
}

.ages-conflict-card-row {
  font-size: 13px;
  color: var(--ages-fg);
}

.ages-conflict-date {
  color: var(--ages-muted);
}

.ages-conflict-buttons {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

.ages-conflict-btn-local {
  flex: 0 1 auto;
}

.ages-conflict-btn-server {
  flex: 0 1 auto;
  margin-top: 0;
}

@media (max-width: 480px) {
  .ages-conflict-cards {
    flex-direction: column;
  }
  .ages-conflict-buttons {
    flex-direction: column-reverse;
  }
  .ages-conflict-buttons button {
    width: 100%;
  }
}

/* ---------- Save bootstrap loader ---------- */

.ages-save-loader {
  position: fixed;
  inset: 0;
  z-index: 9997;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: auto;
}

.ages-save-loader-inner {
  background: var(--ages-bg);
  color: var(--ages-fg);
  padding: 18px 22px;
  border-radius: var(--ages-radius);
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 14px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
}

.ages-save-loader-spinner {
  width: 18px;
  height: 18px;
  border: 2px solid var(--ages-input-border);
  border-top-color: var(--ages-accent);
  border-radius: 50%;
  animation: ages-spin 0.8s linear infinite;
}

@keyframes ages-spin {
  to { transform: rotate(360deg); }
}

@media (max-width: 480px) {
  #ages-auth-header {
    top: 4px;
    right: 4px;
    gap: 8px;
    padding: 4px 6px;
    font-size: 12px;
  }
  .ages-auth-user-email {
    max-width: 140px;
  }
  .ages-auth-modal {
    padding: 18px 16px 14px;
  }
}
